Changeset 92
- Timestamp:
- Apr 7, 2020, 11:53:58 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Core.php
r84 r92 2 2 3 3 $ConfigFileName = dirname(__FILE__).'/../Config/Config.php'; 4 if (file_exists($ConfigFileName)) include_once($ConfigFileName);4 if (file_exists($ConfigFileName)) include_once($ConfigFileName); 5 5 6 6 include_once(dirname(__FILE__).'/../Global.php'); … … 24 24 $this->ShowPage = true; 25 25 $this->BaseURL = $_SERVER['SCRIPT_NAME']; 26 if (substr($this->BaseURL, -10, 10) == '/index.php')26 if (substr($this->BaseURL, -10, 10) == '/index.php') 27 27 $this->BaseURL = substr($this->BaseURL, 0, -10); 28 28 } … … 32 32 global $Config, $DatabaseRevision, $WithoutSessionStart; 33 33 34 if ($this->UseSession) session_start();34 if ($this->UseSession) session_start(); 35 35 36 36 $ErrorHandler = new ErrorHandler(); … … 50 50 51 51 // SQL injection hack protection 52 foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);53 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);52 foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item); 53 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); 54 54 55 55 $this->Config = &$Config; … … 58 58 $this->Setup = new Setup($this); 59 59 $this->Setup->Start(); 60 if ($this->Setup->CheckState())60 if ($this->Setup->CheckState()) 61 61 { 62 62 $this->ModuleManager->Start(); … … 67 67 { 68 68 $this->RunCommon(); 69 if ($this->ShowPage)69 if ($this->ShowPage) 70 70 { 71 71 $this->PathItems = ProcessURL(); … … 80 80 /* @var $Page Page */ 81 81 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 82 if ($ClassName != '')82 if ($ClassName != '') 83 83 { 84 84 $Page = new $ClassName($this); … … 91 91 function RegisterPage($Path, $Handler) 92 92 { 93 if (is_array($Path))93 if (is_array($Path)) 94 94 { 95 95 $Page = &$this->Pages; 96 96 $LastKey = array_pop($Path); 97 foreach ($Path as $PathItem)97 foreach ($Path as $PathItem) 98 98 { 99 99 $Page = &$Page[$PathItem]; 100 100 } 101 if (!is_array($Page)) $Page = array('' => $Page);101 if (!is_array($Page)) $Page = array('' => $Page); 102 102 $Page[$LastKey] = $Handler; 103 103 } else $this->Pages[$Path] = $Handler; … … 111 111 function SearchPage($PathItems, $Pages) 112 112 { 113 if (count($PathItems) > 0) $PathItem = $PathItems[0];113 if (count($PathItems) > 0) $PathItem = $PathItems[0]; 114 114 else $PathItem = ''; 115 if (array_key_exists($PathItem, $Pages))115 if (array_key_exists($PathItem, $Pages)) 116 116 { 117 if (is_array($Pages[$PathItem]))117 if (is_array($Pages[$PathItem])) 118 118 { 119 119 array_shift($PathItems); 120 return ($this->SearchPage($PathItems, $Pages[$PathItem]));121 } else return ($Pages[$PathItem]);122 } else return ('');120 return $this->SearchPage($PathItems, $Pages[$PathItem]); 121 } else return $Pages[$PathItem]; 122 } else return ''; 123 123 } 124 124 125 125 function Link($Target) 126 126 { 127 return ($this->BaseURL.$Target);127 return $this->BaseURL.$Target; 128 128 } 129 129 } … … 141 141 { 142 142 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 143 return ('<h3 align="center">'.T('Required page not found'));143 return '<h3 align="center">'.T('Required page not found'); 144 144 } 145 145 } -
trunk/Application/DefaultConfig.php
r78 r92 6 6 { 7 7 $IsDeveloper = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1')); 8 return (array8 return array 9 9 ( 10 10 array('Name' => 'SystemPassword', 'Type' => 'PasswordEncoded', 'Default' => '', 'Title' => 'Systémové heslo'), … … 53 53 array('Name' => 'MainRouter/ConnectTimeout', 'Type' => 'Integer', 'Default' => '5', 'Title' => 'Vypršení času'), 54 54 array('Name' => 'MainRouter/MangleRuleSubgroupMinPrefix', 'Type' => 'Integer', 'Default' => '28', 'Title' => 'Nejmenší prefix podsítě pro mangle pravidla'), 55 ) );55 ); 56 56 } 57 57 } -
trunk/Application/UpdateTrace.php
r81 r92 44 44 'REFERENCES `Measure`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 45 45 $DbResult = $Manager->Execute('SELECT `Id`, `PermissionAdd` FROM `Measure`'); 46 while ($DbRow = $DbResult->fetch_assoc())46 while ($DbRow = $DbResult->fetch_assoc()) 47 47 { 48 48 $Manager->Execute('INSERT INTO `Permission` (`Measure`, `Operation`) VALUES ('. … … 50 50 } 51 51 $DbResult = $Manager->Execute('SELECT `Id`, `PermissionView` FROM `Measure`'); 52 while ($DbRow = $DbResult->fetch_assoc())52 while ($DbRow = $DbResult->fetch_assoc()) 53 53 { 54 54 $Manager->Execute('INSERT INTO `Permission` (`Measure`, `Operation`) VALUES ('. … … 61 61 { 62 62 $DbResult = $Manager->Execute('SELECT `DataTable`,`DataType` FROM `Measure`;'); 63 while ($Measure = $DbResult->fetch_assoc())63 while ($Measure = $DbResult->fetch_assoc()) 64 64 { 65 65 $Table = $Measure['DataTable']; … … 80 80 function Get() 81 81 { 82 return (array(82 return array( 83 83 65 => array('Revision' => 67, 'Function' => 'UpdateTo67'), 84 84 67 => array('Revision' => 79, 'Function' => 'UpdateTo79'), 85 ) );85 ); 86 86 } 87 87 } -
trunk/Application/Version.php
r90 r92 6 6 // and system will need database update. 7 7 8 $Revision = 88;8 $Revision = 92; 9 9 $DatabaseRevision = 79; 10 $ReleaseTime = strtotime('20 19-10-04');10 $ReleaseTime = strtotime('2020-04-07'); -
trunk/Application/View.php
r90 r92 28 28 { 29 29 $Output = $this->ShowPage($Page->Show()); 30 return ($Output);30 return $Output; 31 31 } 32 32 } -
trunk/Global.php
r77 r92 7 7 function HumanDate($Time) 8 8 { 9 return (date('j.n.Y', $Time));9 return date('j.n.Y', $Time); 10 10 } 11 11 … … 13 13 { 14 14 list($Usec, $Sec) = explode(" ", microtime()); 15 return ( (float)$Usec + (float)$Sec);15 return (float)$Usec + (float)$Sec; 16 16 } 17 17 18 18 function MakeLink($Target, $Title) 19 19 { 20 return ('<a href="'.$Target.'">'.$Title.'</a>');20 return '<a href="'.$Target.'">'.$Title.'</a>'; 21 21 } 22 22 … … 25 25 $Result = '<table cellspacing="0" class="BasicTable">'; 26 26 $Result .= '<tr>'; 27 foreach ($Table['Header'] as $Item)27 foreach ($Table['Header'] as $Item) 28 28 $Result .= '<th>'.$Item.'</th>'; 29 29 $Result .= '</tr>'; 30 foreach ($Table['Rows'] as $Row)30 foreach ($Table['Rows'] as $Row) 31 31 { 32 32 $Result .= '<tr>'; 33 foreach ($Row as $Item)33 foreach ($Row as $Item) 34 34 $Result .= '<td>'.$Item.'</td>'; 35 35 $Result .= '</tr>'; 36 36 } 37 37 $Result .= '</table>'; 38 return ($Result);38 return $Result; 39 39 } 40 40 … … 48 48 ); 49 49 50 foreach ($Class as $Index => $Item)50 foreach ($Class as $Index => $Item) 51 51 { 52 if (!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default'];53 switch ($Item['Type'])52 if (!array_key_exists($Index, $Values)) $Values[$Index] = $Item['Default']; 53 switch ($Item['Type']) 54 54 { 55 55 case 'Boolean': 56 if ($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"';56 if ($Values[$Index] == 0) $Checked = ''; else $Checked = ' checked="yes"'; 57 57 $Edit = '<input type="checkbox" name="'.$Index.'"'.$Checked.'>'; 58 58 break; … … 69 69 } 70 70 $Output = '<h3>Tabulka '.$ClassName.'</h3>'.Table($Table).MakeLink('?Operation=Add2', 'Přidat'); 71 return ($Output);71 return $Output; 72 72 } 73 73 74 74 function ProcessURL() 75 75 { 76 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))76 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) 77 77 $PathString = $_SERVER['REDIRECT_QUERY_STRING']; 78 78 else $PathString = ''; 79 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);79 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1); 80 80 $PathItems = explode('/', $PathString); 81 if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))81 if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false)) 82 82 $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1); 83 83 else $_SERVER['QUERY_STRING'] = ''; 84 84 parse_str($_SERVER['QUERY_STRING'], $_GET); 85 return ($PathItems);85 return $PathItems; 86 86 } 87 87 … … 90 90 $Result = array(); 91 91 $Parts = explode('&', $QueryString); 92 foreach ($Parts as $Part)92 foreach ($Parts as $Part) 93 93 { 94 if ($Part != '')94 if ($Part != '') 95 95 { 96 if (!strpos($Part, '=')) $Part .= '=';96 if (!strpos($Part, '=')) $Part .= '='; 97 97 $Item = explode('=', $Part); 98 98 $Result[$Item[0]] = $Item[1]; 99 99 } 100 100 } 101 return ($Result);101 return $Result; 102 102 } 103 103 … … 105 105 { 106 106 $Parts = array(); 107 foreach ($QueryStringArray as $Index => $Item)107 foreach ($QueryStringArray as $Index => $Item) 108 108 { 109 109 $Parts[] = $Index.'='.$Item; 110 110 } 111 return (implode('&', $Parts));111 return implode('&', $Parts); 112 112 } -
trunk/Graph.php
r85 r92 26 26 global $Config; 27 27 28 if (!array_key_exists('From',$_GET)) die('Musíte zadat čas počátku');28 if (!array_key_exists('From',$_GET)) die('Musíte zadat čas počátku'); 29 29 $StartTime = addslashes($_GET['From']); 30 if (!array_key_exists('To',$_GET)) die('Musíte zadat čas konce');30 if (!array_key_exists('To',$_GET)) die('Musíte zadat čas konce'); 31 31 $EndTime = addslashes($_GET['To']); 32 if ($EndTime < $StartTime) $EndTime = $StartTime + 60;32 if ($EndTime < $StartTime) $EndTime = $StartTime + 60; 33 33 $TimeDifference = $EndTime - $StartTime; 34 if (!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');34 if (!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu'); 35 35 $MeasureId = addslashes($_GET['Measure']); 36 if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;36 if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth; 37 37 else $Width = addslashes($_GET['Width']); 38 if (!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;38 if (!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight; 39 39 else $Height = addslashes($_GET['Height']); 40 if (!array_key_exists('Differential', $_GET)) $Differential = $Config['DefaultVariables']['Differential'];40 if (!array_key_exists('Differential', $_GET)) $Differential = $Config['DefaultVariables']['Differential']; 41 41 else $Differential = addslashes($_GET['Differential']); 42 42 $VerticalLinesCount = round($Height / ($this->FontSize + 4)); … … 54 54 55 55 $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1; 56 if ($Level < 0) $Level = 0;57 if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;56 if ($Level < 0) $Level = 0; 57 if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel; 58 58 59 59 $Points = $Measure->GetValues($StartTime, $EndTime, $Level); … … 63 63 $AvgValue = 0; 64 64 $MinValue = 1000000000000000000; 65 foreach ($Points as $Index => $Item)65 foreach ($Points as $Index => $Item) 66 66 { 67 67 //$Points[$Index]['Min'] = $Points[$Index]['Min'] / $Measure['Divider']; 68 68 //$Points[$Index]['Avg'] = $Points[$Index]['Avg'] / $Measure['Divider']; 69 69 //$Points[$Index]['Max'] = $Points[$Index]['Max'] / $Measure['Divider']; 70 if ($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg'];71 if ($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg'];72 if ($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max'];73 if ($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min'];70 if ($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg']; 71 if ($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg']; 72 if ($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max']; 73 if ($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min']; 74 74 $AvgValue = $AvgValue + $Points[$Index]['Avg']; 75 75 } … … 82 82 $PointsAvg = array(0, $Height - 1); 83 83 $PointsMax = array(0, $Height - 1); 84 if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;85 { 86 foreach ($Points as $Index => $Item)84 if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1; 85 { 86 foreach ($Points as $Index => $Item) 87 87 { 88 88 $PointsMin[] = $Index * $Width / $Measure->DivisionCount; … … 138 138 $TimeRange = $EndTime - $StartTime; 139 139 $TimeMarksIndex = 0; 140 while ((($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) and ($TimeMarksIndex < (count($TimeMarks) - 1)))140 while ((($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) and ($TimeMarksIndex < (count($TimeMarks) - 1))) 141 141 $TimeMarksIndex += 1; 142 if ($TimeMarksIndex < 2) $TimeMarksIndex = 2;142 if ($TimeMarksIndex < 2) $TimeMarksIndex = 2; 143 143 $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1]; 144 144 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; … … 149 149 // Zobraz měřítko Y 150 150 $VerticalLinesDistance = $Height / $VerticalLinesCount; 151 for ($I = 1; $I <= $VerticalLinesCount; $I++)151 for ($I = 1; $I <= $VerticalLinesCount; $I++) 152 152 { 153 153 $Y = $Height - 1 - ($VerticalLinesDistance * $I); 154 for ($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);154 for ($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray); 155 155 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 156 156 } … … 160 160 // Zobraz měřítko X 161 161 $LastTextEnd = 0; 162 for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)162 for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks) 163 163 { 164 164 $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 165 165 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 166 if (($MajorTimeMarks > 60*60*24)) $Text = date('j.n.Y', $Time + $TimeShift);166 if (($MajorTimeMarks > 60*60*24)) $Text = date('j.n.Y', $Time + $TimeShift); 167 167 else $Text = date('j.n.Y G:i', $Time + $TimeShift); 168 168 $BoundBox = imagettfbbox($this->FontSize, 0, $this->FontFileName, $Text); 169 if ($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))169 if ($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2)) 170 170 { 171 for ($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);171 for ($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray); 172 172 imagettftext($Image, $this->FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2, $Height - 2, $Black, $this->FontFileName, $Text); 173 173 $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2; 174 174 } 175 else for ($Y=0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);175 else for ($Y=0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray); 176 176 } 177 177 178 178 // Popisky osy Y 179 for ($I = 1; $I <= $VerticalLinesCount; $I++)179 for ($I = 1; $I <= $VerticalLinesCount; $I++) 180 180 { 181 181 $Y = $Height - 1 - ($VerticalLinesDistance * $I); … … 185 185 $Measure->Data['Unit'], 3); 186 186 $BoundBox = imagettfbbox($this->FontSize, 0, $this->FontFileName, $Text); 187 if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)187 if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) 188 188 imagettftext($Image, $this->FontSize, 0, 2, $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $this->FontFileName, $Text); 189 189 } -
trunk/Modules/Admin/Admin.php
r78 r92 41 41 function Show() 42 42 { 43 if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = '';44 switch ($Operation)43 if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = ''; 44 switch ($Operation) 45 45 { 46 46 case 'Add': … … 59 59 $Output = $this->ShowNone(); 60 60 } 61 return ($Output);61 return $Output; 62 62 } 63 63 … … 70 70 71 71 $Result = $this->Database->select('Measure', '*', '1 ORDER BY Description'); 72 while ($Measure = $Result->fetch_array())72 while ($Measure = $Result->fetch_array()) 73 73 { 74 74 array_push($Table['Rows'], array($Measure['Description'], MakeLink('?Operation=Edit&MeasureId='.$Measure['Id'], 'Editovat').' '.MakeLink('?Operation=Delete&MeasureId='.$Measure['Id'], 'Odstranit').' '.MakeLink('?Operation=RebuildCache&MeasureId='.$Measure['Id'], 'Přestavět cache'))); 75 75 } 76 76 $Output = '<h3>Seznam měření</h3>'.Table($Table).MakeLink('?Operation=Add', 'Přidat'); 77 return ($Output);77 return $Output; 78 78 } 79 79 … … 83 83 $Values = array(); 84 84 $Values = $DbResult->fetch_array(); 85 return (ShowEditTable('Measure', $Values));85 return ShowEditTable('Measure', $Values); 86 86 } 87 87 … … 89 89 { 90 90 $Values = array(); 91 return (ShowEditTable('Measure', $Values));91 return ShowEditTable('Measure', $Values); 92 92 } 93 93 -
trunk/Modules/Measure/Measure.php
r91 r92 83 83 function TimeSegment($Level) 84 84 { 85 return (pow($this->LevelReducing, $Level) * 60);85 return pow($this->LevelReducing, $Level) * 60; 86 86 } 87 87 88 88 function GetDataTable() 89 89 { 90 return ('data_'.$this->Data['Name']);90 return 'data_'.$this->Data['Name']; 91 91 } 92 92 93 93 function AlignTime($Time, $TimeSegment) 94 94 { 95 return (round(($Time - $this->ReferenceTime) / $TimeSegment) * $TimeSegment +96 $this->ReferenceTime );95 return round(($Time - $this->ReferenceTime) / $TimeSegment) * $TimeSegment + 96 $this->ReferenceTime; 97 97 } 98 98 … … 100 100 { 101 101 $Result = $this->Database->select('Measure', '*', '`Id`='.$Id); 102 if ($Result->num_rows > 0)102 if ($Result->num_rows > 0) 103 103 { 104 104 $this->Data = $Result->fetch_array(); 105 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous105 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous 106 106 else $this->Data['ContinuityEnabled'] = 2; // continuous graph 107 107 } else die('Měřená veličina '.$Id.' nenalezena.'); … … 112 112 $Result = $this->Database->select($this->Data['DataTable'], '*', '(`Measure`='.$this->Data['Id'].') AND '. 113 113 '(`Level`=0) ORDER BY `Time` DESC LIMIT 2'); 114 if ($Result->num_rows == 0) {114 if ($Result->num_rows == 0) { 115 115 // No measure value found. Simply insert new first value. 116 116 $this->Database->insert($this->Data['DataTable'], … … 118 118 'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time), 119 119 'Continuity' => 0)); 120 } else if ($Result->num_rows == 1) {120 } else if ($Result->num_rows == 1) { 121 121 // One value exists. Add second value. 122 122 $this->Database->insert($this->Data['DataTable'], … … 128 128 $LastValue = $Result->fetch_array(); 129 129 $NextToLastValue = $Result->fetch_array(); 130 if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < (1 - $this->PeriodTolerance) * $this->Data['Period'])130 if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < (1 - $this->PeriodTolerance) * $this->Data['Period']) 131 131 { 132 132 // New value added too quickly. Need to wait for next measure period. … … 135 135 { 136 136 // We are near defined period and can add new value. 137 if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < (1 + $this->PeriodTolerance) * $this->Data['Period']) {137 if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < (1 + $this->PeriodTolerance) * $this->Data['Period']) { 138 138 // New value added near defined measure period inside tolerance. Keep continuity. 139 139 $Continuity = 1; … … 143 143 $Continuity = 0; 144 144 } 145 if (($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value) and145 if (($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value) and 146 146 ($LastValue['Continuity'] == 1) and ($Continuity == 1)) 147 147 { … … 165 165 function UpdateHigherLevels($Time) 166 166 { 167 for ($Level = 1; $Level <= $this->MaxLevel; $Level++)167 for ($Level = 1; $Level <= $this->MaxLevel; $Level++) 168 168 { 169 169 $TimeSegment = $this->TimeSegment($Level); 170 170 $EndTime = $this->AlignTime($Time, $TimeSegment); 171 //if ($EndTime < $Time) $EndTime = $EndTime + $TimeSegment;171 //if ($EndTime < $Time) $EndTime = $EndTime + $TimeSegment; 172 172 $StartTime = $EndTime - $TimeSegment; 173 173 … … 178 178 '(`Time` < "'.TimeToMysqlDateTime($EndTime).'") AND '. 179 179 '(`Measure`='.$this->Data['Id'].') AND (`Level`='.($Level - 1).') ORDER BY `Time`'); 180 while ($Row = $Result->fetch_array())180 while ($Row = $Result->fetch_array()) 181 181 { 182 182 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); … … 211 211 212 212 // Trim outside parts 213 foreach ($this->ValueTypes as $ValueType)213 foreach ($this->ValueTypes as $ValueType) 214 214 { 215 215 $Values[0][$ValueType] = Interpolation( … … 218 218 } 219 219 $Values[0]['Time'] = $LeftTime; 220 foreach ($this->ValueTypes as $ValueType)220 foreach ($this->ValueTypes as $ValueType) 221 221 { 222 222 $Values[count($Values) - 1][$ValueType] = Interpolation( … … 228 228 229 229 // Perform computation 230 foreach ($this->ValueTypes as $ValueType)230 foreach ($this->ValueTypes as $ValueType) 231 231 { 232 232 // Compute new value 233 for ($I = 0; $I < (count($Values) - 1); $I++)234 { 235 if ($ValueType == 'Avg')233 for ($I = 0; $I < (count($Values) - 1); $I++) 234 { 235 if ($ValueType == 'Avg') 236 236 { 237 237 if ($this->Data['Cumulative']) … … 240 240 } else 241 241 { 242 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']);243 else if ($this->Differential == 0)242 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']); 243 else if ($this->Differential == 0) 244 244 { 245 245 $NewValue[$ValueType] = $NewValue[$ValueType] + ($Values[$I + 1]['Time'] - $Values[$I]['Time']) * … … 251 251 } 252 252 } 253 else if ($ValueType == 'Max')254 { 255 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])253 else if ($ValueType == 'Max') 254 { 255 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']) 256 256 { 257 if (0 > $NewValue[$ValueType]) $NewValue[$ValueType] = 0;257 if (0 > $NewValue[$ValueType]) $NewValue[$ValueType] = 0; 258 258 } 259 259 else 260 260 { 261 if ($this->Differential == 0)261 if ($this->Differential == 0) 262 262 { 263 if ($Values[$I + 1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];263 if ($Values[$I + 1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType]; 264 264 } else { 265 265 $Difference = $Values[$I + 1][$ValueType] - $Values[$I][$ValueType]; 266 if ($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;266 if ($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference; 267 267 } 268 268 } 269 269 } 270 else if ($ValueType == 'Min')271 { 272 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])270 else if ($ValueType == 'Min') 271 { 272 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']) 273 273 { 274 if (0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0;274 if (0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0; 275 275 } else { 276 if ($this->Differential == 0)276 if ($this->Differential == 0) 277 277 { 278 if ($Values[$I + 1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];278 if ($Values[$I + 1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType]; 279 279 } else { 280 280 $Difference = $Values[$I + 1][$ValueType] - $Values[$I][$ValueType]; 281 if ($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;281 if ($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference; 282 282 } 283 283 } … … 286 286 $NewValue[$ValueType] = $NewValue[$ValueType]; 287 287 } 288 //if (($RightTime - $LeftTime) > 0)289 if ($this->Data['Cumulative'] == 0)288 //if (($RightTime - $LeftTime) > 0) 289 if ($this->Data['Cumulative'] == 0) 290 290 { 291 291 $NewValue['Avg'] = $NewValue['Avg'] / ($RightTime - $LeftTime); 292 292 } 293 return ($NewValue);293 return $NewValue; 294 294 } 295 295 … … 299 299 $Result = $this->Database->select($this->Data['DataTable'], '*', '(`Measure`='.$this->Data['Id'].') AND '. 300 300 '(`Level`='.$Level.') ORDER BY `Time` LIMIT 1'); 301 if ($Result->num_rows > 0)301 if ($Result->num_rows > 0) 302 302 { 303 303 $Row = $Result->fetch_array(); … … 307 307 $Result = $this->Database->select($this->Data['DataTable'], '*', '(`Measure`='.$this->Data['Id'].') AND '. 308 308 '(`Level`='.$Level.') ORDER BY `Time` DESC LIMIT 1'); 309 if ($Result->num_rows > 0)309 if ($Result->num_rows > 0) 310 310 { 311 311 $Row = $Result->fetch_array(); … … 313 313 } else $AbsoluteRightTime = 0; 314 314 315 return (array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime));315 return array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime); 316 316 } 317 317 … … 323 323 '(`Time` > "'.TimeToMysqlDateTime($Time).'") AND (`Measure`='. 324 324 $this->Data['Id'].') AND (`Level`='.$Level.') ORDER BY `Time` ASC LIMIT 1'); 325 if ($DbResult->num_rows > 0)325 if ($DbResult->num_rows > 0) 326 326 { 327 327 // Found one value, simply return it 328 328 $Row = $DbResult->fetch_array(); 329 329 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 330 return (array($Row));330 return array($Row); 331 331 } else 332 332 { … … 339 339 '(`Time` < "'.TimeToMysqlDateTime($Time).'") AND (`Measure`='.$this->Data['Id'].') '. 340 340 'AND (`Level`='.$Level.') ORDER BY `Time` DESC LIMIT 1'); 341 if ($DbResult->num_rows > 0)341 if ($DbResult->num_rows > 0) 342 342 { 343 343 $Row = $DbResult->fetch_array(); … … 345 345 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 346 346 } 347 return ($Result);347 return $Result; 348 348 } 349 349 } … … 356 356 '(`Time` < "'.TimeToMysqlDateTime($Time).'") AND (`Measure`='.$this->Data['Id'].') '. 357 357 'AND (`Level`='.$Level.') ORDER BY `Time` DESC LIMIT 1'); 358 if ($DbResult->num_rows > 0)358 if ($DbResult->num_rows > 0) 359 359 { 360 360 // Found one value, simply return it 361 361 $Row = $DbResult->fetch_array(); 362 362 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 363 return (array($Row));363 return array($Row); 364 364 } else { 365 365 // Not found any value. Calculate it … … 372 372 '(`Time` > "'.TimeToMysqlDateTime($Time).'") AND (`Measure`='.$this->Data['Id'].') '. 373 373 'AND (`Level`='.$Level.') ORDER BY `Time` ASC LIMIT 1'); 374 if ($DbResult->num_rows > 0)374 if ($DbResult->num_rows > 0) 375 375 { 376 376 $Row = $DbResult->fetch_array(); … … 378 378 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 379 379 } 380 return ($Result);380 return $Result; 381 381 } 382 382 } … … 386 386 //$AbsoluteTime = GetTimeRange($this->DataId); 387 387 388 // if (($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and388 // if (($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and 389 389 // ($TimeTo > $AbsoluteLeftTime) and ($TimeTo < $AbsoluteRightTime)) 390 390 // { … … 397 397 '(`Measure`='.$this->Data['Id'].') AND (`Level`='.$Level.') ORDER BY `Time`'); 398 398 $Values = array(); 399 while ($Row = $Result->fetch_array())399 while ($Row = $Result->fetch_array()) 400 400 { 401 401 $Values[] = array('Time' => MysqlDateTimeToTime($Row['Time']), … … 406 406 407 407 $Points = array(); 408 if (count($Values) > 0)408 if (count($Values) > 0) 409 409 { 410 410 $Values = array_merge( … … 415 415 $StartIndex = 0; 416 416 $Points = array(); 417 for ($I = 0; $I < $this->DivisionCount; $I++)417 for ($I = 0; $I < $this->DivisionCount; $I++) 418 418 { 419 419 $TimeStart = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * $I; … … 421 421 422 422 $EndIndex = $StartIndex; 423 while ($Values[$EndIndex]['Time'] < $TimeEnd) $EndIndex = $EndIndex + 1;423 while ($Values[$EndIndex]['Time'] < $TimeEnd) $EndIndex = $EndIndex + 1; 424 424 $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1); 425 425 $Points[] = $this->ComputeOneValue($TimeStart, $TimeEnd, $SubValues, $Level); … … 427 427 } 428 428 } else $Points[] = array('Min' => 0, 'Avg' => 0, 'Max' => 0); 429 return ($Points);429 return $Points; 430 430 } 431 431 … … 433 433 { 434 434 echo('Velicina '.$this->Data['Name']."<br>\n"); 435 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous435 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous 436 436 else $this->Data['ContinuityEnabled'] = 2; // continuous graph 437 437 … … 443 443 echo("<br>\n"); 444 444 445 for ($Level = 1; $Level <= $this->MaxLevel; $Level++)445 for ($Level = 1; $Level <= $this->MaxLevel; $Level++) 446 446 { 447 447 echo('Uroven '.$Level."<br>\n"); … … 453 453 $Count = round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); 454 454 echo('For 0 to '.$Count."<br>\n"); 455 for ($I = 0; $I <= $Count; $I++)455 for ($I = 0; $I <= $Count; $I++) 456 456 { 457 457 echo($I.' '); … … 463 463 TimeToMysqlDateTime($EndTime2).'") AND (`Measure`='.$this->Data['Id']. 464 464 ') AND (`Level`='.($Level - 1).') ORDER BY `Time`'); 465 while ($Row = $DbResult->fetch_array())465 while ($Row = $DbResult->fetch_array()) 466 466 { 467 467 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); … … 469 469 } 470 470 471 if (count($Values) > 0)471 if (count($Values) > 0) 472 472 { 473 473 $Values = array_merge( … … 477 477 478 478 $StartIndex = 0; 479 for ($B = 0; $B < $BurstCount; $B++)479 for ($B = 0; $B < $BurstCount; $B++) 480 480 { 481 481 echo('.'); … … 484 484 485 485 $EndIndex = $StartIndex; 486 while ($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1;486 while ($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1; 487 487 $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1); 488 if (count($SubValues) > 2)488 if (count($SubValues) > 2) 489 489 { 490 490 $Point = $this->ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Level); … … 511 511 { 512 512 $Result = $this->Database->select('Measure', 'Id'); 513 while ($Row = $Result->fetch_array())513 while ($Row = $Result->fetch_array()) 514 514 { 515 515 $Measure = new Measure(); -
trunk/Modules/Measure/Page.php
r86 r92 68 68 // Day selection 69 69 $Output .= '<select name="Day">'; 70 for ($I = 1; $I < 32; $I++)71 { 72 if ($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';70 for ($I = 1; $I < 32; $I++) 71 { 72 if ($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = ''; 73 73 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 74 74 } … … 77 77 // Month selection 78 78 $Output .= '<select name="Month">'; 79 foreach ($this->Months as $Index => $Month)80 { 81 if ($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';82 if ($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';79 foreach ($this->Months as $Index => $Month) 80 { 81 if ($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = ''; 82 if ($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>'; 83 83 } 84 84 $Output .= '</select>. '; … … 86 86 // Year selection 87 87 $Output .= '<select name="Year">'; 88 for ($I = 2000; $I <= date("Y"); $I++)89 { 90 if ($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';88 for ($I = 2000; $I <= date("Y"); $I++) 89 { 90 if ($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = ''; 91 91 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 92 92 } … … 95 95 // Hour selection 96 96 $Output .= '<select name="Hour">'; 97 for ($I = 0; $I < 24; $I++)98 { 99 if ($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';97 for ($I = 0; $I < 24; $I++) 98 { 99 if ($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = ''; 100 100 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 101 101 } … … 104 104 // Minute selection 105 105 $Output .= '<select name="Minute">'; 106 for ($I = 0; $I < 60; $I++)107 { 108 if ($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';106 for ($I = 0; $I < 60; $I++) 107 { 108 if ($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = ''; 109 109 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 110 110 } … … 117 117 $Output .= '</form>'; 118 118 119 return ($Output);119 return $Output; 120 120 } 121 121 … … 123 123 { 124 124 $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.$Measure['Id'].') AND (`Level`=0) ORDER BY `Time` ASC LIMIT 1'); 125 if ($Result2->num_rows > 0)125 if ($Result2->num_rows > 0) 126 126 { 127 127 $Row = $Result2->fetch_array(); … … 132 132 $LastMeasureValue = 0; 133 133 } 134 return (array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue));134 return array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue); 135 135 } 136 136 … … 138 138 { 139 139 $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.$Measure['Id'].') AND (`Level`=0) ORDER BY `Time` DESC LIMIT 1'); 140 if ($Result2->num_rows > 0)140 if ($Result2->num_rows > 0) 141 141 { 142 142 $Row = $Result2->fetch_array(); … … 147 147 $LastMeasureValue = 0; 148 148 } 149 return (array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue));149 return array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue); 150 150 } 151 151 … … 164 164 $Output = '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small; margin: 0px auto;">'; 165 165 $Output .= '<tr><th>Měřená veličina</th><th>Poslední hodnota</th><th>Čas posledního měření</th><th>Interpolace</th><th>Poznámky</th>'; 166 if (array_key_exists('Debug', $_GET)) $Output .= '<th>Počet položek</th><th>Čas vykonání</th>';166 if (array_key_exists('Debug', $_GET)) $Output .= '<th>Počet položek</th><th>Čas vykonání</th>'; 167 167 $Output .= '</tr>'; 168 168 $Result = $this->Database->select('Measure', '*', '( `Enabled`=1) AND ((`PermissionView`="all") OR (`PermissionView`="'. 169 169 gethostbyaddr($_SERVER['REMOTE_ADDR']).'")) ORDER BY `Description`'); 170 while ($Measure = $Result->fetch_array())170 while ($Measure = $Result->fetch_array()) 171 171 { 172 172 $StopWatchStart = GetMicrotime(); 173 if (array_key_exists('Debug', $_GET))173 if (array_key_exists('Debug', $_GET)) 174 174 { 175 175 $DbResult = $this->Database->select($Measure['DataTable'], 'COUNT(*)', '`Measure`='.$Measure['Id']); … … 179 179 $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='. 180 180 $Measure['Id'].') AND (`Level`=0) ORDER BY `Time` DESC LIMIT 1'); 181 if ($Result2->num_rows > 0)181 if ($Result2->num_rows > 0) 182 182 { 183 183 $Row = $Result2->fetch_array(); … … 188 188 $LastMeasureValue = ' '; 189 189 } 190 if ($Measure['Continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne';191 if ($Measure['Info'] == '') $Measure['Info'] = ' ';190 if ($Measure['Continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne'; 191 if ($Measure['Info'] == '') $Measure['Info'] = ' '; 192 192 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 193 193 $Output .= '<tr><td style="text-align: left"><a href="?Measure='.$Measure['Id']. … … 195 195 $LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'. 196 196 $Interpolate.'</td><td>'.$Measure['Info'].'</td>'; 197 if (array_key_exists('Debug', $_GET))197 if (array_key_exists('Debug', $_GET)) 198 198 $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>'; 199 199 $Output .= '</tr>'; 200 200 } 201 201 $Output .= '</table>'; 202 return ($Output);202 return $Output; 203 203 } 204 204 … … 214 214 '&TimeSpecify=1&Differential='.$_SESSION['Differential']. 215 215 '">Odkaz na vybraný graf</a><br/>'; 216 return ($Output);216 return $Output; 217 217 } 218 218 … … 221 221 $Output = ''; 222 222 223 if (!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';224 switch ($_GET['Operation'])223 if (!array_key_exists('Operation', $_GET)) $_GET['Operation'] = ''; 224 switch ($_GET['Operation']) 225 225 { 226 226 case 'SetTime': 227 if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and227 if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and 228 228 array_key_exists('Year', $_POST) and array_key_exists('Hour', $_POST) and array_key_exists('Minute', $_POST)) 229 229 { 230 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))230 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) 231 231 { 232 232 $_SESSION[$_GET['Time']] = mktime($_POST['Hour'], $_POST['Minute'], 0, $_POST['Month'], … … 236 236 break; 237 237 case 'SetTimeNow': 238 if (array_key_exists('Time', $_GET))238 if (array_key_exists('Time', $_GET)) 239 239 { 240 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))240 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) 241 241 { 242 242 $_SESSION[$_GET['Time']] = $this->Time; … … 249 249 250 250 // Show graph time range menu 251 if ($_SESSION['TimeSpecify'] == 0)251 if ($_SESSION['TimeSpecify'] == 0) 252 252 { 253 253 $Output .= 'Délka úseku: '; 254 foreach ($this->GraphTimeRanges as $Index => $Item)254 foreach ($this->GraphTimeRanges as $Index => $Item) 255 255 $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a> '; 256 256 $Output .= '<br>'; … … 266 266 '<a href="?Move=Right">></a> <a href="?Move=RightEnd">>|</a> <a href="?Move=Now">Nyní</a><br>'; 267 267 $Output .= '<br/>'; 268 return ($Output);268 return $Output; 269 269 270 270 } … … 277 277 { 278 278 if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable; 279 //if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];280 //if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];279 //if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index]; 280 //if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index]; 281 281 //$$Index = $_SESSION[$Index]; 282 282 } … … 370 370 '((`PermissionView`="all") OR (`PermissionView`="'.gethostbyaddr($_SERVER['REMOTE_ADDR']).'")) '. 371 371 'AND (`Id`='.($_SESSION['Measure'] * 1).')'); 372 if ($Result->num_rows == 0)372 if ($Result->num_rows == 0) 373 373 $_SESSION['Measure'] = $Config['DefaultVariables']['Measure']; 374 374 … … 378 378 $Output .= $this->ShowMeasureTable(); 379 379 $Output .= '</div>'; 380 return ($Output);380 return $Output; 381 381 } 382 382 } -
trunk/Packages/Common/AppModule.php
r69 r92 77 77 function Install() 78 78 { 79 if ($this->Installed) return;79 if ($this->Installed) return; 80 80 $List = array(); 81 81 $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotInstalled)); … … 89 89 function Uninstall() 90 90 { 91 if (!$this->Installed) return;91 if (!$this->Installed) return; 92 92 $this->Stop(); 93 93 $this->Installed = false; … … 100 100 function Upgrade() 101 101 { 102 if (!$this->Installed) return;103 if ($this->InstalledVersion == $this->Version) return;102 if (!$this->Installed) return; 103 if ($this->InstalledVersion == $this->Version) return; 104 104 $List = array(); 105 105 $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed)); … … 117 117 function Start() 118 118 { 119 if ($this->Running) return;120 if (!$this->Installed) return;119 if ($this->Running) return; 120 if (!$this->Installed) return; 121 121 $List = array(); 122 122 $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotRunning)); … … 128 128 function Stop() 129 129 { 130 if (!$this->Running) return;130 if (!$this->Running) return; 131 131 $this->Running = false; 132 132 $List = array(); … … 144 144 function Enable() 145 145 { 146 if ($this->Enabled) return;147 if (!$this->Installed) return;146 if ($this->Enabled) return; 147 if (!$this->Installed) return; 148 148 $List = array(); 149 149 $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotEnabled)); … … 154 154 function Disable() 155 155 { 156 if (!$this->Enabled) return;156 if (!$this->Enabled) return; 157 157 $this->Stop(); 158 158 $this->Enabled = false; … … 203 203 function Perform($List, $Actions, $Conditions = array(ModuleCondition::All)) 204 204 { 205 foreach ($List as $Index => $Module)206 { 207 if (in_array(ModuleCondition::All, $Conditions) or205 foreach ($List as $Index => $Module) 206 { 207 if (in_array(ModuleCondition::All, $Conditions) or 208 208 ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or 209 209 (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or … … 213 213 (!$Module->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions))) 214 214 { 215 foreach ($Actions as $Action)215 foreach ($Actions as $Action) 216 216 { 217 if ($Action == ModuleAction::Start) $Module->Start();218 if ($Action == ModuleAction::Stop) $Module->Stop();219 if ($Action == ModuleAction::Install) $Module->Install();220 if ($Action == ModuleAction::Uninstall) $Module->Uninstall();221 if ($Action == ModuleAction::Enable) $Module->Enable();222 if ($Action == ModuleAction::Disable) $Module->Disable();223 if ($Action == ModuleAction::Upgrade) $Module->Upgrade();217 if ($Action == ModuleAction::Start) $Module->Start(); 218 if ($Action == ModuleAction::Stop) $Module->Stop(); 219 if ($Action == ModuleAction::Install) $Module->Install(); 220 if ($Action == ModuleAction::Uninstall) $Module->Uninstall(); 221 if ($Action == ModuleAction::Enable) $Module->Enable(); 222 if ($Action == ModuleAction::Disable) $Module->Disable(); 223 if ($Action == ModuleAction::Upgrade) $Module->Upgrade(); 224 224 } 225 225 } … … 229 229 function EnumDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All)) 230 230 { 231 foreach ($Module->Dependencies as $Dependency)232 { 233 if (!array_key_exists($Dependency, $this->Modules))231 foreach ($Module->Dependencies as $Dependency) 232 { 233 if (!array_key_exists($Dependency, $this->Modules)) 234 234 throw new Exception(sprintf(T('Module "%s" dependency "%s" not found'), $Module->Name, $Dependency)); 235 235 $DepModule = $this->Modules[$Dependency]; 236 if (in_array(ModuleCondition::All, $Conditions) or236 if (in_array(ModuleCondition::All, $Conditions) or 237 237 ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or 238 238 (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or … … 250 250 function EnumSuperiorDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All)) 251 251 { 252 foreach ($this->Modules as $RefModule)253 { 254 if (in_array($Module->Name, $RefModule->Dependencies) and252 foreach ($this->Modules as $RefModule) 253 { 254 if (in_array($Module->Name, $RefModule->Dependencies) and 255 255 (in_array(ModuleCondition::All, $Conditions) or 256 256 ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or … … 270 270 { 271 271 $this->LoadModules(); 272 if (file_exists($this->FileName)) $this->LoadState();272 if (file_exists($this->FileName)) $this->LoadState(); 273 273 $this->StartEnabled(); 274 274 } … … 315 315 function ModulePresent($Name) 316 316 { 317 return (array_key_exists($Name, $this->Modules));317 return array_key_exists($Name, $this->Modules); 318 318 } 319 319 320 320 function ModuleEnabled($Name) 321 321 { 322 return (array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled);322 return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled; 323 323 } 324 324 325 325 function ModuleRunning($Name) 326 326 { 327 return (array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running);327 return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running; 328 328 } 329 329 … … 331 331 function SearchModuleById($Id) 332 332 { 333 foreach ($this->Modules as $Module)333 foreach ($this->Modules as $Module) 334 334 { 335 335 //DebugLog($Module->Name.' '.$Module->Id); 336 if ($Module->Id == $Id) return($Module->Name);337 } 338 return ('');336 if ($Module->Id == $Id) return $Module->Name; 337 } 338 return ''; 339 339 } 340 340 … … 343 343 $ConfigModules = array(); 344 344 include($this->FileName); 345 foreach ($ConfigModules as $Mod)346 { 347 if (array_key_exists($Mod['Name'], $this->Modules))345 foreach ($ConfigModules as $Mod) 346 { 347 if (array_key_exists($Mod['Name'], $this->Modules)) 348 348 { 349 349 $this->Modules[$Mod['Name']] = $this->Modules[$Mod['Name']]; … … 358 358 { 359 359 $Data = array(); 360 foreach ($this->Modules as $Module)360 foreach ($this->Modules as $Module) 361 361 { 362 362 $Data[] = array('Name' => $Module->Name, 'Enabled' => $Module->Enabled, … … 381 381 { 382 382 $List = scandir($Directory); 383 foreach ($List as $Item)384 { 385 if (is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn'))383 foreach ($List as $Item) 384 { 385 if (is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn')) 386 386 { 387 387 include_once($Directory.'/'.$Item.'/'.$Item.'.php'); … … 394 394 function LoadModules() 395 395 { 396 if (method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))396 if (method_exists($this->OnLoadModules[0], $this->OnLoadModules[1])) 397 397 $this->OnLoadModules(); 398 398 else $this->LoadModulesFromDir($this->ModulesDir); -
trunk/Packages/Common/Application.php
r90 r92 12 12 function DoOnChange() 13 13 { 14 foreach ($this->OnChange as $Callback)14 foreach ($this->OnChange as $Callback) 15 15 { 16 16 call_user_func($Callback); -
trunk/Packages/Common/Common.php
r90 r92 62 62 63 63 $Result = ''; 64 if (array_key_exists('all', $QueryItems))64 if (array_key_exists('all', $QueryItems)) 65 65 { 66 66 $PageCount = 1; … … 73 73 } 74 74 75 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;76 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;77 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;78 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;75 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 76 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 77 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 78 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 79 79 $CurrentPage = $_SESSION['Page']; 80 80 … … 82 82 83 83 $Result = ''; 84 if ($PageCount > 1)84 if ($PageCount > 1) 85 85 { 86 if ($CurrentPage > 0)86 if ($CurrentPage > 0) 87 87 { 88 88 $QueryItems['page'] = 0; … … 93 93 $PagesMax = $PageCount - 1; 94 94 $PagesMin = 0; 95 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;96 if ($PagesMin < ($CurrentPage - $Around))95 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 96 if ($PagesMin < ($CurrentPage - $Around)) 97 97 { 98 98 $Result.= ' ... '; 99 99 $PagesMin = $CurrentPage - $Around; 100 100 } 101 for ($i = $PagesMin; $i <= $PagesMax; $i++)101 for ($i = $PagesMin; $i <= $PagesMax; $i++) 102 102 { 103 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';103 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 104 104 else { 105 105 $QueryItems['page'] = $i; … … 107 107 } 108 108 } 109 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';110 if ($CurrentPage < ($PageCount - 1))109 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 110 if ($CurrentPage < ($PageCount - 1)) 111 111 { 112 112 $QueryItems['page'] = ($CurrentPage + 1); … … 117 117 } 118 118 $QueryItems['all'] = '1'; 119 if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';119 if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 120 120 121 121 $Result = '<div style="text-align: center">'.$Result.'</div>'; 122 122 $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage; 123 123 $this->Page = $CurrentPage; 124 return ($Result);124 return $Result; 125 125 } 126 126 } -
trunk/Packages/Common/Config.php
r69 r92 12 12 function ReadValue($Name) 13 13 { 14 if (!is_array($Name)) $Name = explode('/', $Name);14 if (!is_array($Name)) $Name = explode('/', $Name); 15 15 $Last = array_pop($Name); 16 16 $Data = &$this->Data; 17 foreach ($Name as $Item)17 foreach ($Name as $Item) 18 18 { 19 19 $Data = &$Data[$Item]; 20 20 } 21 return ($Data[$Last]);21 return $Data[$Last]; 22 22 } 23 23 24 24 function WriteValue($Name, $Value) 25 25 { 26 if (!is_array($Name)) $Name = explode('/', $Name);26 if (!is_array($Name)) $Name = explode('/', $Name); 27 27 $Last = array_pop($Name); 28 28 $Data = &$this->Data; 29 foreach ($Name as $Item)29 foreach ($Name as $Item) 30 30 { 31 31 $Data = &$Data[$Item]; … … 38 38 $ConfigData = array(); 39 39 include $FileName; 40 foreach ($this->Data as $Index => $Item)40 foreach ($this->Data as $Index => $Item) 41 41 { 42 if (array_key_exits($Index, $ConfigData))42 if (array_key_exits($Index, $ConfigData)) 43 43 $this->Data[$Index] = $ConfigData[$Index]; 44 44 } … … 52 52 function GetAsArray() 53 53 { 54 return ($this->Data);54 return $this->Data; 55 55 } 56 56 } -
trunk/Packages/Common/Database.php
r90 r92 7 7 { 8 8 list($usec, $sec) = explode(" ", microtime()); 9 return ( (float)$usec + (float)$sec);9 return (float)$usec + (float)$sec; 10 10 } 11 11 … … 17 17 function fetch_assoc() 18 18 { 19 return ($this->PDOStatement->fetch(PDO::FETCH_ASSOC));19 return $this->PDOStatement->fetch(PDO::FETCH_ASSOC); 20 20 } 21 21 22 22 function fetch_array() 23 23 { 24 return ($this->PDOStatement->fetch(PDO::FETCH_BOTH));24 return $this->PDOStatement->fetch(PDO::FETCH_BOTH); 25 25 } 26 26 27 27 function fetch_row() 28 28 { 29 return ($this->PDOStatement->fetch(PDO::FETCH_NUM));29 return $this->PDOStatement->fetch(PDO::FETCH_NUM); 30 30 } 31 31 } … … 61 61 function Connect($Host, $User, $Password, $Database) 62 62 { 63 if ($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;64 else if ($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host;63 if ($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database; 64 else if ($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host; 65 65 else $ConnectionString = ''; 66 66 try { … … 81 81 function Connected() 82 82 { 83 return (isset($this->PDO));83 return isset($this->PDO); 84 84 } 85 85 … … 91 91 function query($Query) 92 92 { 93 if (!$this->Connected()) throw new Exception(T('Not connected to database'));94 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float();93 if (!$this->Connected()) throw new Exception(T('Not connected to database')); 94 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float(); 95 95 $this->LastQuery = $Query; 96 96 //echo('a'.$this->ShowSQLQuery.'<'.$QueryStartTime.', '.microtime_float()); 97 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))97 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) 98 98 $Duration = ' ; '.round(microtime_float() - $QueryStartTime, 4). ' s'; 99 if ($this->LogSQLQuery == true)99 if ($this->LogSQLQuery == true) 100 100 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND); 101 if ($this->ShowSQLQuery == true)101 if ($this->ShowSQLQuery == true) 102 102 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '. 103 103 'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n"); 104 104 $Result = new DatabaseResult(); 105 105 $Result->PDOStatement = $this->PDO->query($Query); 106 if ($Result->PDOStatement)106 if ($Result->PDOStatement) 107 107 { 108 108 $Result->num_rows = $Result->PDOStatement->rowCount(); … … 112 112 $this->Error = $this->PDO->errorInfo(); 113 113 $this->Error = $this->Error[2]; 114 if (($this->Error != '') and ($this->ShowSQLError == true))114 if (($this->Error != '') and ($this->ShowSQLError == true)) 115 115 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); 116 116 throw new Exception('SQL Error: '.$this->Error.', Query: '.$Query); 117 117 } 118 return ($Result);118 return $Result; 119 119 } 120 120 121 121 function select($Table, $What = '*', $Condition = 1) 122 122 { 123 return ($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition));123 return $this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 124 124 } 125 125 … … 139 139 $Name = ''; 140 140 $Values = ''; 141 foreach ($Data as $Key => $Value)141 foreach ($Data as $Key => $Value) 142 142 { 143 143 $Name .= ',`'.$Key.'`'; 144 if (!in_array($Value, $this->Functions))145 { 146 if (is_null($Value)) $Value = 'NULL';144 if (!in_array($Value, $this->Functions)) 145 { 146 if (is_null($Value)) $Value = 'NULL'; 147 147 else $Value = $this->PDO->quote($Value); 148 148 } … … 151 151 $Name = substr($Name, 1); 152 152 $Values = substr($Values, 1); 153 return ('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');153 return 'INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'; 154 154 } 155 155 … … 162 162 { 163 163 $Values = ''; 164 foreach ($Data as $Key => $Value)165 { 166 if (!in_array($Value, $this->Functions))167 { 168 if (is_null($Value)) $Value = 'NULL';164 foreach ($Data as $Key => $Value) 165 { 166 if (!in_array($Value, $this->Functions)) 167 { 168 if (is_null($Value)) $Value = 'NULL'; 169 169 else $Value = $this->PDO->quote($Value); 170 170 } … … 172 172 } 173 173 $Values = substr($Values, 2); 174 return ('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');174 return 'UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'; 175 175 } 176 176 … … 179 179 $Name = ''; 180 180 $Values = ''; 181 foreach ($Data as $Key => $Value)182 { 183 if (!in_array($Value, $this->Functions))184 { 185 if (is_null($Value)) $Value = 'NULL';181 foreach ($Data as $Key => $Value) 182 { 183 if (!in_array($Value, $this->Functions)) 184 { 185 if (is_null($Value)) $Value = 'NULL'; 186 186 else $Value = $this->PDO->quote($Value); 187 187 } … … 203 203 function real_escape_string($Text) 204 204 { 205 return (addslashes($Text));205 return addslashes($Text); 206 206 } 207 207 208 208 function quote($Text) 209 209 { 210 return ($this->PDO->quote($Text));210 return $this->PDO->quote($Text); 211 211 } 212 212 … … 234 234 function TimeToMysqlDateTime($Time) 235 235 { 236 if ($Time == NULL) return(NULL);237 else return (date('Y-m-d H:i:s', $Time));236 if ($Time == NULL) return NULL; 237 else return date('Y-m-d H:i:s', $Time); 238 238 } 239 239 240 240 function TimeToMysqlDate($Time) 241 241 { 242 if ($Time == NULL) return(NULL);243 else return (date('Y-m-d', $Time));242 if ($Time == NULL) return NULL; 243 else return date('Y-m-d', $Time); 244 244 } 245 245 246 246 function TimeToMysqlTime($Time) 247 247 { 248 if ($Time == NULL) return(NULL);249 else return (date('H:i:s', $Time));248 if ($Time == NULL) return NULL; 249 else return date('H:i:s', $Time); 250 250 } 251 251 252 252 function MysqlDateTimeToTime($DateTime) 253 253 { 254 if ($DateTime == '') return(NULL);254 if ($DateTime == '') return NULL; 255 255 $Parts = explode(' ', $DateTime); 256 256 $DateParts = explode('-', $Parts[0]); 257 257 $TimeParts = explode(':', $Parts[1]); 258 258 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 259 return ($Result);259 return $Result; 260 260 } 261 261 262 262 function MysqlDateToTime($Date) 263 263 { 264 if ($Date == '') return(NULL);265 return (MysqlDateTimeToTime($Date.' 0:0:0'));264 if ($Date == '') return NULL; 265 return MysqlDateTimeToTime($Date.' 0:0:0'); 266 266 } 267 267 268 268 function MysqlTimeToTime($Time) 269 269 { 270 if ($Time == '') return(NULL);271 return (MysqlDateTimeToTime('0000-00-00 '.$Time));272 } 270 if ($Time == '') return NULL; 271 return MysqlDateTimeToTime('0000-00-00 '.$Time); 272 } -
trunk/Packages/Common/Error.php
r77 r92 45 45 ); 46 46 47 if (($this->UserErrors & $Number))47 if (($this->UserErrors & $Number)) 48 48 { 49 49 // Error was suppressed with the @-operator 50 if (0 === error_reporting())50 if (0 === error_reporting()) 51 51 { 52 52 return false; … … 58 58 $Backtrace[0]['line'] = $LineNumber; 59 59 $this->Report($Backtrace); 60 //if ((E_ERROR | E_PARSE) & $Number)60 //if ((E_ERROR | E_PARSE) & $Number) 61 61 die(); 62 62 } … … 82 82 'An internal error occurred!<br/>'. 83 83 'Administrator will be notified and the problem will be investigated and fixed soon.'.'<br/><br/>'; 84 if ($this->ShowError == true)84 if ($this->ShowError == true) 85 85 $Output .= '<pre>'.$Message.'</pre><br/>'; 86 86 $Output .= '</body></html>'; … … 93 93 $Date = date('Y-m-d H:i:s'); 94 94 $Error = '# '.$Date."\n"; 95 foreach ($Backtrace as $Item)95 foreach ($Backtrace as $Item) 96 96 { 97 if (!array_key_exists('line', $Item)) $Item['line'] = '';98 if (!array_key_exists('file', $Item)) $Item['file'] = '';97 if (!array_key_exists('line', $Item)) $Item['line'] = ''; 98 if (!array_key_exists('file', $Item)) $Item['file'] = ''; 99 99 100 100 $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function']; 101 101 $Arguments = ''; 102 if (array_key_exists('args', $Item) and is_array($Item['args']))103 foreach ($Item['args'] as $Item)102 if (array_key_exists('args', $Item) and is_array($Item['args'])) 103 foreach ($Item['args'] as $Item) 104 104 { 105 if (is_object($Item)) ;106 else if (is_array($Item)) $Arguments .= "'".serialize($Item)."',";105 if (is_object($Item)) ; 106 else if (is_array($Item)) $Arguments .= "'".serialize($Item)."',"; 107 107 else $Arguments .= "'".$Item."',"; 108 108 } 109 if (strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';109 if (strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')'; 110 110 $Error .= "\n"; 111 111 } 112 112 $Error .= "\n"; 113 113 114 foreach ($this->OnError as $OnError)114 foreach ($this->OnError as $OnError) 115 115 call_user_func($OnError, $Error); 116 116 } -
trunk/Packages/Common/Image.php
r69 r92 65 65 function SaveToFile($FileName) 66 66 { 67 if ($this->Type == IMAGETYPE_JPEG)67 if ($this->Type == IMAGETYPE_JPEG) 68 68 { 69 69 imagejpeg($this->Image, $FileName); 70 70 } else 71 if ($this->Type == IMAGETYPE_GIF)71 if ($this->Type == IMAGETYPE_GIF) 72 72 { 73 imagegif ($this->Image, $FileName);73 imagegif ($this->Image, $FileName); 74 74 } else 75 if ($this->Type == IMAGETYPE_PNG)75 if ($this->Type == IMAGETYPE_PNG) 76 76 { 77 77 imagepng($this->Image, $FileName); … … 83 83 $ImageInfo = getimagesize($FileName); 84 84 $this->Type = $ImageInfo[2]; 85 if ($this->Type == IMAGETYPE_JPEG)85 if ($this->Type == IMAGETYPE_JPEG) 86 86 { 87 87 $this->Image = imagecreatefromjpeg($FileName); 88 88 } else 89 if ($this->Type == IMAGETYPE_GIF)89 if ($this->Type == IMAGETYPE_GIF) 90 90 { 91 91 $this->Image = imagecreatefromgif($FileName); 92 92 } else 93 if ( $this->Type == IMAGETYPE_PNG)93 if ( $this->Type == IMAGETYPE_PNG) 94 94 { 95 95 $this->Image = imagecreatefrompng($FileName); … … 112 112 function GetWidth() 113 113 { 114 return (imagesx($this->Image));114 return imagesx($this->Image); 115 115 } 116 116 117 117 function GetHeight() 118 118 { 119 return (imagesy($this->Image));119 return imagesy($this->Image); 120 120 } 121 121 … … 127 127 function ConvertColor($Color) 128 128 { 129 return (imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff));129 return imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff); 130 130 } 131 131 -
trunk/Packages/Common/Locale.php
r69 r92 20 20 function Translate($Text, $Group = '') 21 21 { 22 if (array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != ''))23 return ($this->Data[$Group][$Text]);24 else return ($Text);22 if (array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != '')) 23 return $this->Data[$Group][$Text]; 24 else return $Text; 25 25 } 26 26 … … 28 28 { 29 29 $Key = array_search($Text, $this->Data[$Group]); 30 if (($Key === FALSE) or ($this->Data[$Group][$Key] == '')) return($Text);31 else return ($Key);30 if (($Key === FALSE) or ($this->Data[$Group][$Key] == '')) return $Text; 31 else return $Key; 32 32 } 33 33 } … … 47 47 { 48 48 $FileName = $this->Dir.'/'.$Language.'.php'; 49 if (file_exists($FileName)) {49 if (file_exists($FileName)) { 50 50 include_once($FileName); 51 51 $ClassName = 'LocaleText'.$Language; … … 59 59 // Search for php files 60 60 $FileList = scandir($Path); 61 foreach ($FileList as $FileName)61 foreach ($FileList as $FileName) 62 62 { 63 63 $FullName = $Path.'/'.$FileName; 64 if (($FileName == '.') or ($FileName == '..')) ; // Skip virtual items65 else if (substr($FileName, 0, 1) == '.') ; // Skip Linux hidden files66 else if (is_dir($FullName)) $this->AnalyzeCode($FullName);67 else if (file_exists($FullName))68 { 69 if (substr($FullName, -4) == '.php')64 if (($FileName == '.') or ($FileName == '..')) ; // Skip virtual items 65 else if (substr($FileName, 0, 1) == '.') ; // Skip Linux hidden files 66 else if (is_dir($FullName)) $this->AnalyzeCode($FullName); 67 else if (file_exists($FullName)) 68 { 69 if (substr($FullName, -4) == '.php') 70 70 { 71 71 $Content = file_get_contents($FullName); 72 72 // Search occurence of T() function 73 while (strpos($Content, 'T(') !== false)73 while (strpos($Content, 'T(') !== false) 74 74 { 75 75 $Previous = strtolower(substr($Content, strpos($Content, 'T(') - 1, 1)); … … 77 77 $Ord = ord($Previous); 78 78 //echo($Ord.','); 79 if (!(($Ord >= ord('a')) and ($Ord <= ord('z'))))79 if (!(($Ord >= ord('a')) and ($Ord <= ord('z')))) 80 80 { 81 81 // Do for non-alpha previous character 82 82 $Original = substr($Content, 0, strpos($Content, ')')); 83 83 $Original2 = ''; 84 if ((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'"))84 if ((substr($Original, 0, 1) == "'") and (substr($Original, -1, 1) == "'")) 85 85 $Original2 = substr($Original, 1, -1); 86 if ((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"'))86 if ((substr($Original, 0, 1) == '"') and (substr($Original, -1, 1) == '"')) 87 87 $Original2 = substr($Original, 1, -1); 88 if ($Original2 != '')88 if ($Original2 != '') 89 89 { 90 if (!array_key_exists($Original2, $this->Texts->Data))90 if (!array_key_exists($Original2, $this->Texts->Data)) 91 91 $this->Texts->Data[$Original2] = ''; 92 92 } … … 109 109 ' $this->Title = \''.$this->Texts->Title.'\';'."\n". 110 110 ' $this->Data = array('."\n"; 111 foreach ($this->Texts->Data as $Index => $Item)111 foreach ($this->Texts->Data as $Index => $Item) 112 112 { 113 113 $Content .= " '".$Index."' => '".$Item."',\n"; … … 122 122 { 123 123 $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode)); 124 if ($DbResult->num_rows > 0)124 if ($DbResult->num_rows > 0) 125 125 { 126 126 $Language = $DbResult->fetch_assoc(); 127 127 $this->Texts->Data = array(); 128 128 $DbResult = $Database->select('Locale', '`Original`, `Translated`', '`Language`='.$Language['Id']); 129 while ($DbRow = $DbResult->fetch_assoc())129 while ($DbRow = $DbResult->fetch_assoc()) 130 130 $this->Texts->Data[$DbRow['Original']] = $DbRow['Translated']; 131 131 } … … 135 135 { 136 136 $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode)); 137 if ($DbResult->num_rows > 0)137 if ($DbResult->num_rows > 0) 138 138 { 139 139 $Language = $DbResult->fetch_assoc(); 140 140 $Database->delete('Locale', '`Language`='.$Language['Id']); 141 foreach ($this->Texts->Data as $Index => $Item)141 foreach ($this->Texts->Data as $Index => $Item) 142 142 $Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '. 143 143 'VALUES('.$Language['Id'].','.$Database->quote($Index).','.$Database->quote($Item).')'); … … 148 148 { 149 149 $DbResult = $Database->select('Language', '*', '`Code`='.$Database->quote($LangCode)); 150 if ($DbResult->num_rows > 0)150 if ($DbResult->num_rows > 0) 151 151 { 152 152 $Language = $DbResult->fetch_assoc(); 153 foreach ($this->Texts->Data as $Index => $Item)153 foreach ($this->Texts->Data as $Index => $Item) 154 154 { 155 155 $DbResult = $Database->select('Locale', '*', '(`Original` ='.$Database->quote($Index). 156 156 ') AND (`Language`='.($Language['Id']).')'); 157 if ($DbResult->num_rows > 0)157 if ($DbResult->num_rows > 0) 158 158 $Database->update('Locale', '(`Language`='.($Language['Id']).') AND '. 159 159 '(`Original` ='.$Database->quote($Index).')', array('Translated' => $Item)); … … 188 188 $this->Available = array(); 189 189 $FileList = scandir($this->Dir); 190 foreach ($FileList as $FileName)191 { 192 if (substr($FileName, -4) == '.php')190 foreach ($FileList as $FileName) 191 { 192 if (substr($FileName, -4) == '.php') 193 193 { 194 194 $Code = substr($FileName, 0, -4); … … 206 206 $Locale->AnalyzeCode($Directory); 207 207 $FileList = scandir($this->Dir); 208 foreach ($FileList as $FileName)209 { 210 if (substr($FileName, -4) == '.php')208 foreach ($FileList as $FileName) 209 { 210 if (substr($FileName, -4) == '.php') 211 211 { 212 212 $FileLocale = new LocaleFile($this->System); … … 215 215 216 216 // Add new 217 foreach ($Locale->Texts->Data as $Index => $Item)218 if (!array_key_exists($Index, $FileLocale->Texts->Data))217 foreach ($Locale->Texts->Data as $Index => $Item) 218 if (!array_key_exists($Index, $FileLocale->Texts->Data)) 219 219 $FileLocale->Texts->Data[$Index] = $Item; 220 220 // Remove old 221 foreach ($FileLocale->Texts->Data as $Index => $Item)222 if (!array_key_exists($Index, $Locale->Texts->Data))221 foreach ($FileLocale->Texts->Data as $Index => $Item) 222 if (!array_key_exists($Index, $Locale->Texts->Data)) 223 223 unset($FileLocale->Texts->Data[$Index]); 224 224 $FileLocale->UpdateToDatabase($this->System->Database, $FileLocale->Texts->Code); … … 232 232 function LoadLocale($Code) 233 233 { 234 if (array_key_exists($Code, $this->Available))234 if (array_key_exists($Code, $this->Available)) 235 235 { 236 236 $this->CurrentLocale->Dir = $this->Dir; … … 245 245 global $GlobalLocaleManager; 246 246 247 if (isset($GlobalLocaleManager)) return($GlobalLocaleManager->CurrentLocale->Texts->Translate($Text, $Group));248 else return ($Text);249 } 247 if (isset($GlobalLocaleManager)) return $GlobalLocaleManager->CurrentLocale->Texts->Translate($Text, $Group); 248 else return $Text; 249 } -
trunk/Packages/Common/Mail.php
r69 r92 69 69 function Organization($org) 70 70 { 71 if (trim($org != '')) $this->xheaders['Organization'] = $org;71 if (trim($org != '')) $this->xheaders['Organization'] = $org; 72 72 } 73 73 74 74 function Priority($Priority) 75 75 { 76 if (!intval($Priority)) return(false);77 78 if (!isset($this->priorities[$Priority - 1])) return(false);76 if (!intval($Priority)) return false; 77 78 if (!isset($this->priorities[$Priority - 1])) return false; 79 79 80 80 $this->xheaders['X-Priority'] = $this->priorities[$Priority - 1]; 81 return (true);81 return true; 82 82 } 83 83 … … 96 96 function Send() 97 97 { 98 if (count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body'));98 if (count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body')); 99 99 100 100 $Body = $this->BuildAttachment($this->BuildBody()); … … 103 103 $this->Headers['CC'] = ''; 104 104 $this->Headers['BCC'] = ''; 105 foreach ($this->Recipients as $Index => $Recipient)106 { 107 if ($Recipient['Type'] == 'SendCombined')108 { 109 if ($Index > 0) $To .= ', ';105 foreach ($this->Recipients as $Index => $Recipient) 106 { 107 if ($Recipient['Type'] == 'SendCombined') 108 { 109 if ($Index > 0) $To .= ', '; 110 110 $To .= $Recipient['Address']; 111 111 } else 112 if ($Recipient['Type'] == 'Send')113 { 114 if ($Index > 0) $To .= ', ';112 if ($Recipient['Type'] == 'Send') 113 { 114 if ($Index > 0) $To .= ', '; 115 115 $To .= $Recipient['Name'].' <'.$Recipient['Address'].'>'; 116 116 } else 117 if ($Recipient['Type'] == 'Copy')118 { 119 if ($Index > 0) $this->Headers['CC'] .= ', ';117 if ($Recipient['Type'] == 'Copy') 118 { 119 if ($Index > 0) $this->Headers['CC'] .= ', '; 120 120 $this->Headers['CC'] .= $Recipient['Name'].' <'.$To['Address'].'>'; 121 121 } else 122 if ($Recipient['Type'] == 'HiddenCopy')123 { 124 if ($Index > 0) $this->Headers['BCC'] .= ', ';122 if ($Recipient['Type'] == 'HiddenCopy') 123 { 124 if ($Index > 0) $this->Headers['BCC'] .= ', '; 125 125 $this->Headers['BCC'] .= $Recipient['Name'].' <'.$To['Address'].'>'; 126 126 } 127 127 } 128 if ($To == '') throw new Exception(T('Mail message need at least one recipient address'));128 if ($To == '') throw new Exception(T('Mail message need at least one recipient address')); 129 129 130 130 $this->Headers['Mime-Version'] = '1.0'; 131 131 132 if ($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent;133 if ($this->ReplyTo != '') $this->Headers['Reply-To'] = $this->ReplyTo;134 if ($this->From != '') $this->Headers['From'] = $this->From;132 if ($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent; 133 if ($this->ReplyTo != '') $this->Headers['Reply-To'] = $this->ReplyTo; 134 if ($this->From != '') $this->Headers['From'] = $this->From; 135 135 136 136 $Headers = ''; 137 foreach ($this->Headers as $Header => $Value)138 { 139 if (($Header != 'Subject') and ($Value != '')) $Headers .= $Header.': '.$Value."\n";137 foreach ($this->Headers as $Header => $Value) 138 { 139 if (($Header != 'Subject') and ($Value != '')) $Headers .= $Header.': '.$Value."\n"; 140 140 } 141 141 142 142 $this->Subject = strtr($this->Subject, "\r\n", ' '); 143 143 144 if ($this->Subject == '') throw new Exception(T('Mail message missing Subject'));144 if ($this->Subject == '') throw new Exception(T('Mail message missing Subject')); 145 145 146 146 147 147 $res = mail($To, $this->Subject, $Body, $Headers); 148 return ($res);148 return $res; 149 149 } 150 150 151 151 function ValidEmail($Address) 152 152 { 153 if (ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1];154 if (ereg("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))155 return (true);156 else return (false);153 if (ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1]; 154 if (ereg("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address)) 155 return true; 156 else return false; 157 157 } 158 158 159 159 function CheckAdresses($Addresses) 160 160 { 161 foreach ($Addresses as $Address)162 { 163 if (!$this->ValidEmail($Address))161 foreach ($Addresses as $Address) 162 { 163 if (!$this->ValidEmail($Address)) 164 164 throw new Exception(sprintf(T('Mail message invalid address %s'), $Address)); 165 165 } … … 168 168 private function ContentEncoding($Charset) 169 169 { 170 if ($Charset != CHARSET_ASCII) return('8bit');171 else return ('7bit');170 if ($Charset != CHARSET_ASCII) return '8bit'; 171 else return '7bit'; 172 172 } 173 173 174 174 private function BuildAttachment($Body) 175 175 { 176 if (count($this->Attachments) > 0)176 if (count($this->Attachments) > 0) 177 177 { 178 178 $this->Headers['Content-Type'] = "multipart/mixed;\n boundary=\"PHP-mixed-".$this->Boundary."\""; … … 181 181 $Result .= $Body; 182 182 183 foreach ($this->Attachments as $Attachment)183 foreach ($this->Attachments as $Attachment) 184 184 { 185 185 $FileName = $Attachment['FileName']; … … 187 187 $ContentType = $Attachment['FileType']; 188 188 $Disposition = $Attachment['Disposition']; 189 if ($Attachment['Type'] == 'File')189 if ($Attachment['Type'] == 'File') 190 190 { 191 if (!file_exists($FileName))191 if (!file_exists($FileName)) 192 192 throw new Exception(sprintf(T('Mail message attached file %s can\'t be found'), $FileName)); 193 193 $Data = file_get_contents($FileName); 194 194 } else 195 if ($Attachment['Type'] == 'Data') $Data = $Attachment['Data'];195 if ($Attachment['Type'] == 'Data') $Data = $Attachment['Data']; 196 196 else $Data = ''; 197 197 … … 203 203 } 204 204 } else $Result = $Body; 205 return ($Result);205 return $Result; 206 206 } 207 207 … … 209 209 { 210 210 $Result = ''; 211 if (count($this->Bodies) > 1)211 if (count($this->Bodies) > 1) 212 212 { 213 213 $this->Headers['Content-Type'] = 'multipart/alternative; boundary="PHP-alt-'.$this->Boundary.'"'; … … 221 221 222 222 223 foreach ($this->Bodies as $Body)224 { 225 if (count($this->Bodies) > 1) $Result .= "\n\n".'--PHP-alt-'.$this->Boundary."\n";223 foreach ($this->Bodies as $Body) 224 { 225 if (count($this->Bodies) > 1) $Result .= "\n\n".'--PHP-alt-'.$this->Boundary."\n"; 226 226 $Result .= 'Content-Type: '.$Body['Type'].'; charset='.$Body['Charset']. 227 227 "\nContent-Transfer-Encoding: ".$this->ContentEncoding($Body['Charset'])."\n\n".$Body['Content']."\n"; 228 228 } 229 return ($Result);229 return $Result; 230 230 } 231 231 } -
trunk/Packages/Common/NetworkAddress.php
r77 r92 14 14 function GetNetMask() 15 15 { 16 return (0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1));16 return 0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1); 17 17 } 18 18 19 19 function AddressToString() 20 20 { 21 return (implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));21 return implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))); 22 22 } 23 23 … … 37 37 $To->Address = $From->Address + $HostMask; 38 38 $To->Prefix = 32; 39 return (array('From' => $From, 'To' => $To));39 return array('From' => $From, 'To' => $To); 40 40 } 41 41 … … 43 43 { 44 44 $this->Prefix = $NewPrefix; 45 if ($this->Prefix > 32) $this->Prefix = 32;46 if ($this->Prefix < 0) $this->Prefix = 0;45 if ($this->Prefix > 32) $this->Prefix = 32; 46 if ($this->Prefix < 0) $this->Prefix = 0; 47 47 $this->Address = $this->Address & $this->GetNetMask(); 48 48 } … … 51 51 { 52 52 $UpperNetmask = $this->GetNetMask(); 53 if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;53 if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true; 54 54 else $Result = false; 55 55 //echo($Address->AddressToString().'/'.$Address->Prefix.' in '.$this->AddressToString().'/'.$this->Prefix.' '.$Result."\n"); 56 return ($Result);56 return $Result; 57 57 } 58 58 } … … 71 71 function AddressToString() 72 72 { 73 return (inet_ntop($this->Address));73 return inet_ntop($this->Address); 74 74 } 75 75 … … 83 83 $Result = array(); 84 84 $Data = array_reverse(unpack('C*', $this->Address)); 85 foreach ($Data as $Item)85 foreach ($Data as $Item) 86 86 { 87 87 … … 89 89 $Result[] = dechex(($Item >> 4) & 15); 90 90 } 91 return ($Result);91 return $Result; 92 92 } 93 93 -
trunk/Packages/Common/Page.php
r69 r92 17 17 function Show() 18 18 { 19 return ('');19 return ''; 20 20 } 21 21 … … 23 23 { 24 24 $Output = $this->Show(); 25 return ($Output);25 return $Output; 26 26 } 27 27 28 28 function SystemMessage($Title, $Text) 29 29 { 30 return (call_user_func_array($this->OnSystemMessage, array($Title, $Text)));30 return call_user_func_array($this->OnSystemMessage, array($Title, $Text)); 31 31 } 32 32 } -
trunk/Packages/Common/PrefixMultiplier.php
r52 r92 74 74 function TruncateDigits($Value, $Digits = 4) 75 75 { 76 for ($II = 2; $II > -6; $II--)76 for ($II = 2; $II > -6; $II--) 77 77 { 78 if ($Value >= pow(10, $II))78 if ($Value >= pow(10, $II)) 79 79 { 80 if ($Digits < ($II + 1)) $RealDigits = $II + 1;80 if ($Digits < ($II + 1)) $RealDigits = $II + 1; 81 81 else $RealDigits = $Digits; 82 82 $Value = round($Value / pow(10, $II - $RealDigits + 1)) * pow(10, $II - $RealDigits + 1); … … 84 84 } 85 85 } 86 return ($Value);86 return $Value; 87 87 } 88 88 … … 93 93 $Negative = ($Value < 0); 94 94 $Value = abs($Value); 95 if (($Unit == '') and ($PrefixType != 'Time'))96 return ($this->TruncateDigits($Value, $Digits));95 if (($Unit == '') and ($PrefixType != 'Time')) 96 return $this->TruncateDigits($Value, $Digits); 97 97 98 98 $I = $PrefixMultipliers[$PrefixType]['BaseIndex']; 99 if ($Value == 0) return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);99 if ($Value == 0) return $Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit; 100 100 101 if ($Value > 1)101 if ($Value > 1) 102 102 { 103 while ((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1))103 while ((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1)) 104 104 $I = $I + 1; 105 105 } else 106 if ($Value < 1)106 if ($Value < 1) 107 107 { 108 while ((($I - 1) >= 0) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]) < 1))108 while ((($I - 1) >= 0) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]) < 1)) 109 109 $I = $I - 1; 110 110 } … … 113 113 // Truncate digits count 114 114 $Value = $this->TruncateDigits($Value, $Digits); 115 if ($Negative) $Value = -$Value;116 return ($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit);115 if ($Negative) $Value = -$Value; 116 return $Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit; 117 117 } 118 118 } -
trunk/Packages/Common/RSS.php
r77 r92 28 28 " <pubDate>".date('r')."</pubDate>\n". 29 29 " <ttl>20</ttl>\n"; 30 foreach ($this->Items as $Item)30 foreach ($this->Items as $Item) 31 31 { 32 32 $Result .= " <item>\n". … … 39 39 $Result .= " </channel>\n". 40 40 "</rss>"; 41 return ($Result);41 return $Result; 42 42 } 43 43 } -
trunk/Packages/Common/Setup.php
r70 r92 29 29 '<input type="submit" name="login" value="'.T('Login').'"/>'. 30 30 '</form>'; 31 return ($Output);31 return $Output; 32 32 } 33 33 … … 37 37 38 38 $Output .= 'Je připojení k databázi: '.$this->YesNo[$this->UpdateManager->Database->Connected()].'<br/>'; 39 if ($this->UpdateManager->Database->Connected())39 if ($this->UpdateManager->Database->Connected()) 40 40 { 41 41 $Output .= 'Je instalováno: '.$this->YesNo[$this->UpdateManager->IsInstalled()].'<br/>'; 42 if ($this->UpdateManager->IsInstalled())42 if ($this->UpdateManager->IsInstalled()) 43 43 $Output .= 'Je aktuální: '.$this->YesNo[$this->UpdateManager->IsUpToDate()].'<br/>'. 44 44 'Verze databáze: '.$this->UpdateManager->GetDbVersion().'<br/>'; 45 45 $Output .= 'Verze databáze kódu: '.$this->UpdateManager->Revision.'<br/>'; 46 if ($this->UpdateManager->IsInstalled())47 { 48 if (!$this->UpdateManager->IsUpToDate())46 if ($this->UpdateManager->IsInstalled()) 47 { 48 if (!$this->UpdateManager->IsUpToDate()) 49 49 $Output .= '<a href="?action=upgrade">'.T('Upgrade').'</a> '; 50 50 $Output .= '<a href="?action=insert_sample_data">Vložit vzorová data</a> '; … … 59 59 $Output .= '<a href="'.$this->System->Link('/').'">'.T('Go to main page').'</a> '; 60 60 $Output .= ''; 61 return ($Output);61 return $Output; 62 62 } 63 63 … … 73 73 74 74 $Output = ''; 75 if (isset($this->Config))76 { 77 if (!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = '';78 if (array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword'];79 if (sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword'])75 if (isset($this->Config)) 76 { 77 if (!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = ''; 78 if (array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword']; 79 if (sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword']) 80 80 { 81 81 $Output .= $this->LoginPanel(); 82 82 } else 83 83 { 84 if (array_key_exists('action', $_GET)) $Action = $_GET['action'];84 if (array_key_exists('action', $_GET)) $Action = $_GET['action']; 85 85 else $Action = ''; 86 if ($Action == 'logout')86 if ($Action == 'logout') 87 87 { 88 88 $_SESSION['SystemPassword'] = ''; … … 90 90 $Output .= $this->LoginPanel(); 91 91 } else 92 if ($Action == 'models')92 if ($Action == 'models') 93 93 { 94 94 $this->System->FormManager->UpdateSQLMeta(); 95 95 } else 96 if ($Action == 'upgrade')96 if ($Action == 'upgrade') 97 97 { 98 98 $Output .= '<h3>Povýšení</h3>'; … … 105 105 $Output .= $this->ControlPanel(); 106 106 } else 107 if ($Action == 'install')107 if ($Action == 'install') 108 108 { 109 109 $Output .= '<h3>Instalace</h3>'; … … 114 114 $Output .= $this->ControlPanel(); 115 115 } else 116 if ($Action == 'uninstall')116 if ($Action == 'uninstall') 117 117 { 118 118 $Output .= '<h3>Odinstalace</h3>'; … … 120 120 $Output .= $this->ControlPanel(); 121 121 } else 122 if ($Action == 'reload_modules')122 if ($Action == 'reload_modules') 123 123 { 124 124 $Output .= '<h3>Znovunačtení seznamu modulů</h3>'; … … 127 127 $Output .= $this->ControlPanel(); 128 128 } else 129 if ($Action == 'insert_sample_data')129 if ($Action == 'insert_sample_data') 130 130 { 131 131 $Output .= '<h3>Vložení vzorových dat</h3>'; … … 133 133 $Output .= $this->ControlPanel(); 134 134 } else 135 if ($Action == 'modules')135 if ($Action == 'modules') 136 136 { 137 137 $Output .= $this->ShowModules(); 138 138 } else 139 if ($Action == 'configure_save')139 if ($Action == 'configure_save') 140 140 { 141 141 $Output .= $this->ConfigSave($this->Config); 142 142 $Output .= $this->ControlPanel(); 143 143 } else 144 if ($Action == 'configure')144 if ($Action == 'configure') 145 145 { 146 146 $Output .= $this->PrepareConfig($this->Config); … … 152 152 } else 153 153 { 154 if (array_key_exists('configure_save', $_POST))154 if (array_key_exists('configure_save', $_POST)) 155 155 { 156 156 $Output .= $this->ConfigSave(array()); … … 160 160 } 161 161 } 162 return ($Output);162 return $Output; 163 163 } 164 164 … … 166 166 { 167 167 $Output = ''; 168 if (array_key_exists('op', $_GET)) $Operation = $_GET['op'];168 if (array_key_exists('op', $_GET)) $Operation = $_GET['op']; 169 169 else $Operation = ''; 170 if ($Operation == 'install')170 if ($Operation == 'install') 171 171 { 172 172 $this->System->ModuleManager->Modules[$_GET['name']]->Install(); … … 174 174 $Output .= 'Modul '.$_GET['name'].' instalován<br/>'; 175 175 } else 176 if ($Operation == 'uninstall')176 if ($Operation == 'uninstall') 177 177 { 178 178 $this->System->ModuleManager->Modules[$_GET['name']]->Uninstall(); … … 180 180 $Output .= 'Modul '.$_GET['name'].' odinstalován<br/>'; 181 181 } else 182 if ($Operation == 'enable')182 if ($Operation == 'enable') 183 183 { 184 184 $this->System->ModuleManager->Modules[$_GET['name']]->Enable(); … … 186 186 $Output .= 'Modul '.$_GET['name'].' povolen<br/>'; 187 187 } else 188 if ($Operation == 'disable')188 if ($Operation == 'disable') 189 189 { 190 190 $this->System->ModuleManager->Modules[$_GET['name']]->Disable(); … … 192 192 $Output .= 'Modul '.$_GET['name'].' zakázán<br/>'; 193 193 } else 194 if ($Operation == 'upgrade')194 if ($Operation == 'upgrade') 195 195 { 196 196 $this->System->ModuleManager->Modules[$_GET['name']]->Upgrade(); … … 200 200 $Output .= '<h3>Správa modulů</h3>'; 201 201 $Output .= $this->ShowList(); 202 return ($Output);202 return $Output; 203 203 } 204 204 … … 221 221 array('Name' => '', 'Title' => 'Akce'), 222 222 )); 223 foreach ($this->System->ModuleManager->Modules as $Module)224 { 225 if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);223 foreach ($this->System->ModuleManager->Modules as $Module) 224 { 225 if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies); 226 226 else $Dependencies = ' '; 227 227 $Actions = ''; 228 if ($Module->Installed == true)228 if ($Module->Installed == true) 229 229 { 230 230 $Actions .= ' <a href="?action=modules&op=uninstall&name='.$Module->Name.'">Odinstalovat</a>'; 231 if ($Module->Enabled == true) $Actions .= ' <a href="?action=modules&op=disable&name='.$Module->Name.'">Zakázat</a>';231 if ($Module->Enabled == true) $Actions .= ' <a href="?action=modules&op=disable&name='.$Module->Name.'">Zakázat</a>'; 232 232 else $Actions .= ' <a href="?action=modules&op=enable&name='.$Module->Name.'">Povolit</a>'; 233 if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&op=upgrade&name='.$Module->Name.'">Povýšit</a>';233 if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&op=upgrade&name='.$Module->Name.'">Povýšit</a>'; 234 234 } else $Actions .= ' <a href="?action=modules&op=install&name='.$Module->Name.'">Instalovat</a>'; 235 235 … … 244 244 $Output .= $Pageing->Show(); 245 245 //$Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>'; 246 return ($Output);246 return $Output; 247 247 } 248 248 … … 250 250 { 251 251 $Output = ''; 252 if (!file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir))252 if (!file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir)) 253 253 $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože složka "'.$this->ConfigDir.'" není povolená pro zápis!'; 254 if (file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir.'/Config.php'))254 if (file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir.'/Config.php')) 255 255 $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože soubor "'.$this->ConfigDir.'/Config.php" není povolen pro zápis!'; 256 256 $Output .= '<h3>Nastavení systému</h3>'. 257 257 '<form action="?action=configure_save" method="post">'. 258 258 '<table>'; 259 foreach ($this->ConfigDefinition as $Def)259 foreach ($this->ConfigDefinition as $Def) 260 260 { 261 261 $PathParts = explode('/', $Def['Name']); 262 262 $TempConfig = &$Config; 263 foreach ($PathParts as $Part)264 if (array_key_exists($Part, $TempConfig))263 foreach ($PathParts as $Part) 264 if (array_key_exists($Part, $TempConfig)) 265 265 { 266 266 $TempConfig = &$TempConfig[$Part]; 267 267 } 268 if (!is_array($TempConfig)) $Value = $TempConfig;268 if (!is_array($TempConfig)) $Value = $TempConfig; 269 269 else $Value = $Def['Default']; 270 270 $Output .= '<tr><td>'.$Def['Title'].'</td><td>'; 271 if ($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';272 if ($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';273 if ($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';274 if ($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';275 if ($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';276 if ($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';277 if ($Def['Type'] == 'Array') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.implode(',', $Value).'"/>';271 if ($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 272 if ($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>'; 273 if ($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>'; 274 if ($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 275 if ($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 276 if ($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 277 if ($Def['Type'] == 'Array') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.implode(',', $Value).'"/>'; 278 278 } 279 279 $Output .= '</td></tr>'. … … 281 281 '</table>'. 282 282 '</form>'; 283 return ($Output);283 return $Output; 284 284 } 285 285 … … 287 287 { 288 288 $Config = $DefaultConfig; 289 foreach ($this->ConfigDefinition as $Def)289 foreach ($this->ConfigDefinition as $Def) 290 290 { 291 291 $Value = null; 292 if ($Def['Type'] == 'String') if(array_key_exists($Def['Name'], $_POST))292 if ($Def['Type'] == 'String') if (array_key_exists($Def['Name'], $_POST)) 293 293 $Value = $_POST[$Def['Name']]; 294 if ($Def['Type'] == 'Password') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))294 if ($Def['Type'] == 'Password') if (array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != '')) 295 295 $Value = $_POST[$Def['Name']]; 296 if ($Def['Type'] == 'PasswordEncoded') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))296 if ($Def['Type'] == 'PasswordEncoded') if (array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != '')) 297 297 $Value = sha1($_POST[$Def['Name']]); 298 if ($Def['Type'] == 'Integer') if(array_key_exists($Def['Name'], $_POST))298 if ($Def['Type'] == 'Integer') if (array_key_exists($Def['Name'], $_POST)) 299 299 $Value = $_POST[$Def['Name']]; 300 if ($Def['Type'] == 'Float') if(array_key_exists($Def['Name'], $_POST))300 if ($Def['Type'] == 'Float') if (array_key_exists($Def['Name'], $_POST)) 301 301 $Value = $_POST[$Def['Name']]; 302 if ($Def['Type'] == 'Boolean') if(array_key_exists($Def['Name'], $_POST))302 if ($Def['Type'] == 'Boolean') if (array_key_exists($Def['Name'], $_POST)) 303 303 $Value = $_POST[$Def['Name']]; 304 if ($Def['Type'] == 'Array') if(array_key_exists($Def['Name'], $_POST))304 if ($Def['Type'] == 'Array') if (array_key_exists($Def['Name'], $_POST)) 305 305 $Value = explode(',', $_POST[$Def['Name']]); 306 if (!is_null($Value))306 if (!is_null($Value)) 307 307 { 308 308 $PathParts = explode('/', $Def['Name']); 309 309 $TempConfig = &$Config; 310 foreach ($PathParts as $Part)310 foreach ($PathParts as $Part) 311 311 { 312 312 $TempConfig = &$TempConfig[$Part]; 313 313 } 314 if (!is_array($TempConfig)) $TempConfig = $Value;314 if (!is_array($TempConfig)) $TempConfig = $Value; 315 315 else $Value = $Def['Default']; 316 316 } … … 319 319 file_put_contents($this->ConfigDir.'/Config.php', $ConfigText); 320 320 $Output = 'Konfigurace nastavena<br/>'; 321 return ($Output);321 return $Output; 322 322 } 323 323 … … 327 327 "\$IsDeveloper = array_key_exists('REMOTE_ADDR', \$_SERVER) and in_array(\$_SERVER['REMOTE_ADDR'], array('127.0.0.1'));\n\n"; 328 328 329 foreach ($this->ConfigDefinition as $Def)329 foreach ($this->ConfigDefinition as $Def) 330 330 { 331 331 $PathParts = explode('/', $Def['Name']); 332 332 $Output .= "\$Config"; 333 foreach ($PathParts as $Part)333 foreach ($PathParts as $Part) 334 334 $Output .= "['".$Part."']"; 335 335 $TempConfig = &$Config; 336 336 $Output .= ' = '; 337 foreach ($PathParts as $Part)338 if (array_key_exists($Part, $TempConfig))337 foreach ($PathParts as $Part) 338 if (array_key_exists($Part, $TempConfig)) 339 339 { 340 340 $TempConfig = &$TempConfig[$Part]; 341 341 } 342 if (!is_array($TempConfig)) $Value = $TempConfig;342 if (!is_array($TempConfig)) $Value = $TempConfig; 343 343 else $Value = $Def['Default']; 344 if ($Def['Type'] == 'Array')344 if ($Def['Type'] == 'Array') 345 345 { 346 346 $Output .= ' array('; 347 foreach ($Value as $Index => $Item)347 foreach ($Value as $Index => $Item) 348 348 $Output .= '\''.$Item.'\', '; 349 349 $Output .= ')'; … … 353 353 } 354 354 $Output .= "\n\n"; 355 return ($Output);355 return $Output; 356 356 } 357 357 } … … 362 362 { 363 363 $Output = ''; 364 if (!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>';364 if (!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>'; 365 365 else { 366 if (!$this->System->Setup->UpdateManager->IsInstalled())366 if (!$this->System->Setup->UpdateManager->IsInstalled()) 367 367 $Output .= T('System requires database initialization').'<br>'; 368 368 else 369 if (!$this->System->Setup->UpdateManager->IsUpToDate())369 if (!$this->System->Setup->UpdateManager->IsUpToDate()) 370 370 $Output .= T('System requires database upgrade').'<br>'; 371 371 } 372 372 $Output .= sprintf(T('Front page was not configured. Continue to %s'), '<a href="'.$this->System->Link('/setup/').'">'.T('setup').'</a>'); 373 return ($Output);373 return $Output; 374 374 } 375 375 } … … 402 402 function CheckState() 403 403 { 404 return($this->Database->Connected() and $this->UpdateManager->IsInstalled() and405 $this->UpdateManager->IsUpToDate() );404 $this->Database->Connected() and $this->UpdateManager->IsInstalled() and 405 $this->UpdateManager->IsUpToDate(); 406 406 } 407 407 … … 435 435 { 436 436 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->UpdateManager->VersionTable.'"'); 437 return ($DbResult->num_rows > 0);437 return $DbResult->num_rows > 0; 438 438 } 439 439 … … 443 443 $this->UpdateManager->Trace = $Updates->Get(); 444 444 $Output = $this->UpdateManager->Upgrade(); 445 return ($Output);445 return $Output; 446 446 } 447 447 } -
trunk/Packages/Common/Table.php
r90 r92 7 7 function Show() 8 8 { 9 return ('');9 return ''; 10 10 } 11 11 } … … 15 15 function GetCell($Y, $X) 16 16 { 17 return ('');17 return ''; 18 18 } 19 19 … … 28 28 function RowsCount() 29 29 { 30 return (0);30 return 0; 31 31 } 32 32 } … … 38 38 function GetCell($Y, $X) 39 39 { 40 return ($this->Cells[$Y][$X]);40 return $this->Cells[$Y][$X]; 41 41 } 42 42 43 43 function RowsCount() 44 44 { 45 return (count($this->Cells));45 return count($this->Cells); 46 46 } 47 47 } … … 55 55 function GetCell($Y, $X) 56 56 { 57 return ($this->Cells[$Y][$X]);57 return $this->Cells[$Y][$X]; 58 58 } 59 59 … … 62 62 $this->Cells = array(); 63 63 $DbResult = $this->Database->query($this->Query); 64 while ($DbRow = $DbResult->fetch_row())64 while ($DbRow = $DbResult->fetch_row()) 65 65 { 66 66 $this->Cells[] = $DbRow; … … 75 75 function RowsCount() 76 76 { 77 return (count($this->Cells));77 return count($this->Cells); 78 78 } 79 79 } … … 114 114 { 115 115 $this->Columns = array(); 116 foreach ($Columns as $Column)116 foreach ($Columns as $Column) 117 117 { 118 118 $NewCol = new TableColumn(); … … 121 121 $this->Columns[] = $NewCol; 122 122 } 123 if (count($this->Columns) > 0)123 if (count($this->Columns) > 0) 124 124 $this->DefaultColumn = $this->Columns[0]->Name; 125 125 else $this->DefaultColumn = ''; … … 131 131 $Output .= $this->GetOrderHeader(); 132 132 $this->Table->BeginRead(); 133 for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++)133 for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++) 134 134 { 135 135 $Output .= '<tr>'; 136 136 137 for ($X = 0; $X < count($this->Columns); $X++)137 for ($X = 0; $X < count($this->Columns); $X++) 138 138 { 139 139 $Cell = $this->Table->GetCell($Y, $X); 140 if ($Cell == '') $Output .= '<td> </td>';140 if ($Cell == '') $Output .= '<td> </td>'; 141 141 else $Output .= '<td>'.$Cell.'</td>'; 142 142 } … … 145 145 $this->Table->EndRead(); 146 146 $Output .= '</table>'; 147 return ($Output);147 return $Output; 148 148 } 149 149 150 150 function GetOrderHeader() 151 151 { 152 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];153 if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];154 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn;155 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder;152 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 153 if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir']; 154 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn; 155 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder; 156 156 157 157 // Check OrderCol 158 158 $Found = false; 159 foreach ($this->Columns as $Column)159 foreach ($this->Columns as $Column) 160 160 { 161 if ($Column->Name == $_SESSION['OrderCol'])161 if ($Column->Name == $_SESSION['OrderCol']) 162 162 { 163 163 $Found = true; … … 165 165 } 166 166 } 167 if ($Found == false)167 if ($Found == false) 168 168 { 169 169 $_SESSION['OrderCol'] = $this->DefaultColumn; … … 171 171 } 172 172 // Check OrderDir 173 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1))173 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) 174 174 $_SESSION['OrderDir'] = 0; 175 175 176 176 $Result = ''; 177 177 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 178 foreach ($this->Columns as $Index => $Column)178 foreach ($this->Columns as $Index => $Column) 179 179 { 180 180 $QueryItems['OrderCol'] = $Column->Name; 181 181 $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir']; 182 if ($Column->Name == $_SESSION['OrderCol'])182 if ($Column->Name == $_SESSION['OrderCol']) 183 183 $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.$this->OrderArrowImage[$_SESSION['OrderDir']].'" alt="order arrow">'; 184 184 else $ArrowImage = ''; 185 if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>';185 if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>'; 186 186 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column->Title.$ArrowImage.'</a></th>'; 187 187 } … … 190 190 $this->OrderDirection = $_SESSION['OrderDir']; 191 191 192 return ('<tr>'.$Result.'</tr>');192 return '<tr>'.$Result.'</tr>'; 193 193 } 194 194 } -
trunk/Packages/Common/UTF8.php
r69 r92 529 529 { 530 530 $Result = ''; 531 for ($I = 0; $I < strlen($String); $I++)531 for ($I = 0; $I < strlen($String); $I++) 532 532 { 533 if (ord($String[$I]) < 128) $Result .= $String[$I];534 else if (ord($String[$I]) > 127)533 if (ord($String[$I]) < 128) $Result .= $String[$I]; 534 else if (ord($String[$I]) > 127) 535 535 { 536 536 $Result .= $this->CharTable[$Charset][ord($String[$I])]; 537 537 } 538 538 } 539 return ($Result);539 return $Result; 540 540 } 541 541 … … 544 544 $Result = ''; 545 545 $UTFPrefix = ''; 546 for ($I = 0; $I < strlen($String); $I++)546 for ($I = 0; $I < strlen($String); $I++) 547 547 { 548 if (ord($String{$I}) & 0x80) // UTF control character548 if (ord($String{$I}) & 0x80) // UTF control character 549 549 { 550 if (ord($String{$I}) & 0x40) // First550 if (ord($String{$I}) & 0x40) // First 551 551 { 552 if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));552 if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset])); 553 553 $UTFPrefix = $String{$I}; 554 554 } … … 556 556 } else 557 557 { 558 if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));558 if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset])); 559 559 $UTFPrefix = ''; 560 560 $Result .= $String{$I}; 561 561 } 562 562 } 563 return ($Result);563 return $Result; 564 564 } 565 565 } -
trunk/Packages/Common/Update.php
r90 r92 23 23 $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1'); 24 24 $Version = $DbResult->fetch_assoc(); 25 return ($Version['Revision']);25 return $Version['Revision']; 26 26 } 27 27 … … 29 29 { 30 30 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"'); 31 return ($DbResult->num_rows > 0);31 return $DbResult->num_rows > 0; 32 32 } 33 33 34 34 function IsUpToDate() 35 35 { 36 return ($this->Revision <= $this->GetDbVersion());36 return $this->Revision <= $this->GetDbVersion(); 37 37 } 38 38 … … 41 41 $DbRevision = $this->GetDbVersion(); 42 42 $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>'; 43 while ($this->Revision > $DbRevision)43 while ($this->Revision > $DbRevision) 44 44 { 45 if (!array_key_exists($DbRevision, $this->Trace))45 if (!array_key_exists($DbRevision, $this->Trace)) 46 46 die('Missing upgrade trace for revision '.$DbRevision); 47 47 $TraceItem = $this->Trace[$DbRevision]; … … 56 56 $TraceItem['Revision'].' WHERE `Id`=1'); 57 57 } 58 return ($Output);58 return $Output; 59 59 } 60 60 … … 81 81 echo($Query.';<br/>'); 82 82 flush(); 83 return ($this->Database->query($Query));83 return $this->Database->query($Query); 84 84 } 85 85 } -
trunk/Packages/Common/VarDumper.php
r55 r92 49 49 self::$_depth=$depth; 50 50 self::dumpInternal($var,0); 51 if ($highlight)51 if ($highlight) 52 52 { 53 53 $result=highlight_string("<?php\n".self::$_output,true); … … 60 60 private static function dumpInternal($var,$level) 61 61 { 62 switch (gettype($var))62 switch (gettype($var)) 63 63 { 64 64 case 'boolean': … … 84 84 break; 85 85 case 'array': 86 if (self::$_depth<=$level)86 if (self::$_depth<=$level) 87 87 self::$_output.='array(...)'; 88 else if (empty($var))88 else if (empty($var)) 89 89 self::$_output.='array()'; 90 90 else … … 93 93 $spaces=str_repeat(' ',$level*4); 94 94 self::$_output.="array\n".$spaces.'('; 95 foreach ($keys as $key)95 foreach ($keys as $key) 96 96 { 97 97 self::$_output.="\n".$spaces." [$key] => "; … … 102 102 break; 103 103 case 'object': 104 if (($id=array_search($var,self::$_objects,true))!==false)104 if (($id=array_search($var,self::$_objects,true))!==false) 105 105 self::$_output.=get_class($var).'#'.($id+1).'(...)'; 106 else if (self::$_depth<=$level)106 else if (self::$_depth<=$level) 107 107 self::$_output.=get_class($var).'(...)'; 108 108 else … … 114 114 $spaces=str_repeat(' ',$level*4); 115 115 self::$_output.="$className#$id\n".$spaces.'('; 116 foreach ($keys as $key)116 foreach ($keys as $key) 117 117 { 118 118 $keyDisplay=strtr(trim($key),array("\0"=>':')); -
trunk/Point.php
r63 r92 16 16 { 17 17 $Point = new Point($X, $Y); 18 return ($Point);18 return $Point; 19 19 } 20 20 … … 23 23 { 24 24 $Y = ($P2->Y - $P1->Y) / ($P2->X - $P1->X) * ($X - $P1->X) + $P1->Y; 25 return ($Y);25 return $Y; 26 26 } -
trunk/add.php
r87 r92 12 12 // Try to load single value 13 13 $Time = time(); 14 if (array_key_exists('MeasureId', $_GET) and array_key_exists('Value', $_GET))14 if (array_key_exists('MeasureId', $_GET) and array_key_exists('Value', $_GET)) 15 15 { 16 16 if (array_key_exists('Time', $_GET)) $Time = $_GET['Time'] * 1; … … 39 39 $Measure->Load($MeasureId); 40 40 $HostName = gethostbyaddr($_SERVER['REMOTE_ADDR']); 41 if (($HostName == $Measure->Data['PermissionAdd']) or ($_SERVER['REMOTE_ADDR'] == gethostbyname($Measure->Data['PermissionAdd'])))41 if (($HostName == $Measure->Data['PermissionAdd']) or ($_SERVER['REMOTE_ADDR'] == gethostbyname($Measure->Data['PermissionAdd']))) 42 42 { 43 43 $Measure->AddValue($Value, $Time);
Note:
See TracChangeset
for help on using the changeset viewer.