| 
 
     
签到天数: 4 天 连续签到: 1 天 [LV.2]Lyoko 初出 - UID
 - 1572 
 - 经验点数
 - 724 点 
 - 人气点数
 - 55 点 
 - 能量点数
 - 1 点 
 - 阅读权限
 - 255 
 - 在线时间
 - 231 小时 
 
  | 
回复 10# 康-jingkangyu  
 
 
要能直接存取数据库才能看到,论坛本身没这个功能。 
另外我也是在自己的数据库副本上操作的,因为扫描全表太消耗资源了。 
查询语句附:- SELECT authorid, FLOOR((dateline+28800)/604800) AS wk, COUNT(*) AS pcnt, SUM(CHAR_LENGTH(message)) AS scnt FROM clcn_posts WHERE tid != 3706 GROUP BY wk, authorid ORDER BY authorid, wk;
 
  复制代码 绘图程序- <?php
 
 - set_time_limit(0);
 
 - $conn = new mysqli('127.0.0.1', '*', '*', '*');
 
 - $query = $conn->query('SELECT authorid, FLOOR((dateline+28800)/604800) AS wk, COUNT(*) AS pcnt, SUM(CHAR_LENGTH(message)) AS scnt FROM clcn_posts WHERE tid != 3706 GROUP BY wk, authorid ORDER BY authorid, wk;');
 
 - $pcnt = array();
 
 - $scnt = array();
 
 - while($data = $query->fetch_array(MYSQLI_ASSOC)) {
 
 -         $pcnt[$data['authorid']][$data['wk']] = $data['pcnt'];
 
 -         $scnt[$data['authorid']][$data['wk']] = $data['scnt'];
 
 - }
 
 - foreach($pcnt as $uid => $poststat) {
 
 -         $startwk = min(array_keys($poststat));
 
 -         $endwk = max(array_keys($poststat));
 
 -         echo "\rProcessing $uid...                ";
 
 -         if($endwk - $startwk < 4) continue;
 
 -         echo "\rProcessing $uid: Calculating...                ";
 
 -         $posts = array_sum($poststat);
 
 -         $maxposts = max($poststat);
 
 -         
 
 -         $lengthstat = $scnt[$uid];
 
 -         $maxlength = max($lengthstat);
 
 -         
 
 -         $im = imagecreatetruecolor(705, 455);
 
 -         $red = imagecolorallocate($im, 255, 0, 0);
 
 -         $blue = imagecolorallocate($im, 0, 0, 255);
 
 -         $black = imagecolorallocate($im, 0, 0, 0);
 
 -         $w = imagecolorallocate($im, 255, 255, 255);
 
 -         
 
 -         $style = array($w, $w, $red, $red, $red, $red, $red, $w, $w, $w);
 
 -         $styleS = array($w, $w, $blue, $blue, $blue, $blue, $blue, $w, $w, $w);
 
 -         
 
 -         echo "\rProcessing $uid: Building Frame...                ";
 
 -         imagefill($im, 0, 0, $w);
 
 -         
 
 -         imagelinethick($im, 50, 5, 50, 405, $black, 2);
 
 -         imagelinethick($im, 50, 405, 650, 405, $black, 2);
 
 -         imagelinethick($im, 650, 405, 650, 5, $black, 2);
 
 -         
 
 -         imagestring($im, 5, 30, 400, 0, $red);
 
 -         imagestring($im, 5, 20, 0, $maxposts, $red);
 
 -         imagestring($im, 5, 50, 415, $startwk, $black);
 
 -         imagestring($im, 5, 620, 415, $endwk, $black);
 
 -         imagestring($im, 5, 655, 400, 0, $blue);
 
 -         imagestring($im, 5, 655, 0, $maxlength, $blue);
 
 -         
 
 -         $wks = $endwk - $startwk;
 
 -         $chars = array_sum($lengthstat);
 
 -         $avglength = round($chars / $wks);
 
 -         $avgpost = round($posts / $wks, 2);
 
 -         
 
 -         $Y = 400 * $posts / $wks / $maxposts;
 
 -         $Ys = 400 * $chars / $wks / $maxlength;
 
 -         imagestring($im, 5, 5, 397 - $Y, $avgpost, $red);
 
 -         imagestring($im, 5, 655, 397 - $Ys, $avglength, $blue);
 
 -         
 
 -         imagesetstyle($im, $styleS);
 
 -         imageline($im, 50, 405 - $Ys, 650, 405 - $Ys, IMG_COLOR_STYLED);
 
 -         imagesetstyle($im, $style);
 
 -         imageline($im, 50, 405 - $Y, 650, 405 - $Y, IMG_COLOR_STYLED);
 
 -         
 
 -         $lastX = 0;
 
 -         $lastY = 400 * $poststat[$startwk] / $maxposts;
 
 -         $lastXs = 0;
 
 -         $lastYs = 400 * $lengthstat[$startwk] / $maxlength;
 
 -         imagefilledellipse($im, $lastXs + 50, 405 - $lastYs, 7, 7, $blue);
 
 -         imagefilledellipse($im, $lastX + 50, 405 - $lastY, 7, 7, $red);
 
 -         
 
 -         if($lengthstat[$startwk] == $maxlength) imagestring($im, 3, 50, 440, $startwk, $blue);
 
 -         if($poststat[$startwk] == $maxposts) imagestring($im, 3, 50, 430, $startwk, $red);
 
 -         
 
 -         for($i = 1; $i <= $wks; $i++) {
 
 -                 echo "\rProcessing $uid: Drawing $i / $wks...                ";
 
 -                 $X = 600 * $i / $wks;
 
 -                 $Y = 400 * $poststat[$i + $startwk] / $maxposts;
 
 -                 $Xs = 600 * $i / $wks;
 
 -                 $Ys = 400 * $lengthstat[$i + $startwk] / $maxlength;
 
 -                 imagelinethick($im, $lastXs + 50, 405 - $lastYs, $Xs + 50, 405 - $Ys, $blue, 2);
 
 -                 imagelinethick($im, $lastX + 50, 405 - $lastY, $X + 50, 405 - $Y, $red, 2);
 
 -                 imagefilledellipse($im, $Xs + 50, 405 - $Ys, 7, 7, $blue);
 
 -                 imagefilledellipse($im, $X + 50, 405 - $Y, 7, 7, $red);
 
 -                 $lastX = $X;
 
 -                 $lastY = $Y;
 
 -                 $lastXs = $Xs;
 
 -                 $lastYs = $Ys;
 
 -                 
 
 -                 if($lengthstat[$i + $startwk] == $maxlength) imagestring($im, 3, $X + 50, 440, $i + $startwk, $blue);
 
 -                 if($poststat[$i + $startwk] == $maxposts) imagestring($im, 3, $X + 50, 430, $i + $startwk, $red);
 
 -         }
 
 -         
 
 -         echo "\rProcessing $uid: Saving file...                ";
 
 -         imagepng($im, $uid.'.png', 9);
 
 -         imagedestroy($im);
 
 - }
 
  
- function imagelinethick($image, $x1, $y1, $x2, $y2, $color, $thick = 1)
 
 - {
 
 -     if ($thick == 1) {
 
 -         return imageline($image, $x1, $y1, $x2, $y2, $color);
 
 -     }
 
 -     $t = $thick / 2 - 0.5;
 
 -     if ($x1 == $x2 || $y1 == $y2) {
 
 -         return imagefilledrectangle($image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color);
 
 -     }
 
 -     $k = ($y2 - $y1) / ($x2 - $x1); //y = kx + q
 
 -     $a = $t / sqrt(1 + pow($k, 2));
 
 -     $points = array(
 
 -         round($x1 - (1+$k)*$a), round($y1 + (1-$k)*$a),
 
 -         round($x1 - (1-$k)*$a), round($y1 - (1+$k)*$a),
 
 -         round($x2 + (1+$k)*$a), round($y2 - (1-$k)*$a),
 
 -         round($x2 + (1-$k)*$a), round($y2 + (1+$k)*$a),
 
 -     );
 
 -     imagefilledpolygon($image, $points, 4, $color);
 
 -     return imagepolygon($image, $points, 4, $color);
 
 - }
 
 - ?>
 
  复制代码 |   
 
 
 
 |