Changeset 96
- Timestamp:
- Jan 5, 2026, 6:38:18 PM (41 hours ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
Application/Version.php (modified) (1 diff)
-
Graph.php (modified) (1 diff)
-
Modules/Measure/Measure.php (modified) (7 diffs)
-
Modules/Measure/Page.php (modified) (7 diffs)
-
add.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Version.php
r95 r96 6 6 // and system will need database update. 7 7 8 $Revision = 9 5;8 $Revision = 96; 9 9 $DatabaseRevision = 79; 10 $ReleaseTime = strtotime('202 1-12-06');10 $ReleaseTime = strtotime('2025-01-05'); -
trunk/Graph.php
r95 r96 7 7 public Database $Database; 8 8 public int $FontSize; 9 public string $FontFileName Name;9 public string $FontFileName; 10 10 public float $ValueToImageHeigthCoefficient; 11 11 public int $DefaultWidth; -
trunk/Modules/Measure/Measure.php
r95 r96 64 64 function __construct(Database $Database) 65 65 { 66 $this->Id = 0;67 66 $this->ValueTypes = array('Min', 'Avg', 'Max'); 68 67 $this->Database = &$Database; … … 103 102 } 104 103 105 function AddValue( float $Value, int $Time): void104 function AddValue(int $Time, float $Min, float $Avg, float $Max): void 106 105 { 107 106 $Result = $this->Database->select($this->Data['DataTable'], '*', '(`Measure`='.$this->Data['Id'].') AND '. … … 110 109 // No measure value found. Simply insert new first value. 111 110 $this->Database->insert($this->Data['DataTable'], 112 array('Min' => $ Value, 'Avg' => $Value, 'Max' => $Value, 'Level' => 0,111 array('Min' => $Min, 'Avg' => $Avg, 'Max' => $Max, 'Level' => 0, 113 112 'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time), 114 113 'Continuity' => 0)); … … 116 115 // One value exists. Add second value. 117 116 $this->Database->insert($this->Data['DataTable'], 118 array('Min' => $ Value, 'Avg' => $Value, 'Max' => $Value, 'Level' => 0,117 array('Min' => $Min, 'Avg' => $Avg, 'Max' => $Max, 'Level' => 0, 119 118 'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time), 120 119 'Continuity' => 1)); … … 138 137 $Continuity = 0; 139 138 } 140 if (($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value) and 139 if (($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == $Min) and 140 ($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Avg) and 141 ($LastValue['Max'] == $NextToLastValue['Max']) and ($LastValue['Max'] == $Max) and 141 142 ($LastValue['Continuity'] == 1) and ($Continuity == 1)) 142 143 { … … 148 149 { 149 150 // Last value is different or not with continuity flag. Need to add new value. 150 $this->Database->insert($this->Data['DataTable'], array('Min' => $ Value,151 'Avg' => $ Value, 'max' => $Value, 'Level' => 0, 'Measure' => $this->Data['Id'],151 $this->Database->insert($this->Data['DataTable'], array('Min' => $Min, 152 'Avg' => $Avg, 'Max' => $Max, 'Level' => 0, 'Measure' => $this->Data['Id'], 152 153 'Time' => TimeToMysqlDateTime($Time), 153 154 'Continuity' => $Continuity)); … … 561 562 $this->Database->query('DROP TABLE `'.$Measure->GetDataTable().'`'); 562 563 } 563 564 564 } -
trunk/Modules/Measure/Page.php
r95 r96 3 3 class PageMain extends Page 4 4 { 5 var $Months; 6 var $GraphTimeRanges; 5 var int $Time; 6 var array $Months; 7 var array $GraphTimeRanges; 7 8 8 9 function __construct(System $System) … … 61 62 } 62 63 63 function EditTime( $Time): string64 function EditTime(int $Time): string 64 65 { 65 66 $Output = '<form style="display: inline;" action="?Operation=SetTime&Time='.$Time.'" method="post">'; … … 120 121 } 121 122 122 function GetFirstMeasure( $Measure): array123 function GetFirstMeasure(array $Measure): array 123 124 { 124 125 $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.$Measure['Id'].') AND (`Level`=0) ORDER BY `Time` ASC LIMIT 1'); … … 135 136 } 136 137 137 function GetLastMeasure( $Measure): array138 function GetLastMeasure(array $Measure): array 138 139 { 139 140 $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.$Measure['Id'].') AND (`Level`=0) ORDER BY `Time` DESC LIMIT 1'); … … 150 151 } 151 152 152 function LoadMeasure( $Id): array153 function LoadMeasure(int $Id): array 153 154 { 154 155 $DbResult = $this->Database->select('Measure', '*', '( `Enabled`=1) AND (`Id`='.$Id.') AND ((`PermissionView`="all") OR (`PermissionView`="'. … … 267 268 $Output .= '<br/>'; 268 269 return $Output; 269 270 270 } 271 271 … … 360 360 global $Config; 361 361 362 $Debug = 0;363 362 $this->HandleURL(); 364 363 -
trunk/add.php
r95 r96 10 10 $AddedValues = 0; 11 11 12 $Time = time(); 13 if (array_key_exists('Time', $_GET)) $Time = $_GET['Time'] * 1; 14 12 15 // Try to load single value 13 $Time = time(); 14 if (array_key_exists('MeasureId', $_GET) and array_key_exists('Value', $_GET)) 16 if (array_key_exists('MeasureId', $_GET)) 15 17 { 16 if (array_key_exists('Time', $_GET)) $Time = $_GET['Time'] * 1; 17 AddValue(addslashes($_GET['MeasureId']), addslashes($_GET['Value']), $Time); 18 $AddedValues = $AddedValues + 1; 18 $MeasureId = $_GET['MeasureId'] * 1; 19 if (array_key_exists('Avg', $_GET)) $Avg = $_GET['Avg'] * 1; 20 else if (array_key_exists('Value', $_GET)) $Avg = $_GET['Value'] * 1; // For back compatibility 21 else die('Missing avg value parameter.'); 22 23 if (array_key_exists('Min', $_GET)) $Min = $_GET['Min'] * 1; else $Min = $Avg; 24 if (array_key_exists('Max', $_GET)) $Max = $_GET['Max'] * 1; else $Max = $Avg; 25 AddValue($MeasureId, $Time, $Min, $Avg, $Max); 26 $AddedValues++; 19 27 } 20 28 21 29 // Try to load multiple values 22 $Time = time();23 30 $I = 1; 24 31 while (array_key_exists('MeasureId'.$I, $_GET) and array_key_exists('Value'.$I, $_GET)) 25 32 { 26 if (array_key_exists('Time'.$I, $_GET)) $Time = $_GET['Time'.$I] * 1; 27 AddValue(addslashes($_GET['MeasureId'.$I]), addslashes($_GET['Value'.$I]), $Time); 28 $AddedValues = $AddedValues + 1; 33 $MeasureId = $_GET['MeasureId'.$I] * 1; 34 if (array_key_exists('Avg'.$I, $_GET)) $Avg = $_GET['Avg'.$I] * 1; 35 else if (array_key_exists('Value'.$I, $_GET)) $Avg = $_GET['Value'.$I] * 1; // For back compatibility 36 else die('Missing avg value parameter.'); 37 38 if (array_key_exists('Min'.$I, $_GET)) $Min = $_GET['Min'.$I] * 1; else $Min = $Avg; 39 if (array_key_exists('Max'.$I, $_GET)) $Max = $_GET['Max'.$I] * 1; else $Max = $Avg; 40 AddValue($MeasureId, $Time, $Min, $Avg, $Max); 41 $AddedValues++; 29 42 $I++; 30 43 } … … 32 45 if ($AddedValues == 0) echo('Nebyly zadány potřebné parametry MeasureId a Value.'."\n"); 33 46 34 function AddValue(int $MeasureId, float $Value, int $Time): void47 function AddValue(int $MeasureId, int $Time, float $Min, float $Avg, float $Max): void 35 48 { 36 49 global $Core; … … 39 52 $Measure->Load($MeasureId); 40 53 $HostName = gethostbyaddr($_SERVER['REMOTE_ADDR']); 41 if (($HostName == $Measure->Data['PermissionAdd']) or ($_SERVER['REMOTE_ADDR'] == gethostbyname($Measure->Data['PermissionAdd']))) 54 if (($HostName == $Measure->Data['PermissionAdd']) or 55 ($_SERVER['REMOTE_ADDR'] == gethostbyname($Measure->Data['PermissionAdd']))) 42 56 { 43 $Measure->AddValue($Value, $Time); 44 echo('Hodnota '.$Value.' uložena'."\n"); 45 } else echo('Nemáte oprávnění k aktualizaci zadané veličiny!<br>Vaše adresa: '.$HostName.'('.$_SERVER['REMOTE_ADDR'].')'."\n"); 57 $Measure->AddValue($Time, $Min, $Avg, $Max); 58 echo('Hodnota avg: '.$Avg.', min: '.$Min.', max: '.$Max.' uložena'."\n"); 59 } else echo('Nemáte oprávnění k aktualizaci zadané veličiny!<br>'. 60 'Vaše adresa: '.$HostName.'('.$_SERVER['REMOTE_ADDR'].')'."\n"); 46 61 }
Note:
See TracChangeset
for help on using the changeset viewer.
