Changeset 6
- Timestamp:
- Oct 16, 2007, 10:12:26 PM (17 years ago)
- Files:
-
- 5 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
admin.php
r4 r6 27 27 ); 28 28 29 $Result = $Database->select('measure', '*' );29 $Result = $Database->select('measure', '*', '1 ORDER BY Description'); 30 30 while($Measure = $Result->fetch_array()) 31 31 { 32 array_push($Table['Rows'], array($Measure[' Name'], Link('?Operation=Edit&MeasureId='.$Measure['Id'], 'Editovat').' '.Link('?Operation=Delete&MeasureId='.$Measure['Id'], 'Odstranit')));32 array_push($Table['Rows'], array($Measure['Description'], MakeLink('?Operation=Edit&MeasureId='.$Measure['Id'], 'Editovat').' '.MakeLink('?Operation=Delete&MeasureId='.$Measure['Id'], 'Odstranit'))); 33 33 } 34 $Output = '<h3>Seznam mìøení</h3>'.Table($Table). Link('?Operation=Add', 'Pøidat');34 $Output = '<h3>Seznam mìøení</h3>'.Table($Table).MakeLink('?Operation=Add', 'Pøidat'); 35 35 return($Output); 36 36 } -
config.sample.php
r1 r6 2 2 3 3 $Config = array( 4 ' database' => array(5 ' host' => 'localhost',6 ' user' => 'stat',7 ' password' => 'serepes',8 ' database' => 'statistic',9 ' prefix' => '',10 ' charset' => 'latin2',4 'Database' => array( 5 'Host' => 'localhost', 6 'User' => 'root', 7 'Password' => '', 8 'Database' => 'statistic', 9 'Prefix' => '', 10 'Charset' => 'latin2', 11 11 ), 12 'add_url' => 'http://localhost/statistic/new/add.php', 12 'AddNewValueUrl' => 'http://localhost/dev/statistic/add.php', 13 'Debug' => 0, 14 'Web' => array( 15 'Title' => 'Statistika', 16 'Charset' => 'iso-8859-2', 17 ), 18 'DivisionCount' => 500, 19 'LevelReducing' => 5, 20 'MaxLevel' => 4, 21 'ReferenceTime' => 0, 22 'ImageWidth' => 750, 23 'ImageHeight' => 200, 24 'ValueToImageHeigthCoefficient' => 0.9, 25 'FontFileName' => 'arial.ttf', 26 'FontSize' => 10, 27 'DefaultVariables' => array( 28 'TimeStart' => time() - 3600*24, 29 'TimeEnd' => time(), 30 'Measure' => 1, 31 'Period' => 'day', 32 'TimeSpecify' => 5, 33 ), 13 34 ); 14 35 36 // For back compatibility during development 37 $DivisionCount = $Config['DivisionCount']; 38 $ReferenceTime = $Config['ReferenceTime']; 39 $LevelReducing = $Config['LevelReducing']; 40 $MaxLevel = $Config['MaxLevel']; 41 $DefaultWidth = $Config['ImageWidth']; 42 $DefaultHeight = $Config['ImageHeight']; 43 $K = $Config['ValueToImageHeigthCoefficient']; 44 $FontFile = $Config['FontFileName']; 45 $FontSize = $Config['FontSize']; 46 15 47 ?> -
global.php
r4 r6 2 2 3 3 session_start(); 4 include ('config.php');5 include ('database.php');6 include ('code.php');7 include ('types.php');8 include ('classes.php');9 include ('stat_functions.php');4 include_once('config.php'); 5 include_once('database.php'); 6 include_once('code.php'); 7 include_once('types.php'); 8 include_once('classes.php'); 9 include_once('stat_functions.php'); 10 10 $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']); 11 11 $Database->Prefix = $Config['Database']['Prefix']; … … 29 29 30 30 31 function Link($Target, $Title)31 function MakeLink($Target, $Title) 32 32 { 33 33 return('<a href="'.$Target.'">'.$Title.'</a>'); … … 57 57 $Class = $Classes[$ClassName]; 58 58 $Table = array( 59 'Header' => array('Polo ¾ka', 'Hodnota'),59 'Header' => array('Poloka', 'Hodnota'), 60 60 'Rows' => array(), 61 61 ); -
graph.php
r3 r6 5 5 else $Debug = 0; 6 6 7 $DefaultWidth = 750;8 $DefaultHeight = 200;9 $K = 0.9; // Coeficient for decreasing graph height10 $FontFile = 'arial.ttf';11 $FontSize = 10;12 13 7 if(!array_key_exists('From',$_GET)) die('Musíte zadat èas poèátku'); 14 8 $StartTime = addslashes($_GET['From']); … … 47 41 foreach($Points as $Index => $Item) 48 42 { 49 $Points[$Index]['min'] = $Points[$Index]['min'] / $Measure[' display_divider'];50 $Points[$Index]['avg'] = $Points[$Index]['avg'] / $Measure[' display_divider'];51 $Points[$Index]['max'] = $Points[$Index]['max'] / $Measure[' display_divider'];43 $Points[$Index]['min'] = $Points[$Index]['min'] / $Measure['Divider']; 44 $Points[$Index]['avg'] = $Points[$Index]['avg'] / $Measure['Divider']; 45 $Points[$Index]['max'] = $Points[$Index]['max'] / $Measure['Divider']; 52 46 if($Points[$Index]['avg'] > $MaxValue) $MaxValue = $Points[$Index]['avg']; 53 47 if($Points[$Index]['avg'] < $MinValue) $MinValue = $Points[$Index]['avg']; … … 56 50 $AvgValue = $AvgValue + $Points[$Index]['avg']; 57 51 } 58 $MinValue = round($MinValue * $Measure[' display_divider']) / $Measure['display_divider'];59 $MaxValue = round($MaxValue * $Measure[' display_divider']) / $Measure['display_divider'];60 $AvgValue = round($AvgValue / count($Points) * $Measure[' display_divider']) / $Measure['display_divider'];52 $MinValue = round($MinValue * $Measure['Divider']) / $Measure['Divider']; 53 $MaxValue = round($MaxValue * $Measure['Divider']) / $Measure['Divider']; 54 $AvgValue = round($AvgValue / count($Points) * $Measure['Divider']) / $Measure['Divider']; 61 55 62 56 // Generate polygon and recalculate y values to fit graph height … … 91 85 92 86 93 array_unshift($Points, $Height - 1); 94 array_unshift($Points, 0); 95 $Points[] = $Width - 1; 96 $Points[] = $Height - 1; 87 //array_unshift($Points, $Height - 1); 88 //array_unshift($Points, 0); 89 //$Points[] = $Width - 1; 90 //$Points[] = $Height - 1; 91 92 //print_r($PointsMax); 97 93 98 94 // Generate image … … 182 178 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 183 179 184 imagettftext($Image, $FontSize, 0, $Width-94, 14, $Red, $FontFile, "Max. ".$MaxValue.' '.$Measure[' unit']);185 imagettftext($Image, $FontSize, 0, $Width-194, 14, $Green, $FontFile, "Avg. ".$AvgValue.' '.$Measure[' unit']);186 imagettftext($Image, $FontSize, 0, $Width-294, 14, $Blue, $FontFile, "Min. ".$MinValue.' '.$Measure[' unit']);180 imagettftext($Image, $FontSize, 0, $Width-94, 14, $Red, $FontFile, "Max. ".$MaxValue.' '.$Measure['Unit']); 181 imagettftext($Image, $FontSize, 0, $Width-194, 14, $Green, $FontFile, "Avg. ".$AvgValue.' '.$Measure['Unit']); 182 imagettftext($Image, $FontSize, 0, $Width-294, 14, $Blue, $FontFile, "Min. ".$MinValue.' '.$Measure['Unit']); 187 183 imagestring($Image, 2, 50, 20, 'Vygenerováno za '.$GenerationTime.' sekund', $Black); 188 184 //imagestring($Image, 2, 50, 30, 'Level: '.$Level, $Black); 189 185 190 imagettftext($Image, $FontSize, 0, 50, 14, $Black, $FontFile, to_utf8($Measure[' description']));186 imagettftext($Image, $FontSize, 0, 50, 14, $Black, $FontFile, to_utf8($Measure['Description'])); 191 187 imagerectangle($Image, 0, 0, $Width - 1, $Height - 1, $Black); // Frame border 192 188 imagepng($Image); -
index.php
r3 r6 98 98 ); 99 99 100 $Variables = array( 101 'TimeStart' => time() - 3600*24, 102 'TimeEnd' => time(), 103 'Measure' => 1, 104 'Period' => 'day', 105 'TimeSpecify' => 0, 106 ); 107 108 foreach($Variables as $Index => $Variable) 100 foreach($Config['DefaultVariables'] as $Index => $Variable) 109 101 { 110 102 if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable; … … 182 174 183 175 $Output .= '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small;">'; 184 $Output .= '<tr><th>Mìøená velièina</th><th>Èas posledního mìøení</th><th>Poslední hodnota</th><th>Interpolace</th><th>Poznámky</th></tr>'; 176 $Output .= '<tr><th>Mìøená velièina</th><th>Èas posledního mìøení</th><th>Poslední hodnota</th><th>Interpolace</th><th>Poznámky</th>'; 177 if(array_key_exists('Debug', $_GET)) $Output .= '<th>Poèet polo¾ek</th><th>Èas vykonání</th>'; 178 $Output .= '</tr>'; 185 179 $Database->select_db('measure'); 186 180 $Result = $Database->select('measure', '*', 'Enabled=1 AND PermissionView="all" OR PermissionView="'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'" ORDER BY Description'); … … 190 184 { 191 185 $StopWatchStart = GetMicrotime(); 192 // DB_Select('stat_data', 'COUNT(*)', 'measure='.$Measure['id']); 193 // $RowCount = DB_Row(); 194 // $RowCount = $RowCount[0]; 195 // $RowCount = 0; 196 $Result2 = $Database->select('stat_data', 'time, avg', 'measure='.$Measure['id'].' ORDER BY time DESC LIMIT 1'); 186 if(array_key_exists('Debug', $_GET)) 187 { 188 $DbResult = $Database->select($Measure['DataTable'], 'COUNT(*)', 'measure='.$Measure['Id']); 189 $RowCount = $DbResult->fetch_array(); 190 $RowCount = $RowCount[0]; 191 } 192 $Result2 = $Database->select($Measure['DataTable'], 'time, avg', 'measure='.$Measure['Id'].' ORDER BY time DESC LIMIT 1'); 197 193 if($Result2->num_rows > 0) 198 194 { 199 195 $Row = $Result2->fetch_array(); 200 196 $LastMeasureTime = date('j.n.Y G:i:s', MysqlDateTimeToTime($Row['time'])); 201 $LastMeasureValue = round($Row['avg'] / $Measure[' display_divider']);197 $LastMeasureValue = round($Row['avg'] / $Measure['Divider']); 202 198 } else { 203 199 $LastMeasureTime = ' '; 204 200 $LastMeasureValue = ' '; 205 201 } 206 if($Measure[' continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne';207 if($Measure[' info'] == '') $Measure['info'] = ' ';202 if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne'; 203 if($Measure['Info'] == '') $Measure['Info'] = ' '; 208 204 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 209 $Output .= '<tr><td><a href="?Measure='.$Measure[' id'].'">'.$Measure['description'].'</a></td><td align="center">'.$LastMeasureValue.' '.$Measure['display_unit'].'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['info'].'</td>';210 //<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td></tr>');211 flush();205 $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'">'.$Measure['Description'].'</a></td><td align="center">'.$LastMeasureValue.' '.$Measure['Unit'].'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Info'].'</td>'; 206 if(array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>'; 207 $Output .= '</tr>'; 212 208 } 213 209 $Output .= '</table>'; -
stat_functions.php
r2 r6 1 1 <?php 2 3 $DivisionCount = 500;4 $ReferenceTime = 0;5 $LevelReducing = 5;6 $MaxLevel = 4;7 2 8 3 $ValueTypes = array('min', 'avg', 'max'); … … 36 31 function StatTableName($Level) 37 32 { 38 if($Level == 0) return(' stat_data');39 else return(' stat_data_cache');33 if($Level == 0) return('data'); 34 else return('data_cache'); 40 35 } 41 36 … … 49 44 { 50 45 global $Database; 51 $Result = $Database->select(' stat_measure', '*', 'id='.$Id);46 $Result = $Database->select('measure', '*', 'Id='.$Id); 52 47 if($Result->num_rows > 0) 53 48 { 54 49 $Measure = $Result->fetch_array(); 55 if($Measure[' continuity'] == 0) $Measure['ContinuityEnabled'] = 0; // non continuous50 if($Measure['Continuity'] == 0) $Measure['ContinuityEnabled'] = 0; // non continuous 56 51 else $Measure['ContinuityEnabled'] = 2; // continuous graph 57 52 } else die('Mìøená velièina nenalezena'); … … 64 59 65 60 $Time = time(); 66 $Value = round($Measure['divider']*$Value);67 68 $Result = $Databse->select( 'stat_data', '*', 'measure='.$Measure['id'].' AND level=0 ORDER BY time DESC LIMIT 2');69 if($Result->num_rows == 0) $Database->insert('stat_data', array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure[' id'], 'time' => TimeToMysqlDateTime($Time),61 //$Value = round($Measure['divider'] * $Value); 62 63 $Result = $Databse->select($Measure['DataTable'], '*', 'measure='.$Measure['Id'].' AND level=0 ORDER BY time DESC LIMIT 2'); 64 if($Result->num_rows == 0) $Database->insert('stat_data', array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['Id'], 'time' => TimeToMysqlDateTime($Time), 70 65 'continuity' => 0)); 71 else if($Result->num_rows == 1) $Database->insert( 'stat_data', array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['id'], 'time' => TimeToMysqlDateTime($Time),66 else if($Result->num_rows == 1) $Database->insert($Measure['DataTable'], array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['Id'], 'time' => TimeToMysqlDateTime($Time), 72 67 'continuity' => 1)); 73 68 else { … … 85 80 { 86 81 echo('s'); 87 $Database->update( 'stat_data', 'time="'.$LastValue['time'].'" AND level=0 AND measure='.$Measure['id'], array('time' => 'NOW()'));82 $Database->update($Measure['DataTable'], 'time="'.$LastValue['time'].'" AND level=0 AND measure='.$Measure['Id'], array('time' => 'NOW()')); 88 83 } else 89 84 { 90 $Database->insert( 'stat_data', array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['id'], 'time' => TimeToMysqlDateTime($Time),85 $Database->insert($Measure['DataTable'], array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['Id'], 'time' => TimeToMysqlDateTime($Time), 91 86 'continuity' => $Continuity)); 92 87 } … … 109 104 // Load values in time range 110 105 $Values = array(); 111 $Result = $Database->select( StatTableName($Level-1), '*', 'time > "'.TimeToMysqlDateTime($StartTime).'" AND time < "'.112 TimeToMysqlDateTime($EndTime).'" AND measure='.$Measure[' id'].' AND level='.($Level-1).' ORDER BY time');106 $Result = $Database->select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($StartTime).'" AND time < "'. 107 TimeToMysqlDateTime($EndTime).'" AND measure='.$Measure['Id'].' AND level='.($Level-1).' ORDER BY time'); 113 108 while($Row = $Result->fetch_array()) 114 109 { … … 126 121 //print_r($Point); 127 122 128 $Database->delete( StatTableName($Level), '(time > "'.TimeToMysqlDateTime($StartTime).'") AND129 (time < "'.TimeToMysqlDateTime($EndTime).'") AND measure='.$Measure[' id'].' AND level='.$Level);123 $Database->delete($Measure['DataTable'], '(time > "'.TimeToMysqlDateTime($StartTime).'") AND 124 (time < "'.TimeToMysqlDateTime($EndTime).'") AND measure='.$Measure['Id'].' AND level='.$Level); 130 125 $Continuity = $Values[1]['continuity']; 131 $Database->insert( StatTableName($Level), array('level' => $Level, 'measure' => $Measure['id'], 'min' => $Point['min'],126 $Database->insert($DataTable, array('level' => $Level, 'measure' => $Measure['Id'], 'min' => $Point['min'], 132 127 'avg' => $Point['avg'], 'max' => $Point['max'], 'continuity' => $Continuity, 'time' => TimeToMysqlDateTime($StartTime+($EndTime-$StartTime)/2))); 133 128 … … 203 198 } 204 199 //if(($RightTime - $LeftTime) > 0) 205 if($Measure[' cumulative'] == 0) $NewValue['avg'] = $NewValue['avg'] / ($RightTime - $LeftTime);200 if($Measure['Cumulative'] == 0) $NewValue['avg'] = $NewValue['avg'] / ($RightTime - $LeftTime); 206 201 return($NewValue); 207 202 //echo($NewValue['avg'].'<br>'); … … 214 209 215 210 // Get first and last time 216 echo($Measure[' id'].','.$Level.','.StatTableName($Level)."\n");217 $Result = $Database->select( StatTableName($Level), '*', 'measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time LIMIT 1');211 echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n"); 212 $Result = $Database->select($Measure['DataTable'], '*', 'measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time LIMIT 1'); 218 213 if($Result->num_rows > 0) 219 214 { … … 222 217 } else $AbsoluteLeftTime = 0; 223 218 224 $Result = $Database->select( StatTableName($Level), '*', 'measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1');219 $Result = $Database->select($Measure['DataTable'], '*', 'measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1'); 225 220 if($Result->num_rows > 0) 226 221 { … … 239 234 function LoadRightSideValue($Level, $Measure, $Time) 240 235 { 241 global $Debug ;236 global $Debug, $Database; 242 237 $Result = array(); 243 $ Result = $Database->select(StatTableName($Level), '*', 'time > "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time ASC LIMIT 1');244 if($ Result->num_rows > 0)245 { 246 $Row = $ Result->fetch_array();238 $DbResult = $Database->select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time ASC LIMIT 1'); 239 if($DbResult->num_rows > 0) 240 { 241 $Row = $DbResult->fetch_array(); 247 242 $Row['time'] = MysqlDateTimeToTime($Row['time']); 248 243 return(array($Row)); … … 253 248 //array_push($Values, array('time' => $Time, 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0)); 254 249 $Result[] = array('time' => ($Time + TimeSegment($Level)), 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0); 255 $ Result = $Database->select(StatTableName($Level), '*', 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1');256 if($ Result->num_rows > 0)257 { 258 $Row = $ Result->fetch_array();250 $DbResult = $Database->select($Measure['DataTable'], '*', 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1'); 251 if($DbResult->num_rows > 0) 252 { 253 $Row = $DbResult->fetch_array(); 259 254 array_unshift($Result, array('time' => (MysqlDateTimeToTime($Row['time'])+10), 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0)); 260 255 } … … 266 261 function LoadLeftSideValue($Level, $Measure, $Time) 267 262 { 268 global $Debug ;263 global $Debug, $Database; 269 264 $Result = array(); 270 //echo('SELECT * FROM '.StatTableName($Level). ' WHERE '. 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure[' id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1'."<br>\n");271 $ Result = $Database->select(StatTableName($Level), '*', 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1');272 if($ Result->num_rows > 0)273 { 274 $Row = $ Result->fetch_array();265 //echo('SELECT * FROM '.StatTableName($Level). ' WHERE '. 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1'."<br>\n"); 266 $DbResult = $Database->select($Measure['DataTable'], '*', 'time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time DESC LIMIT 1'); 267 if($DbResult->num_rows > 0) 268 { 269 $Row = $DbResult->fetch_array(); 275 270 $Row['time'] = MysqlDateTimeToTime($Row['time']); 276 271 return(array($Row)); … … 282 277 $Result[] = array('time' => ($Time - TimeSegment($Level)), 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0); 283 278 284 $ Result = $Database->select(StatTableName($Level), '*', 'time > "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['id'].' AND level='.$Level.' ORDER BY time ASC LIMIT 1');285 if($ Result->num_rows > 0)286 { 287 $Row = $ Result->fetch_array();279 $DbResult = $Database->select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time ASC LIMIT 1'); 280 if($DbResult->num_rows > 0) 281 { 282 $Row = $DbResult->fetch_array(); 288 283 array_push($Result, array('time' => (MysqlDateTimeToTime($Row['time'])-10), 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0)); 289 284 } … … 295 290 function GetValues($Measure, $TimeFrom, $TimeTo, $Level) 296 291 { 297 global $DivisionCount, $Debug ;292 global $DivisionCount, $Debug, $Database; 298 293 299 294 if($Debug) echo('TimeFrom: '.$TimeFrom.'('.TimeToMysqlDateTime($TimeFrom).')<br>'); … … 307 302 308 303 // Load values in time range 309 $Result = $Database->select( StatTableName($Level), 'time, min, avg, max, continuity', 'time > "'.TimeToMysqlDateTime($TimeFrom).'" AND time < "'.310 TimeToMysqlDateTime($TimeTo).'" AND measure='.$Measure[' id'].' AND level='.$Level.' ORDER BY time');304 $Result = $Database->select($Measure['DataTable'], 'time, min, avg, max, continuity', 'time > "'.TimeToMysqlDateTime($TimeFrom).'" AND time < "'. 305 TimeToMysqlDateTime($TimeTo).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time'); 311 306 // echo($Level.' '.TimeToMysqlDateTime($TimeFrom).' '.TimeToMysqlDateTime($TimeTo)); 312 307 $Values = array(); … … 334 329 $StartIndex = 0; 335 330 $Points = array(); 331 //echo($DivisionCount.'<br>'); 336 332 for($I = 0; $I < $DivisionCount; $I++) 337 333 { … … 358 354 global $MaxLevel, $LevelReducing; 359 355 360 echo('Velicina '.$Measure[' name']."\n");361 if($Measure[' continuity'] == 0) $Measure['ContinuityEnabled'] = 0; // non continuous356 echo('Velicina '.$Measure['Name']."\n"); 357 if($Measure['Continuity'] == 0) $Measure['ContinuityEnabled'] = 0; // non continuous 362 358 else $Measure['ContinuityEnabled'] = 2; // continuous graph 363 359 364 360 // Clear previous items 365 $Result = $Database->select( 'stat_data_cache', 'COUNT(*)', 'level>0 AND measure='.$Measure['id']);361 $Result = $Database->select($Measure['DataTable'], 'COUNT(*)', 'level>0 AND measure='.$Measure['Id']); 366 362 $Row = $Result->fetch_array(); 367 363 echo("Mazu starou cache (".$Row[0]." polozek)..."); 368 $Database->delete( 'stat_data_cache', 'level>0 AND measure='.$Measure['id']);364 $Database->delete($Measure['DataTable'], 'level>0 AND measure='.$Measure['Id']); 369 365 echo("\n"); 370 366 … … 373 369 echo('Uroven '.$Level."\n"); 374 370 $TimeRange = GetTimeRange($Measure, $Level-1); 375 //echo($Measure[' id'].','.($Level-1)."\n");371 //echo($Measure['Id'].','.($Level-1)."\n"); 376 372 //echo(TimeToMysqlDateTime($TimeRange['left']).'-'.TimeToMysqlDateTime($TimeRange['right'])."\n"); 377 373 $TimeSegment = TimeSegment($Level); … … 386 382 $EndTime2 = $StartTime + ($I+1) * $BurstCount * $TimeSegment; 387 383 $Values = array(); 388 DB_Select( StatTableName($Level-1), '*', 'time > "'.TimeToMysqlDateTime($StartTime2).'" AND time < "'.389 TimeToMysqlDateTime($EndTime2).'" AND measure='.$Measure[' id'].' AND level='.($Level-1).' ORDER BY time');384 DB_Select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($StartTime2).'" AND time < "'. 385 TimeToMysqlDateTime($EndTime2).'" AND measure='.$Measure['Id'].' AND level='.($Level-1).' ORDER BY time'); 390 386 while($Row = DB_Row()) 391 387 { … … 414 410 $Point = ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Measure, $Level); 415 411 $Continuity = $SubValues[1]['continuity']; 416 DB_Insert( StatTableName($Level), array('level' => $Level, 'measure' => $Measure['id'], 'min' => $Point['min'],412 DB_Insert($Measure['DataTable'], array('level' => $Level, 'measure' => $Measure['Id'], 'min' => $Point['min'], 417 413 'avg' => $Point['avg'], 'max' => $Point['max'], 'continuity' => $Continuity, 'time' => TimeToMysqlDateTime($StartTime3+($EndTime3-$StartTime3)/2))); 418 414 } … … 424 420 } 425 421 echo("Uroven dokoncena\n"); 426 DB_Select( 'stat_data', 'COUNT(*)', 'level='.$Level.' AND measure='.$Measure['id']);422 DB_Select($Measure['DataTable'], 'COUNT(*)', 'level='.$Level.' AND measure='.$Measure['Id']); 427 423 $Row = DB_Row(); 428 424 echo("Vlozeno ".$Row[0]." polozek.\n"); … … 438 434 // Load measures 439 435 $Measures = array(); 440 $Result = $Database->select(' stat_measure', '*');436 $Result = $Database->select('measure', '*'); 441 437 while($Measures[] = $Result->fetch_array()); 442 438 array_pop($Measures);
Note:
See TracChangeset
for help on using the changeset viewer.