- Timestamp:
- Feb 20, 2015, 9:31:53 AM (10 years ago)
- Location:
- branches/old
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/old/global.php
r50 r52 12 12 include_once('types.php'); 13 13 include_once('classes.php'); 14 include_once('Common/PrefixMultiplier.php'); 15 $PrefixMultiplier = new PrefixMultiplier(); 14 16 include_once('stat_functions.php'); 15 17 $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']); … … 79 81 switch($Item['Type']) 80 82 { 81 case 'Boolean': 83 case 'Boolean': 82 84 if($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"'; 83 85 $Edit = '<input type="checkbox" name="'.$Index.'"'.$Checked.'>'; 84 86 break; 85 case 'String': 87 case 'String': 86 88 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">'; 87 89 break; 88 case 'Integer': 90 case 'Integer': 89 91 $Edit = '<input type="text" name="'.$Index.'" value="'.$Values[$Index].'">'; 90 92 break; … … 95 97 } 96 98 $Output = '<h3>Tabulka '.$ClassName.'</h3>'.Table($Table).MakeLink('?Operation=Add2', 'Přidat'); 97 return($Output); 99 return($Output); 98 100 } -
branches/old/graph.php
r51 r52 161 161 $Y = $Height - 1 - ($VerticalLinesDistance * $I); 162 162 //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * $K * $Height); 163 $Text = AddPrefixMultipliers(round(($I * $VerticalLinesDistance / $Height / $K * ($MaxValue - $MinValue) + $MinValue)), $Measure['Unit'], 3);163 $Text = $PrefixMultiplier->Add(round(($I * $VerticalLinesDistance / $Height / $K * ($MaxValue - $MinValue) + $MinValue)), $Measure['Unit'], 3); 164 164 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 165 165 if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) … … 169 169 170 170 $Left = $Width - 10; 171 $Text = " Max. ". AddPrefixMultipliers($MaxValue, $Measure['Unit']);171 $Text = " Max. ".$PrefixMultiplier->Add($MaxValue, $Measure['Unit']); 172 172 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 173 173 $Left -= ($BoundingBox[2] - $BoundingBox[0]); 174 174 imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text); 175 175 176 $Text = " Avg. ". AddPrefixMultipliers($AvgValue, $Measure['Unit'], 4);176 $Text = " Avg. ".$PrefixMultiplier->Add($AvgValue, $Measure['Unit'], 4); 177 177 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 178 178 $Left -= ($BoundingBox[2] - $BoundingBox[0]); 179 179 imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text); 180 180 181 $Text = " Min. ". AddPrefixMultipliers($MinValue, $Measure['Unit']);181 $Text = " Min. ".$PrefixMultiplier->Add($MinValue, $Measure['Unit']); 182 182 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 183 183 $Left -= ($BoundingBox[2] - $BoundingBox[0]); -
branches/old/index.php
r51 r52 182 182 $RowCount = $RowCount[0]; 183 183 } 184 $Result2 = $Database->select($Measure['DataTable'], 'time, avg', ' measure='.$Measure['Id'].' AND level=0ORDER BY time DESC LIMIT 1');184 $Result2 = $Database->select($Measure['DataTable'], 'time, avg', '(measure='.$Measure['Id'].') AND (level=0) ORDER BY time DESC LIMIT 1'); 185 185 if($Result2->num_rows > 0) 186 186 { 187 187 $Row = $Result2->fetch_array(); 188 188 $LastMeasureTime = date('j.n.Y G:i:s', MysqlDateTimeToTime($Row['time'])); 189 $LastMeasureValue = AddPrefixMultipliers($Row['avg'], $Measure['Unit']);189 $LastMeasureValue = $PrefixMultiplier->Add($Row['avg'], $Measure['Unit']); 190 190 } else { 191 191 $LastMeasureTime = ' '; … … 195 195 if($Measure['Info'] == '') $Measure['Info'] = ' '; 196 196 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 197 $Output .= '<tr><td ><a href="?Measure='.$Measure['Id'].'&Differential=0">'.$Measure['Description'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Info'].'</td>';197 $Output .= '<tr><td style="text-align: left"><a href="?Measure='.$Measure['Id'].'&Differential=0">'.$Measure['Description'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Info'].'</td>'; 198 198 if(array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>'; 199 199 $Output .= '</tr>'; -
branches/old/stat_functions.php
r51 r52 2 2 3 3 $ValueTypes = array('min', 'avg', 'max'); 4 $PrefixMultipliers = array(5 array('y', 'yocto', pow(10, -24)),6 array('z', 'zepto', pow(10, -21)),7 array('a', 'atto', pow(10, -18)),8 array('f', 'femto', pow(10, -15)),9 array('p', 'piko', pow(10, -12)),10 array('n', 'nano', pow(10, -9)),11 array('u', 'mikro', pow(10, -6)),12 array('m', 'mili', pow(10, -3)),13 array('', '', pow(10, 0)),14 array('k', 'kilo', pow(10, 3)),15 array('M', 'mega', pow(10, 6)),16 array('G', 'giga', pow(10, 9)),17 array('T', 'tera', pow(10, 12)),18 array('P', 'peta', pow(10, 15)),19 array('E', 'exa', pow(10, 18)),20 array('Z', 'zetta', pow(10, 21)),21 array('Y', 'yotta', pow(10, 24)),22 );23 24 function TruncateDigits($Value, $Digits = 4)25 {26 for($II = 2; $II > -6; $II--)27 {28 if($Value >= pow(10, $II))29 {30 if($Digits < ($II + 1)) $RealDigits = $II + 1;31 else $RealDigits = $Digits;32 $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1);33 break;34 }35 }36 return($Value);37 }38 39 function AddPrefixMultipliers($Value, $Unit, $Digits = 4)40 {41 global $PrefixMultipliers;42 43 if($Unit == '') return(TruncateDigits($Value, $Digits));44 $I = 8;45 if($Value > 0) $II = 1;46 else if($Value < 0) $II = -1;47 else $II = 0;48 while((($Value / $PrefixMultipliers[$I + $II][2]) > $II) and (($I + $II) >= 0)49 and (($I + $II) <= count($PrefixMultipliers))) $I = $I + $II;50 $Value = $Value / $PrefixMultipliers[$I][2];51 52 // Truncate digits count53 $Value = TruncateDigits($Value, $Digits);54 55 return($Value.' '.$PrefixMultipliers[$I][0].$Unit);56 }57 4 58 5 function GetMicrotime()
Note:
See TracChangeset
for help on using the changeset viewer.