Changeset 14


Ignore:
Timestamp:
Oct 17, 2007, 7:53:48 PM (17 years ago)
Author:
george
Message:

Oprava: Funkce pro přestavbu cache.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • admin.php

    r13 r14  
    1313  case 'Edit':
    1414    $Output = ShowEdit(); 
     15    break;
     16  case 'RebuildCache':
     17    $Output = ShowRebuildCache(); 
    1518    break;
    1619  default:
     
    3033  while($Measure = $Result->fetch_array())
    3134  {
    32     array_push($Table['Rows'], array($Measure['Description'], MakeLink('?Operation=Edit&MeasureId='.$Measure['Id'], 'Editovat').' '.MakeLink('?Operation=Delete&MeasureId='.$Measure['Id'], 'Odstranit')));
     35    array_push($Table['Rows'], array($Measure['Description'], MakeLink('?Operation=Edit&MeasureId='.$Measure['Id'], 'Editovat').' '.MakeLink('?Operation=Delete&MeasureId='.$Measure['Id'], 'Odstranit').' '.MakeLink('?Operation=RebuildCache&MeasureId='.$Measure['Id'], 'Pøestavìt cache')));
    3336  }
    3437  $Output = '<h3>Seznam mìøení</h3>'.Table($Table).MakeLink('?Operation=Add', 'Pøidat');
     
    3942{
    4043  global $Database;
    41   $DbResult = $Database->select('measure', '*', 'Id='.$_GET['MeasureId']);
     44  $DbResult = $Database->select('measure', '*', 'Id='.addslashes($_GET['MeasureId']));
    4245  $Values = array();
    4346  $Values = $DbResult->fetch_array();
     
    5255}
    5356
     57function ShowRebuildCache()
     58{
     59  global $Database;
     60  echo("Vytvaøím novou cache...<br>");
     61  $DbResult = $Database->select('measure', '*', 'Id='.addslashes($_GET['MeasureId']));
     62  $Measure = $DbResult->fetch_array();
     63
     64  RebuildMeasureCache($Measure); 
     65  echo('Dokonèeno<br>');         
     66}
     67
    5468?>
  • graph.php

    r13 r14  
    181181  imagettftext($Image, $FontSize, 0, $Width-194, 14, $Green, $FontFile, "Avg.  ".AddPrefixMultipliers($AvgValue, $Measure['Unit']));
    182182  imagettftext($Image, $FontSize, 0, $Width-294, 14, $Blue, $FontFile, "Min.  ".AddPrefixMultipliers($MinValue, $Measure['Unit']));
    183   imagestring($Image, 2, 50, 20, 'Vygenerováno za '.$GenerationTime.' sekund', $Black);
     183  imagestring($Image, 2, 70, 20, 'Vygenerováno za '.$GenerationTime.' sekund', $Black);
    184184  //imagestring($Image, 2, 50, 30, 'Level: '.$Level, $Black);
    185185
    186   imagettftext($Image, $FontSize, 0, 50, 14, $Black, $FontFile, to_utf8($Measure['Description']));
     186  imagettftext($Image, $FontSize, 0, 70, 14, $Black, $FontFile, to_utf8($Measure['Description']));
    187187  imagerectangle($Image, 0, 0, $Width - 1, $Height - 1, $Black);   // Frame border
    188188  imagepng($Image);
  • index.php

    r13 r14  
    190190    $RowCount = $RowCount[0];
    191191  }
    192   $Result2 = $Database->select($Measure['DataTable'], 'time, avg', 'measure='.$Measure['Id'].' ORDER BY time DESC LIMIT 1');
     192  $Result2 = $Database->select($Measure['DataTable'], 'time, avg', 'measure='.$Measure['Id'].' AND level=0 ORDER BY time DESC LIMIT 1');
    193193  if($Result2->num_rows > 0)
    194194  {
  • rebuild.php

    r1 r14  
    1 <?
     1<?php
    22
    3 include('error.php');
    4 include('stat_functions.php');
    5 include('db.php');
    6 DB_Init('localhost', 'stat', '', 'statistic');
     3include('global.php');
    74
    85//$Measure = GetMeasureById(12);
  • stat_functions.php

    r13 r14  
    249249function GetTimeRange($Measure, $Level)
    250250{
    251   global $Debug;
     251  global $Debug, $Database;
    252252 
    253253  // Get first and last time
    254   echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n");
     254  //echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n");
    255255  $Result = $Database->select($Measure['DataTable'], '*', 'measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time LIMIT 1');
    256256  if($Result->num_rows > 0)
     
    395395function RebuildMeasureCache($Measure)
    396396{
    397   global $MaxLevel, $LevelReducing;
    398 
    399   echo('Velicina '.$Measure['Name']."\n");
     397  global $MaxLevel, $LevelReducing, $Database;
     398
     399  echo('Velicina '.$Measure['Name']."<br>\n");
    400400  if($Measure['Continuity'] == 0) $Measure['ContinuityEnabled'] = 0;  // non continuous
    401401    else $Measure['ContinuityEnabled'] = 2;    // continuous graph
    402402
    403403  // Clear previous items
    404   $Result = $Database->select($Measure['DataTable'], 'COUNT(*)', 'level>0 AND measure='.$Measure['Id']);
    405   $Row = $Result->fetch_array();
     404  $DbResult = $Database->select($Measure['DataTable'], 'COUNT(*)', 'level>0 AND measure='.$Measure['Id']);
     405  $Row = $DbResult->fetch_array();
    406406  echo("Mazu starou cache (".$Row[0]." polozek)...");
    407407  $Database->delete($Measure['DataTable'], 'level>0 AND measure='.$Measure['Id']);
    408   echo("\n");
     408  echo("<br>\n");
    409409
    410410  for($Level=1; $Level <= $MaxLevel; $Level++)
    411411  {
    412     echo('Uroven '.$Level."\n");
     412    echo('Uroven '.$Level."<br>\n");
    413413    $TimeRange = GetTimeRange($Measure, $Level-1);
    414414    //echo($Measure['Id'].','.($Level-1)."\n");
     
    418418    $EndTime = AlignTime($TimeRange['right'], $TimeSegment);
    419419    $BurstCount = 500;
    420     echo('For 0 to '.round(($EndTime - $StartTime) / $TimeSegment / $BurstCount)."\n");
     420    echo('For 0 to '.round(($EndTime - $StartTime) / $TimeSegment / $BurstCount)."<br>\n");
    421421    for($I = 0; $I <= round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); $I++)
    422422    {
     
    425425      $EndTime2 = $StartTime + ($I+1) * $BurstCount * $TimeSegment;
    426426      $Values = array();
    427       DB_Select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($StartTime2).'" AND time < "'.
     427      $DbResult = $Database->select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($StartTime2).'" AND time < "'.
    428428        TimeToMysqlDateTime($EndTime2).'" AND measure='.$Measure['Id'].' AND level='.($Level-1).' ORDER BY time');
    429       while($Row = DB_Row())
     429      while($Row = $DbResult->fetch_array())
    430430      {
    431431        $Row['time'] = MysqlDateTimeToTime($Row['time']);
     
    453453            $Point = ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Measure, $Level);
    454454            $Continuity = $SubValues[1]['continuity'];   
    455             DB_Insert($Measure['DataTable'], array('level' => $Level, 'measure' => $Measure['Id'], 'min' => $Point['min'],
     455            $Database->insert($Measure['DataTable'], array('level' => $Level, 'measure' => $Measure['Id'], 'min' => $Point['min'],
    456456              'avg' => $Point['avg'], 'max' => $Point['max'], 'continuity' => $Continuity, 'time' => TimeToMysqlDateTime($StartTime3+($EndTime3-$StartTime3)/2)));
    457457          }       
     
    462462      //array_pop($NextValues);
    463463    } 
    464     echo("Uroven dokoncena\n");         
    465     DB_Select($Measure['DataTable'], 'COUNT(*)', 'level='.$Level.' AND measure='.$Measure['Id']);
    466     $Row = DB_Row();
    467     echo("Vlozeno ".$Row[0]." polozek.\n");
     464    echo("Uroven dokoncena<br>\n");         
     465    $DbResult = $Database->select($Measure['DataTable'], 'COUNT(*)', 'level='.$Level.' AND measure='.$Measure['Id']);
     466    $Row = $DbResult->fetch_array();
     467    echo("Vlozeno ".$Row[0]." polozek.<br>\n");
    468468  }
    469469}   
     
    479479  $Result = $Database->select('measure', '*');
    480480  while($Measures[] = $Result->fetch_array());
    481   array_pop($Measures);
     481    array_pop($Measures);
    482482
    483483  foreach($Measures as $Measure)
  • style/style.css

    r7 r14  
    1 body {
    2         font-family: Arial, Helvetica, sans-serif;
     1body
     2{
     3  font-family :  Arial, sans-serif;
     4}
     5.BasicTable
     6{
     7  border-width: thin;
     8  border-style: solid;
     9  border-color: red;
     10  padding: 0px 0px 0px 0px;
     11  border-collapse: collapse;
     12}
     13.BasicTable td
     14{
     15  border-width: 2px;
     16  border-style: solid;
     17  border-color: Silver;
     18  padding: 2px;
     19}
     20.BasicTable th
     21{
     22  border-width: 2px;
     23  border-style: solid;
     24  border-color: Silver;
     25  padding: 2px;
     26}
     27h3
     28{
     29  margin-bottom: 3px;
    330}
    431
Note: See TracChangeset for help on using the changeset viewer.