Changeset 46 for trunk


Ignore:
Timestamp:
Jul 27, 2014, 9:05:14 PM (10 years ago)
Author:
chronos
Message:
  • Opraveno: SQL aktualizace 40 plus chybějící tabulka MeasureMethod.
  • Opraveno: Neplatné ukázkové konfigurační soubory.
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Config/ConfigSample.php

    r40 r46  
    11<?php
    22
    3 $Config = array
     3$Config['Application'] = array
    44(
    5   'Database' => array
    6   (
    7     'Host' => 'localhost',
    8     'User' => 'root',
    9     'Password' => '',
    10     'Database' => 'statistic',
    11     'Prefix' => '',
    12     'Charset' => 'utf8',
    13   ),
    145  'AddNewValueUrl' => 'http://localhost/dev/statistic/?Module=Measure&amp;Action=Add',
    156  'Debug' => 0,
    16   'Web' => array
    17   (
    18     'Title' => 'Statistika',
    19     'Charset' => 'utf-8',
    20     'Admin' => 'Admin',
    21     'AdminEmail' => 'admin@domain',
    22     'ShowPHPError' => false,
    23     'ShowSQLQuery' => false,
    24     'ShowSQLError' => false,
    25     'ErrorLogFile' => 'php_script_error.log',   
    26     'Locale' => 'cz',
    27     'UserAnonymousId' => 1,
    28     'ShowRuntimeInfo' => false,
    29     'FormatHTML' => false,
    30   ),
    317  'DivisionCount' => 500,
    328  'LevelReducing' => 5,
  • trunk/Application/CustomOutput.php

    r45 r46  
    1515    $Tag = new XMLTag('div');
    1616    $Tag->Attributes = array('class' => 'Header');
     17    $Tag->SubElements = ' ';
    1718    return($Tag);
    1819  }
  • trunk/Application/Model/Measure.php

    r45 r46  
    1313  var $DivisionCount = 500;
    1414  var $ValueTypes = array('Min', 'Avg', 'Max');
    15  
     15
    1616  function Load($Id)
    1717  {
     
    2424    } else throw new Exception('Measure not found');
    2525  }
    26  
     26
    2727  function TimeSegment($Base, $Level)
    2828  {
     
    5050    $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2');
    5151    //echo($Database->LastQuery."\n");
    52     if($Result->num_rows == 0) 
    53     {
    54        $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 0)); 
     52    if($Result->num_rows == 0)
     53    {
     54       $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 0));
    5555       //echo($Database->LastQuery."\n");
    5656    } else if($Result->num_rows == 1)
     
    6464      //echo($Level.': '.$Time.' - '.MysqlDateTimeToTime($LastValue['Time']).' '.($Time - MysqlDateTimeToTime($LastValue['Time'])).' = '.$Measure['Period']."\n");
    6565      if((($Time - $this->Database->MysqlDateTimeToTime($LastValue['Time'])) < 0.75 * $this->Data['Period']) and ($Level == 0))
    66       { 
     66      {
    6767        echo('Too short period\n');
    6868      } else
     
    7373        if(($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == $Value['Min']) and ($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value['Avg']) and ($LastValue['Max'] == $NextToLastValue['Max']) and ($LastValue['Max'] == $Value['Max']) and ($LastValue['Continuity'] == 1) and ($Continuity == 1))
    7474        {
    75           $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") AND (Level='.$Level.') AND (Measure='.$Measure['Id'].')', array('Time' => $this->Database->TimeToMysqlDateTime($Time)));
     75          $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") AND (Level='.$Level.') AND (Measure='.$this->Data['Id'].')', array('Time' => $this->Database->TimeToMysqlDateTime($Time)));
    7676          //echo($this->Database->LastQuery."\n");
    7777        } else
     
    7979          $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => $Continuity));
    8080        }
    81       } 
     81      }
    8282
    8383      // Update next level
     
    8585      {
    8686        $Level = $Level + 1;
    87         //echo('Level '.$Level."<br>\n");
     87        //echo('Level '.$Level."<br/>\n");
    8888        $TimeSegment = $this->TimeSegment($this->Data['Period'], 1);
    8989        $EndTime = $this->AlignTime($Time, $TimeSegment);
     
    9191        $StartTime = $EndTime - $TimeSegment;
    9292
    93         //echo(" ".$TimeSegment." ".$StartTime.'-'.$EndTime."<br>\n");
     93        //echo(" ".$TimeSegment." ".$StartTime.'-'.$EndTime."<br/>\n");
    9494        //flush();
    9595
     
    127127  {
    128128    $Y = ($Y2 - $Y1) / ($X2 - $X1) * ($X - $X1) + $Y1;
    129     //echo($Y1.'-'.$Y.'-'.$Y2.' '.$X1.'-'.$X.'-'.$X2.'<br>');
     129    //echo($Y1.'-'.$Y.'-'.$Y2.' '.$X1.'-'.$X.'-'.$X2.'<br/>');
    130130    return($Y);
    131131  }
     
    182182            }
    183183          }
    184         } 
    185         else if($ValueType == 'Min') 
    186         {
    187           //echo($Values[$I+1]['continuity'].'=='.$Measure['ContinuityEnabled'].'<br>');
     184        }
     185        else if($ValueType == 'Min')
     186        {
     187          //echo($Values[$I+1]['continuity'].'=='.$Measure['ContinuityEnabled'].'<br/>');
    188188          if($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])
    189189          {
     
    203203      $NewValue[$ValueType] = $NewValue[$ValueType];
    204204    }
    205     //if(($RightTime - $LeftTime) > 0) 
    206     if($this->Data['Cumulative'] == 0) 
     205    //if(($RightTime - $LeftTime) > 0)
     206    if($this->Data['Cumulative'] == 0)
    207207    {
    208208      $NewValue['Avg'] = $NewValue['Avg'] / ($RightTime - $LeftTime);
    209209    }
    210210    return($NewValue);
    211     //echo($NewValue['avg'].'<br>');
     211    //echo($NewValue['avg'].'<br/>');
    212212    //return(array('min' => rand(0,1), 'avg' => $NewValue['avg'], 'max' => rand(0,1)));
    213213  }
     
    216216  {
    217217    // Get first and last time
    218     //echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n"); 
     218    //echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n");
    219219    $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time LIMIT 1');
    220220    if($Result->num_rows > 0)
     
    231231    } else $AbsoluteRightTime = 0;
    232232
    233     if($this->Debug) 
    234     {
    235       echo('AbsoluteLeftTime: '.$AbsoluteLeftTime.'('.$this->Database->TimeToMysqlDateTime($AbsoluteLeftTime).')<br>');
    236       echo('AbsoluteRightTime: '.$AbsoluteRightTime.'('.$this->Database->TimeToMysqlDateTime($AbsoluteRightTime).')<br>');
     233    if($this->Debug)
     234    {
     235      echo('AbsoluteLeftTime: '.$AbsoluteLeftTime.'('.$this->Database->TimeToMysqlDateTime($AbsoluteLeftTime).')<br/>');
     236      echo('AbsoluteRightTime: '.$AbsoluteRightTime.'('.$this->Database->TimeToMysqlDateTime($AbsoluteRightTime).')<br/>');
    237237    }
    238238    return(array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime));
     
    240240
    241241  function LoadRightSideValue($Level, $Time)
    242   { 
     242  {
    243243    $Result = array();
    244244    $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.$this->Database->TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1');
     
    267267  {
    268268    $Result = array();
    269     //echo('SELECT * FROM '.StatTableName($Level). ' WHERE '. 'Time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY Time DESC LIMIT 1'."<br>\n");
     269    //echo('SELECT * FROM '.StatTableName($Level). ' WHERE '. 'Time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY Time DESC LIMIT 1'."<br/>\n");
    270270    $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time < "'.$this->Database->TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1');
    271271    if($DbResult->num_rows > 0)
     
    294294  function GetValues($TimeFrom, $TimeTo, $Level)
    295295  {
    296     if($this->Debug) echo('TimeFrom: '.$TimeFrom.'('.$this->Database->TimeToMysqlDateTime($TimeFrom).')<br>');
    297     if($this->Debug) echo('TimeTo: '.$TimeTo.'('.$this->Database->TimeToMysqlDateTime($TimeTo).')<br>');
     296    if($this->Debug) echo('TimeFrom: '.$TimeFrom.'('.$this->Database->TimeToMysqlDateTime($TimeFrom).')<br/>');
     297    if($this->Debug) echo('TimeTo: '.$TimeTo.'('.$this->Database->TimeToMysqlDateTime($TimeTo).')<br/>');
    298298
    299299    //$AbsoluteTime = GetTimeRange($MeasureId);
    300300
    301     //  if(($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and 
     301    //  if(($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and
    302302    //    ($TimeTo > $AbsoluteLeftTime) and ($TimeTo < $AbsoluteRightTime))
    303303    //  {
     
    319319    //  die();
    320320    if($this->Debug) echo('Item count: '.count($Values));
    321  
     321
    322322    $Points = array();
    323323    if(count($Values) > 0)
    324324    {
    325325      $Values = array_merge($this->LoadLeftSideValue($Level, $TimeFrom), $Values, $this->LoadRightSideValue($Level, $TimeTo));
    326       //echo(count($Values).'<br>');
    327       //echo($TimeFrom.','.$TimeTo.'<br>');
    328       //echo($Values[0]['Time'].'<br>');
     326      //echo(count($Values).'<br/>');
     327      //echo($TimeFrom.','.$TimeTo.'<br/>');
     328      //echo($Values[0]['Time'].'<br/>');
    329329      $StartIndex = 0;
    330330      $Points = array();
    331       //echo($DivisionCount.'<br>');
     331      //echo($DivisionCount.'<br/>');
    332332      if($this->Debug) print_r($Values);
    333333      //die();
     
    335335      {
    336336        $TimeStart = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * $I;
    337         //if($Debug) echo('TimeStart '.$I.': '.$TimeStart.'('.TimeToMysqlDateTime($TimeStart).')<br>');
     337        //if($Debug) echo('TimeStart '.$I.': '.$TimeStart.'('.TimeToMysqlDateTime($TimeStart).')<br/>');
    338338        $TimeEnd = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * ($I + 1);
    339         if($this->Debug) echo('TimeEnd '.$I.': '.$TimeEnd.'('.$this->Database->TimeToMysqlDateTime($TimeEnd).')<br>');
    340         //echo($TimeStart.','.$TimeEnd.'<br>');
     339        if($this->Debug) echo('TimeEnd '.$I.': '.$TimeEnd.'('.$this->Database->TimeToMysqlDateTime($TimeEnd).')<br/>');
     340        //echo($TimeStart.','.$TimeEnd.'<br/>');
    341341
    342342        $EndIndex = $StartIndex;
     
    344344        //while(($Values[$EndIndex]['Time'] < $TimeEnd)) $EndIndex = $EndIndex + 1;
    345345        $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1);
    346         //echo($StartIndex.','.$EndIndex.' '.count($SubValues).'<br>');
     346        //echo($StartIndex.','.$EndIndex.' '.count($SubValues).'<br/>');
    347347        //print_r($SubValues);
    348348        $Points[] = $this->ComputeOneValue($TimeStart, $TimeEnd, $SubValues, $Level);
     
    356356  function RebuildMeasureCache()
    357357  {
    358     echo('Velicina '.$this->Data['Name']."<br>\n");
     358    echo('Velicina '.$this->Data['Name']."<br/>\n");
    359359    if($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0;  // non continuous
    360360      else $this->Data['ContinuityEnabled'] = 2;    // continuous graph
     
    365365    echo("Mazu starou cache (".$Row[0]." polozek)...");
    366366    $this->Database->delete($this->Data['DataTable'], 'Level > 0 AND Measure='.$this->Data['Id']);
    367     echo("<br>\n");
     367    echo("<br/>\n");
    368368
    369369    for($Level = 1; $Level <= $this->MaxLevel; $Level++)
    370370    {
    371       echo('Uroven '.$Level."<br>\n");
     371      echo('Uroven '.$Level."<br/>\n");
    372372      $TimeRange = $this->GetTimeRange($Level - 1);
    373373      //echo($Measure['Id'].','.($Level-1)."\n");
     
    377377      $EndTime = $this->AlignTime($TimeRange['Right'], $TimeSegment);
    378378      $BurstCount = 500;
    379       echo('For 0 to '.round(($EndTime - $StartTime) / $TimeSegment / $BurstCount)."<br>\n");
     379      echo('For 0 to '.round(($EndTime - $StartTime) / $TimeSegment / $BurstCount)."<br/>\n");
    380380      for($I = 0; $I <= round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); $I++)
    381381      {
     
    384384        $EndTime2 = $StartTime + ($I + 1) * $BurstCount * $TimeSegment;
    385385        $Values = array();
    386         $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.$this->Database->TimeToMysqlDateTime($StartTime2).'" AND Time < "'.$this->Database->TimeToMysqlDateTime($EndTime2).'" AND Measure='.$Measure['Id'].' AND Level='.($Level - 1).' ORDER BY Time');
     386        $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.
     387          $this->Database->TimeToMysqlDateTime($StartTime2).'" AND Time < "'.
     388          $this->Database->TimeToMysqlDateTime($EndTime2).'" AND Measure='.$this->Data['Id'].
     389          ' AND Level='.($Level - 1).' ORDER BY Time');
    387390        while($Row = $DbResult->fetch_assoc())
    388391        {
     
    393396        if(count($Values) > 0)
    394397        {
    395           $Values = array_merge($this->LoadLeftSideValue($Level - 1, $StartTime2), $Values, $this->LoadRightSideValue($Level - 1, $Measure, $EndTime2));
     398          $Values = array_merge($this->LoadLeftSideValue($Level - 1, $StartTime2),
     399            $Values, $this->LoadRightSideValue($Level - 1, $EndTime2));
    396400
    397401          $StartIndex = 0;
     
    405409            while($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1;
    406410            $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1);
    407             //echo($StartIndex.','.$EndIndex.' '.count($SubValues).'<br>');
     411            //echo($StartIndex.','.$EndIndex.' '.count($SubValues).'<br/>');
    408412            //print_r($SubValues);
    409413            if(count($SubValues) > 2)
     
    418422        // Load values in time range
    419423        //array_pop($NextValues);
    420       } 
    421       echo("Uroven dokoncena<br>\n");
     424      }
     425      echo("Uroven dokoncena<br/>\n");
    422426      $DbResult = $this->Database->select($this->Data['DataTable'], 'COUNT(*)', 'Level='.$Level.' AND Measure='.$this->Data['Id']);
    423427      $Row = $DbResult->fetch_row();
    424       echo("Vloženo ".$Row[0]." položek.<br>\n");
     428      echo("Vloženo ".$Row[0]." položek.<br/>\n");
    425429    }
    426430  }
     
    441445    {
    442446      $Measure->RebuildMeasureCache();
    443       echo('Velicina dokoncena<br>');
     447      echo('Velicina dokoncena<br/>');
    444448    }
    445449  }
  • trunk/Application/Model/User.php

    r42 r46  
    3838    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    3939    $Row = $Query->fetch_assoc();
    40     if($Row['User'] != $this->AnonymousUserId) 
     40    if($Row['User'] != $this->AnonymousUserId)
    4141    {
    4242      $Query = $this->Database->select('User', '*', 'Id='.$Row['User']);
    4343      $this->Data = $Query->fetch_assoc();
    4444      $Result = $this->System->Translate('UserLogged');
    45     } else 
     45    } else
    4646    {
    4747      $Query = $this->Database->select('User', '*', 'Id='.$this->AnonymousUserId);
     
    7575        if($Query->num_rows > 0) $Result = $this->System->Translate('NameUsed');
    7676        else
    77         { 
     77        {
    7878          $Query = $this->Database->select('User', '*', 'Email = "'.$Email.'"');
    7979          if($Query->num_rows > 0) $Result = $this->System->Translate('EmailUsed');
     
    8282            $this->Database->insert('User', array('Name' => $Name, 'Login' => $Login, 'Password' => $this->PasswordHash($Login, $Password), 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1, 'Role' => 2));
    8383            $UserId = $this->Database->insert_id;
    84            
     84
    8585            $Subject = FromUTF8('Registrace nového účtu', 'iso2');
    86             $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/">http://'.$Config['System']['Host'].$Config['System']['RootFolder']."/</a>.<br>\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br><br>\n\nVáš účet je: ".$Login."\n<br>Pro dokončení registrace klikněte na tento odkaz: ".'<a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'">http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte.";
     86            $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/">http://'.$Config['System']['Host'].$Config['System']['RootFolder']."/</a>.<br/>\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br/><br/>\n\nVáš účet je: ".$Login."\n<br/>Pro dokončení registrace klikněte na tento odkaz: ".'<a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'">http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'</a>.'."\n<br/> \n\n<br/><br/>Na tento email neodpovídejte.";
    8787            $AdditionalHeaders = "To: ".$Name." <".$Email.">\n"."From: ".FromUTF8($Config['System']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8";
    8888            mail($Email, $Subject, $Message, $AdditionalHeaders);
     
    121121      if($Row['Password'] != $this->PasswordHash($Login, $Password)) $Result = $this->System->Translate('BadPassword');
    122122      else if($Row['Locked'] == 1) $Result = $this->System->Translate('AccountLocked');
    123       else 
    124       {
    125         $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()', 'LastIpAddress' => GetRemoteAddress()));     
     123      else
     124      {
     125        $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()', 'LastIpAddress' => GetRemoteAddress()));
    126126        $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $Row['Id']));
    127127        // načtení stavu stromu
     
    185185    // Check group-operation relation
    186186    $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `GroupOrOperation`="'.$OperationId.'" AND `Type`="Operation"');
    187     if($DbResult->num_rows > 0) return(true); 
     187    if($DbResult->num_rows > 0) return(true);
    188188    return(false);
    189189  }
     
    222222
    223223      $Subject = 'Obnova hesla';
    224       $Message = 'Požádali jste o zaslání nového hesla na serveru <a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'">http://'.$Config['System']['Host'].$Config['System']['RootFolder']."</a>.<br />\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br /><br />\n\nVaše nové heslo k účtu ".$Row['Login']." je: ".$NewPassword."\n<br>Pro aktivaci tohoto hesla klikněte na ".'<a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/?Action=PasswordRecoveryConfirm&User='.$Row['Id'].'&H='.$Row['Password'].'&P='.$NewPassword.'">tento odkaz</a>.'."\n<br /> Po přihlášení si prosím změňte heslo na nové.\n\n<br><br>Na tento email neodpovídejte.";
     224      $Message = 'Požádali jste o zaslání nového hesla na serveru <a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'">http://'.$Config['System']['Host'].$Config['System']['RootFolder']."</a>.<br />\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br /><br />\n\nVaše nové heslo k účtu ".$Row['Login']." je: ".$NewPassword."\n<br/>Pro aktivaci tohoto hesla klikněte na ".'<a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/?Action=PasswordRecoveryConfirm&User='.$Row['Id'].'&H='.$Row['Password'].'&P='.$NewPassword.'">tento odkaz</a>.'."\n<br /> Po přihlášení si prosím změňte heslo na nové.\n\n<br/><br/>Na tento email neodpovídejte.";
    225225      $AdditionalHeaders = "To: ".$Row['Name']." <".$Row['Email'].">\n"."From: ".FromUTF8($Config['System']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8";
    226226      mail($Row['Email'], $Subject, $Message, $AdditionalHeaders);
     
    247247    return($Output);
    248248  }
    249  
     249
    250250  function ServerCount()
    251251  {
     
    264264      $Total += $Server->RealmCount();
    265265    }
    266     return($Total);   
     266    return($Total);
    267267  }
    268268}
  • trunk/Application/View/Graph.php

    r45 r46  
    66class GraphView extends View
    77{
     8  var $DefaultWidth;
     9  var $DefaultHeight;
     10
     11  function __construct($System)
     12  {
     13        parent::__construct($System);
     14    $this->DefaultWidth = 800;
     15    $this->DefaultHeight = 200;
     16  }
     17
    818  function Render()
    919  {
    10     if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug']; 
     20    if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];
    1121      else $Debug = 0;
    12  
     22
    1323    if(!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku');
    1424    $StartTime = addslashes($_GET['From']);
     
    1828    $TimeDifference = $EndTime - $StartTime;
    1929    if(!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');
    20     $MeasureId = addslashes($_GET['Measure']);   
    21     if(!array_key_exists('Width', $_GET)) $Width = $DefaultWidth;
     30    $MeasureId = addslashes($_GET['Measure']);
     31    if(!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;
    2232      else $Width = addslashes($_GET['Width']);
    23     if(!array_key_exists('Height', $_GET)) $Height = $DefaultHeight;
     33    if(!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;
    2434      else $Height = addslashes($_GET['Height']);
    2535    if(!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential'];
     
    5060    $Points = $Measure->GetValues($StartTime, $EndTime, $Level);
    5161
    52     if($Debug) echo('Points count: '.count($Points).'<br/>'); 
    53     //if($Debug) foreach($Points as $Index => $Item) 
    54     // echo($Index.': '.$Item['min'].'<br>');
     62    if($Debug) echo('Points count: '.count($Points).'<br/>');
     63    //if($Debug) foreach($Points as $Index => $Item)
     64    // echo($Index.': '.$Item['min'].'<br/>');
    5565
    5666    // Calculate total max, avg, min value
     
    7383    $AvgValue = $AvgValue / count($Points); //round( * $Measure['Divider']) / $Measure['Divider'];
    7484
    75     // Generate polygon and recalculate y values to fit graph height 
     85    // Generate polygon and recalculate y values to fit graph height
    7686    $PointsMin = array(0, $Height - 1);
    7787    $PointsAvg = array(0, $Height - 1);
    7888    $PointsMax = array(0, $Height - 1);
    7989    if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
    80     { 
     90    {
    8191      foreach($Points as $Index => $Item)
    8292      {
     
    8797        $PointsMax[] = $Index * $Width / $Measure->DivisionCount;
    8898        $PointsMax[] = $Height - 1 - ($Points[$Index]['Max'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient'];
    89         //echo($Index.' - '.$Item.' '.$Points[$Index].'<br>');
     99        //echo($Index.' - '.$Item.' '.$Points[$Index].'<br/>');
    90100      }
    91101    }
     
    107117    //array_unshift($Points, 0);
    108118    //$Points[] = $Width - 1;
    109     //$Points[] = $Height - 1;
     119    //$Points[] = $Height - 1;      echo('sds');
     120
    110121
    111122    //print_r($PointsMax);
    112  
     123
    113124    // Generate image
    114     if(!$Debug) 
     125    if(!$Debug)
    115126    {
    116127      Header('Content-type: image/png');
    117       Header('Cache-Control: no-cache');  // Dynamic graph - no cache 
     128      Header('Cache-Control: no-cache');  // Dynamic graph - no cache
    118129      $Image = @imagecreate($Width, $Height);
    119130      $BackgroundColor = imagecolorallocate($Image, 255, 255, 255);
     
    132143      imagefilledpolygon($Image, $PointsAvg, count($PointsAvg) / 2, $LightGreen);
    133144      imagefilledpolygon($Image, $PointsMin, count($PointsMin) / 2, $LightBlue);
    134  
     145
    135146      $TimeMarks = array(1, 60, 60*60, 60*60*24, 60*60*24*7, 60*60*24*30, 60*60*24*365, 60*60*24*365*10);
    136  
     147
    137148      $TimeRange = $EndTime - $StartTime;
    138149      $TimeMarksIndex = 0;
     
    140151      if($TimeMarksIndex < 2) $TimeMarksIndex = 2;
    141152      $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1];
    142       $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; 
    143    
    144       $TimeShift = $Measure->AlignTime($StartTime, $MajorTimeMarks) - $StartTime; 
     153      $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2];
     154
     155      $TimeShift = $Measure->AlignTime($StartTime, $MajorTimeMarks) - $StartTime;
    145156      //imagestring($Image, 10, 40, 50, $TimeShift, $Black);
    146  
     157
    147158      // Zobraz měřítko Y
    148159      $VerticalLinesDistance = $Height / $VerticalLinesCount;
     
    152163        for($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
    153164        //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    154       } 
    155 
    156       $TimeShift = $Measure->AlignTime($StartTime, $MinorTimeMarks) - $StartTime; 
    157  
     165      }
     166
     167      $TimeShift = $Measure->AlignTime($StartTime, $MinorTimeMarks) - $StartTime;
     168
    158169      // Zobraz měřítko X
    159170      $LastTextEnd = 0;
    160171      for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
    161172      {
    162         $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 
     173        $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width;
    163174        //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    164175        if(($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift);
     
    172183        }
    173184        else for($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
    174       } 
    175  
     185      }
     186
    176187      // Popisky osy Y
    177188      for($I = 1; $I <= $VerticalLinesCount; $I++)
     
    183194        if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
    184195          imagettftext($Image, $FontSize, 0, 2,  $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text);
    185       } 
     196      }
    186197      $GenerationTime = floor(($this->System->GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    187198
     
    208219      imagepng($Image);
    209220      imagedestroy($Image);
    210     }   
     221    }
    211222  }
    212223}
  • trunk/Application/View/Main.php

    r45 r46  
    2424      'caption' => 'Měsíc',
    2525      'period' => 2592000, // 3600 * 24 * 30,
    26     ), 
     26    ),
    2727    'year' => array(
    2828      'caption' => 'Rok',
     
    4646    for($I = 1; $I < 32; $I++)
    4747    {
    48       if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = ''; 
     48      if($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';
    4949      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
    5050    }
     
    5454    $Output .= '<select name="Month">';
    5555    foreach($this->Months as $Index => $Month)
    56     { 
     56    {
    5757      if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
    5858      if($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';
     
    6363    $Output .= '<select name="Year">';
    6464    for($I = 2000; $I < 2010; $I++)
    65     { 
     65    {
    6666      if($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';
    6767      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
     
    7272    $Output .= '<select name="Hour">';
    7373    for($I = 0; $I < 24; $I++)
    74     { 
     74    {
    7575      if($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';
    7676      $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
     
    8080    // Minute selection
    8181    $Output .= '<select name="Minute">';
    82     for($I = 0; $I < 60; $I++) 
     82    for($I = 0; $I < 60; $I++)
    8383    {
    8484      if($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';
     
    9999  {
    100100    $Debug = 0;
    101 
    102101    foreach($this->Config['Application']['DefaultVariables'] as $Index => $Variable)
    103102    {
     
    112111      $_SESSION['TimeEnd'] = time() - 60;
    113112      $_SESSION['TimeStart'] = $_SESSION['TimeEnd'] - $this->GraphTimeRanges[$_SESSION['Period']]['period'];
    114     } 
     113    }
    115114
    116115    $Output = '<div class="Title">Statistiky</div>';
     
    130129          }
    131130        }
    132         break; 
     131        break;
    133132      case 'SetTimeNow':
    134         if(array_key_exists('Time', $_GET)) 
     133        if(array_key_exists('Time', $_GET))
    135134        {
    136135          if(($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))
     
    142141        break;
    143142    }
    144     $Output .= '<strong>Časový úsek:</strong><br>';
     143    $Output .= '<strong>Časový úsek:</strong><br/>';
    145144    // Show graf time range menu
    146145    if($_SESSION['TimeSpecify'] == 0)
     
    150149        $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a>&nbsp;';
    151150      $Output .= '<br/>';
    152       $Output .= '<a href="?TimeSpecify=1">Přesnější nastavení...</a><br>';
     151      $Output .= '<a href="?TimeSpecify=1">Přesnější nastavení...</a><br/>';
    153152    } else {
    154153      $Output .= '<table cellspacing="0" cellpadding="2" border="0">';
     
    156155      $Output .= '<tr><td>Konec:</td><td>'.$this->EditTime('TimeEnd').'</td></tr>';
    157156      $Output .= '</table>';
    158       $Output .= '<a href="?TimeSpecify=0">Jednoduché nastavení...</a><br>';
     157      $Output .= '<a href="?TimeSpecify=0">Jednoduché nastavení...</a><br/>';
    159158    }
    160159    $Output .= '<br/>'.$this->Graph();
     
    162161    $Output .= '<br/>'.$this->MeasureTable();
    163162    return($Output);
    164   } 
    165  
     163  }
     164
    166165  function Graph()
    167166  {
    168167    $Output = '<strong>Graf:</strong><br/>';
    169     $Output .= '<img alt="Graf" src="?M=Graph&amp;Measure='.$_SESSION['Measure'].'&amp;From='.$_SESSION['TimeStart'].'&amp;To='.$_SESSION['TimeEnd'].'&amp;Width='.$this->Config['Application']['GraphSize']['Width'].'&amp;Height='.$this->Config['Application']['GraphSize']['Height'].'&amp;Differential='.$_SESSION['Differential'].'" width="'.$this->Config['Application']['GraphSize']['Width'].'" height="'.$this->Config['Application']['GraphSize']['Height'].'"><br>';
    170     $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&amp;TimeStart='.$_SESSION['TimeStart'].'&amp;TimeEnd='.$_SESSION['TimeEnd'].'&amp;TimeSpecify=1&amp;Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>';
     168    $Output .= '<img alt="Graf" src="?M=Graph&amp;Measure='.$_SESSION['Measure'].
     169      '&amp;From='.$_SESSION['TimeStart'].'&amp;To='.$_SESSION['TimeEnd'].'&amp;Width='.
     170      $this->Config['Application']['ImageWidth'].'&amp;Height='.$this->Config['Application']['ImageHeight'].
     171      '&amp;Differential='.$_SESSION['Differential'].'" width="'.$this->Config['Application']['ImageWidth'].
     172      '" height="'.$this->Config['Application']['ImageHeight'].'"/><br/>';
     173    $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&amp;TimeStart='.$_SESSION['TimeStart'].'&amp;TimeEnd='.$_SESSION['TimeEnd'].'&amp;TimeSpecify=1&amp;Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br/>';
    171174//print_r(GetValues($Measure, $TimeStart, $TimeEnd));
    172175    return($Output);
    173176  }
    174  
     177
    175178  function MeasureTable()
    176179  {
     
    202205        $LastMeasureValue = '&nbsp;';
    203206      }
    204       if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; 
     207      if($Measure['Continuity'] == 1) $Interpolate = 'Ano';
    205208        else $Interpolate = 'Ne';
    206209      if($Measure['Info'] == '') $Measure['Info'] = '&nbsp;';
     
    214217    //print_r(gd_info());
    215218    //print_r($_SESSION);
    216  
     219
    217220    //ShowPage($Output);
    218221    //echo(AddPrefixMultipliers('-0.000000071112345', 'B'));
  • trunk/Application/View/Page.php

    r40 r46  
    1111
    1212  function ShowHeader($Title, $Path)
    13   {   
     13  {
    1414    $BodyParam = '';
    1515    if($this->Load != '') $BodyParam .= ' onload="'.$this->Load.'"';
    1616    if($this->Unload != '') $BodyParam .= ' onunload="'.$this->Unload.'"';
    1717    $Output = '<?xml version="1.0" encoding="'.$this->Config['Web']['Charset'].'"?>'."\n".
    18     '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
    19     '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'.
     18    '<!DOCTYPE html>'.
     19    '<html>'.
    2020    '<head><link rel="stylesheet" href="Application/Style/Style.css" type="text/css" media="all" />'.
    21     '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->Config['Web']['Charset'].'" />'.
     21    '<meta http-equiv="content-type" content="text/html; charset='.$this->Config['Web']['Charset'].'" />'.
    2222    '<script type="text/javascript" src="Application/Style/Global.js"></script>'.
    2323    '<title>'.$this->Config['Web']['Title'].' - '.$Path.'</title>
     
    2525    return($Output);
    2626  }
    27  
     27
    2828  function ShowFooter()
    2929  {
    3030    global $ScriptTimeStart;
    31    
     31
    3232    $Time = round($this->System->GetMicrotime() - $ScriptTimeStart, 2);
    3333    $Output = '<div class="Footer">
     
    3939    if($this->Config['Web']['ShowRuntimeInfo'] == true) $Output .= '<li>Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s</li><li>Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B</li>';
    4040  $Output .= '</ul></div></body></html>';
    41     return($Output); 
     41    return($Output);
    4242  }
    43  
     43
    4444  function GetOutput($Content)
    45   { 
     45  {
    4646    global $Config;
    47    
     47
    4848    $Output = $this->ShowHeader($this->FullTitle, $this->ShortTitle).$Content;
    4949    $Output .= $this->ShowFooter();
     
    5454
    5555  function SystemMessage($Text)
    56   { 
     56  {
    5757    return('<table align="center"><tr><td><div class="SystemMessage"><h3>Systémová zpráva</h3><div>'.$Text.'</div></div</td></tr></table>');
    5858    //ShowFooter();
    5959    //die();
    6060  }
    61  
     61
    6262  function AccessDenied()
    6363  {
    64     return($this->GetOutput($this->SystemMessage($this->System->Translate('AccessDenied')))); 
     64    return($this->GetOutput($this->SystemMessage($this->System->Translate('AccessDenied'))));
    6565  }
    6666}
  • trunk/Base/Config/ConfigSample.php

    r42 r46  
    11<?php
    22
    3 $Config = array(
     3$Config = array
     4(
    45  'Database' => array
    56  (
     
    1112    'Charset' => 'utf8',
    1213  ),
    13   'Web' => array
     14  'System' => array
    1415  (
    1516    'FormatHTML' => false,
  • trunk/Base/Database.php

    r42 r46  
    1010  var $ShowSQLQuery = false;
    1111  var $ShowSQLError = false;
    12  
     12
    1313  function query($Query)
    14   { 
     14  {
    1515    if($this->ShowSQLQuery)
    1616    {
    17       if(isset($_SERVER['REMOTE_ADDR'])) echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>'); 
     17      if(isset($_SERVER['REMOTE_ADDR'])) echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>');
    1818      else echo($Query."\n");
    1919    }
     
    2525    }
    2626
    27     return($Result); 
     27    return($Result);
    2828  }
    2929
    3030  function select($Table, $What = '*', $Condition = 1)
    3131  {
    32     return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition)); 
     32    return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition));
    3333  }
    3434
    3535  function delete($Table, $Condition)
    3636  {
    37     $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 
     37    $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition);
    3838  }
    39  
     39
    4040  function insert($Table, $Data)
    4141  {
     
    5050    $Name = substr($Name, 1);
    5151    $Values = substr($Values, 1);
    52     $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 
     52    $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    5353  }
    54  
     54
    5555  function update($Table, $Condition, $Data)
    5656  {
     
    6161      $Values .= ', `'.$Key.'`='.$Value;
    6262    }
    63     $Values = substr($Values, 2); 
     63    $Values = substr($Values, 2);
    6464    $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
    6565  }
    66  
     66
    6767  function replace($Table, $Data)
    6868  {
     
    7979    //echo('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES ('.$Values.')<br />');
    8080    $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    81     //echo($this->error().'<br>');
     81    //echo($this->error().'<br/>');
    8282  }
    83  
     83
    8484  function charset($Charset)
    8585  {
  • trunk/Readme.txt

    r40 r46  
    88* Zkopírujte ukázkový soubor Application/Config/ConfigSample.php jako Config.php do stejné složky a upravte v něm nastavení.
    99* Vytvořete v databázi uživatele statistic a tabulku statistic a doplňte přístupové údaje do Config.php.
    10 * Proveďtě import ukázkových dat ze souboru Full.sql s nejvyšším číslem revize umístěným ve složce SQL. Samotná struktura tabulky measure je v Measure.sql a ukázková struktura datové tabulky je v Data.sql.
     10* Proveďte import ukázkových dat ze souboru Full.sql s nejvyšším číslem revize umístěným ve složce SQL. Samotná struktura tabulky measure je v Measure.sql a ukázková struktura datové tabulky je v Data.sql.
    1111* Ve složce measure_scripts je ukázkový soubor monitor.sample.php, který zajišťuje získávání informací o různých veličinách v počítači a jejich plnění do systému. Zkopírujte jej jako monitor.php a upravte dle potřeb.
    1212
  • trunk/SQL/Updates/40.sql

    r40 r46  
    1 RENAME TABLE `Measure2` TO `Measure`
     1RENAME TABLE `measure` TO `Measure`
    22ALTER TABLE `Measure`  ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    33
     
    8989ALTER TABLE `MeasureGroup` CHANGE `Parent` `Parent` INT( 11 ) NULL ;
    9090
    91 ALTER TABLE `Measure` ADD `Group` INT NOT NULL AFTER `Id` ;
     91ALTER TABLE `Measure` ADD `Group` INT NULL AFTER `Id` ;
    9292ALTER TABLE `Measure` ADD INDEX ( `Group` ) ;
    9393ALTER TABLE `Measure` ADD FOREIGN KEY ( `Group` ) REFERENCES `MeasureGroup` ( `Id` );
    9494ALTER TABLE `Measure` DROP `OldName` ;
    95 ALTER TABLE `Measure`   DROP `PermissionView`,   DROP `PermissionAdd`;
     95ALTER TABLE `Measure` DROP `PermissionView`,   DROP `PermissionAdd`;
    9696
    9797ALTER TABLE `Measure` CHANGE `Name` `Name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
Note: See TracChangeset for help on using the changeset viewer.