Changeset 49


Ignore:
Timestamp:
Feb 20, 2015, 8:30:42 AM (9 years ago)
Author:
chronos
Message:
  • Fixed: Use time() instead of NOW() in AddValue function.
  • Modified: Removed some whitespace.
Location:
branches/old
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • branches/old

    • Property svn:ignore
      •  

        old new  
        11config.php
         2.buildpath
         3.project
         4.settings
  • branches/old/add.php

    r28 r49  
    1313  } else echo('Nemáte oprávnění k aktualizaci zadané veličiny!<br>Vaše adresa: '.gethostbyaddr($_SERVER['REMOTE_ADDR']).'('.$_SERVER['REMOTE_ADDR'].')');
    1414} else echo('Nebyly zadány potřebné parametry');
    15 
    16 ?>
  • branches/old/global.php

    r28 r49  
    6464    'Rows' => array(),
    6565  );
    66  
     66
    6767  foreach($Class as $Index => $Item)
    6868  {
     
    8181        break;
    8282      default:
    83         $Edit = 'Neznámý typ';     
     83        $Edit = 'Neznámý typ';
    8484    }
    8585    array_push($Table['Rows'], array($Item['Caption'], $Edit));
     
    8888  return($Output);
    8989}
    90 
    91 ?>
  • branches/old/index.php

    r28 r49  
    77{
    88      global $Months;
    9      
     9
    1010      $Output = '<form style="display: inline;" action="?Operation=SetTime&amp;Time='.$Time.'" method="post">';
    11      
     11
    1212      $TimeParts = getdate($_SESSION[$Time]);
    1313      //print_r($TimeParts);
    14          
     14
    1515      // Day selection
    1616      $Output .= '<select name="Day">';
     
    2121      }
    2222      $Output .= '</select>. ';
    23      
     23
    2424      // Month selection
    2525      $Output .= '<select name="Month">';
     
    178178  $StopWatchStart = GetMicrotime();
    179179  if(array_key_exists('Debug', $_GET))
    180   { 
     180  {
    181181    $DbResult = $Database->select($Measure['DataTable'], 'COUNT(*)', 'measure='.$Measure['Id']);
    182182    $RowCount = $DbResult->fetch_array();
     
    201201}
    202202$Output .= '</table>';
    203 $Output .= '<br><a href="http://game.zdechov.net/statistic/development/">Sekce vývoje systému</a>';
     203$Output .= '<br><a href="http://svn.zdechov.net/trac/statistic/">Sekce vývoje systému</a>';
    204204//echo(time());
    205205//print_r(gd_info());
     
    210210
    211211//echo(AddPrefixMultipliers('-0.000000071112345', 'B'));
    212 
    213 ?>
  • branches/old/stat_functions.php

    r28 r49  
    1919  array('E', 'exa', pow(10, 18)),
    2020  array('Z', 'zetta', pow(10, 21)),
    21   array('Y', 'yotta', pow(10, 24)), 
     21  array('Y', 'yotta', pow(10, 24)),
    2222);
    2323
     
    2727  {
    2828    if($Value >= pow(10, $II))
    29     { 
    30       if($Digits < ($II + 1)) $RealDigits = $II + 1; else $RealDigits = $Digits; 
     29    {
     30      if($Digits < ($II + 1)) $RealDigits = $II + 1; else $RealDigits = $Digits;
    3131      $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1);
    32       break;     
     32      break;
    3333    }
    3434  }
     
    4242  if($Unit == '') return(TruncateDigits($Value, $Digits));
    4343  $I = 8;
    44   if($Value > 0) $II = 1; 
     44  if($Value > 0) $II = 1;
    4545  else if($Value < 0) $II = -1;
    4646  else $II = 0;
    47   while((($Value / $PrefixMultipliers[$I + $II][2]) > $II) and (($I + $II) >= 0) and (($I + $II) <= count($PrefixMultipliers))) $I = $I + $II;
     47  while((($Value / $PrefixMultipliers[$I + $II][2]) > $II) and (($I + $II) >= 0)
     48    and (($I + $II) <= count($PrefixMultipliers))) $I = $I + $II;
    4849  $Value = $Value / $PrefixMultipliers[$I][2];
    49  
     50
    5051  // Truncate digits count
    5152  $Value = TruncateDigits($Value, $Digits);
    52    
     53
    5354  return($Value.' '.$PrefixMultipliers[$I][0].$Unit);
    5455}
     
    6364{
    6465  $Parts = explode(' ', $Time);
    65   $DateParts = explode('-', $Parts[0]); 
     66  $DateParts = explode('-', $Parts[0]);
    6667  $TimeParts = explode(':', $Parts[1]);
    6768  $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
    68   return($Result); 
     69  return($Result);
    6970}
    7071
    7172function TimeToMysqlDateTime($Time)
    7273{
    73   return(date('Y-m-d H:i:s', $Time)); 
     74  return(date('Y-m-d H:i:s', $Time));
    7475}
    7576
     
    9596{
    9697  global $Database;
     98
    9799  $Result = $Database->select('measure', '*', 'Id='.$Id);
    98   if($Result->num_rows > 0) 
     100  if($Result->num_rows > 0)
    99101  {
    100102    $Measure = $Result->fetch_array();
    101103    if($Measure['Continuity'] == 0) $Measure['ContinuityEnabled'] = 0;  // non continuous
    102       else $Measure['ContinuityEnabled'] = 2;    // continuous graph 
    103   } else die('M��enďż˝ veliďż˝ina nenalezena');
     104      else $Measure['ContinuityEnabled'] = 2;    // continuous graph
     105  } else die('Měřená veličina nenalezena');
    104106  return($Measure);
    105107}
     
    108110{
    109111  global $LevelReducing, $MaxLevel, $Database;
    110  
     112
    111113  $Time = time();
    112114  //$Value = round($Measure['divider'] * $Value);
    113115
    114116  $Result = $Database->select($Measure['DataTable'], '*', 'measure='.$Measure['Id'].' AND level=0 ORDER BY time DESC LIMIT 2');
    115   if($Result->num_rows == 0) $Database->insert($Measure['DataTable'], array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['Id'], 'time' => TimeToMysqlDateTime($Time),
    116     'continuity' => 0));
     117  if($Result->num_rows == 0) $Database->insert($Measure['DataTable'],
     118    array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0,
     119    'measure' => $Measure['Id'], 'time' => TimeToMysqlDateTime($Time), 'continuity' => 0));
    117120  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),
    118121    'continuity' => 1));
     
    123126    {
    124127    }
    125     else 
     128    else
    126129    {
    127130      if(($Time - MysqlDateTimeToTime($LastValue['time'])) < 1.25 * $Measure['Period']) $Continuity = 1;
     
    130133        ($LastValue['continuity'] == 1) and ($Continuity == 1))
    131134      {
    132         //echo('s');
    133         $Database->update($Measure['DataTable'], 'time="'.$LastValue['time'].'" AND level=0 AND measure='.$Measure['Id'], array('time' => 'NOW()'));
     135        $Database->update($Measure['DataTable'], '(time="'.$LastValue['time'].'") AND '.
     136        '(level=0) AND (measure='.$Measure['Id'].')', array('time' => TimeToMysqlDateTime($Time)));
    134137      } else
    135138      {
    136         $Database->insert($Measure['DataTable'], array('min' => $Value, 'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['Id'], 'time' => TimeToMysqlDateTime($Time),
    137           'continuity' => $Continuity));       
    138       }
    139     }
    140   }
    141    
     139        $Database->insert($Measure['DataTable'], array('min' => $Value,
     140          'avg' => $Value, 'max' => $Value, 'level' => 0, 'measure' => $Measure['Id'], 'time' => TimeToMysqlDateTime($Time),
     141          'continuity' => $Continuity));
     142      }
     143    }
     144  }
     145
    142146    // Update levels
    143147    //echo($Time."<br>\n");
     
    170174      $Point = ComputeOneValue($StartTime, $EndTime, $Values, $Measure, $Level);
    171175      //print_r($Point);
    172      
     176
    173177      $Database->delete($Measure['DataTable'], '(time > "'.TimeToMysqlDateTime($StartTime).'") AND
    174178        (time < "'.TimeToMysqlDateTime($EndTime).'") AND measure='.$Measure['Id'].' AND level='.$Level);
     
    247251        {
    248252          if(0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0;
    249         }
    250         else
    251         {
     253        } else {
    252254          if($Differential == 0)
    253255          {
     
    256258            $Difference = $Values[$I+1][$ValueType] - $Values[$I][$ValueType];
    257259            if($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;
    258           } 
     260          }
    259261        }
    260262      }
    261            
    262     } 
     263    }
    263264    $NewValue[$ValueType] = $NewValue[$ValueType];
    264265  }
     
    276277{
    277278  global $Debug, $Database;
    278  
     279
    279280  // Get first and last time
    280281  //echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n");
     
    302303
    303304function LoadRightSideValue($Level, $Measure, $Time)
    304 { 
     305{
    305306  global $Debug, $Database;
    306307  $Result = array();
     
    326327    return($Result);
    327328  }
    328 } 
     329}
    329330
    330331function LoadLeftSideValue($Level, $Measure, $Time)
     
    339340    $Row['time'] = MysqlDateTimeToTime($Row['time']);
    340341    return(array($Row));
    341   } 
    342   else
    343   {
     342  } else {
    344343    //$Time = $Values[0]['time'] - 60;
    345344    //array_unshift($Values, array('time' => $Time, 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0));
    346345    $Result[] = array('time' => ($Time - TimeSegment($Level)), 'min' => 0, 'avg' => 0, 'max' => 0, 'continuity' => 0);
    347    
     346
    348347    $DbResult = $Database->select($Measure['DataTable'], '*', 'time > "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY time ASC LIMIT 1');
    349348    if($DbResult->num_rows > 0)
     
    360359{
    361360  global $DivisionCount, $Debug, $Database;
    362  
     361
    363362  if($Debug) echo('TimeFrom: '.$TimeFrom.'('.TimeToMysqlDateTime($TimeFrom).')<br>');
    364363  if($Debug) echo('TimeTo: '.$TimeTo.'('.TimeToMysqlDateTime($TimeTo).')<br>');
    365364
    366365  //$AbsoluteTime = GetTimeRange($MeasureId);
    367  
     366
    368367//  if(($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and
    369368//    ($TimeTo > $AbsoluteLeftTime) and ($TimeTo < $AbsoluteRightTime))
     
    392391  {
    393392    $Values = array_merge(LoadLeftSideValue($Level, $Measure, $TimeFrom), $Values, LoadRightSideValue($Level, $Measure, $TimeTo));
    394    
     393
    395394    //echo(count($Values).'<br>');
    396395    //echo($TimeFrom.','.$TimeTo.'<br>');
     
    458457        $Values[] = $Row;
    459458      }
    460      
     459
    461460      if(count($Values) > 0)
    462       {       
     461      {
    463462        $Values = array_merge(LoadLeftSideValue($Level-1, $Measure, $StartTime2), $Values, LoadRightSideValue($Level-1, $Measure, $EndTime2));
    464  
     463
    465464        $StartIndex = 0;
    466465        for($B = 0; $B < $BurstCount; $B++)
    467         {         
     466        {
    468467          echo('.');
    469468          $StartTime3 = $StartTime2 + (($EndTime2 - $StartTime2) / $BurstCount) * $B;
    470469          $EndTime3 = $StartTime2 + (($EndTime2 - $StartTime2) / $BurstCount) * ($B+1);
    471          
     470
    472471          $EndIndex = $StartIndex;
    473472          while($Values[$EndIndex]['time'] < $EndTime3) $EndIndex = $EndIndex + 1;
     
    476475          //print_r($SubValues);
    477476          if(count($SubValues) > 2)
    478           {       
     477          {
    479478            $Point = ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Measure, $Level);
    480479            $Continuity = $SubValues[1]['continuity'];   
    481480            $Database->insert($Measure['DataTable'], array('level' => $Level, 'measure' => $Measure['Id'], 'min' => $Point['min'],
    482481              'avg' => $Point['avg'], 'max' => $Point['max'], 'continuity' => $Continuity, 'time' => TimeToMysqlDateTime($StartTime3+($EndTime3-$StartTime3)/2)));
    483           }       
    484           $StartIndex = $EndIndex - 1; 
     482          }
     483          $StartIndex = $EndIndex - 1;
    485484        }
    486485      }
    487486      // Load values in time range
    488487      //array_pop($NextValues);
    489     } 
    490     echo("Uroven dokoncena<br>\n");         
     488    }
     489    echo("Uroven dokoncena<br>\n");
    491490    $DbResult = $Database->select($Measure['DataTable'], 'COUNT(*)', 'level='.$Level.' AND measure='.$Measure['Id']);
    492491    $Row = $DbResult->fetch_array();
     
    498497{
    499498  global $Database;
    500  
    501  
     499
    502500//  echo("Vytvarim novou cache...\n");
    503501    // Load measures
     
    509507  foreach($Measures as $Measure)
    510508  {
    511     RebuildMeasureCache($Measure); 
    512     echo('Velicina dokoncena<br>');         
     509    RebuildMeasureCache($Measure);
     510    echo('Velicina dokoncena<br/>');
    513511  }
    514512}
     
    517515{
    518516  global $Database;
     517
    519518  $Database->query('CREATE TABLE `data_'.$Measure['Name'].'` (
    520519`Time` TIMESTAMP NOT NULL ,
     
    532531) ENGINE = MYISAM ;');
    533532}
    534 
    535 ?>
Note: See TracChangeset for help on using the changeset viewer.