📄 graph.php
字号:
if ($TotalSent < 1024) $txtTotalSent = sprintf("Sent %.1f KBytes", $TotalSent);else if ($TotalSent < 1024*1024) $txtTotalSent = sprintf("Sent %.1f MBytes", $TotalSent/1024.0);else $txtTotalSent = sprintf("Sent %.1f GBytes", $TotalSent/(1024.0*1024.0)); ImageString($im, 2, XOFFSET+5, $height-20, $txtTotalSent, $black);ImageString($im, 2, $width/2+XOFFSET/2, $height-20, $txtPeakSendRate, $black);// Draw X AxisImageLine($im, 0, $height-YOFFSET, $width, $height-YOFFSET, $black);// Day/Month Seperator barsif ((24*60*60*($width-XOFFSET))/$interval > ($width-XOFFSET)/10) { $ts = getdate($timestamp); $MarkTime = mktime(0, 0, 0, $ts['mon'], $ts['mday'], $ts['year']); $x = ts2x($MarkTime); while ($x < XOFFSET) { $MarkTime += (24*60*60); $x = ts2x($MarkTime); } while ($x < ($width-10)) { // Day Lines ImageLine($im, $x, 0, $x, $height-YOFFSET, $black); ImageLine($im, $x+1, 0, $x+1, $height-YOFFSET, $black); $txtDate = strftime("%a, %b %d", $MarkTime); ImageString($im, 2, $x-30, $height-YOFFSET+10, $txtDate, $black); // Calculate Next x $MarkTime += (24*60*60); $x = ts2x($MarkTime); } }else if ((24*60*60*30*($width-XOFFSET))/$interval > ($width-XOFFSET)/10) { // Monthly Bars $ts = getdate($timestamp); $month = $ts['mon']; $MarkTime = mktime(0, 0, 0, $month, 1, $ts['year']); $x = ts2x($MarkTime); while ($x < XOFFSET) { $month++; $MarkTime = mktime(0, 0, 0, $month, 1, $ts['year']); $x = ts2x($MarkTime); } while ($x < ($width-10)) { // Day Lines ImageLine($im, $x, 0, $x, $height-YOFFSET, $black); ImageLine($im, $x+1, 0, $x+1, $height-YOFFSET, $black); $txtDate = strftime("%b, %Y", $MarkTime); ImageString($im, 2, $x-25, $height-YOFFSET+10, $txtDate, $black); // Calculate Next x $month++; $MarkTime = mktime(0, 0, 0, $month, 1, $ts['year']); $x = ts2x($MarkTime); } }else { // Year Bars $ts = getdate($timestamp); $year = $ts['year']; $MarkTime = mktime(0, 0, 0, 1, 1, $year); $x = ts2x($MarkTime); while ($x < XOFFSET) { $year++; $MarkTime = mktime(0, 0, 0, 1, 1, $year); $x = ts2x($MarkTime); } while ($x < ($width-10)) { // Day Lines ImageLine($im, $x, 0, $x, $height-YOFFSET, $black); ImageLine($im, $x+1, 0, $x+1, $height-YOFFSET, $black); $txtDate = strftime("%b, %Y", $MarkTime); ImageString($im, 2, $x-25, $height-YOFFSET+10, $txtDate, $black); // Calculate Next x $year++; $MarkTime = mktime(0, 0, 0, 1, 1, $year); $x = ts2x($MarkTime); } }// Draw Major Tick Marksif ((6*60*60*($width-XOFFSET))/$interval > 10) // pixels per 6 hours is more than 2 $MarkTimeStep = 6*60*60; // Major ticks are 6 hourselse if ((24*60*60*($width-XOFFSET))/$interval > 10) $MarkTimeStep = 24*60*60; // Major ticks are 24 hours;else if ((24*60*60*30*($width-XOFFSET))/$interval > 10) { // Major tick marks are months $MarkTimeStep = 0; // Skip the standard way of drawing major tick marks below $ts = getdate($timestamp); $month = $ts['mon']; $MarkTime = mktime(0, 0, 0, $month, 1, $ts['year']); $x = ts2x($MarkTime); while ($x < XOFFSET) { $month++; $MarkTime = mktime(0, 0, 0, $month, 1, $ts['year']); $x = ts2x($MarkTime); } while ($x < ($width-10)) { // Day Lines $date = getdate($MarkTime); if ($date['mon'] != 1) { ImageLine($im, $x, $height-YOFFSET-5, $x, $height-YOFFSET+5, $black); $txtDate = strftime("%b", $MarkTime); ImageString($im, 2, $x-5, $height-YOFFSET+10, $txtDate, $black); } // Calculate Next x $month++; $MarkTime = mktime(0, 0, 0, $month, 1, $ts['year']); $x = ts2x($MarkTime); } }else $MarkTimeStep = 0; // Skip Major Tick Marksif ($MarkTimeStep) { $ts = getdate($timestamp); $MarkTime = mktime(0, 0, 0, $ts['mon'], $ts['mday'], $ts['year']); $x = ts2x($MarkTime); while ($x < ($width-10)) { if ($x > XOFFSET) { ImageLine($im, $x, $height-YOFFSET-5, $x, $height-YOFFSET+5, $black); } $MarkTime += $MarkTimeStep; $x = ts2x($MarkTime); } }// Draw Minor Tick marksif ((60*60*($width-XOFFSET))/$interval > 4) // pixels per hour is more than 2 $MarkTimeStep = 60*60; // Minor ticks are 1 hourelse if ((6*60*60*($width-XOFFSET))/$interval > 4) $MarkTimeStep = 6*60*60; // Minor ticks are 6 hourselse if ((24*60*60*($width-XOFFSET))/$interval > 4) $MarkTimeStep = 24*60*60;else $MarkTimeStep = 0; // Skip minor tick marksif ($MarkTimeStep) { $ts = getdate($timestamp); $MarkTime = mktime(0, 0, 0, $ts['mon'], $ts['mday'], $ts['year']); $x = ts2x($MarkTime); while ($x < ($width-10)) { if ($x > XOFFSET) { ImageLine($im, $x, $height-YOFFSET, $x, $height-YOFFSET+5, $black); } $MarkTime += $MarkTimeStep; $x = ts2x($MarkTime); } }// Draw Y AxisImageLine($im, XOFFSET, 0, XOFFSET, $height, $black);$YLegend = 'k';$Divisor = 1;if ($YMax*8 > 1024*2) { $Divisor = 1024; // Display in m $YLegend = 'm'; }if ($YMax*8 > 1024*1024*2) { $Divisor = 1024*1024; // Display in g $YLegend = 'g'; }if ($YMax*8 > 1024*1024*1024*2) { $Divisor = 1024*1024*1024; // Display in t $YLegend = 't'; } $YStep = $YMax/10;if ($YStep < 1) $YStep=1;$YTic=$YStep; while ($YTic <= ($YMax - $YMax/10)) { $y = ($height-YOFFSET)-(($YTic*($height-YOFFSET))/$YMax); ImageLine($im, XOFFSET, $y, $width, $y, $black); $txtYLegend = sprintf("%4.1f %sbits/s", (8.0*$YTic)/$Divisor, $YLegend); ImageString($im, 2, 3, $y-7, $txtYLegend, $black); $YTic += $YStep; }imagepng($im); imagedestroy($im);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -