Changeset 3 for index.php


Ignore:
Timestamp:
Oct 13, 2007, 5:41:26 PM (17 years ago)
Author:
george
Message:

Přepracováno: Nově použití objektové třídy mysqli pro přístup k mysql databázi.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • index.php

    r1 r3  
    1 <?
    2 include('stat_functions.php');
    3 include('db.php');
    4 DB_Init('localhost', 'stat', '', 'statistic');
    5 DB_Query('SET CHARACTER SET latin2');
     1<?php
     2include('global.php');
    63
    74$Debug = 0;
     
    10097  ),
    10198);
    102 
    103 session_start();
    10499
    105100$Variables = array(
     
    125120}
    126121
    127 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    128 <html><head>
    129   <meta http-equiv="Content-Language" content="cs">
    130   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
    131   <title>Statistika</title>
    132   <LINK REL="StyleSheet" HREF="style.css" TYPE="text/css" MEDIA="all">
    133   </head><body style="font-family: sans-serif;">');
    134   echo('<div class="Title">Statistiky</div>');
     122
     123$Output = '<div class="Title">Statistiky</div>';
    135124
    136125if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
     
    168157    echo('<br><br>');
    169158    */
    170     echo('<strong>Èasový úsek:</strong><br>');
     159    $Output .= '<strong>Èasový úsek:</strong><br>';
    171160    // Show graf time range menu
    172161    if($_SESSION['TimeSpecify'] == 0)
    173162    {
    174       echo('Délka úseku: ');
     163      $Output .= 'Délka úseku: ';
    175164      foreach($GrafTimeRanges as $Index => $Item)
    176         echo('<a href="?Period='.$Index.'">'.$Item['caption'].'</a>&nbsp;');
    177       echo('<br>');
    178       echo('<a href="?TimeSpecify=1">Pøesnìj¹í nastavení...</a><br>')
     165        $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a>&nbsp;';
     166      $Output .= '<br>';
     167      $Output .= '<a href="?TimeSpecify=1">Pøesnìj¹í nastavení...</a><br>'
    179168    } else {
    180       echo('<table cellspacing="0" cellpadding="2" border="0">');
    181       echo('<tr><td>Poèátek:</td><td>'.EditTime('TimeStart').'</td></tr>');
    182       echo('<tr><td>Konec:</td><td>'.EditTime('TimeEnd').'</td></tr>');
    183       echo('</table>');
    184       echo('<a href="?TimeSpecify=0">Jednoduché nastavení...</a><br>')
     169      $Output .= '<table cellspacing="0" cellpadding="2" border="0">';
     170      $Output .= '<tr><td>Poèátek:</td><td>'.EditTime('TimeStart').'</td></tr>';
     171      $Output .= '<tr><td>Konec:</td><td>'.EditTime('TimeEnd').'</td></tr>';
     172      $Output .= '</table>';
     173      $Output .= '<a href="?TimeSpecify=0">Jednoduché nastavení...</a><br>'
    185174    }
    186 echo('<br>');
    187 
    188 echo('<strong>Graf:</strong><br>');
    189 echo('<img alt="Graf" src="graph.php?Measure='.$_SESSION['Measure'].'&amp;From='.$_SESSION['TimeStart'].'&amp;To='.$_SESSION['TimeEnd'].'&amp;Width=750&amp;Height=200" width="750" height="214"><br>');
     175$Output .= '<br>';
     176
     177$Output .= '<strong>Graf:</strong><br>';
     178$Output .= '<img alt="Graf" src="graph.php?Measure='.$_SESSION['Measure'].'&amp;From='.$_SESSION['TimeStart'].'&amp;To='.$_SESSION['TimeEnd'].'&amp;Width=750&amp;Height=200" width="750" height="214"><br>';
    190179//print_r(GetValues($Measure, $TimeStart, $TimeEnd));
    191180 
    192 echo('<br>');
    193 
    194 echo('<table border="1" cellspacing="0" cellpadding="2" style="font-size: small;">');
    195 echo('<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>');
    196 DB_Select('stat_measure', '*', 'enabled=1 AND permission_view="all" OR permission_view="'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'" ORDER BY description');
    197 while($Measure = DB_Row())
    198 {
    199   DB_Save();
     181$Output .= '<br>';
     182
     183$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>';
     185$Database->select_db('measure');
     186$Result = $Database->select('measure', '*', 'Enabled=1 AND PermissionView="all" OR PermissionView="'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'" ORDER BY Description');
     187//echo($Database->error);
     188
     189while($Measure = $Result->fetch_array())
     190{
    200191  $StopWatchStart = GetMicrotime();
    201192//  DB_Select('stat_data', 'COUNT(*)', 'measure='.$Measure['id']);
     
    203194//  $RowCount = $RowCount[0];
    204195//  $RowCount = 0;
    205   DB_Select('stat_data', 'time, avg', 'measure='.$Measure['id'].' ORDER BY time DESC LIMIT 1');
    206   if(DB_NumRows() > 0)
     196  $Result2 = $Database->select('stat_data', 'time, avg', 'measure='.$Measure['id'].' ORDER BY time DESC LIMIT 1');
     197  if($Result2->num_rows > 0)
    207198  {
    208     $Row = DB_Row();
     199    $Row = $Result2->fetch_array();
    209200    $LastMeasureTime = date('j.n.Y G:i:s', MysqlDateTimeToTime($Row['time']));
    210201    $LastMeasureValue = round($Row['avg'] / $Measure['display_divider']);
     
    216207  if($Measure['info'] == '') $Measure['info'] = '&nbsp;';
    217208  $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    218   echo('<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>');
     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>';
    219210  //<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td></tr>');
    220211  flush();
    221   DB_Load();
    222212}
    223 echo('</table>');
    224 echo('<br><a href="development/">Sekce vývoje systému</a>');
     213$Output .= '</table>';
     214$Output .= '<br><a href="development/">Sekce vývoje systému</a>';
    225215//echo(time());
    226216//print_r(gd_info());
    227 echo('<br><div style="font-size: small;">Kontakt: robie@centrum.cz</div>');
    228 echo('</body></html>');
     217$Output .= '<br><div style="font-size: small;">Kontakt: robie@centrum.cz</div>';
     218$Output .= '</body></html>';
    229219//print_r($_SESSION);
    230220
     221ShowPage($Output);
    231222
    232223
Note: See TracChangeset for help on using the changeset viewer.