Changeset 3


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.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • add.php

    r1 r3  
    11<?
    2 include('stat_functions.php');
    3 include('db.php');
    4 DB_Init('localhost', 'stat', '', 'statistic');
     2include('global.php');
    53
    64if(array_key_exists('MeasureId', $_GET) and array_key_exists('Value', $_GET))
  • code.php

    r1 r3  
    1 <?
     1<?php
    22/*
    33  ISO8859-2 <-> UTF-8 conversion functions designed for use in PHP-GTK apps
  • database.php

    r1 r3  
    1010  function select($Table, $What = '*', $Condition = 1)
    1111  {
    12     return($this->query("SELECT ".$What." FROM ".$this->Prefix.$Table." WHERE ".$Condition)); 
     12    $Query = "SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition;
     13    return($this->query($Query)); 
    1314  }
    1415
    1516  function delete($Table, $Condition)
    1617  {
    17     $this->query("DELETE FROM ".$this->Prefix.$Table." WHERE ".$Condition); 
     18    $this->query("DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition); 
    1819  }
    1920 
     
    3132    $Name = substr($Name, 1);
    3233    $Values = substr($Values, 1);
    33     $this->query('INSERT INTO '.$this->Prefix.$Table-' ('.$Name.') VALUES('.$Values.')'); 
     34    $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 
     35    //echo('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    3436  }
    3537 
    3638  function update($Table, $Condition, $Data)
    3739  {
     40    $Values = '';
    3841    foreach($Data as $Key => $Value)
    3942    {
     
    4346    }
    4447    $Values = substr($Values, 2); 
    45     $this->query('UPDATE '.$this->Prefix.$Table.' SET '.$Values.' WHERE ('.$Condition.')');
     48    $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
    4649  }
    4750 
     
    5962    $Name = substr($Name, 1);
    6063    $Values = substr($Values, 1);
    61     $this->query('REPLACE INTO '.$this->Prefix.$Table.' ('.$Name.') VALUES('.$values.')');
     64    $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` (`'.$Name.'`) VALUES('.$values.')');
    6265  }
    6366 
  • error.log

    r1 r3  
    88 /var/www/html/statistic/new/graph.php(42)      GetValues('8','Undefined variable: Row','/var/www/html/statistic/new/stat_functions.php','307','a:7:{s:7:"Measure";a:23:{i:0;s:1:"2";s:2:"id";s:1:"2";i:1;s:7:"inet_up";s:4:"name";s:7:"inet_up";i:2;s:17:"Internet odesláno";s:11:"description";s:17:"Internet odesláno";i:3;s:4:"1288";s:7:"divider";s:4:"1288";i:4;s:6:"kbit/s";s:4:"unit";s:6:"kbit/s";i:5;s:1:"0";s:10:"continuity";s:1:"0";i:6;s:2:"60";s:6:"period";s:2:"60";i:7;s:7:"inet_up";s:8:"old_name";s:7:"inet_up";i:8;s:9:"localhost";s:16:"privileged_hosts";s:9:"localhost";i:9;s:0:"";s:4:"info";s:0:"";i:10;s:1:"1";s:7:"enabled";s:1:"1";s:17:"ContinuityEnabled";i:0;}s:8:"TimeFrom";s:10:"1183925682";s:6:"TimeTo";s:10:"1184530482";s:5:"Level";d:0;s:13:"DivisionCount";i:500;s:5:"Debug";i:0;s:6:"Values";a:0:{}}')
    99
     10# 2007-08-18 10:14:25 : mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'stat'@'localhost' (using password: YES)
     11 C:\www\dev\statistic\db.php(23)        mysql_connect('localhost','stat','serepes')
     12 C:\www\dev\statistic\graph.php(6)      DB_Init('localhost','stat','','statistic')
     13
     14# 2007-08-18 10:16:57 : mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'stat'@'localhost' (using password: YES)
     15 C:\www\dev\statistic\db.php(23)        mysql_connect('localhost','stat','serepes')
     16 C:\www\dev\statistic\graph.php(6)      DB_Init('localhost','stat','','statistic')
     17
     18# 2007-08-18 10:19:16 : mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'stat'@'localhost' (using password: YES)
     19 C:\www\dev\statistic\db.php(23)        mysql_connect('localhost','stat','serepes')
     20 C:\www\dev\statistic\graph.php(6)      DB_Init('localhost','stat','','statistic')
     21
  • graph.php

    r1 r3  
    11<?php
    2 include('error.php');
    3 include('stat_functions.php');
    4 include('db.php');
    5 include('code.php');
    6 DB_Init('localhost', 'stat', '', 'statistic');
    7 DB_Query('SET CHARACTER SET latin2');
     2include('global.php');
    83 
    94if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];
  • 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.