Changeset 44


Ignore:
Timestamp:
Nov 24, 2009, 5:19:21 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Třída pro provádění odměrů na straně klienta.
  • Přidáno: Podpora pro spouštění s parametry přes příkazový řádek.
Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Model/Measurement/MeasureClient.php

    r43 r44  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../../Base/Model.php');
    24
    35class MeasureClient extends Model
     
    810    while($MeasureClient = $DbResult->fetch_assoc())
    911    {
    10       if(class_exists($MeasureClient['MeasureClass']))
     12      $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$MeasureClient['Method']);
     13      $MeasureMethod = $DbResult2->fetch_assoc();
     14      echo($MeasureClient['MeasureId'].',');
     15      include_once(dirname(__FILE__).'/'.$MeasureMethod['MeasureClass'].'.php');
     16      $MeasureMethod['MeasureClass'] .= 'Measurement';
     17      if(class_exists($MeasureMethod['MeasureClass']))
    1118      {
    12         $MeasureClass = new $MeasureClient['MeasureClass']();
    13         if(method_exists($MeasureClass, $MeasureClass['Method']))
     19        $MeasureClass = new $MeasureMethod['MeasureClass']($this->System);
     20        if(method_exists($MeasureClass, $MeasureMethod['Method']))
    1421        {
    15           if($MeasureClient['Parameter'] != '') $Value = $Measure->$MeasureClient['Method']($MeasureClient['Parameter']);
    16             else $Value = $Measure->$MeasureClient['Method']();
    17           file_get_contents($MeasureClient['Host'].$MeasureClient['Path'].'/?MeasureId='.$MeasureClient['MeasureId'].'&amp;Value='.addslashes($Value));
    18         } else echo('Metoda '.$MeasureClient['Method'].' neexistuje.');
    19       } else echo('Třída '.$MeasureClient['MeasureClass'].' neexistuje.');
    20      
     22          if($MeasureClient['Parameter'] != '') $Value = $Measure->$MeasureMethod['Method']($MeasureClient['Parameter']);
     23            else $Value = $MeasureClass->$MeasureMethod['Method']();
     24          echo(file_get_contents('http://'.$MeasureClient['Host'].$MeasureClient['Path'].'/?M=Add&MeasureId='.$MeasureClient['MeasureId'].'&Value='.addslashes($Value)));
     25        } else echo('Metoda '.$MeasureMethod['Method'].' neexistuje.');
     26      } else echo('Třída '.$MeasureMethod['MeasureClass'].' neexistuje.');
    2127    }
    2228  }
  • trunk/Application/Model/Measurement/System.php

    r43 r44  
    22
    33// Funkce pro získání stavových informací o systému
    4 
    5 function ErrorHandler($errno,$errmsg,$filename,$linenum,$vars)
    6 {
    7 
    84
    95include_once(dirname(__FILE__).'/Measurement.php');
     
    5450  }
    5551
    56   function CpuUsage()
     52  function CPUUsage()
    5753  {
    5854    $CpuStateFileName = '/tmp/LastCpuUsage';
    59     $LastCpuUsage = unserializa(file_get_contents($CpuStateFileName));
     55    $LastCpuUsage = unserialize(file_get_contents($CpuStateFileName));
    6056    //$cpuIDLEprev, $cpuSYSTprev, $cpuUSERprev;
    6157 
  • trunk/Application/View/Main.php

    r43 r44  
    206206      if($Measure['Info'] == '') $Measure['Info'] = '&nbsp;';
    207207      $GenerationTime = floor(($this->System->GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    208       $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'&amp;Differential=0">'.$Measure['Description'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Info'].'</td>';
     208      $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'&amp;Differential=0">'.$Measure['Name'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Description'].'</td>';
    209209      if(array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
    210210      $Output .= '</tr>';
  • trunk/Base/HTTP.php

    r42 r44  
    33class HTTP
    44{
    5   function GetQueryStringArray()
     5  function GetQueryStringArray($QueryString)
    66  {
    77    $Result = array();
    8     $Parts = explode('&', $_SERVER['QUERY_STRING']);
     8    $Parts = explode('&', $QueryString);
    99    foreach($Parts as $Part)
    1010    {
  • trunk/index.php

    r42 r44  
    44$BaseDir = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/'));
    55if($BaseDir != '') chdir($BaseDir);
     6
     7include_once(dirname(__FILE__).'/Base/HTTP.php');
     8
     9// Is executed from command line?
     10if(!isset($_SERVER['REMOTE_ADDR']))
     11{
     12  $HTTP = new HTTP();
     13  $_GET = $HTTP->GetQueryStringArray($_SERVER['argv'][1]);
     14}
     15print_r($_SERVER);
     16print_r($_GET);
    617
    718include_once(dirname(__FILE__).'/Application/Application.php');
Note: See TracChangeset for help on using the changeset viewer.