- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 159 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/DefaultConfig.php
r791 r873 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'), -
trunk/Application/System.php
r858 r873 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__).'/Version.php'); … … 40 40 $this->ConfigManager = new Config(); 41 41 $this->RootURLFolder = $_SERVER['SCRIPT_NAME']; 42 if (substr($this->RootURLFolder, -10, 10) == '/index.php')42 if (substr($this->RootURLFolder, -10, 10) == '/index.php') 43 43 $this->RootURLFolder = substr($this->RootURLFolder, 0, -10); 44 44 $this->CommandLine = array(); … … 48 48 function RegisterPage($Path, $Handler) 49 49 { 50 if (is_array($Path))50 if (is_array($Path)) 51 51 { 52 52 $Page = &$this->Pages; 53 53 $LastKey = array_pop($Path); 54 foreach ($Path as $PathItem)54 foreach ($Path as $PathItem) 55 55 { 56 56 $Page = &$Page[$PathItem]; 57 57 } 58 if (!is_array($Page)) $Page = array('' => $Page);58 if (!is_array($Page)) $Page = array('' => $Page); 59 59 $Page[$LastKey] = $Handler; 60 60 } else $this->Pages[$Path] = $Handler; … … 68 68 function SearchPage($PathItems, $Pages) 69 69 { 70 if (count($PathItems) > 0) $PathItem = $PathItems[0];70 if (count($PathItems) > 0) $PathItem = $PathItems[0]; 71 71 else $PathItem = ''; 72 if (array_key_exists($PathItem, $Pages))73 { 74 if (is_array($Pages[$PathItem]))72 if (array_key_exists($PathItem, $Pages)) 73 { 74 if (is_array($Pages[$PathItem])) 75 75 { 76 76 array_shift($PathItems); 77 return ($this->SearchPage($PathItems, $Pages[$PathItem]));78 } else return ($Pages[$PathItem]);79 } else return ('');77 return ($this->SearchPage($PathItems, $Pages[$PathItem])); 78 } else return ($Pages[$PathItem]); 79 } else return (''); 80 80 } 81 81 82 82 function PageNotFound() 83 83 { 84 return ('Page '.implode('/', $this->PathItems).' not found.');84 return ('Page '.implode('/', $this->PathItems).' not found.'); 85 85 } 86 86 … … 91 91 /* @var $Page Page */ 92 92 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 93 if ($ClassName != '')93 if ($ClassName != '') 94 94 { 95 95 $Page = new $ClassName($this); … … 102 102 function ModulePresent($Name) 103 103 { 104 return (array_key_exists($Name, $this->Modules));104 return (array_key_exists($Name, $this->Modules)); 105 105 } 106 106 … … 112 112 function HumanDate($Time) 113 113 { 114 return (date('j.n.Y', $Time));114 return (date('j.n.Y', $Time)); 115 115 } 116 116 117 117 function Link($Target) 118 118 { 119 return ($this->RootURLFolder.$Target);119 return ($this->RootURLFolder.$Target); 120 120 } 121 121 … … 126 126 'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '. 127 127 'WHERE (`Action`.`Id`='.$Id.')'); 128 if ($DbResult->num_rows > 0)128 if ($DbResult->num_rows > 0) 129 129 { 130 130 $Action = $DbResult->fetch_assoc(); 131 if ($Action['Icon'] == '') $Action['Icon'] = 'clear.png';132 if (substr($Action['URL'], 0, 4) != 'http') $Action['URL'] = $this->Link($Action['URL']);133 if (!defined('NEW_PERMISSION') or $this->User->CheckPermission('System', 'Read', 'Item', $Id))131 if ($Action['Icon'] == '') $Action['Icon'] = 'clear.png'; 132 if (substr($Action['URL'], 0, 4) != 'http') $Action['URL'] = $this->Link($Action['URL']); 133 if (!defined('NEW_PERMISSION') or $this->User->CheckPermission('System', 'Read', 'Item', $Id)) 134 134 $Output .= '<img alt="'.$Action['Title'].'" src="'.$this->Link('/images/favicons/'.$Action['Icon']). 135 135 '" width="16" height="16" /> <a href="'.$Action['URL'].'">'.$Action['Title'].'</a>'; 136 136 } 137 return ($Output);137 return ($Output); 138 138 } 139 139 … … 148 148 149 149 // SQL injection hack protection 150 foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);151 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);152 153 if (isset($_SERVER['REMOTE_ADDR'])) session_start();150 foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item); 151 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); 152 153 if (isset($_SERVER['REMOTE_ADDR'])) session_start(); 154 154 155 155 $ConfigFileName = dirname(dirname(__FILE__)).'/config.php'; 156 if (file_exists($ConfigFileName))156 if (file_exists($ConfigFileName)) 157 157 $this->ConfigManager->LoadFromFile($ConfigFileName); 158 158 //$this->Config = $this->ConfigManager->GetAsArray(); … … 166 166 $this->Database->ShowSQLError = $this->Config['Web']['ShowSQLError']; 167 167 $this->Database->ShowSQLQuery = $this->Config['Web']['ShowSQLQuery']; 168 if (isset($this->Config['Web']['LogSQLQuery']))168 if (isset($this->Config['Web']['LogSQLQuery'])) 169 169 $this->Database->LogSQLQuery = $this->Config['Web']['LogSQLQuery']; 170 170 } catch (Exception $E) { … … 181 181 $this->LinkLocaleExceptions = array('images', 'style', 'files'); 182 182 183 if (isset($this->Config['Web']['RootFolder']))183 if (isset($this->Config['Web']['RootFolder'])) 184 184 $this->RootURLFolder = $this->Config['Web']['RootFolder']; 185 185 $this->FormManager->Root = $this->RootURLFolder; … … 193 193 $this->Setup = new Setup($this); 194 194 $this->Setup->Start(); 195 if ($this->Setup->CheckState())195 if ($this->Setup->CheckState()) 196 196 { 197 197 $this->ModuleManager->Start(); … … 202 202 { 203 203 $this->RunCommon(); 204 if ($this->ShowPage)204 if ($this->ShowPage) 205 205 { 206 206 $this->PathItems = ProcessURL(); 207 207 208 208 // Detect interface locale 209 if (isset($this->Config['Web']['Locale']))209 if (isset($this->Config['Web']['Locale'])) 210 210 $this->LocaleManager->DefaultLangCode = $this->Config['Web']['Locale']; 211 211 $this->LocaleManager->LangCode = $this->LocaleManager->DefaultLangCode; 212 if (count($this->PathItems) > 0)212 if (count($this->PathItems) > 0) 213 213 { 214 214 $NewLangCode = $this->PathItems[0]; 215 if (array_key_exists($NewLangCode, $this->LocaleManager->Available))215 if (array_key_exists($NewLangCode, $this->LocaleManager->Available)) 216 216 { 217 217 array_shift($this->PathItems); … … 219 219 } 220 220 } 221 if (array_key_exists($this->LocaleManager->LangCode, $this->LocaleManager->Available))221 if (array_key_exists($this->LocaleManager->LangCode, $this->LocaleManager->Available)) 222 222 $this->LocaleManager->LoadLocale($this->LocaleManager->LangCode); 223 223 … … 231 231 232 232 $this->RunCommon(); 233 if (count($argv) > 1)234 { 235 if (array_key_exists($argv[1], $this->CommandLine))233 if (count($argv) > 1) 234 { 235 if (array_key_exists($argv[1], $this->CommandLine)) 236 236 { 237 237 $Command = $this->CommandLine[$argv[1]]; … … 282 282 { 283 283 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 284 return ('<h3 align="center">Požadovaná stránka neexistuje.</h3>');284 return ('<h3 align="center">Požadovaná stránka neexistuje.</h3>'); 285 285 } 286 286 } -
trunk/Application/UpdateTrace.php
r870 r873 203 203 $ServiceCategoryHire = $Manager->Database->insert_id; 204 204 $DbResult = $Manager->Execute("SELECT * FROM Member WHERE Hire>0"); 205 while ($Member = $DbResult->fetch_assoc())205 while ($Member = $DbResult->fetch_assoc()) 206 206 { 207 207 $Manager->Execute("INSERT INTO `Service` ( … … 308 308 // Set all string collation to utf8 general 309 309 $DbResult = $Manager->Execute("SHOW TABLES"); 310 while ($DbRow = $DbResult->fetch_row())310 while ($DbRow = $DbResult->fetch_row()) 311 311 { 312 312 $Manager->Execute("ALTER TABLE `".$DbRow[0]."` CONVERT TO CHARACTER SET utf8"); … … 871 871 $ActionId = $Manager->Database->insert_id; 872 872 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Nabídky"'); 873 if ($DbResult->num_rows > 0)873 if ($DbResult->num_rows > 0) 874 874 { 875 875 $DbRow = $DbResult->fetch_assoc(); … … 889 889 // Convert monthly plus payment for consumption to regular service 890 890 $DbResult = $Manager->Execute('SELECT `MonthlyPlus`, `Member` FROM `MemberPayment` WHERE `MonthlyPlus` > 0'); 891 while ($DbRow = $DbResult->fetch_assoc)891 while ($DbRow = $DbResult->fetch_assoc) 892 892 { 893 893 $Manager->Execute("INSERT INTO `Service` (`Id` ,`Name` ,`Category` ,`Price` ,`VAT`) ". … … 987 987 $ActionId = $Manager->Database->insert_id; 988 988 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Sklad"'); 989 if ($DbResult->num_rows > 0)989 if ($DbResult->num_rows > 0) 990 990 { 991 991 $DbRow = $DbResult->fetch_assoc(); … … 1025 1025 $ActionId = $Manager->Database->insert_id; 1026 1026 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Finance"'); 1027 if ($DbResult->num_rows > 0)1027 if ($DbResult->num_rows > 0) 1028 1028 { 1029 1029 $DbRow = $DbResult->fetch_assoc(); … … 1047 1047 // IS menu item 1048 1048 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Příjmy a výdaje"'); 1049 if ($DbResult->num_rows > 0)1049 if ($DbResult->num_rows > 0) 1050 1050 { 1051 1051 $DbRow = $DbResult->fetch_assoc(); … … 1089 1089 // IS menu item 1090 1090 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Závazky a pohledávky"'); 1091 if ($DbResult->num_rows > 0)1091 if ($DbResult->num_rows > 0) 1092 1092 { 1093 1093 $DbRow = $DbResult->fetch_assoc(); … … 1120 1120 $SearchText = 'Připojení k síti'; 1121 1121 $DbResult = $Manager->Execute('SELECT * FROM `FinanceInvoiceItem` WHERE `Description` LIKE "'.$SearchText.' za období%";'); 1122 while ($DbRow = $DbResult->fetch_assoc())1122 while ($DbRow = $DbResult->fetch_assoc()) 1123 1123 { 1124 1124 $Text = trim(substr($DbRow['Description'], strlen($SearchText.' za období') + 1)); … … 1134 1134 $SearchText = 'Připojení k Internetu'; 1135 1135 $DbResult = $Manager->Execute('SELECT * FROM `FinanceInvoiceItem` WHERE `Description` LIKE "'.$SearchText.' za období%";'); 1136 while ($DbRow = $DbResult->fetch_assoc())1136 while ($DbRow = $DbResult->fetch_assoc()) 1137 1137 { 1138 1138 $Text = trim(substr($DbRow['Description'], strlen($SearchText.' za období') + 1)); … … 1141 1141 $PeriodFrom = $PeriodFrom[2].'-'.$PeriodFrom[1].'-'.$PeriodFrom[0]; 1142 1142 $Text[1] = trim($Text[1]); 1143 if (strpos($Text[1], ' ') !== false) $Text[1] = substr($Text[1], 0, strpos($Text[1], ' '));1143 if (strpos($Text[1], ' ') !== false) $Text[1] = substr($Text[1], 0, strpos($Text[1], ' ')); 1144 1144 $PeriodTo = explode('.', trim($Text[1])); 1145 1145 $PeriodTo = $PeriodTo[2].'-'.$PeriodTo[1].'-'.$PeriodTo[0]; … … 1199 1199 $ActionId = $Manager->Database->insert_id; 1200 1200 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Systém"'); 1201 if ($DbResult->num_rows > 0)1201 if ($DbResult->num_rows > 0) 1202 1202 { 1203 1203 $DbRow = $DbResult->fetch_assoc(); … … 1250 1250 $ActionId = $Manager->Database->insert_id; 1251 1251 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"'); 1252 if ($DbResult->num_rows > 0)1252 if ($DbResult->num_rows > 0) 1253 1253 { 1254 1254 $DbRow = $DbResult->fetch_assoc(); … … 1457 1457 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 1458 1458 'WHERE `FinanceOperation`.`BillCodeText`!=""'); 1459 while ($DbRow = $DbResult->fetch_assoc())1459 while ($DbRow = $DbResult->fetch_assoc()) 1460 1460 { 1461 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';1461 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; 1462 1462 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 1463 1463 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); … … 1475 1475 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 1476 1476 'WHERE `FinanceInvoice`.`BillCodeText`!=""'); 1477 while ($DbRow = $DbResult->fetch_assoc())1477 while ($DbRow = $DbResult->fetch_assoc()) 1478 1478 { 1479 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';1479 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; 1480 1480 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 1481 1481 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); … … 1512 1512 { 1513 1513 $DbResult = $Manager->Database->query('SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT SUM(`Price` * `Quantity`) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`,`FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE `Sum` != `Value`'); 1514 while ($DbRow = $DbResult->fetch_assoc())1514 while ($DbRow = $DbResult->fetch_assoc()) 1515 1515 { 1516 1516 $Manager->Database->query('UPDATE `FinanceInvoiceItem` SET `Price` = -`Price` WHERE `FinanceInvoice`='.$DbRow['Id']); … … 1624 1624 $ActionId = $Manager->Database->insert_id; 1625 1625 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Zákazníci"'); 1626 if ($DbResult->num_rows > 0)1626 if ($DbResult->num_rows > 0) 1627 1627 { 1628 1628 $DbRow = $DbResult->fetch_assoc(); … … 1812 1812 'FROM `Contract` '. 1813 1813 'WHERE `Contract`.`BillCodeText`!=""'); 1814 while ($DbRow = $DbResult->fetch_assoc())1814 while ($DbRow = $DbResult->fetch_assoc()) 1815 1815 { 1816 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';1816 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; 1817 1817 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 1818 1818 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); … … 1877 1877 'LEFT JOIN `StockMoveGroup` ON `StockMoveGroup`.`Id` = `StockMove`.`Group` '. 1878 1878 'WHERE `StockMove`.`BillCodeText`!=""'); 1879 while ($DbRow = $DbResult->fetch_assoc())1879 while ($DbRow = $DbResult->fetch_assoc()) 1880 1880 { 1881 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL';1881 if ($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; 1882 1882 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 1883 1883 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); … … 1940 1940 $ActionId = $Manager->Database->insert_id; 1941 1941 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Pokladny"'); 1942 if ($DbResult->num_rows > 0)1942 if ($DbResult->num_rows > 0) 1943 1943 { 1944 1944 $DbRow = $DbResult->fetch_assoc(); … … 2096 2096 $ActionId = $Manager->Database->insert_id; 2097 2097 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"'); 2098 if ($DbResult->num_rows > 0)2098 if ($DbResult->num_rows > 0) 2099 2099 { 2100 2100 $DbRow = $DbResult->fetch_assoc(); … … 2115 2115 function Get() 2116 2116 { 2117 return (array(2117 return (array( 2118 2118 491 => array('Revision' => 493, 'Function' => 'UpdateTo493'), 2119 2119 493 => array('Revision' => 494, 'Function' => 'UpdateTo494'), -
trunk/Application/Version.php
r872 r873 1 1 <?php 2 2 3 $Revision = 87 2; // Subversion revision3 $Revision = 873; // Subversion revision 4 4 $DatabaseRevision = 870; // SQL structure revision 5 5 $ReleaseTime = strtotime('2020-04-06'); -
trunk/Application/View.php
r796 r873 26 26 27 27 // TODO: Move to external code 28 if (isset($this->System->Config['Web']['FormatHTML']))28 if (isset($this->System->Config['Web']['FormatHTML'])) 29 29 $this->FormatHTML = $this->System->Config['Web']['FormatHTML']; 30 if (isset($this->System->Config['Web']['ShowRuntimeInfo']))30 if (isset($this->System->Config['Web']['ShowRuntimeInfo'])) 31 31 $this->ShowRuntimeInfo = $this->System->Config['Web']['ShowRuntimeInfo']; 32 if (isset($this->System->Config['Web']['Charset']))32 if (isset($this->System->Config['Web']['Charset'])) 33 33 $this->Encoding = $this->System->Config['Web']['Charset']; 34 if (isset($this->System->Config['Web']['Style']))34 if (isset($this->System->Config['Web']['Style'])) 35 35 $this->Style = $this->System->Config['Web']['Style']; 36 36 } … … 38 38 function SystemMessage($Title, $Text) 39 39 { 40 return ('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>');40 return ('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>'); 41 41 //ShowFooter(); 42 42 //die(); … … 45 45 function ShowNavigation($Page) 46 46 { 47 if (array_key_exists('REQUEST_URI', $_SERVER))47 if (array_key_exists('REQUEST_URI', $_SERVER)) 48 48 $ScriptName = $_SERVER['REQUEST_URI']; 49 49 else $ScriptName = ''; 50 while (strpos($ScriptName, '//') !== false)50 while (strpos($ScriptName, '//') !== false) 51 51 $ScriptName = str_replace('//', '/', $ScriptName); 52 if (strpos($ScriptName, '?') !== false)52 if (strpos($ScriptName, '?') !== false) 53 53 $ScriptName = substr($ScriptName, 0, strrpos($ScriptName, '?')); 54 54 $ScriptName = substr($ScriptName, strlen($this->System->Link(''))); 55 if (substr($ScriptName, -1, 1) == '/') $ScriptName = substr($ScriptName, 0, -1);55 if (substr($ScriptName, -1, 1) == '/') $ScriptName = substr($ScriptName, 0, -1); 56 56 57 57 $Output = ''; 58 while ($Page)58 while ($Page) 59 59 { 60 60 $Output = ' > <a href="'.$this->System->Link($ScriptName).'/">'.$Page->ShortTitle.'</a>'.$Output; 61 61 62 if (class_exists($Page->ParentClass))62 if (class_exists($Page->ParentClass)) 63 63 { 64 64 $PageClass = $Page->ParentClass; … … 68 68 } 69 69 $Output = substr($Output, 6); 70 return ($Output);70 return ($Output); 71 71 } 72 72 … … 79 79 80 80 $BodyParam = ''; 81 if (isset($Page->Load)) $BodyParam .= ' onload="'.$Page->Load.'"';82 if (isset($Page->Unload)) $BodyParam .= ' onunload="'.$Page->Unload.'"';81 if (isset($Page->Load)) $BodyParam .= ' onload="'.$Page->Load.'"'; 82 if (isset($Page->Unload)) $BodyParam .= ' onunload="'.$Page->Unload.'"'; 83 83 $Output = '<?xml version="1.0" encoding="'.$this->Encoding.'"?>'."\n". 84 84 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'. … … 91 91 // Show page headers 92 92 $Bar = ''; 93 foreach ($this->System->PageHeaders as $Item)93 foreach ($this->System->PageHeaders as $Item) 94 94 $Output .= call_user_func($Item); 95 95 96 96 $Output .= '</head><body'.$BodyParam.'>'; 97 if ($this->BasicHTML == false)97 if ($this->BasicHTML == false) 98 98 { 99 99 //$Output .= '<div class="MainTitle">'.$Title.'</div>'; 100 100 $Output .= '<div class="MainTitle"><span class="MenuItem"><strong>Navigace :: </strong> '.$Navigation.'</span><div class="MenuItem2">'; 101 101 $Bar = ''; 102 foreach ($this->System->Bars['Top'] as $BarItem)102 foreach ($this->System->Bars['Top'] as $BarItem) 103 103 $Bar .= call_user_func($BarItem); 104 if (trim($Bar) != '') $Output .= $Bar;104 if (trim($Bar) != '') $Output .= $Bar; 105 105 else $Output .= ' '; 106 106 $Output .= '</div></div>'; 107 107 } 108 return ($Output);108 return ($Output); 109 109 } 110 110 … … 115 115 $Time = round(GetMicrotime() - $ScriptTimeStart, 2); 116 116 $Output = ''; 117 if ($this->BasicHTML == false)117 if ($this->BasicHTML == false) 118 118 { 119 119 $Output .= '<div id="Footer">'. 120 120 '<i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' | '. 121 121 ' Verze: '.$Revision.' ('.$this->System->HumanDate($ReleaseTime).') |'; 122 if ($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').122 if ($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time'). 123 123 ' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |'; 124 124 $Output .= '</i></div>'; 125 125 } 126 126 $Output .= '</body></html>'; 127 return ($Output);127 return ($Output); 128 128 } 129 129 … … 133 133 134 134 $Output = $Page->Show(); 135 if ($Page->ClearPage == false)135 if ($Page->ClearPage == false) 136 136 { 137 137 $Output = $this->ShowHeader($Page).$Output.$this->ShowFooter(); 138 if ($this->FormatHTML == true) $Output = $this->FormatOutput($Output);138 if ($this->FormatHTML == true) $Output = $this->FormatOutput($Output); 139 139 } 140 return ($Output);140 return ($Output); 141 141 } 142 142 … … 147 147 $Page->Database = $this->Database; 148 148 $Page->FormatHTML = $this->FormatHTML; 149 return ($Page);149 return ($Page); 150 150 } 151 151 … … 156 156 $nn = 0; 157 157 $n = 0; 158 while ($s != '')158 while ($s != '') 159 159 { 160 160 $start = strpos($s, '<'); 161 161 $end = strpos($s, '>'); 162 if ($start != 0)162 if ($start != 0) 163 163 { 164 164 $end = $start - 1; … … 166 166 } 167 167 $line = trim(substr($s, $start, $end + 1)); 168 if (strlen($line) > 0)169 if ($line[0] == '<')168 if (strlen($line) > 0) 169 if ($line[0] == '<') 170 170 { 171 if ($s[$start + 1] == '/')171 if ($s[$start + 1] == '/') 172 172 { 173 173 $n = $n - 2; … … 175 175 } else 176 176 { 177 if (strpos($line, ' ')) $cmd = substr($line, 1, strpos($line, ' ') - 1);177 if (strpos($line, ' ')) $cmd = substr($line, 1, strpos($line, ' ') - 1); 178 178 else $cmd = substr($line, 1, strlen($line) - 2); 179 179 //echo('['.$cmd.']'); 180 if (strpos($s, '</'.$cmd.'>')) $n = $n + 2;180 if (strpos($s, '</'.$cmd.'>')) $n = $n + 2; 181 181 } 182 182 }// else $line = '['.$line.']'; 183 //if ($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));184 if ($line != '') $out .= (str_repeat(' ', $nn).$line."\n");183 //if ($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n")); 184 if ($line != '') $out .= (str_repeat(' ', $nn).$line."\n"); 185 185 $s = substr($s, $end + 1, strlen($s)); 186 186 $nn = $n; 187 187 } 188 return ($out);188 return ($out); 189 189 } 190 190 } -
trunk/Common/Form/Form.php
r872 r873 67 67 { 68 68 $Item = $this->Definition['Items'][$Index]; 69 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))70 { 71 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))69 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 70 { 71 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 72 72 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 73 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')73 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 74 74 $UseType = 'OneToMany'; 75 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')75 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 76 76 $UseType = 'Enumeration'; 77 77 } else $UseType = $Item['Type']; … … 88 88 'Rows' => array(), 89 89 ); 90 foreach ($this->Definition['Items'] as $Index => $Item)91 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))92 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or90 foreach ($this->Definition['Items'] as $Index => $Item) 91 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 92 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 93 93 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 94 94 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 95 95 { 96 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))97 { 98 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))96 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 97 { 98 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 99 99 $this->FormManager->Type->RegisterType($Item['Type'], '', $this->FormManager->FormTypes[$Item['Type']]); 100 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')100 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 101 101 $UseType = 'OneToMany'; 102 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')102 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 103 103 $UseType = 'Enumeration'; 104 104 } else $UseType = $Item['Type']; … … 107 107 'Type' => $Item['Type'], 'Values' => $this->Values, 108 108 'Filter' => $this->ValuesFilter[$Index])); 109 if (array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix'];110 if (!$this->FormManager->Type->IsHidden($UseType))109 if (array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix']; 110 if (!$this->FormManager->Type->IsHidden($UseType)) 111 111 array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); 112 112 } 113 113 $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.Table($Table). 114 114 '</fieldset>'; 115 return ($Output);115 return ($Output); 116 116 } 117 117 118 118 function ShowEditForm() 119 119 { 120 if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';120 if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit'; 121 121 $Output = '<form enctype="multipart/form-data" class="Form" action="'.$this->OnSubmit.'" method="post">'.$this->ShowEditBlock(). 122 122 '<div><input name="submit" type="submit" value="'.$this->Definition['SubmitText'].'" /> '. 123 123 '<input type="button" value="Zrušit" onclick="location.href=\'?\'"/></div></form>'; 124 return ($Output);124 return ($Output); 125 125 } 126 126 … … 184 184 function LoadValuesFromDatabase($Id) 185 185 { 186 foreach ($this->Definition['Items'] as $Index => $Item)187 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or186 foreach ($this->Definition['Items'] as $Index => $Item) 187 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 188 188 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 189 189 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 190 190 { 191 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))192 { 193 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))191 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 192 { 193 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 194 194 $this->FormManager->Type->RegisterType($Item['Type'], '', 195 195 $this->FormManager->FormTypes[$Item['Type']]); 196 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')196 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 197 197 $UseType = 'OneToMany'; 198 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')198 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 199 199 $UseType = 'Enumeration'; 200 200 } else $UseType = $Item['Type']; 201 if (!array_key_exists('SQL', $Item)) $Item['SQL'] = '';201 if (!array_key_exists('SQL', $Item)) $Item['SQL'] = ''; 202 202 else $Item['SQL'] = str_replace('#Id', $Id, $Item['SQL']); 203 203 $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery', … … 205 205 } 206 206 $Columns = implode(',', $Columns); 207 if (array_key_exists('SQL', $this->Definition))207 if (array_key_exists('SQL', $this->Definition)) 208 208 $SourceTable = '('.$this->Definition['SQL'].') AS `TX`'; 209 209 else $SourceTable = '`'.$this->Definition['Table'].'` AS `TX`'; 210 210 $DbResult = $this->Database->query('SELECT '.$Columns.' FROM '.$SourceTable.' WHERE `TX`.`Id`='.$Id); 211 211 $DbRow = $DbResult->fetch_array(); 212 foreach ($this->Definition['Items'] as $Index => $Item)213 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or212 foreach ($this->Definition['Items'] as $Index => $Item) 213 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 214 214 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 215 215 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 216 216 { 217 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))218 { 219 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))217 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 218 { 219 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 220 220 $this->FormManager->Type->RegisterType($Item['Type'], '', 221 221 $this->FormManager->FormTypes[$Item['Type']]); 222 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')222 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 223 223 $UseType = 'OneToMany'; 224 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')224 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 225 225 $UseType = 'Enumeration'; 226 226 } else $UseType = $Item['Type']; … … 235 235 { 236 236 $Values = array(); 237 foreach ($this->Definition['Items'] as $Index => $Item)238 { 239 if (array_key_exists($Index, $this->Values))240 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or237 foreach ($this->Definition['Items'] as $Index => $Item) 238 { 239 if (array_key_exists($Index, $this->Values)) 240 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 241 241 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 242 242 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) … … 245 245 'Type' => $Item['Type'], 'Values' => $this->Values); 246 246 247 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))248 { 249 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))247 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 248 { 249 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 250 250 $this->FormManager->Type->RegisterType($Item['Type'], '', 251 251 $this->FormManager->FormTypes[$Item['Type']]); 252 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')252 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 253 253 { 254 254 $UseType = 'OneToMany'; 255 255 } 256 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')256 else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 257 257 $UseType = 'Enumeration'; 258 258 } else $UseType = $Item['Type']; 259 259 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnSaveDb', $Parameters); 260 if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]);261 } 262 } 263 if ($Id == 0)260 if (($Item['Type'] == 'Password') and ($Values[$Index] == '')) unset($Values[$Index]); 261 } 262 } 263 if ($Id == 0) 264 264 { 265 265 $Values['Id'] = $Id; … … 316 316 } 317 317 } 318 return ($Values);318 return ($Values); 319 319 } 320 320 … … 322 322 { 323 323 $Valid = true; 324 foreach ($this->Definition['Items'] as $Index => $Item)325 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or324 foreach ($this->Definition['Items'] as $Index => $Item) 325 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 326 326 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 327 327 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and … … 330 330 ($Item['ReadOnly'] != true)))) 331 331 { 332 //if (array_key_exists($Context.$Index, $_POST))333 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))334 { 335 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))332 //if (array_key_exists($Context.$Index, $_POST)) 333 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 334 { 335 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 336 336 $this->FormManager->Type->RegisterType($Item['Type'], '', 337 337 $this->FormManager->FormTypes[$Item['Type']]); 338 338 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type']; 339 if ($CustomType == 'Reference')339 if ($CustomType == 'Reference') 340 340 $UseType = 'OneToMany'; 341 else if ($CustomType == 'Enumeration')341 else if ($CustomType == 'Enumeration') 342 342 $UseType = 'Enumeration'; 343 343 } else $UseType = $Item['Type']; 344 344 345 345 $Parameters = array('Value' => $this->Values[$Index]); 346 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];346 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 347 347 else $Parameters['Null'] = false; 348 if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate',348 if (!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate', 349 349 $Parameters)) { 350 350 $this->ValuesValidate[$Index] = true; … … 352 352 } 353 353 } 354 if ($Valid == false) throw new Exception('not validated');355 return ($Valid);354 if ($Valid == false) throw new Exception('not validated'); 355 return ($Valid); 356 356 } 357 357 } … … 360 360 function MakeLink($Target, $Title) 361 361 { 362 return ('<a href="'.$Target.'">'.$Title.'</a>');362 return ('<a href="'.$Target.'">'.$Title.'</a>'); 363 363 } 364 364 … … 366 366 { 367 367 $Result = '<table class="BasicTable">'; 368 if (array_key_exists('Header', $Table))368 if (array_key_exists('Header', $Table)) 369 369 { 370 370 $Result .= '<tr>'; 371 foreach ($Table['Header'] as $Item)371 foreach ($Table['Header'] as $Item) 372 372 $Result .= '<th>'.$Item.'</th>'; 373 373 $Result .= '</tr>'; 374 374 } 375 foreach ($Table['Rows'] as $Row)375 foreach ($Table['Rows'] as $Row) 376 376 { 377 377 $Result .= '<tr>'; 378 foreach ($Row as $Index => $Item)379 { 380 if ($Index == 0) $Class = ' class="Header"'; else $Class = '';378 foreach ($Row as $Index => $Item) 379 { 380 if ($Index == 0) $Class = ' class="Header"'; else $Class = ''; 381 381 $Result .= '<td'.$Class.' style="width: '.(floor(100 / count($Row))).'%">'.$Item.'</td>'; 382 382 } … … 384 384 } 385 385 $Result .= '</table>'; 386 return ($Result);386 return ($Result); 387 387 } 388 388 … … 432 432 $this->Database->query('DELETE FROM DataType'); 433 433 434 foreach ($this->Type->TypeDefinitionList as $Name => $Type)434 foreach ($this->Type->TypeDefinitionList as $Name => $Type) 435 435 { 436 436 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Name.'"'); 437 if ($DbResult->num_rows == 0)437 if ($DbResult->num_rows == 0) 438 438 { 439 439 $this->Database->insert('DataType', array('Name' => $Name, … … 447 447 } 448 448 449 foreach ($this->Classes as $Class)450 if (!array_key_exists('SQL', $Class) and ($Class['Table'] != ''))449 foreach ($this->Classes as $Class) 450 if (!array_key_exists('SQL', $Class) and ($Class['Table'] != '')) 451 451 { 452 452 $DbResult = $this->Database->query('SELECT * FROM information_schema.tables WHERE table_schema = "centrala_big" 453 453 AND table_name = "'.$Class['Table'].'" LIMIT 1'); 454 if ($DbResult->num_rows == 0) continue;454 if ($DbResult->num_rows == 0) continue; 455 455 456 456 echo($Class['Table'].'<br>'); 457 457 $Module = 1; 458 458 $DbResult = $this->Database->select('Model', 'Id', 'Name="'.$Class['Table'].'"'); 459 if ($DbResult->num_rows == 0)459 if ($DbResult->num_rows == 0) 460 460 { 461 461 $this->Database->insert('Model', array('Name' => $Class['Table'], 'Title' => $Class['Title'], 'Module' => $Module)); … … 469 469 } 470 470 471 foreach ($Class['Items'] as $Name => $Field)471 foreach ($Class['Items'] as $Name => $Field) 472 472 { 473 473 echo($Name.', '); 474 474 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Field['Type'].'"'); 475 if ($DbResult->num_rows > 0)475 if ($DbResult->num_rows > 0) 476 476 { 477 477 $DbRow = $DbResult->fetch_assoc(); … … 482 482 // Search parent type 483 483 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Type['Type'].'"'); 484 if ($DbResult->num_rows > 0)484 if ($DbResult->num_rows > 0) 485 485 { 486 486 $DbRow = $DbResult->fetch_assoc(); … … 494 494 495 495 $DbResult = $this->Database->select('ModelField', 'Id', '(Name="'.$Name.'") AND (Model='.$Model.')'); 496 if ($DbResult->num_rows == 0)496 if ($DbResult->num_rows == 0) 497 497 { 498 498 $this->Database->insert('ModelField', array('Name' => $Name, -
trunk/Common/Form/Types/Base.php
r738 r873 17 17 function OnView($Item) 18 18 { 19 return ('');19 return (''); 20 20 } 21 21 22 22 function OnEdit($Item) 23 23 { 24 return ('');24 return (''); 25 25 } 26 26 27 27 function OnLoad($Item) 28 28 { 29 return ('');29 return (''); 30 30 } 31 31 32 32 function OnLoadDb($Item) 33 33 { 34 return ($Item['Value']);34 return ($Item['Value']); 35 35 } 36 36 37 37 function OnSaveDb($Item) 38 38 { 39 return ($Item['Value']);39 return ($Item['Value']); 40 40 } 41 41 42 42 function DatabaseEscape($Value) 43 43 { 44 return (addslashes($Value));44 return (addslashes($Value)); 45 45 } 46 46 47 47 function OnFilterName($Item) 48 48 { 49 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))49 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != '')) 50 50 $SQL = '('.$Item['SQL'].') AS '; 51 51 else $SQL = ''; 52 return ($SQL.'`'.$Item['Name'].'`');52 return ($SQL.'`'.$Item['Name'].'`'); 53 53 } 54 54 55 55 function OnFilterNameQuery($Item) 56 56 { 57 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))57 if (array_key_exists('SQL', $Item) and ($Item['SQL'] != '')) 58 58 $Output = '('.$Item['SQL'].') AS `'.$Item['Name'].'`, ('.$Item['SQL'].') AS `'.$Item['Name'].'_Filter`'; 59 59 else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`'; 60 return ($Output);60 return ($Output); 61 61 } 62 62 63 63 function Validate($Item) 64 64 { 65 return (true);65 return (true); 66 66 } 67 67 68 68 function GetValidationFormat() 69 69 { 70 return ('');70 return (''); 71 71 } 72 72 } -
trunk/Common/Form/Types/Boolean.php
r738 r873 9 9 function OnView($Item) 10 10 { 11 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';12 return ('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>');11 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 12 return ('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>'); 13 13 } 14 14 15 15 function OnEdit($Item) 16 16 { 17 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';18 return ('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>');17 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 18 return ('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>'); 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 if (array_key_exists($Item['Name'], $_POST)) return(1);24 else return (0);23 if (array_key_exists($Item['Name'], $_POST)) return (1); 24 else return (0); 25 25 } 26 26 } -
trunk/Common/Form/Types/Color.php
r548 r873 10 10 { 11 11 $Output = '<span style="background-color: #'.$Item['Value'].'"> </span>'; 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return ($_POST[$Item['Name']]); 24 24 } 25 25 } -
trunk/Common/Form/Types/Date.php
r872 r873 11 11 global $MonthNames; 12 12 13 if ($Item['Value'] == null) return('');14 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();13 if ($Item['Value'] == null) return (''); 14 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 15 15 $Parts = getdate($Item['Value']); 16 16 17 17 $Output = $Parts['mday'].'.'.$Parts['mon'].'.'.$Parts['year']; 18 return ($Output);18 return ($Output); 19 19 } 20 20 … … 32 32 $Output = ''; 33 33 $Style = ''; 34 if (array_key_exists('Null', $Item) and $Item['Null'])34 if (array_key_exists('Null', $Item) and $Item['Null']) 35 35 { 36 if (!$IsNull)36 if (!$IsNull) 37 37 { 38 38 $Checked = ' checked="1"'; … … 49 49 // Day 50 50 $Output .= '<select name="'.$Item['Name'].'-day" id="'.$Item['Name'].'-day" '.$Style.'>'; 51 for ($I = 1; $I <= 31; $I++)51 for ($I = 1; $I <= 31; $I++) 52 52 { 53 if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = '';53 if ($Parts['mday'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 54 54 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 55 55 } … … 57 57 // Month 58 58 $Output .= '<select name="'.$Item['Name'].'-month" id="'.$Item['Name'].'-month" '.$Style.'>'; 59 for ($I = 1; $I <= 12; $I++)59 for ($I = 1; $I <= 12; $I++) 60 60 { 61 if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = '';61 if ($Parts['mon'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 62 62 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>'; 63 63 } … … 65 65 // Year 66 66 $Output .= '<select name="'.$Item['Name'].'-year" id="'.$Item['Name'].'-year" '.$Style.'>'; 67 for ($I = 1900; $I < 2100; $I++)67 for ($I = 1900; $I < 2100; $I++) 68 68 { 69 if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = '';69 if ($Parts['year'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 70 70 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 71 71 } 72 72 $Output .= '</select>'; 73 return ($Output);73 return ($Output); 74 74 } 75 75 76 76 function OnLoad($Item) 77 77 { 78 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);79 else return (mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year']));78 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return (null); 79 else return (mktime(0, 0, 0, $_POST[$Item['Name'].'-month'], $_POST[$Item['Name'].'-day'], $_POST[$Item['Name'].'-year'])); 80 80 } 81 81 82 82 function OnLoadDb($Item) 83 83 { 84 return (MysqlDateToTime($Item['Value']));84 return (MysqlDateToTime($Item['Value'])); 85 85 } 86 86 87 87 function OnSaveDb($Item) 88 88 { 89 if ($Item['Value'] == null) return(null);90 else return (date('Y-m-d', $Item['Value']));89 if ($Item['Value'] == null) return (null); 90 else return (date('Y-m-d', $Item['Value'])); 91 91 } 92 92 93 93 function DatabaseEscape($Value) 94 94 { 95 return ('"'.addslashes($Value).'"');95 return ('"'.addslashes($Value).'"'); 96 96 } 97 97 } -
trunk/Common/Form/Types/Enumeration.php
r738 r873 8 8 { 9 9 $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']); 10 if (array_key_exists($Item['Value'], $Type['Parameters']['States']))10 if (array_key_exists($Item['Value'], $Type['Parameters']['States'])) 11 11 $Output = $Type['Parameters']['States'][$Item['Value']]; 12 12 else $Output = $Item['Value']; 13 return ($Output);13 return ($Output); 14 14 } 15 15 … … 18 18 $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']); 19 19 $Output = '<select name="'.$Item['Name'].'">'; 20 if (array_key_exists('Null', $Item) and $Item['Null'])20 if (array_key_exists('Null', $Item) and $Item['Null']) 21 21 { 22 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';22 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = ''; 23 23 $Output .= '<option value=""'.$Selected.'></option>'; 24 24 } 25 foreach ($Type['Parameters']['States'] as $Index => $StateName)25 foreach ($Type['Parameters']['States'] as $Index => $StateName) 26 26 { 27 if ($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = '';27 if ($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = ''; 28 28 $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$StateName.'</option>'; 29 29 } 30 30 $Output .= '</select>'; 31 return ($Output);31 return ($Output); 32 32 } 33 33 34 34 function OnLoad($Item) 35 35 { 36 if ($_POST[$Item['Name']] == '') return(NULL);37 return ($_POST[$Item['Name']]);36 if ($_POST[$Item['Name']] == '') return (NULL); 37 return ($_POST[$Item['Name']]); 38 38 } 39 39 40 40 function OnLoadDb($Item) 41 41 { 42 if ($Item['Value'] == '') return(NULL);43 else return ($Item['Value']);42 if ($Item['Value'] == '') return (NULL); 43 else return ($Item['Value']); 44 44 } 45 45 } -
trunk/Common/Form/Types/File.php
r738 r873 16 16 $Result = $FileInfo->file($this->FileName); 17 17 //$FileInfo->close(); 18 return ($Result);18 return ($Result); 19 19 } 20 20 … … 22 22 { 23 23 $FileName = $this->GetFullName($Item); 24 if (file_exists($FileName)) $Result = filesize($FileName);24 if (file_exists($FileName)) $Result = filesize($FileName); 25 25 else $Result = 0; 26 return ($Result);26 return ($Result); 27 27 } 28 28 … … 30 30 { 31 31 $ParentId = $this->Directory; 32 while ($ParentId != null)32 while ($ParentId != null) 33 33 { 34 34 $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$ParentId); … … 38 38 } 39 39 $Result = $this->UploadFileFolder.'/'.$Path.$File->Name; 40 return ($Result);40 return ($Result); 41 41 } 42 42 43 43 function GetExt() 44 44 { 45 return (substr($this->Name, 0, strpos($this->Name, '.') - 1));45 return (substr($this->Name, 0, strpos($this->Name, '.') - 1)); 46 46 } 47 47 48 48 function Delete() 49 49 { 50 if (file_exists($this->GetFullName())) unlink($this->GetFullName());50 if (file_exists($this->GetFullName())) unlink($this->GetFullName()); 51 51 } 52 52 53 53 function GetContent() 54 54 { 55 if ($this->TempName != '') $Content = file_get_contents($this->TempName);55 if ($this->TempName != '') $Content = file_get_contents($this->TempName); 56 56 else $Content = file_get_contents($this->GetFullName()); 57 return ($Content);57 return ($Content); 58 58 } 59 59 } … … 75 75 { 76 76 $File = &$Item['Value']; 77 return ('<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'.77 return ('<a href="'.$this->FileDownloadURL.'?id='.$File->Id.'">'. 78 78 $File.'</a> ('.HumanSize($File->Size).')'); 79 79 } … … 86 86 $File = &$Item['Value']; 87 87 $Output = '<input type="file" name="'.$Item['Name'].'" value="'.$File->Name.'">'; 88 return ($Output);88 return ($Output); 89 89 } 90 90 91 91 function OnLoad($Item) 92 92 { 93 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();93 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 94 94 $File = &$Item['Value']; 95 if (array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != ''))95 if (array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != '')) 96 96 { 97 97 $UploadFile = $_FILES[$Item['Name']]; 98 if (file_exists($UploadFile['tmp_name']))98 if (file_exists($UploadFile['tmp_name'])) 99 99 { 100 100 $File->Name = $UploadFile['name']; … … 103 103 } 104 104 } 105 return ($File);105 return ($File); 106 106 } 107 107 108 108 function OnLoadDb($Item) 109 109 { 110 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();110 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 111 111 $File = &$Item['Value']; 112 112 $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id); 113 if ($DbResult->num_rows() > 0)113 if ($DbResult->num_rows() > 0) 114 114 { 115 115 $DbRow = $DbResult->fetch_assoc(); … … 118 118 $File->Directory = $DbRow['Directory']; 119 119 } 120 return ($File);120 return ($File); 121 121 } 122 122 123 123 function OnSaveDb($Item) 124 124 { 125 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();125 if (!is_object($Item['Value'])) $Item['Value'] = new DbFile(); 126 126 $File = &$Item['Value']; 127 127 $Properties = array('Name' => $File->Name, 128 128 'Size' => $File->GetSize(), 'Directory' => $File->Directory); 129 129 $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id); 130 if ($DbResult->num_rows() > 0)130 if ($DbResult->num_rows() > 0) 131 131 { 132 132 $DbRow = $DbResult->fetch_assoc(); 133 if ($File->TempName != '')133 if ($File->TempName != '') 134 134 { 135 135 $FileName = $File->GetFullName(); … … 142 142 $File->Id = $this->Database->insert_id; 143 143 } 144 if (!move_uploaded_file($File->TempName, $FileName))144 if (!move_uploaded_file($File->TempName, $FileName)) 145 145 SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!'); 146 146 } -
trunk/Common/Form/Types/Float.php
r548 r873 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return ($_POST[$Item['Name']]); 24 24 } 25 25 } -
trunk/Common/Form/Types/GPS.php
r548 r873 10 10 11 11 $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 12 if ($DbResult->num_rows > 0)12 if ($DbResult->num_rows > 0) 13 13 { 14 14 $DbRow = $DbResult->fetch_assoc(); … … 17 17 $Output = '<a href="http://www.mapy.cz/?st=search&fr=loc:'.$DbRow['Latitude'].' '.$DbRow['Longitude'].'">'.$Latitude[0].'°'.$Latitude[1]."'".$Latitude[2].'" '.$Longitude[0].'°'.$Longitude[1]."'".$Longitude[2].'"</a>'; 18 18 } 19 return ($Output);19 return ($Output); 20 20 } 21 21 … … 24 24 global $Database; 25 25 26 if ($Item['Value'] != '')26 if ($Item['Value'] != '') 27 27 { 28 28 $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']); 29 if ($DbResult->num_rows > 0)29 if ($DbResult->num_rows > 0) 30 30 { 31 31 $DbRow = $DbResult->fetch_assoc(); … … 40 40 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'"/>\''; 41 41 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'"/>"'; 42 return ($Output);42 return ($Output); 43 43 } 44 44 … … 50 50 $Longitude = $this->Implode($_POST[$Item['Name'].'-lon-deg'], $_POST[$Item['Name'].'-lon-min'], $_POST[$Item['Name'].'-lon-sec']); 51 51 $Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")'); 52 return ($Database->insert_id);52 return ($Database->insert_id); 53 53 } 54 54 … … 61 61 $Float = ($Float - intval($Float)) * 60; 62 62 $Seconds = round($Float, 3); 63 return (array($Degrees, $Minutes, $Seconds));63 return (array($Degrees, $Minutes, $Seconds)); 64 64 } 65 65 66 66 function Implode($Degrees, $Minutes, $Seconds) 67 67 { 68 if ($Degrees < 0) return(-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60));69 else return ($Degrees + ($Minutes + $Seconds / 60) / 60);68 if ($Degrees < 0) return (-(abs($Degrees) + ($Minutes + $Seconds / 60) / 60)); 69 else return ($Degrees + ($Minutes + $Seconds / 60) / 60); 70 70 } 71 71 } -
trunk/Common/Form/Types/Hidden.php
r738 r873 14 14 { 15 15 $Output = $Item['Value']; 16 return ($Output);16 return ($Output); 17 17 } 18 18 … … 20 20 { 21 21 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />'; 22 return ($Output);22 return ($Output); 23 23 } 24 24 25 25 function OnLoad($Item) 26 26 { 27 return ($_POST[$Item['Name']]);27 return ($_POST[$Item['Name']]); 28 28 } 29 29 } -
trunk/Common/Form/Types/Hyperlink.php
r548 r873 8 8 { 9 9 $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>'; 10 return ($Output);10 return ($Output); 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 return ($Output);16 return ($Output); 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return ($_POST[$Item['Name']]); 22 22 } 23 23 } -
trunk/Common/Form/Types/IPv4Address.php
r738 r873 8 8 { 9 9 $Output = $Item['Value']; 10 return ($Output);10 return ($Output); 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 return ($Output);16 return ($Output); 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return ($_POST[$Item['Name']]); 22 22 } 23 23 24 24 function Validate($Item) 25 25 { 26 if ($Item['Null'] and ($Item['Value'] == '')) return(true);27 return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)));26 if ($Item['Null'] and ($Item['Value'] == '')) return (true); 27 return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4))); 28 28 } 29 29 30 30 function GetValidationFormat() 31 31 { 32 return ('x.x.x.x kde x je hodnota 0..255');32 return ('x.x.x.x kde x je hodnota 0..255'); 33 33 } 34 34 } -
trunk/Common/Form/Types/IPv6Address.php
r738 r873 8 8 { 9 9 $Output = $Item['Value']; 10 return ($Output);10 return ($Output); 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 return ($Output);16 return ($Output); 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return ($_POST[$Item['Name']]); 22 22 } 23 23 24 24 function Validate($Item) 25 25 { 26 if ($Item['Null'] and ($Item['Value'] == '')) return(true);27 return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6)));26 if ($Item['Null'] and ($Item['Value'] == '')) return (true); 27 return (filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6))); 28 28 } 29 29 30 30 function GetValidationFormat() 31 31 { 32 return ('xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f');32 return ('xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f'); 33 33 } 34 34 } -
trunk/Common/Form/Types/Image.php
r738 r873 7 7 global $System; 8 8 9 return ('<img src="'.$System->Link('/images/favicons/'.$Item['Value']).'"/> '.$Item['Value']);9 return ('<img src="'.$System->Link('/images/favicons/'.$Item['Value']).'"/> '.$Item['Value']); 10 10 } 11 11 } -
trunk/Common/Form/Types/Integer.php
r738 r873 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return ($_POST[$Item['Name']]); 24 24 } 25 25 26 26 function Validate($Item) 27 27 { 28 if ($Item['Null'] and ($Item['Value'] == '')) return(true);29 return (preg_match('/^\-*[0-9\.]+$/', $Item['Value']));28 if ($Item['Null'] and ($Item['Value'] == '')) return (true); 29 return (preg_match('/^\-*[0-9\.]+$/', $Item['Value'])); 30 30 } 31 31 32 32 function GetValidationFormat() 33 33 { 34 return ('číselná hodnota');34 return ('číselná hodnota'); 35 35 } 36 36 } -
trunk/Common/Form/Types/MacAddress.php
r738 r873 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 … … 22 22 { 23 23 //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>'); 24 return (strtoupper($_POST[$Item['Name']]));24 return (strtoupper($_POST[$Item['Name']])); 25 25 } 26 26 27 27 function DatabaseEscape($Value) 28 28 { 29 return ('"'.addslashes($Value).'"');29 return ('"'.addslashes($Value).'"'); 30 30 } 31 31 32 32 function Validate($Item) 33 33 { 34 if ($Item['Null'] and ($Item['Value'] == '')) return(true);35 return (preg_match('/^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$/', $Item['Value']));34 if ($Item['Null'] and ($Item['Value'] == '')) return (true); 35 return (preg_match('/^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$/', $Item['Value'])); 36 36 } 37 37 38 38 function GetValidationFormat() 39 39 { 40 return ('XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F');40 return ('XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F'); 41 41 } 42 42 } -
trunk/Common/Form/Types/OneToMany.php
r738 r873 10 10 { 11 11 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 12 if ($Item['Value'] != '')12 if ($Item['Value'] != '') 13 13 { 14 14 $Output = '<a href="?t='.$Type['Parameters']['Table'].'&a='. 15 15 'view'.'&i='.$Item['Value'].'">'.$Item['Filter'].'</a>'; 16 16 } else $Output = ''; 17 return ($Output);17 return ($Output); 18 18 } 19 19 … … 22 22 $Output = '<select name="'.$Item['Name'].'" id="'.$Item['Name'].'">'; 23 23 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 24 if (array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];24 if (array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition']; 25 25 else $Where = ''; 26 if (array_key_exists('Null', $Item) and $Item['Null'])26 if (array_key_exists('Null', $Item) and $Item['Null']) 27 27 { 28 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';28 if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = ''; 29 29 $Output .= '<option value=""'.$Selected.'></option>'; 30 30 } 31 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];31 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View']; 32 32 else $Table = $Type['Parameters']['Table']; 33 33 $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS `Name`,'.$Type['Parameters']['Id'].' AS `Id` FROM '.$Table.''.$Where.' ORDER BY `Name`'); 34 while ($DbRow = $DbResult->fetch_assoc())34 while ($DbRow = $DbResult->fetch_assoc()) 35 35 { 36 if ($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = '';36 if ($Item['Value'] == $DbRow['Id']) $Selected = ' selected="1"'; else $Selected = ''; 37 37 $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Name'].'</option>'; 38 38 } 39 39 $Output .= '</select>'; 40 if ($this->FormManager->ShowRelation)40 if ($this->FormManager->ShowRelation) 41 41 { 42 42 $URL = ''; 43 if (array_key_exists('OnPreset', $Item))43 if (array_key_exists('OnPreset', $Item)) 44 44 { 45 45 $Preset = call_user_func($Item['OnPreset'], $Item['Values']); … … 51 51 'onclick="return popupwindow("'.$this->FormManager->Root.'/is/?a=select&t='.$Table.'&r='.$Item['Name'].'","test");" style="cursor:hand;cursor:pointer"/>'; 52 52 } 53 return ($Output);53 return ($Output); 54 54 } 55 55 56 56 function OnLoad($Item) 57 57 { 58 if ($_POST[$Item['Name']] == '') return(NULL);59 else return ($_POST[$Item['Name']]);58 if ($_POST[$Item['Name']] == '') return (NULL); 59 else return ($_POST[$Item['Name']]); 60 60 } 61 61 62 62 function OnLoadDb($Item) 63 63 { 64 if ($Item['Value'] == '') return(NULL);65 else return ($Item['Value']);64 if ($Item['Value'] == '') return (NULL); 65 else return ($Item['Value']); 66 66 } 67 67 68 68 function OnFilterName($Item) 69 69 { 70 return ('`'.$Item['Name'].'_Filter`');70 return ('`'.$Item['Name'].'_Filter`'); 71 71 } 72 72 … … 74 74 { 75 75 $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']]; 76 //if ($Item['Value'] != '')76 //if ($Item['Value'] != '') 77 77 //{ 78 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View'];78 if (array_key_exists('View', $Type['Parameters'])) $Table = $Type['Parameters']['View']; 79 79 else $Table = $Type['Parameters']['Table']; 80 80 $Output = '`'.$Item['Name'].'`, (SELECT '.$Type['Parameters']['Name'].''. … … 82 82 $Type['Parameters']['Id'].'`=`TX`.`'.$Item['Name'].'`) AS `'.$Item['Name'].'_Filter`'; 83 83 //} else $Output = '`'.$Item['Name'].'`, `'.$Item['Name'].'` AS `'.$Item['Name'].'_Filter`'; 84 return ($Output);84 return ($Output); 85 85 } 86 86 } -
trunk/Common/Form/Types/OneToMany2.php
r548 r873 8 8 { 9 9 $Output = '<a href="?Action=ShowList&TableId='.$Item['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; 10 return ($Output);10 return ($Output); 11 11 } 12 12 … … 14 14 { 15 15 $Output = '<a href="?Action=ShowList&TableId='.$Item['TypeDefinition'].'&ParentTable='.$Item['SourceTable'].'&ParentColumn='.$Item['SourceItemId'].'">Seznam</a>'; 16 return ($Output);16 return ($Output); 17 17 } 18 18 19 19 function OnLoad($Item) 20 20 { 21 return ($_POST[$Item['Name']]);21 return ($_POST[$Item['Name']]); 22 22 } 23 23 } -
trunk/Common/Form/Types/Password.php
r738 r873 10 10 { 11 11 $Output = ''; 12 for ($I = 0; $I < 6; $I++)12 for ($I = 0; $I < 6; $I++) 13 13 $Output .= '*'; 14 return ($Output);14 return ($Output); 15 15 } 16 16 … … 18 18 { 19 19 $Output = '<input type="password" name="'.$Item['Name'].'" value=""/>'; 20 return ($Output);20 return ($Output); 21 21 } 22 22 … … 27 27 $Result = $_POST[$Item['Name']]; 28 28 /* 29 if (!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]);29 if (!array_key_exists('SourceItemId', $Item)) $Result = sha1($_POST[$Item['Name']]); 30 30 else 31 31 { 32 32 $DbRestult = $Database->query('SELECT '.$Item['Name'].' FROM '.$Item['SourceTable'].' WHERE Id='.$Item['SourceItemId']); 33 if ($DbResult->num_rows > 0)33 if ($DbResult->num_rows > 0) 34 34 { 35 35 $DbRow = $DbResult->fetch_assoc(); 36 if ($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']];36 if ($_POST[$Item['Name']] == '') $Result = $DbRow[$Item['Name']]; 37 37 else $Result = sha1($_POST[$Item['Name']]); 38 38 } else $Result = sha1($_POST[$Item['Name']]); 39 39 } 40 40 */ 41 return ($Result);41 return ($Result); 42 42 } 43 43 44 44 function OnSaveDb($Item) 45 45 { 46 if ($Item['Value'] == '') return('');46 if ($Item['Value'] == '') return (''); 47 47 else { 48 48 $PasswordHash = new PasswordHash(); 49 return ($PasswordHash->Hash($Item['Value'], $Item['Values']['Salt']));49 return ($PasswordHash->Hash($Item['Value'], $Item['Values']['Salt'])); 50 50 } 51 51 } … … 53 53 function OnLoadDb($Item) 54 54 { 55 return ('');55 return (''); 56 56 } 57 57 } -
trunk/Common/Form/Types/RandomHash.php
r738 r873 14 14 { 15 15 $Output = $Item['Value']; 16 return ($Output);16 return ($Output); 17 17 } 18 18 19 19 function OnEdit($Item) 20 20 { 21 if ($Item['Value'] == '')21 if ($Item['Value'] == '') 22 22 { 23 23 // Create only once … … 26 26 } 27 27 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />'; 28 return ($Output);28 return ($Output); 29 29 } 30 30 31 31 function OnLoad($Item) 32 32 { 33 return ($_POST[$Item['Name']]);33 return ($_POST[$Item['Name']]); 34 34 } 35 35 } -
trunk/Common/Form/Types/String.php
r574 r873 10 10 { 11 11 $Output = $Item['Value']; 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 … … 22 22 { 23 23 //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>'); 24 return ($_POST[$Item['Name']]);24 return ($_POST[$Item['Name']]); 25 25 } 26 26 27 27 function DatabaseEscape($Value) 28 28 { 29 return ('"'.addslashes($Value).'"');29 return ('"'.addslashes($Value).'"'); 30 30 } 31 31 } -
trunk/Common/Form/Types/Text.php
r799 r873 10 10 { 11 11 $Output = str_replace("\n", '<br/>', strip_tags($Item['Value'])); 12 return ($Output);12 return ($Output); 13 13 } 14 14 … … 16 16 { 17 17 $Output = '<textarea name="'.$Item['Name'].'">'.$Item['Value'].'</textarea>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 21 21 function OnLoad($Item) 22 22 { 23 return ($_POST[$Item['Name']]);23 return ($_POST[$Item['Name']]); 24 24 } 25 25 26 26 function DatabaseEscape($Value) 27 27 { 28 return ('"'.addslashes($Value).'"');28 return ('"'.addslashes($Value).'"'); 29 29 } 30 30 } -
trunk/Common/Form/Types/Time.php
r872 r873 9 9 function OnView($Item) 10 10 { 11 if ($Item['Value'] == 0) return('');12 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();11 if ($Item['Value'] == 0) return (''); 12 if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time(); 13 13 $TimeParts = getdate($Item['Value']); 14 14 15 15 $Output = sprintf('%02d', $TimeParts['hours']).':'.sprintf('%02d', $TimeParts['minutes']).':'.sprintf('%02d', $TimeParts['seconds']); 16 return ($Output);16 return ($Output); 17 17 } 18 18 … … 28 28 $Output = ''; 29 29 $Style = ''; 30 if (array_key_exists('Null', $Item) and $Item['Null'])30 if (array_key_exists('Null', $Item) and $Item['Null']) 31 31 { 32 if ($IsNull)32 if ($IsNull) 33 33 { 34 34 $Checked = ' checked="1"'; … … 45 45 // Hour 46 46 $Output .= '<select name="'.$Item['Name'].'-hour" id="'.$Item['Name'].'-hour" '.$Style.'>'; 47 for ($I = 1; $I <= 24; $I++)47 for ($I = 1; $I <= 24; $I++) 48 48 { 49 if ($TimeParts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = '';49 if ($TimeParts['hours'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 50 50 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 51 51 } … … 53 53 // Minute 54 54 $Output .= '<select name="'.$Item['Name'].'-minute" id="'.$Item['Name'].'-minute" '.$Style.'>'; 55 for ($I = 1; $I <= 60; $I++)55 for ($I = 1; $I <= 60; $I++) 56 56 { 57 if ($TimeParts['month'] == $I) $Selected = ' selected="1"'; else $Selected = '';57 if ($TimeParts['month'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 58 58 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 59 59 } … … 61 61 // Second 62 62 $Output .= '<select name="'.$Item['Name'].'-second" id="'.$Item['Name'].'-second" '.$Style.'>'; 63 for ($I = 1; $I <= 60; $I++)63 for ($I = 1; $I <= 60; $I++) 64 64 { 65 if ($TimeParts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = '';65 if ($TimeParts['seconds'] == $I) $Selected = ' selected="1"'; else $Selected = ''; 66 66 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 67 67 } 68 68 $Output .= '</select>'; 69 return ($Output);69 return ($Output); 70 70 } 71 71 72 72 function OnLoad($Item) 73 73 { 74 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return(null);75 return (mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second']));74 if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return (null); 75 return (mktime($_POST[$Item['Name'].'-hour'], $_POST[$Item['Name'].'-minute'], $_POST[$Item['Name'].'-second'])); 76 76 } 77 77 78 78 function OnLoadDb($Item) 79 79 { 80 return (MysqlTimeToTime($Item['Value']));80 return (MysqlTimeToTime($Item['Value'])); 81 81 } 82 82 83 83 function OnSaveDb($Item) 84 84 { 85 if ($Item['Value'] == null) return(null);86 else return (date('H:i:s', $Item['Value']));85 if ($Item['Value'] == null) return (null); 86 else return (date('H:i:s', $Item['Value'])); 87 87 } 88 88 89 89 function DatabaseEscape($Value) 90 90 { 91 return ('"'.addslashes($Value).'"');91 return ('"'.addslashes($Value).'"'); 92 92 } 93 93 } -
trunk/Common/Form/Types/TimeDiff.php
r660 r873 7 7 function OnView($Item) 8 8 { 9 if ($Item['Value'] == null) $Output = '';9 if ($Item['Value'] == null) $Output = ''; 10 10 else { 11 11 $Output = sprintf('%02d', floor($Item['Value'] / 3600 % 24)).':'. … … 13 13 sprintf('%02d', floor($Item['Value'] % 60)); 14 14 $Days = floor($Item['Value'] / (60 * 60 * 24)); 15 if ($Days > 0) $Output = $Days.' dnů '.$Output;15 if ($Days > 0) $Output = $Days.' dnů '.$Output; 16 16 } 17 return ($Output);17 return ($Output); 18 18 } 19 19 } -
trunk/Common/Form/Types/Type.php
r738 r873 67 67 function ExecuteTypeEvent($TypeName, $Event, $Parameters = array()) 68 68 { 69 if (array_key_exists($TypeName, $this->TypeDefinitionList))69 if (array_key_exists($TypeName, $this->TypeDefinitionList)) 70 70 { 71 71 $Type = $this->TypeDefinitionList[$TypeName]; 72 72 $TypeClass = 'Type'.$Type['Class']; 73 73 $TypeObject = new $TypeClass($this->FormManager); 74 if (is_callable(array($TypeObject, $Event))) return($TypeObject->$Event($Parameters));75 else return ($TypeName.'->'.$Event.'('.serialize($Parameters).')');76 } else return ($TypeName);74 if (is_callable(array($TypeObject, $Event))) return ($TypeObject->$Event($Parameters)); 75 else return ($TypeName.'->'.$Event.'('.serialize($Parameters).')'); 76 } else return ($TypeName); 77 77 } 78 78 79 79 function IsHidden($TypeName) 80 80 { 81 if (array_key_exists($TypeName, $this->TypeDefinitionList))81 if (array_key_exists($TypeName, $this->TypeDefinitionList)) 82 82 { 83 83 $Type = $this->TypeDefinitionList[$TypeName]; 84 84 $TypeClass = 'Type'.$Type['Class']; 85 85 $TypeObject = new $TypeClass($this->FormManager); 86 return ($TypeObject->Hidden);87 } else return (false);86 return ($TypeObject->Hidden); 87 } else return (false); 88 88 } 89 89 90 90 function RegisterType($Name, $ParentType, $Parameters) 91 91 { 92 if ($ParentType != '')92 if ($ParentType != '') 93 93 { 94 94 $Type = $this->TypeDefinitionList[$ParentType]; … … 97 97 $Type['Name'] = $Name; 98 98 $Type['Class'] = $Name; 99 if (array_key_exists('Parameters', $Type))99 if (array_key_exists('Parameters', $Type)) 100 100 $Type['Parameters'] = array_merge($Type['Parameters'], $Parameters); 101 101 else $Type['Parameters'] = $Parameters; … … 111 111 function GetTypeDefinition($TypeName) 112 112 { 113 return ($this->TypeDefinitionList[$TypeName]);113 return ($this->TypeDefinitionList[$TypeName]); 114 114 } 115 115 } -
trunk/Common/Global.php
r869 r873 25 25 26 26 $UnitIndex = 0; 27 while ($Value > 1024)27 while ($Value > 1024) 28 28 { 29 29 $Value = round($Value / 1024, 3); 30 30 $UnitIndex++; 31 31 } 32 return ($Value.' '.$UnitNames[$UnitIndex]);32 return ($Value.' '.$UnitNames[$UnitIndex]); 33 33 } 34 34 … … 48 48 function HumanDate($Time) 49 49 { 50 if ($Time != '') {50 if ($Time != '') { 51 51 $Date = explode(' ', $Time); 52 52 $Parts = explode('-', $Date[0]); 53 if ($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);54 else return (' ');55 } else return (' ');53 if ($Date != '0000-00-00') return (($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]); 54 else return (' '); 55 } else return (' '); 56 56 } 57 57 … … 62 62 $Around = 10; 63 63 $Result = ''; 64 if ($Count>1)65 { 66 if ($Page>0)64 if ($Count>1) 65 { 66 if ($Page>0) 67 67 { 68 68 $Result.= '<a href="'.$URL.'0"><<</a> '; … … 71 71 $PagesMax = $Count-1; 72 72 $PagesMin = 0; 73 if ($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;74 if ($PagesMin<($Page-$Around))73 if ($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around; 74 if ($PagesMin<($Page-$Around)) 75 75 { 76 76 $Result.= ' .. '; 77 77 $PagesMin = $Page-$Around; 78 78 } 79 for ($i=$PagesMin;$i<=$PagesMax;$i++)80 { 81 if ($i==$Page) $Result.= '<strong>';79 for ($i=$PagesMin;$i<=$PagesMax;$i++) 80 { 81 if ($i==$Page) $Result.= '<strong>'; 82 82 $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> '; 83 if ($i==$Page) $Result.= '</strong>';84 } 85 if ($PagesMax<($Count-1)) $Result .= ' .. ';86 if ($Page<($Count-1))83 if ($i==$Page) $Result.= '</strong>'; 84 } 85 if ($PagesMax<($Count-1)) $Result .= ' .. '; 86 if ($Page<($Count-1)) 87 87 { 88 88 $Result.= '<a href="'.$URL.($Page+1).'">></a> '; … … 90 90 } 91 91 } 92 return ($Result);92 return ($Result); 93 93 } 94 94 95 95 function ExtractTime($Time) 96 96 { 97 return (array(97 return (array( 98 98 'Year' => date('Y', $Time), 99 99 'Month' => date('n', $Time), … … 109 109 $Result = array(); 110 110 $Parts = explode('&', $QueryString); 111 foreach ($Parts as $Part)112 { 113 if ($Part != '')114 { 115 if (!strpos($Part, '=')) $Part .= '=';111 foreach ($Parts as $Part) 112 { 113 if ($Part != '') 114 { 115 if (!strpos($Part, '=')) $Part .= '='; 116 116 $Item = explode('=', $Part); 117 117 $Result[$Item[0]] = $Item[1]; 118 118 } 119 119 } 120 return ($Result);120 return ($Result); 121 121 } 122 122 … … 124 124 { 125 125 $Parts = array(); 126 foreach ($QueryStringArray as $Index => $Item)126 foreach ($QueryStringArray as $Index => $Item) 127 127 { 128 128 $Parts[] = $Index.'='.$Item; 129 129 } 130 return (implode('&', $Parts));130 return (implode('&', $Parts)); 131 131 } 132 132 … … 138 138 139 139 $Result = ''; 140 if (array_key_exists('all', $QueryItems))140 if (array_key_exists('all', $QueryItems)) 141 141 { 142 142 $PageCount = 1; … … 149 149 } 150 150 151 if (!array_key_exists($ObjectName.'Page', $_SESSION)) $_SESSION[$ObjectName.'Page'] = 0;152 if (array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName)) {153 if (array_key_exists('page', $_GET)) $_SESSION[$ObjectName.'Page'] = $_GET['page'] * 1;154 } 155 if ($_SESSION[$ObjectName.'Page'] < 0) $_SESSION[$ObjectName.'Page'] = 0;156 if ($_SESSION[$ObjectName.'Page'] >= $PageCount) $_SESSION[$ObjectName.'Page'] = $PageCount - 1;151 if (!array_key_exists($ObjectName.'Page', $_SESSION)) $_SESSION[$ObjectName.'Page'] = 0; 152 if (array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName)) { 153 if (array_key_exists('page', $_GET)) $_SESSION[$ObjectName.'Page'] = $_GET['page'] * 1; 154 } 155 if ($_SESSION[$ObjectName.'Page'] < 0) $_SESSION[$ObjectName.'Page'] = 0; 156 if ($_SESSION[$ObjectName.'Page'] >= $PageCount) $_SESSION[$ObjectName.'Page'] = $PageCount - 1; 157 157 $CurrentPage = $_SESSION[$ObjectName.'Page']; 158 158 … … 161 161 162 162 $Result = ''; 163 if ($PageCount > 1)164 { 165 if ($CurrentPage > 0)163 if ($PageCount > 1) 164 { 165 if ($CurrentPage > 0) 166 166 { 167 167 $QueryItems['page'] = 0; … … 172 172 $PagesMax = $PageCount - 1; 173 173 $PagesMin = 0; 174 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;175 if ($PagesMin < ($CurrentPage - $Around))174 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 175 if ($PagesMin < ($CurrentPage - $Around)) 176 176 { 177 177 $Result.= ' ... '; 178 178 $PagesMin = $CurrentPage - $Around; 179 179 } 180 for ($i = $PagesMin; $i <= $PagesMax; $i++)181 { 182 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';180 for ($i = $PagesMin; $i <= $PagesMax; $i++) 181 { 182 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 183 183 else { 184 184 $QueryItems['page'] = $i; … … 186 186 } 187 187 } 188 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';189 if ($CurrentPage < ($PageCount - 1))188 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 189 if ($CurrentPage < ($PageCount - 1)) 190 190 { 191 191 $QueryItems['page'] = ($CurrentPage + 1); … … 196 196 } 197 197 $QueryItems['all'] = '1'; 198 if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';198 if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 199 199 200 200 $Result = '<div style="text-align: center">'.$Result.'</div>'; 201 return (array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,201 return (array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 202 202 'Page' => $CurrentPage, 203 203 'Output' => $Result, … … 212 212 global $OrderDirSQL, $OrderArrowImage, $Config, $System; 213 213 214 if (array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName))215 { 216 if (array_key_exists('OrderCol', $_GET)) $_SESSION[$ObjectName.'OrderCol'] = $_GET['OrderCol'];217 if (array_key_exists('OrderDir', $_GET)) $_SESSION[$ObjectName.'OrderDir'] = $_GET['OrderDir'];218 } 219 if (!array_key_exists($ObjectName.'OrderCol', $_SESSION)) $_SESSION[$ObjectName.'OrderCol'] = $DefaultColumn;220 if (!array_key_exists($ObjectName.'OrderDir', $_SESSION) ) $_SESSION[$ObjectName.'OrderDir'] = $DefaultOrder;214 if (array_key_exists('ObjectName', $_GET) and ($_GET['ObjectName'] == $ObjectName)) 215 { 216 if (array_key_exists('OrderCol', $_GET)) $_SESSION[$ObjectName.'OrderCol'] = $_GET['OrderCol']; 217 if (array_key_exists('OrderDir', $_GET)) $_SESSION[$ObjectName.'OrderDir'] = $_GET['OrderDir']; 218 } 219 if (!array_key_exists($ObjectName.'OrderCol', $_SESSION)) $_SESSION[$ObjectName.'OrderCol'] = $DefaultColumn; 220 if (!array_key_exists($ObjectName.'OrderDir', $_SESSION) ) $_SESSION[$ObjectName.'OrderDir'] = $DefaultOrder; 221 221 222 222 // Check OrderCol 223 223 $Found = false; 224 foreach ($Columns as $Column)225 { 226 if ($Column['Name'] == $_SESSION[$ObjectName.'OrderCol'])224 foreach ($Columns as $Column) 225 { 226 if ($Column['Name'] == $_SESSION[$ObjectName.'OrderCol']) 227 227 { 228 228 $Found = true; … … 230 230 } 231 231 } 232 if (($_SESSION[$ObjectName.'OrderCol'] == '') or ($Found == false))232 if (($_SESSION[$ObjectName.'OrderCol'] == '') or ($Found == false)) 233 233 { 234 234 $_SESSION[$ObjectName.'OrderCol'] = $DefaultColumn; … … 236 236 } 237 237 // Check OrderDir 238 if (($_SESSION[$ObjectName.'OrderDir'] != 0) and ($_SESSION[$ObjectName.'OrderDir'] != 1))238 if (($_SESSION[$ObjectName.'OrderDir'] != 0) and ($_SESSION[$ObjectName.'OrderDir'] != 1)) 239 239 $_SESSION[$ObjectName.'OrderDir'] = 0; 240 240 241 241 $Result = ''; 242 242 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 243 foreach ($Columns as $Index => $Column)243 foreach ($Columns as $Index => $Column) 244 244 { 245 245 $QueryItems['ObjectName'] = $ObjectName; 246 246 $QueryItems['OrderCol'] = $Column['Name']; 247 247 $QueryItems['OrderDir'] = 1 - $_SESSION[$ObjectName.'OrderDir']; 248 if ($Column['Name'] == $_SESSION[$ObjectName.'OrderCol'])248 if ($Column['Name'] == $_SESSION[$ObjectName.'OrderCol']) 249 249 $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'. 250 250 $System->Link('/images/'.$OrderArrowImage[$_SESSION[$ObjectName.'OrderDir']]).'" alt="order arrow">'; 251 251 else $ArrowImage = ''; 252 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';252 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>'; 253 253 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>'; 254 254 } 255 return (array(255 return (array( 256 256 'SQL' => ' ORDER BY `'.$_SESSION[$ObjectName.'OrderCol'].'` '.$OrderDirSQL[$_SESSION[$ObjectName.'OrderDir']], 257 257 'Output' => '<tr>'.$Result.'</tr>', … … 263 263 function GetRemoteAddress() 264 264 { 265 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];265 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR']; 266 266 else $IP = '0.0.0.0'; 267 return ($IP);267 return ($IP); 268 268 } 269 269 … … 274 274 $Result = true; 275 275 $RemoteAddr = GetRemoteAddress(); 276 foreach ($Config['Web']['IntranetSubnets'] as $Subnet)277 { 278 if (substr($RemoteAddr, 0, strlen($Subnet)) == $Subnet)276 foreach ($Config['Web']['IntranetSubnets'] as $Subnet) 277 { 278 if (substr($RemoteAddr, 0, strlen($Subnet)) == $Subnet) 279 279 { 280 280 $Result = false; … … 282 282 } 283 283 } 284 return ($Result);284 return ($Result); 285 285 } 286 286 … … 292 292 '(SELECT `Member` FROM `NetworkDevice` WHERE (SELECT `Device` FROM `NetworkInterface` '. 293 293 'WHERE `LocalIP` = "'.$IP.'") = `NetworkDevice`.`Id`) = `Member`.`Id`'); 294 if ($DbResult->num_rows > 0)294 if ($DbResult->num_rows > 0) 295 295 { 296 296 $DbRow = $DbResult->fetch_assoc(); 297 return ($DbRow['Id']);298 } else return ('');297 return ($DbRow['Id']); 298 } else return (''); 299 299 } 300 300 … … 302 302 { 303 303 $Result = shell_exec('which '.$Command); 304 return (!empty($Result));304 return (!empty($Result)); 305 305 } 306 306 307 307 function RemoveDiacritic($Text) 308 308 { 309 return (str_replace(309 return (str_replace( 310 310 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 311 311 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'), … … 317 317 function RouterOSIdent($Name) 318 318 { 319 return (strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-',319 return (strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-', 320 320 'č' => 'c', 'š' => 's', 'ě' => 'e', 'ř' => 'r', 'ž' => 'z', 'ý' => 'y', 321 321 'á' => 'a', 'í' => 'i', 'é' => 'e', 'ů' => 'u', 'ú' => 'u', 'ď' => 'd', … … 329 329 function NotBlank($Text) 330 330 { 331 if ($Text == '') return(' ');332 else return ($Text);331 if ($Text == '') return (' '); 332 else return ($Text); 333 333 } 334 334 … … 352 352 function ProcessURL() 353 353 { 354 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))354 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) 355 355 $PathString = $_SERVER['REDIRECT_QUERY_STRING']; 356 356 else $PathString = ''; 357 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);357 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1); 358 358 $PathItems = explode('/', $PathString); 359 if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))359 if (array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false)) 360 360 $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1); 361 361 else $_SERVER['QUERY_STRING'] = ''; 362 362 parse_str($_SERVER['QUERY_STRING'], $_GET); 363 return ($PathItems);363 return ($PathItems); 364 364 } 365 365 366 366 function RepeatFunction($Period, $Callback) 367 367 { 368 while (1)368 while (1) 369 369 { 370 370 $StartTime = time(); … … 372 372 $EndTime = time(); 373 373 $Delay = $Period - ($EndTime - $StartTime); 374 if ($Delay < 0) $Delay = 0;374 if ($Delay < 0) $Delay = 0; 375 375 376 376 echo('Waiting remaining '.$Delay.' of '.$Period.' seconds period...'."\n"); -
trunk/Common/VCL/Database.php
r738 r873 28 28 29 29 $ColumnSQL = array(); 30 foreach ($this->Columns as $Column)30 foreach ($this->Columns as $Column) 31 31 { 32 32 $ColumnSQL[] = $Column->Name; … … 35 35 36 36 // Get total filtered item count in database 37 if ($this->Filter != '')37 if ($this->Filter != '') 38 38 { 39 39 $Query = 'SELECT COUNT(*) FROM (SELECT '.$ColumnSQL.' FROM '.$this->SQL.') AS `TS` '.$this->Filter; … … 46 46 $this->Rows = array(); 47 47 $VisibleItemCount = 0; 48 if (($this->SortOrder != 0) and ($this->SortOrder != 1)) $this->SortOrder = 0;49 //if ($this->SortColumn)48 if (($this->SortOrder != 0) and ($this->SortOrder != 1)) $this->SortOrder = 0; 49 //if ($this->SortColumn) 50 50 $this->SortColumn = $this->Columns[0]->Name; 51 51 $this->OrderSQL = ' ORDER BY `'.$this->SortColumn.'` '.$this->OrderDirSQL[$this->SortOrder]; … … 54 54 $this->Filter.' '.$this->OrderSQL.$SQLLimit; 55 55 $DbResult = $this->Database->query($Query); 56 while ($DbRow = $DbResult->fetch_assoc())56 while ($DbRow = $DbResult->fetch_assoc()) 57 57 { 58 if (method_exists($this->OnRowDraw[0], $this->OnRowDraw[1]))58 if (method_exists($this->OnRowDraw[0], $this->OnRowDraw[1])) 59 59 $DbRow = call_user_func($this->OnRowDraw, $DbRow); 60 60 $this->Rows[] = $DbRow; … … 62 62 } 63 63 $Row = '<td colspan="'.count($this->Columns).'" style="text-align: right;">Zobrazeno <strong>'.$VisibleItemCount.'</strong>'; 64 if ($this->Filter != '') $Row .= ' z filtrovaných <strong>'.$TotalFilteredCount.'</strong>';64 if ($this->Filter != '') $Row .= ' z filtrovaných <strong>'.$TotalFilteredCount.'</strong>'; 65 65 $Row .= ' z celkem <strong>'.$TotalCount.'</strong>'; 66 66 $ListView->Rows[] = $Row; 67 67 $Output = parent::Show(); 68 return ($Output);68 return ($Output); 69 69 } 70 70 } -
trunk/Common/VCL/General.php
r693 r873 8 8 //echo($Name.','); 9 9 $Result = ''; 10 if ($Persistent)11 if (array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name];12 if (array_key_exists($Name, $_GET))10 if ($Persistent) 11 if (array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name]; 12 if (array_key_exists($Name, $_GET)) 13 13 { 14 14 $Result = $_GET[$Name]; 15 if ($Persistent) $_SESSION[$Name] = $Result;16 } 17 return ($Result);15 if ($Persistent) $_SESSION[$Name] = $Result; 16 } 17 return ($Result); 18 18 } 19 19 … … 34 34 $Output = ''; 35 35 //$Output .= '#'.$this->Id; 36 return ($Output);36 return ($Output); 37 37 } 38 38 … … 48 48 function Show() 49 49 { 50 if ($this->Visible)50 if ($this->Visible) 51 51 { 52 52 $Output = parent::Show(); 53 foreach ($this->Items as $Item)53 foreach ($this->Items as $Item) 54 54 $Output .= $Item->Show(); 55 return ($Output);56 } 57 } 58 59 function Prepare() 60 { 61 foreach ($this->Items as $Item)55 return ($Output); 56 } 57 } 58 59 function Prepare() 60 { 61 foreach ($this->Items as $Item) 62 62 $Item->Prepare(); 63 63 } … … 70 70 function Show() 71 71 { 72 if ($this->Visible)73 { 74 return (parent::Show().'<button>'.$this->Caption.'</button>');72 if ($this->Visible) 73 { 74 return (parent::Show().'<button>'.$this->Caption.'</button>'); 75 75 } 76 76 } … … 83 83 function Show() 84 84 { 85 return (parent::Show().'<input type="text" name="'.$this->Id.'" value="'.$this->Text.'"/>');85 return (parent::Show().'<input type="text" name="'.$this->Id.'" value="'.$this->Text.'"/>'); 86 86 } 87 87 … … 108 108 function Show() 109 109 { 110 if (array_key_exists($this->Id.'_Page', $_GET))110 if (array_key_exists($this->Id.'_Page', $_GET)) 111 111 $this->Position = $_GET[$this->Id.'_Page']; 112 if ($this->Position >= $this->Count) $this->Position = $this->Count / $this->PageSize - 1;112 if ($this->Position >= $this->Count) $this->Position = $this->Count / $this->PageSize - 1; 113 113 $Output = ''; 114 for ($I = 0; $I < $this->Count / $this->PageSize; $I++)114 for ($I = 0; $I < $this->Count / $this->PageSize; $I++) 115 115 { 116 116 $Text = '<a href="?'.$this->Id.'_Page='.$I.'">'.$I.'</a> '; 117 if ($I == $this->Position) $Text = '<strong>'.$Text.'</strong>';117 if ($I == $this->Position) $Text = '<strong>'.$Text.'</strong>'; 118 118 $Output .= $Text; 119 119 } 120 120 $Output .= '<br/>'; 121 return ($Output);121 return ($Output); 122 122 } 123 123 … … 134 134 function Show() 135 135 { 136 return ($this->Name);136 return ($this->Name); 137 137 } 138 138 } … … 155 155 { 156 156 $Output = '<table class="WideTable" style="font-size: small;><tr>'; 157 foreach ($this->Columns as $Column)158 { 159 if ($this->OnColumnDraw != '') $Text = call_user_func($this->OnColumnDraw, $Column);157 foreach ($this->Columns as $Column) 158 { 159 if ($this->OnColumnDraw != '') $Text = call_user_func($this->OnColumnDraw, $Column); 160 160 else $Text = $Column->Show(); 161 161 $Output .= '<th>'.$Text.'</th>'; 162 162 } 163 163 $Output .= '</tr>'; 164 foreach ($this->Rows as $Row)164 foreach ($this->Rows as $Row) 165 165 { 166 166 $Output .= '<tr>'; 167 foreach ($Row as $Value)167 foreach ($Row as $Value) 168 168 $Output .= '<td>'.$Value.'</td>'; 169 169 $Output .= '</tr>'; 170 170 } 171 171 $Output .= '</table>'; 172 return ($Output);172 return ($Output); 173 173 } 174 174 } … … 192 192 function ColumnClick($Column) 193 193 { 194 return ('?'.$this->Id.'_SortColumn='.$Column->Id.'&'.$this->Id.'_SortOrder='.(1 - $this->SortOrder));194 return ('?'.$this->Id.'_SortColumn='.$Column->Id.'&'.$this->Id.'_SortOrder='.(1 - $this->SortOrder)); 195 195 } 196 196 … … 201 201 $Output = $Column->Show(); 202 202 203 if ($Column->Name == $this->SortColumn)203 if ($Column->Name == $this->SortColumn) 204 204 { 205 205 $Output .= '<img style="vertical-align: middle; border: 0px;" src="'. 206 206 $System->Link('/images/'.$this->OrderArrowImage[$this->SortOrder]).'" alt="order arrow">'; 207 207 } 208 if ($this->OnColumnClick != '')208 if ($this->OnColumnClick != '') 209 209 $Output = '<a href="'.call_user_func($this->OnColumnClick, $Column).'">'.$Output.'</a>'; 210 return ($Output);210 return ($Output); 211 211 } 212 212 … … 219 219 $Output .= parent::Show(); 220 220 $Output .= $this->PageSelect->Show(); 221 return ($Output);221 return ($Output); 222 222 } 223 223 … … 239 239 { 240 240 $Output .= '<table>'; 241 foreach ($this->Rows as $RowNum => $Row)241 foreach ($this->Rows as $RowNum => $Row) 242 242 { 243 243 $Output .= '<tr>'; 244 foreach ($Row as $ColNum => $Value)244 foreach ($Row as $ColNum => $Value) 245 245 { 246 if ($this->Span[$RowNum][$ColNum] != 1) $Span = ' colspan="'.$this->Span[$RowNum][$ColNum].'"';246 if ($this->Span[$RowNum][$ColNum] != 1) $Span = ' colspan="'.$this->Span[$RowNum][$ColNum].'"'; 247 247 else $Span = ''; 248 248 $Output .= '<td'.$Span.'>'.$Value->Show().'</td>'; … … 251 251 } 252 252 $Output .= '</table>'; 253 return ($Output);254 } 255 256 function Prepare() 257 { 258 foreach ($this->Rows as $RowNum => $Row)259 { 260 foreach ($Row as $ColNum => $Value)253 return ($Output); 254 } 255 256 function Prepare() 257 { 258 foreach ($this->Rows as $RowNum => $Row) 259 { 260 foreach ($Row as $ColNum => $Value) 261 261 { 262 262 $Value->Prepare(); … … 274 274 { 275 275 $Output = $this->Caption; 276 if (method_exists($this->OnExecute[0], $this->OnExecute[1]))276 if (method_exists($this->OnExecute[0], $this->OnExecute[1])) 277 277 { 278 278 $Link = 'O='.$this->Id.'&M=Execute'; 279 279 $Output = '<a href="?'.$Link.'">'.$Output.'</a>'; 280 280 }; 281 return ($Output);281 return ($Output); 282 282 } 283 283 … … 286 286 $Object = ReadSessionVar('O', false); 287 287 $Method = ReadSessionVar('M', false); 288 if (($Object == $this->Id) and ($Method == 'Execute'))288 if (($Object == $this->Id) and ($Method == 'Execute')) 289 289 call_user_func($this->OnExecute, $this); 290 290 } … … 298 298 { 299 299 $Output = '<!DOCTYPE html><html><head></head><body>'; 300 foreach ($this->Items as $Item)300 foreach ($this->Items as $Item) 301 301 $Output .= $Item->Show(); 302 302 $Output .= '</body></html>'; 303 return ($Output);304 } 305 306 function Prepare() 307 { 308 foreach ($this->Items as $Item)303 return ($Output); 304 } 305 306 function Prepare() 307 { 308 foreach ($this->Items as $Item) 309 309 $Item->Prepare(); 310 310 } -
trunk/Modules/API/API.php
r804 r873 47 47 { 48 48 // p - token 49 if (array_key_exists('p', $_GET)) {49 if (array_key_exists('p', $_GET)) { 50 50 $Token = $_GET['p']; 51 51 $DbResult = $this->Database->query('SELECT `User` FROM `APIToken` WHERE `Token`="'.$Token.'"'); 52 if ($DbResult->num_rows > 0)52 if ($DbResult->num_rows > 0) 53 53 { 54 54 $DbRow = $DbResult->fetch_assoc(); … … 57 57 } else die('Missing access token'); 58 58 // f - data format 59 if (array_key_exists('f', $_GET)) $this->DataFormat = $_GET['f'];59 if (array_key_exists('f', $_GET)) $this->DataFormat = $_GET['f']; 60 60 else $this->DataFormat = 'php'; 61 61 // a - action 62 if (array_key_exists('a', $_GET)) $Action = $_GET['a'];62 if (array_key_exists('a', $_GET)) $Action = $_GET['a']; 63 63 else $Action = ''; 64 64 // t - table 65 if (array_key_exists('t', $_GET)) $Table = $_GET['t'];65 if (array_key_exists('t', $_GET)) $Table = $_GET['t']; 66 66 else $Table = ''; 67 67 // i - index of item 68 if (array_key_exists('i', $_GET)) $ItemId = $_GET['i'];68 if (array_key_exists('i', $_GET)) $ItemId = $_GET['i']; 69 69 else $ItemId = 0; 70 70 71 if ($Action == 'list') $Output = $this->ShowList($Table, $ItemId);71 if ($Action == 'list') $Output = $this->ShowList($Table, $ItemId); 72 72 else $Output = 'Unsupported action'; 73 73 74 return ($Output);74 return ($Output); 75 75 } 76 76 77 77 function ShowList($Table, $ItemId) 78 78 { 79 if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))79 if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes))) 80 80 $FormClass = $this->System->FormManager->Classes[$Table]; 81 else return ('Table not found');81 else return ('Table not found'); 82 82 83 if (array_key_exists('SQL', $FormClass))83 if (array_key_exists('SQL', $FormClass)) 84 84 $SourceTable = '('.$FormClass['SQL'].') AS `TX`'; 85 85 else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`'; 86 86 87 87 $Filter = ''; 88 if ($ItemId != 0)88 if ($ItemId != 0) 89 89 { 90 90 $Filter .= '`Id`='.$ItemId; 91 91 } 92 if ($Filter != '') $Filter = ' WHERE '.$Filter;92 if ($Filter != '') $Filter = ' WHERE '.$Filter; 93 93 94 94 $Result = array(); 95 95 $DbResult = $this->Database->query('SELECT * FROM '.$SourceTable.$Filter); 96 while ($DbRow = $DbResult->fetch_assoc())96 while ($DbRow = $DbResult->fetch_assoc()) 97 97 { 98 98 $Result[] = $DbRow; 99 99 } 100 if ($this->DataFormat == 'php') $Output = serialize($Result);101 else if ($this->DataFormat == 'xml') $Output = $this->array2xml($Result);102 else if ($this->DataFormat == 'json') $Output = json_encode($Result);100 if ($this->DataFormat == 'php') $Output = serialize($Result); 101 else if ($this->DataFormat == 'xml') $Output = $this->array2xml($Result); 102 else if ($this->DataFormat == 'json') $Output = json_encode($Result); 103 103 else die('Unknown data format '.$this->DataFormat); 104 return ($Output);104 return ($Output); 105 105 } 106 106 … … 114 114 $array2xml = function ($node, $array) use ($dom, &$array2xml) 115 115 { 116 foreach ($array as $key => $value)116 foreach ($array as $key => $value) 117 117 { 118 118 if ( is_array($value) ) 119 119 { 120 if (is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric');120 if (is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric'); 121 121 $n = $dom->createElement($key); 122 122 $node->appendChild($n); 123 123 $array2xml($n, $value); 124 124 } else { 125 if (is_numeric($key)) $key = 'N'.$key; //die('XML attribute name "'.$key.'" can\'t be numeric');125 if (is_numeric($key)) $key = 'N'.$key; //die('XML attribute name "'.$key.'" can\'t be numeric'); 126 126 $attr = $dom->createAttribute($key); 127 127 $attr->value = $value; -
trunk/Modules/Chat/Chat.php
r790 r873 14 14 { 15 15 $Num = dechex($Num); 16 return (substr($Num, 4, 2).substr($Num, 2, 2).substr($Num, 0, 2));16 return (substr($Num, 4, 2).substr($Num, 2, 2).substr($Num, 0, 2)); 17 17 } 18 18 … … 21 21 global $MonthNames; 22 22 23 if (!$this->System->User->CheckPermission('Chat', 'Display')) return('Nemáte oprávnění');23 if (!$this->System->User->CheckPermission('Chat', 'Display')) return ('Nemáte oprávnění'); 24 24 25 if (array_key_exists('date', $_GET)) $Date = $_GET['date'];25 if (array_key_exists('date', $_GET)) $Date = $_GET['date']; 26 26 else $Date = date('Y-m-d'); 27 27 $DateParts = explode('-', $Date); … … 35 35 $EndDateParts = explode('-', $EndDateTimeParts[0]); 36 36 37 if (!array_key_exists('year', $_SESSION)) $_SESSION['year'] = date('Y', time());38 if (array_key_exists('year', $_GET)) $_SESSION['year'] = addslashes($_GET['year']);37 if (!array_key_exists('year', $_SESSION)) $_SESSION['year'] = date('Y', time()); 38 if (array_key_exists('year', $_GET)) $_SESSION['year'] = addslashes($_GET['year']); 39 39 40 if (!array_key_exists('month', $_SESSION)) $_SESSION['month'] = date('n', time());41 if (array_key_exists('month', $_GET)) $_SESSION['month'] = addslashes($_GET['month']);40 if (!array_key_exists('month', $_SESSION)) $_SESSION['month'] = date('n', time()); 41 if (array_key_exists('month', $_GET)) $_SESSION['month'] = addslashes($_GET['month']); 42 42 43 43 $Output = '<div class="ChatHistory">'; 44 for ($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--)44 for ($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--) 45 45 { 46 if ($_SESSION['year'] == $Year)46 if ($_SESSION['year'] == $Year) 47 47 { 48 48 $Output .= '<div class="Year">'.$Year.'<div class="YearContent">'; 49 if ($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1] + 0); else $StartMonth = 1;50 if ($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1] + 0); else $EndMonth = 12;51 for ($Month = $EndMonth; $Month >= $StartMonth; $Month--)49 if ($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1] + 0); else $StartMonth = 1; 50 if ($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1] + 0); else $EndMonth = 12; 51 for ($Month = $EndMonth; $Month >= $StartMonth; $Month--) 52 52 { 53 if ($_SESSION['month'] == $Month)53 if ($_SESSION['month'] == $Month) 54 54 { 55 55 $Output .= '<div class="Months">'.$MonthNames[$Month].'<span>'; 56 if (($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1;57 if (($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year));58 for ($Day = $StartDay; $Day <= $EndDay; $Day++)56 if (($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1; 57 if (($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year)); 58 for ($Day = $StartDay; $Day <= $EndDay; $Day++) 59 59 { 60 60 $Text = '<a href="?date='.$Year.'-'.$Month.'-'.$Day.'">'.$Day.'</a> '; 61 if (($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong>'.$Text.'</strong>';61 if (($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong>'.$Text.'</strong>'; 62 62 $Output .= $Text; 63 63 } … … 72 72 $DbResult = $this->Database->select('ChatHistory', 'Nick, Color, Text, UNIX_TIMESTAMP(Time)', "RoomType = 0 AND Time > '".$Date." 00:00:00' AND Time < '".$Date." 23:59:59' ORDER BY Time DESC"); 73 73 $Output .= '<div class="ChatHistoryText">'; 74 if ($DbResult->num_rows > 0)75 while ($Row = $DbResult->fetch_array())74 if ($DbResult->num_rows > 0) 75 while ($Row = $DbResult->fetch_array()) 76 76 { 77 77 $Text = $Row['Text'];; … … 81 81 else $Output .= 'V daném dni nebyly zaznamenány žádné zprávy.'; 82 82 $Output .= '</div>'; 83 return ($Output);83 return ($Output); 84 84 } 85 85 } -
trunk/Modules/Chat/irc_bot.php
r738 r873 30 30 function Say($Message, $Recipient = '') 31 31 { 32 if ($Recipient == '') $Recipient = $this->Channel;32 if ($Recipient == '') $Recipient = $this->Channel; 33 33 $this->Command(': PRIVMSG '.$Recipient.' :'.$Message); 34 34 } … … 43 43 global $Database; 44 44 45 while (!fwrite($this->File, ''))45 while (!fwrite($this->File, '')) 46 46 { 47 47 $this->Command('JOIN '.$this->Channel); … … 51 51 52 52 $LineParts = explode(' ', $Line); 53 if (count($LineParts) > 0)53 if (count($LineParts) > 0) 54 54 { 55 if ($LineParts[0] == 'PING')55 if ($LineParts[0] == 'PING') 56 56 { 57 57 $this->Command('PONG '.trim($LineParts[1])."\n"); … … 59 59 } 60 60 61 if (count($LineParts) > 1)62 { 63 if ((trim($LineParts[1]) == 'INVITE') && (substr(trim($LineParts[3]), 0, 2) == ':#'))61 if (count($LineParts) > 1) 62 { 63 if ((trim($LineParts[1]) == 'INVITE') && (substr(trim($LineParts[3]), 0, 2) == ':#')) 64 64 { 65 65 $CurrentChannel = substr(trim($LineParts[3]), 1); … … 78 78 79 79 // Log messages to database 80 if (strpos($Line, 'PRIVMSG') !== false)80 if (strpos($Line, 'PRIVMSG') !== false) 81 81 { 82 82 $Text = addslashes($Commands[2]); … … 91 91 92 92 explode(':', $Line); 93 foreach ($Commands as $Index => $Item)93 foreach ($Commands as $Index => $Item) 94 94 $Commands[$Index] = trim($Item); 95 95 96 if (count($Commands) >= 2)96 if (count($Commands) >= 2) 97 97 { 98 98 $Command = $Commands[2]; 99 99 100 100 // Jméno - Pošle vizitku 101 if ($Command == $this->Nick)101 if ($Command == $this->Nick) 102 102 { 103 103 $this->Say('Ahoj lidi, ja jsem '.$this->OwnerName.' bot. Random#: '.rand(0, 10)); … … 106 106 107 107 // hhelp - vypise tuto napovedu 108 if ($Command == 'hhelp')108 if ($Command == 'hhelp') 109 109 { 110 110 $this->Say('Ja jsem Harvester.'); … … 124 124 125 125 // hsay:Message - Posle zpravu 126 if ($Command == 'hsay')126 if ($Command == 'hsay') 127 127 { 128 128 $this->Say($Commands[3]); … … 131 131 132 132 // hpsay:to:Message - Posle soukromou zpravu kanalu nebo osobe 133 if ($Command == 'hpsay')133 if ($Command == 'hpsay') 134 134 { 135 135 $this->Say($Commands[4], $Commands[3]); … … 138 138 139 139 // hcol:to:Message - Posle kolizni zpravu kanalu nebo osobe 140 if ($Command == 'hcol')140 if ($Command == 'hcol') 141 141 { 142 142 $this->Say($Commands[4], $Commands[3]); … … 145 145 146 146 // hdo:Command - Posle serveru prikaz 147 if ($Command == 'hdo')147 if ($Command == 'hdo') 148 148 { 149 149 $hdo = explode('hdo:', $Line); … … 153 153 154 154 // hpart:Channel - Odpoji se z kanalu 155 if ($Command == 'hpart')155 if ($Command == 'hpart') 156 156 { 157 157 $hdo = explode('hpart:', $Line); 158 if (trim($hdo[1]) != trim($this->Channel))158 if (trim($hdo[1]) != trim($this->Channel)) 159 159 { 160 160 $this->Command('PART :'.trim($hdo[1])."\n"); … … 164 164 165 165 // hmove:Channel - Zmeni aktivni kanal 166 if ($Command == 'hmove')166 if ($Command == 'hmove') 167 167 { 168 168 $hdo = explode("hmove:", $Line); 169 if (trim($hdo[1]) != trim($$this->Cannel))169 if (trim($hdo[1]) != trim($$this->Cannel)) 170 170 { 171 171 $this->Channel = trim($hdo[1]); … … 177 177 178 178 // htime - udaje o casu 179 if ($Command == 'htime')179 if ($Command == 'htime') 180 180 { 181 181 $Date = implode("-", getdate(time())); … … 185 185 186 186 // hjoke - Posle nahodny vtip 187 if ($Command == 'hjoke')187 if ($Command == 'hjoke') 188 188 { 189 189 $Joke = ($this->Jokes[rand(0, (sizeof($this->Jokes) - 1))]); -
trunk/Modules/Customer/Customer.php
r871 r873 201 201 $Output .= ' platících:'.$DbRow['0'].'<br/>'; 202 202 203 return ($Output);203 return ($Output); 204 204 } 205 205 -
trunk/Modules/EmailQueue/EmailQueue.php
r738 r873 11 11 $Output = $this->System->ModuleManager->Modules['EmailQueue']->Process(); 12 12 $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány').$Output; 13 return ($Output);13 return ($Output); 14 14 } 15 15 } … … 79 79 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 80 80 'From' => $From); 81 if ($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId;81 if ($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId; 82 82 $this->Database->insert('EmailQueue', $Values); 83 83 } … … 87 87 $Output = ''; 88 88 $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0'); 89 while ($DbRow = $DbResult->fetch_assoc())89 while ($DbRow = $DbResult->fetch_assoc()) 90 90 { 91 91 $Mail = new Mail(); … … 95 95 $Mail->AddBody(strip_tags($DbRow['Content']), 'text/plain'); 96 96 $Mail->AddBody($DbRow['Content'], 'text/html'); 97 if ($DbRow['AttachmentFile'] != '')97 if ($DbRow['AttachmentFile'] != '') 98 98 { 99 99 $DbResult2 = $this->Database->select('File', '*', 'Id='.$DbRow['AttachmentFile']); 100 while ($File = $DbResult2->fetch_assoc())100 while ($File = $DbResult2->fetch_assoc()) 101 101 $Mail->AttachFile($this->Config['Web']['FileRootFolder'].$File['DrivePath'], $File['MimeType']); 102 102 } … … 106 106 $Output .= 'To: '.$DbRow['To'].' Subject: '.$DbRow['Subject'].'<br />'; 107 107 } 108 return ($Output);108 return ($Output); 109 109 } 110 110 } -
trunk/Modules/Error/Error.php
r784 r873 45 45 $this->System->ModuleManager->Modules['Log']->NewRecord('Error', 'Log', $Error); 46 46 47 //if ($Config['Web']['ErrorLogFile'] != '')47 //if ($Config['Web']['ErrorLogFile'] != '') 48 48 // error_log($Error, 3, $Config['Web']['ErrorLogFile']); 49 49 // Pošli mi zprávu (pokud je to kritická chyba) 50 50 //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error); 51 51 // Show error message 52 if ($this->ErrorHandler->ShowError == true)52 if ($this->ErrorHandler->ShowError == true) 53 53 { 54 if (array_key_exists('REMOTE_ADDR', $_SERVER))54 if (array_key_exists('REMOTE_ADDR', $_SERVER)) 55 55 { 56 56 echo('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n". -
trunk/Modules/File/File.php
r738 r873 16 16 { 17 17 $DbResult = $this->Database->select('File', 'Name', 'Id='.$Id); 18 if ($DbResult->num_rows > 0)18 if ($DbResult->num_rows > 0) 19 19 { 20 20 $DbRow = $DbResult->fetch_assoc(); … … 28 28 // Submited form with file input have to be enctype="multipart/form-data" 29 29 $Result = 0; 30 if (array_key_exists($Name, $_FILES) and ($_FILES[$Name]['name'] != ''))30 if (array_key_exists($Name, $_FILES) and ($_FILES[$Name]['name'] != '')) 31 31 { 32 if (file_exists($_FILES[$Name]['tmp_name']))32 if (file_exists($_FILES[$Name]['tmp_name'])) 33 33 { 34 34 $FileName = substr($_FILES[$Name]['name'], strrpos($_FILES[$Name]['name'], '/')); 35 35 $this->Database->query('INSERT INTO File (`Name`, `Size`) VALUES ("'.$FileName.'", '.filesize($_FILES[$Name]['tmp_name']).')'); 36 36 $InsertId = $this->Database->insert_id; 37 if (move_uploaded_file($_FILES[$Name]['tmp_name'], $this->FilesDir.'/'.$InsertId.'_'.$FileName)) $Result = $InsertId;37 if (move_uploaded_file($_FILES[$Name]['tmp_name'], $this->FilesDir.'/'.$InsertId.'_'.$FileName)) $Result = $InsertId; 38 38 } 39 39 } 40 return ($Result);40 return ($Result); 41 41 } 42 42 … … 46 46 47 47 $Result = $MimeTypes[pathinfo($FileName, PATHINFO_EXTENSION)][0]; 48 return ($Result);48 return ($Result); 49 49 } 50 50 … … 52 52 { 53 53 $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id)); 54 if ($DbResult->num_rows > 0)54 if ($DbResult->num_rows > 0) 55 55 { 56 56 $DbRow = $DbResult->fetch_assoc(); 57 if ($DbRow['Directory'] != '') $FileName = $this->GetDir($DbRow['Directory']);57 if ($DbRow['Directory'] != '') $FileName = $this->GetDir($DbRow['Directory']); 58 58 else $FileName = $this->FilesDir; 59 59 $FileName .= $DbRow['Name']; 60 if (file_exists($FileName))60 if (file_exists($FileName)) 61 61 { 62 62 Header('Content-Type: '.$this->DetectMimeType($FileName)); … … 71 71 $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$Id); 72 72 $DbRow = $DbResult->fetch_assoc(); 73 if ($DbRow['Parent'] != '') $Result = $this->GetDir($DbRow['Parent']);73 if ($DbRow['Parent'] != '') $Result = $this->GetDir($DbRow['Parent']); 74 74 else $Result = $this->FilesDir; 75 75 $Result .= $DbRow['Name'].'/'; 76 return ($Result);76 return ($Result); 77 77 } 78 78 } … … 83 83 function Show() 84 84 { 85 if (array_key_exists('id', $_GET)) $Id = $_GET['id'];86 else if (array_key_exists('i', $_GET)) $Id = $_GET['i'];87 else return ($this->SystemMessage('Chyba', 'Nezadáno id souboru'));85 if (array_key_exists('id', $_GET)) $Id = $_GET['id']; 86 else if (array_key_exists('i', $_GET)) $Id = $_GET['i']; 87 else return ($this->SystemMessage('Chyba', 'Nezadáno id souboru')); 88 88 $this->ClearPage = true; 89 89 $Output = $this->System->Modules['File']->Download($Id); 90 return ($Output);90 return ($Output); 91 91 } 92 92 } -
trunk/Modules/Finance/Bill.php
r748 r873 8 8 function GenerateHTML() 9 9 { 10 return ('');10 return (''); 11 11 } 12 12 … … 22 22 { 23 23 $Encoding = new Encoding(); 24 if ($this->Checked == false) {25 if (CommandExist('htmldoc')) {24 if ($this->Checked == false) { 25 if (CommandExist('htmldoc')) { 26 26 $this->Checked = true; 27 27 } else throw new Exception('htmldoc is not installed.'); … … 29 29 $Output = shell_exec('echo "'.addslashes($Encoding->FromUTF8($HtmlCode)). 30 30 '"|htmldoc --no-numbered --webpage --no-embedfonts --charset 8859-2 -t pdf -'); 31 return ($Output);31 return ($Output); 32 32 } 33 33 } … … 43 43 $Subject['AddressStreet'].'<br>'. 44 44 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; 45 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';46 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';47 if ($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>';48 if ($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>';49 return ($Output);45 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>'; 46 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>'; 47 if ($Subject['Account'] != '') $Output .= 'Účet: '.$Subject['Account'].'<br>'; 48 if ($Subject['PayVAT'] != '') $Output .= 'Plátce DPH: '.$BooleanText[$Subject['PayVAT']].'<br>'; 49 return ($Output); 50 50 } 51 51 … … 78 78 $InvoiceItems = array(); 79 79 $DbResult = $this->Database->select('FinanceInvoiceItem', '*, ROUND(`Price` * `Quantity`, '.$Finance->Rounding.') AS `Total`', '`FinanceInvoice`='.$this->InvoiceId); 80 while ($Item = $DbResult->fetch_assoc())80 while ($Item = $DbResult->fetch_assoc()) 81 81 { 82 82 $InvoiceItems[$Item['Id']] = $Item; … … 84 84 85 85 // If direction is in => switch sides 86 if ($Invoice['Direction'] == FINANCE_DIRECTION_OUT)87 { 88 } 89 else if ($Invoice['Direction'] == FINANCE_DIRECTION_IN)86 if ($Invoice['Direction'] == FINANCE_DIRECTION_OUT) 87 { 88 } 89 else if ($Invoice['Direction'] == FINANCE_DIRECTION_IN) 90 90 { 91 91 $Subject = $SubjectTo; … … 121 121 'Datum zdanitel. plnění: '.HumanDate($Invoice['Time']).'<br>'. 122 122 'Datum splatnosti: '.HumanDate($Invoice['TimeDue']).'<br>'; 123 if (($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != ''))123 if (($Invoice['PeriodFrom'] != '') and ($Invoice['PeriodTo'] != '')) 124 124 $Output .= 'Fakturované období: '.HumanDate($Invoice['PeriodFrom']).' - '. 125 125 HumanDate($Invoice['PeriodTo']).'<br>'; … … 133 133 134 134 $Total = 0; 135 foreach ($InvoiceItems as $Item)135 foreach ($InvoiceItems as $Item) 136 136 { 137 137 $Output .= '<tr><td>'.$Item['Description'].'</td><td align="right">'. … … 146 146 '</table>'; 147 147 148 return ($Output);148 return ($Output); 149 149 } 150 150 } … … 174 174 175 175 $BooleanText = array('Ne', 'Ano'); 176 if ($Operation['Direction'] == FINANCE_DIRECTION_OUT)176 if ($Operation['Direction'] == FINANCE_DIRECTION_OUT) 177 177 $Desc = array( 178 178 'Type' => 'VÝDAJOVÝ', … … 180 180 'Target' => 'Vydáno komu', 181 181 ); 182 else if ($Operation['Direction'] == FINANCE_DIRECTION_IN)182 else if ($Operation['Direction'] == FINANCE_DIRECTION_IN) 183 183 $Desc = array( 184 184 'Type' => 'PŘÍJMOVÝ', … … 206 206 $Subject['AddressStreet'].'<br>'. 207 207 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; 208 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>';209 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>';208 if ($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>'; 209 if ($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>'; 210 210 $Description = $Operation['Text']; 211 211 $Output .= '</td></tr>'. … … 215 215 '<tr><td> </td><td><br><br>'.$Desc['Signature'].':</td></tr>'; 216 216 $Output .= '</table>'; 217 return ($Output);217 return ($Output); 218 218 } 219 219 } -
trunk/Modules/Finance/Finance.php
r866 r873 44 44 { 45 45 $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`'); 46 while ($BillingPeriod = $DbResult->fetch_assoc())46 while ($BillingPeriod = $DbResult->fetch_assoc()) 47 47 $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod; 48 48 … … 80 80 function W2Kc($Spotreba) 81 81 { 82 return (round($Spotreba * 0.72 * $this->kWh));82 return (round($Spotreba * 0.72 * $this->kWh)); 83 83 } 84 84 … … 93 93 // Create DocumentLineSequence from previous 94 94 $DbResult = $this->Database->select('DocumentLine', 'Id', '`Yearly` = 1'); 95 while ($DbRow = $DbResult->fetch_assoc())95 while ($DbRow = $DbResult->fetch_assoc()) 96 96 { 97 97 $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId, … … 102 102 function GetFinanceYear($Year) 103 103 { 104 if ($Year == 0)104 if ($Year == 0) 105 105 { 106 106 // Get latest year 107 107 $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1'); 108 108 } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year); 109 if ($DbResult->num_rows == 0) {110 if ($Year == date('Y'))109 if ($DbResult->num_rows == 0) { 110 if ($Year == date('Y')) 111 111 { 112 112 $this->CreateFinanceYear($Year); … … 115 115 } 116 116 $FinanceYear = $DbResult->fetch_assoc(); 117 if ($FinanceYear['Closed'] == 1)117 if ($FinanceYear['Closed'] == 1) 118 118 throw new Exception('Rok '.$FinanceYear['Year'].' je již uzavřen. Nelze do něj přidávat položky.'); 119 119 return $FinanceYear; … … 131 131 $Sequence = $DbResult->fetch_assoc(); 132 132 133 if ($Sequence['YearPrefix'] == 1)133 if ($Sequence['YearPrefix'] == 1) 134 134 { 135 135 $Result = $DocumentLine['Shortcut'].$Sequence['NextNumber'].'/'.$FinanceYear['Year']; … … 138 138 $this->Database->query('UPDATE `DocumentLineSequence` SET `NextNumber` = `NextNumber` + 1 '. 139 139 'WHERE (`DocumentLine`='.$Id.') AND (`FinanceYear`='.$FinanceYear['Id'].')'); 140 return ($Result);140 return ($Result); 141 141 } 142 142 … … 151 151 { 152 152 $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id); 153 if ($DbResult->num_rows == 1) {153 if ($DbResult->num_rows == 1) { 154 154 $Group = $DbResult->fetch_assoc(); 155 return ($Group);155 return ($Group); 156 156 } else die('Finance group id '.$Id.' not found in table '.$Table); 157 157 } … … 162 162 $this->Database->query('TRUNCATE TABLE `MemberPayment`'); 163 163 $DbResult = $this->Database->query('SELECT * FROM `Member`'); 164 while ($Member = $DbResult->fetch_assoc())164 while ($Member = $DbResult->fetch_assoc()) 165 165 { 166 166 $DbResult2 = $this->Database->query('SELECT ((SELECT COALESCE(SUM(`Value`), 0) FROM `FinanceOperation` '. … … 182 182 $DbRow = $DbResult2->fetch_assoc(); 183 183 $Monthly = 0; 184 if ($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price'];184 if ($DbRow['Price'] != '') $MonthlyInet = $DbRow['Price']; 185 185 else $MonthlyInet = 0; 186 186 … … 189 189 $Monthly = round($Monthly); 190 190 191 if ($Member['BillingPeriod'] == 1)191 if ($Member['BillingPeriod'] == 1) 192 192 { 193 193 // Inactive payer … … 204 204 } 205 205 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment'); 206 return ($Output);206 return ($Output); 207 207 } 208 208 … … 214 214 TimeToMysqlDate($Time).'") OR (ValidTo IS NULL)) LIMIT 1'); 215 215 $Row = $DbResult->fetch_array(); 216 return ($Row[0]);216 return ($Row[0]); 217 217 } 218 218 } … … 665 665 function BeforeInsertFinanceOperation($Form) 666 666 { 667 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);667 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 668 668 else $Year = date("Y", $Form->Values['ValidFrom']); 669 669 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup'); 670 670 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year); 671 return ($Form->Values);671 return ($Form->Values); 672 672 } 673 673 … … 677 677 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 678 678 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 679 return ($Form->Values);679 return ($Form->Values); 680 680 } 681 681 … … 685 685 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 686 686 ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 687 return ($Form->Values);687 return ($Form->Values); 688 688 } 689 689 … … 691 691 { 692 692 // Get new DocumentLineCode by selected invoice Group 693 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);693 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 694 694 else $Year = date("Y", $Form->Values['ValidFrom']); 695 695 $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup'); 696 696 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 697 return ($Form->Values);697 return ($Form->Values); 698 698 } 699 699 … … 707 707 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 708 708 ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 709 return ($Form->Values);709 return ($Form->Values); 710 710 } 711 711 … … 718 718 $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '. 719 719 ($Sum * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id); 720 return ($Form->Values);720 return ($Form->Values); 721 721 } 722 722 … … 727 727 $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']); 728 728 $this->AfterInsertFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']); 729 return ($Form->Values);729 return ($Form->Values); 730 730 } 731 731 … … 736 736 $ParentForm->LoadValuesFromDatabase($Form->Values['FinanceInvoice']); 737 737 $this->BeforeModifyFinanceInvoice($ParentForm, $Form->Values['FinanceInvoice']); 738 return ($Form->Values);738 return ($Form->Values); 739 739 } 740 740 741 741 function BeforeInsertContract($Form) 742 742 { 743 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);743 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 744 744 else $Year = date("Y", $Form->Values['ValidFrom']); 745 745 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year); 746 return ($Form->Values);746 return ($Form->Values); 747 747 } 748 748 } -
trunk/Modules/Finance/Import.php
r812 r873 9 9 function Show() 10 10 { 11 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');12 if (array_key_exists('Operation', $_GET))11 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return ('Nemáte oprávnění'); 12 if (array_key_exists('Operation', $_GET)) 13 13 { 14 if ($_GET['Operation'] == 'prepare') return($this->Prepare());15 else if ($_GET['Operation'] == 'insert') return($this->Insert());14 if ($_GET['Operation'] == 'prepare') return ($this->Prepare()); 15 else if ($_GET['Operation'] == 'insert') return ($this->Insert()); 16 16 else echo('Neplatná akce'); 17 17 } else … … 22 22 $Output .= '<input type="submit" value="Analyzovat"/>'; 23 23 $Output .= '</form>'; 24 return ($Output);24 return ($Output); 25 25 } 26 26 } … … 31 31 $Finance->LoadMonthParameters(0); 32 32 $Data = explode("\n", $_POST['Source']); 33 foreach ($Data as $Key => $Value)33 foreach ($Data as $Key => $Value) 34 34 { 35 35 $Value = str_replace('\"', '"', $Value); 36 36 $Data[$Key] = str_getcsv($Value, ',', '"', "\\"); 37 37 //print_r($Data[$Key]); 38 foreach ($Data[$Key] as $Key2 => $Value2)38 foreach ($Data[$Key] as $Key2 => $Value2) 39 39 { 40 if (substr($Data[$Key][$Key2], 0, 2) == '\"')40 if (substr($Data[$Key][$Key2], 0, 2) == '\"') 41 41 $Data[$Key][$Key2] = substr($Data[$Key][$Key2], 2, -2); 42 42 } … … 61 61 //print_r($Data); 62 62 63 if ($Header != $Data[0]) {63 if ($Header != $Data[0]) { 64 64 $Output = 'Nekompatibilní struktura CSV'; 65 65 print_r($Header); … … 73 73 $Output = '<form action="?Operation=insert" method="post">'; 74 74 $I = 0; 75 foreach ($Data as $Key => $Value)75 foreach ($Data as $Key => $Value) 76 76 { 77 if (count($Value) <= 1) continue;78 if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna77 if (count($Value) <= 1) continue; 78 if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna 79 79 $Time = explode('.', $Value[0]); 80 80 $Time = $Time[2].'-'.$Time[1].'-'.$Time[0]; 81 81 $Money = $Value[1]; 82 if (is_numeric($Value[5]))82 if (is_numeric($Value[5])) 83 83 { 84 84 $Subject = $Value[5] * 1; 85 85 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id='.$this->Database->real_escape_string($Subject)); 86 if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';86 if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')'; 87 87 } else 88 88 { 89 89 $Subject = '? ('.$Value[5].')'; 90 90 } 91 if (!is_numeric($Subject))91 if (!is_numeric($Subject)) 92 92 { 93 93 $Mode = 'Ručně'; … … 99 99 } 100 100 101 if ($Money < 0) $Text = 'Platba převodem';101 if ($Money < 0) $Text = 'Platba převodem'; 102 102 else $Text = 'Přijatá platba'; 103 103 $Automatic .= '<tr>'. … … 121 121 $Output .= '<input type="submit" value="Zpracovat"/></form>'; 122 122 } 123 return ($Output);123 return ($Output); 124 124 } 125 125 … … 142 142 $Output = ''; 143 143 144 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)144 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 145 145 { 146 if ($_POST['Money'.$I] < 0) {146 if ($_POST['Money'.$I] < 0) { 147 147 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup'); 148 148 } else { … … 156 156 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted'); 157 157 } 158 return ($Output);158 return ($Output); 159 159 } 160 160 } -
trunk/Modules/Finance/Manage.php
r866 r873 10 10 { 11 11 $Output = ''; 12 if (!$this->System->User->CheckPermission('Finance', 'Manage'))13 return ('Nemáte oprávnění');14 15 if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation'];12 if (!$this->System->User->CheckPermission('Finance', 'Manage')) 13 return ('Nemáte oprávnění'); 14 15 if (array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; 16 16 else $Operation = ''; 17 switch ($Operation)17 switch ($Operation) 18 18 { 19 19 case 'Recalculate': … … 42 42 $Output .= '<a href="'.$this->System->Link('/finance/import/').'">Import plateb</a><br />'; 43 43 } 44 return ($Output);44 return ($Output); 45 45 } 46 46 … … 52 52 53 53 $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount']; 54 if ($MonthCount <= 0) return(array('From' => NULL, 'To' => NULL, 'MonthCount' => 0));54 if ($MonthCount <= 0) return (array('From' => NULL, 'To' => NULL, 'MonthCount' => 0)); 55 55 $MonthCurrent = date('n', $Time); 56 56 … … 67 67 $PeriodTo = mktime(0, 0, 0, $MonthTo, date('t', mktime(0, 0, 0, $MonthTo, 1, $Year)), $Year); 68 68 69 return (array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount));69 return (array('From' => $PeriodFrom, 'To' => $PeriodTo, 'MonthCount' => $MonthCount)); 70 70 } 71 71 72 72 function ShowMonthlyPayment() 73 73 { 74 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');74 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění'); 75 75 $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '. 76 76 '`MemberPayment`.`Cash` AS `Cash`, '. … … 106 106 107 107 $DbResult = $this->Database->query($Query); 108 while ($Row = $DbResult->fetch_assoc())108 while ($Row = $DbResult->fetch_assoc()) 109 109 { 110 110 $Output .= '<tr>'. … … 120 120 $Output .= $PageList['Output']; 121 121 $Output .= '<a href="?Operation=ProcessMonthlyPayment">Generovat faktury</a>'; 122 return ($Output);122 return ($Output); 123 123 } 124 124 … … 131 131 $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 132 132 $SumValue = 0; 133 foreach ($Items as $Item) {133 foreach ($Items as $Item) { 134 134 $SumValue = $SumValue + $Item['Price'] * $Item['Quantity']; 135 135 } … … 143 143 'Generate' => 1, 'Group' => $Group['Id'])); 144 144 $InvoiceId = $this->Database->insert_id; 145 foreach ($Items as $Item)145 foreach ($Items as $Item) 146 146 $this->Database->insert('FinanceInvoiceItem', array('FinanceInvoice' => $InvoiceId, 147 147 'Description' => $Item['Description'], 'Price' => $Item['Price'], … … 149 149 //$LastInsertTime = $Time; 150 150 //$this->CheckAdvancesAndLiabilities($Subject); 151 return ($InvoiceId);151 return ($InvoiceId); 152 152 } 153 153 … … 162 162 'FROM `MemberPayment` JOIN `Member` ON `Member`.`Id`=`MemberPayment`.`Member` '. 163 163 'JOIN `Subject` ON `Subject`.`Id`=`Member`.`Subject`'); 164 while ($Member = $DbResult->fetch_assoc())164 while ($Member = $DbResult->fetch_assoc()) 165 165 { 166 166 $Output .= $Member['SubjectName'].': '; … … 168 168 169 169 /* Check if need to produce new invoice for customer */ 170 if (($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and170 if (($Period['MonthCount'] > 0) and ($Member['Blocked'] == 0) and 171 171 ($Period['From'] > $Member['BillingPeriodLastUnixTime'])) 172 172 { … … 178 178 'WHERE (`ServiceCustomerRel`.`Customer`='. 179 179 $Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '); 180 while ($Service = $DbResult2->fetch_assoc())180 while ($Service = $DbResult2->fetch_assoc()) 181 181 { 182 182 $InvoiceItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'], … … 188 188 // TODO: In case of negative invoice it is not sufficient to reverse invoicing direction 189 189 // Other subject should invoice only positive items. Negative items should be somehow removed. 190 if ($MonthlyTotal >= 0)190 if ($MonthlyTotal >= 0) 191 191 { 192 192 $InvoiceGroupId = INVOICE_GROUP_OUT; … … 197 197 // Load invoice group 198 198 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup'); 199 foreach ($InvoiceItems as $Index => $Item)199 foreach ($InvoiceItems as $Index => $Item) 200 200 { 201 201 $InvoiceItems[$Index]['Price'] = $Item['Price'] * $FinanceGroup['ValueSign']; 202 202 } 203 203 204 if ($PayPerPeriod != 0)204 if ($PayPerPeriod != 0) 205 205 { 206 206 $TimePeriodText = date('j.n.Y', $Period['From']).' - '.date('j.n.Y', $Period['To']); … … 217 217 $Output .= "\n"; 218 218 } 219 return ($Output);219 return ($Output); 220 220 } 221 221 … … 225 225 $DbResult = $this->Database->select($Table, '*', '(`ChangeAction` IS NOT NULL) AND '. 226 226 '(`ChangeTime` <= "'.TimeToMysqlDateTime($Time).'") ORDER BY `ChangeTime` ASC'); 227 while ($Service = $DbResult->fetch_assoc())228 { 229 if ($Service['ChangeAction'] == 'add')227 while ($Service = $DbResult->fetch_assoc()) 228 { 229 if ($Service['ChangeAction'] == 'add') 230 230 { 231 231 unset($Service['Id']); … … 235 235 $this->Database->insert($Table, $Service); 236 236 } else 237 if ($Service['ChangeAction'] == 'modify')237 if ($Service['ChangeAction'] == 'modify') 238 238 { 239 239 unset($Service['Id']); … … 244 244 $this->Database->update($Table, '`Id`='.$ReplaceId, $Service); 245 245 } else 246 if ($Service['ChangeAction'] == 'delete')246 if ($Service['ChangeAction'] == 'delete') 247 247 { 248 248 $this->Database->delete($Table, '`Id`='.$Service['ReplaceId']); … … 270 270 $this->TableUpdateChanges('ServiceCustomerRel'); 271 271 272 return ($Output);272 return ($Output); 273 273 } 274 274 275 275 function ProcessMonthlyPayment() 276 276 { 277 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');277 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění'); 278 278 $Output = ''; 279 279 … … 311 311 // Zkontrolovat odečtení měsíčního poplatku 312 312 $Output .= 'Kontrola odečtení poplatků: Poslední měsíc-'.$MonthLast.' Aktuální měsíc-'.$MonthCurrent."\n"; 313 if ($MonthCurrent != $MonthLast)313 if ($MonthCurrent != $MonthLast) 314 314 { 315 315 $Output .= 'Odečítám pravidelný poplatek...'."\n"; … … 335 335 } 336 336 $Output = str_replace("\n", '<br/>', $Output); 337 return ($Output);337 return ($Output); 338 338 } 339 339 … … 366 366 $MainSubjectAccount = $DbResult->fetch_assoc(); 367 367 368 if ($User['Email'] != '')368 if ($User['Email'] != '') 369 369 { 370 370 $Title = 'Pravidelné vyúčtování služeb'; … … 392 392 '`Time`, -`Value`, `File` FROM `FinanceInvoice` WHERE (`Subject`='. 393 393 $Member['Subject'].')) ORDER BY `Time` DESC) AS `T1` WHERE (`T1`.`Time` > "'.$Member['BillingPeriodLastDate'].'")'); 394 while ($DbRow = $DbResult->fetch_assoc())394 while ($DbRow = $DbResult->fetch_assoc()) 395 395 { 396 396 $Text = $DbRow['Text']; … … 417 417 $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '. 418 418 'AND (`Value` != 0) AND (`Generate` = 1)'.$Where); 419 while ($Row = $DbResult->fetch_assoc())419 while ($Row = $DbResult->fetch_assoc()) 420 420 { 421 421 if ($Row['File'] == null) … … 447 447 $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '. 448 448 'AND (`Value` != 0) AND (`Generate` = 1)'.$Where); 449 while ($Row = $DbResult->fetch_assoc())449 while ($Row = $DbResult->fetch_assoc()) 450 450 { 451 451 if ($Row['File'] == null) … … 462 462 $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName; 463 463 $Bill->SaveToFile($FullFileName); 464 if (file_exists($FullFileName))464 if (file_exists($FullFileName)) 465 465 { 466 466 $this->Database->update('File', 'Id='.$FileId, array('Name' => $FileName, 'Size' => filesize($FullFileName))); … … 478 478 $Output .= $this->GenerateInvoice(' AND (`File` IS NULL)'); 479 479 $Output .= $this->GenerateOperation(' AND (`File` IS NULL)'); 480 return ($Output);480 return ($Output); 481 481 } 482 482 } -
trunk/Modules/Finance/Trade.php
r847 r873 65 65 $Row = $DbResult->fetch_array(); 66 66 $Balance['SmallAssets']['End'] = $Row[0] + 0; 67 return ($Balance);67 return ($Balance); 68 68 } 69 69 … … 77 77 $StartYear = date('Y', $this->StartEvidence); 78 78 $EndYear = date('Y', time()); 79 for ($Year = $StartYear; $Year <= $EndYear; $Year++)79 for ($Year = $StartYear; $Year <= $EndYear; $Year++) 80 80 { 81 81 $EndTime = mktime(0, 0, 0, 12, 31, $Year); 82 82 //$Year = date('Y', $EndTime); 83 83 $StartTime = mktime(0, 0, 0, 1, 1, $Year); 84 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;84 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; 85 85 86 86 $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); … … 113 113 $StartYear = date('Y', $this->StartEvidence); 114 114 $EndYear = date('Y', time()); 115 for ($Year = $StartYear; $Year <= $EndYear; $Year++)116 { 117 for ($Month = 1; $Month <= 12; $Month++)115 for ($Year = $StartYear; $Year <= $EndYear; $Year++) 116 { 117 for ($Month = 1; $Month <= 12; $Month++) 118 118 { 119 119 $EndTime = mktime(0, 0, 0, $Month, 31, $Year); 120 120 //$Year = date('Y', $EndTime); 121 121 $StartTime = mktime(0, 0, 0, $Month, 1, $Year); 122 if (($StartTime < time()) and ($EndTime > $this->StartEvidence))122 if (($StartTime < time()) and ($EndTime > $this->StartEvidence)) 123 123 { 124 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence;124 if ($StartTime < $this->StartEvidence) $StartTime = $this->StartEvidence; 125 125 126 126 $Balance = $this->GetTimePeriodBalance($StartTime, $EndTime); … … 164 164 'WHERE (`ValueSign` = 1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 165 165 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 166 while ($Row = $DbResult->fetch_array())166 while ($Row = $DbResult->fetch_array()) 167 167 { 168 168 $Row['Time'] = explode(' ', $Row['Time']); … … 204 204 'WHERE (`FinanceOperationGroup`.`ValueSign` = -1) AND (`FinanceOperation`.`Time` >= "'.$Year['DateStart'].'") '. 205 205 'AND (`FinanceOperation`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 206 while ($Row = $DbResult->fetch_array())206 while ($Row = $DbResult->fetch_array()) 207 207 { 208 208 $Row['Time'] = explode(' ', $Row['Time']); … … 245 245 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = 1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 246 246 '") AND (`FinanceInvoice`.`Time` <= "'.$Year['DateEnd'].'") ORDER BY `Time`'); 247 while ($Row = $DbResult->fetch_array())248 { 249 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' ';247 while ($Row = $DbResult->fetch_array()) 248 { 249 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 250 250 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. 251 251 '</td><td>'.$Row['SubjectName'].'</td><td>'.$Row['Text'].'</td><td>'.$Row['Value'].'</td></tr>'; … … 276 276 'WHERE (`FinanceInvoiceGroup`.`ValueSign` = -1) AND (`FinanceInvoice`.`Time` >= "'.$Year['DateStart']. 277 277 '") AND (FinanceInvoice.Time <= "'.$Year['DateEnd'].'") ORDER BY Time'); 278 while ($Row = $DbResult->fetch_array())279 { 280 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' ';278 while ($Row = $DbResult->fetch_array()) 279 { 280 if ($Row['TimePayment'] == '0000-00-00 00:00:00') $Row['TimePayment'] = ' '; 281 281 $Row['Value'] = $Row['Value'] * $Row['ValueSign']; 282 282 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['BillName']. … … 314 314 'WHERE (T6.Subject = Subject.Id) AND (`FinanceOperationGroup`.`ValueSign` = -1)) AS `Spends` '. 315 315 'FROM Subject ORDER BY Name'); 316 while ($Row = $DbResult->fetch_assoc())316 while ($Row = $DbResult->fetch_assoc()) 317 317 { 318 318 $Output .= '<tr><td style="text-align: left;"><a href="?table=SubjectAccount&Id='.$Row['Id'].'">'.$Row['Name'].'</a></td><td>'.$Row['Liabilities'].' / '.$Row['OpenedLiabilities'].'</td><td>'.$Row['Claims'].' / '.$Row['OpenedClaims'].'</td><td>'.$Row['Gains'].'</td><td>'.$Row['Spends'].'</td><td>'.($Row['Gains'] - $Row['Spends'] - $Row['Claims'] + $Row['Liabilities']).'</td><td>'.$Row['Cash'].'</td></tr>'; … … 330 330 'FROM StockSerialNumber JOIN Product ON Product.Id = StockSerialNumber.Product '. 331 331 'WHERE (TimeElimination IS NOT NULL)'); 332 while ($Row = $DbResult->fetch_array())332 while ($Row = $DbResult->fetch_array()) 333 333 { 334 334 $Output .= '<tr><td>'.$Row['Name'].'</td><td>'.$Row['Price'].'</td><td>'.$Row['TimeEnlistment'].'</td><td>'.$Row['TimeElimination'].'</td></tr>'; … … 349 349 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 350 350 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 351 while ($Row = $DbResult->fetch_array())351 while ($Row = $DbResult->fetch_array()) 352 352 { 353 353 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.$Row['Text']. … … 364 364 'LEFT JOIN `DocumentLineCode` ON `DocumentLineCode`.`Id` = `FinanceInvoice`.`BillCode` '. 365 365 'WHERE `Subject`='.$_GET['Id'].' ORDER BY `Time`'); 366 while ($Row = $DbResult->fetch_array())366 while ($Row = $DbResult->fetch_array()) 367 367 { 368 368 $Output .= '<tr><td>'.HumanDate($Row['Time']).'</td><td>'.HumanDate($Row['TimePayment']). … … 375 375 $Output .= '<tr><th>Datum vytvoření</th><th>Datum zaplacení</th><th>Název</th><th>Hodnota [Kč]</th></tr>'; 376 376 $DbResult = $this->Database->select('FinanceAdvances', '*', 'Subject='.$_GET['Id']); 377 while ($Row = $DbResult->fetch_array())377 while ($Row = $DbResult->fetch_array()) 378 378 { 379 379 $Output .= '<tr><td>'.$Row['Time'].'</td><td>'.$Row['TimePass'].'</td><td>'.$Row['ValueSign'].'</td><td>'.($Row['Value']).'</td><td>'.$Row['CashFlowId'].'</td></tr>'; … … 411 411 $Output .= '<strong>Roční přehledy</strong><br/>'; 412 412 $Output .= $this->ShowFinanceYears(); 413 if (array_key_exists('year', $_GET))413 if (array_key_exists('year', $_GET)) 414 414 { 415 415 $Year = $_GET['year'] * 1; … … 426 426 function Show() 427 427 { 428 if (!$this->System->User->CheckPermission('Finance', 'TradingStatus'))429 return ('Nemáte oprávnění');428 if (!$this->System->User->CheckPermission('Finance', 'TradingStatus')) 429 return ('Nemáte oprávnění'); 430 430 431 431 $Finance = &$this->System->Modules['Finance']; 432 432 433 433 $Output = ''; 434 if (!array_key_exists('table', $_GET)) $_GET['table'] = '';435 switch ($_GET['table'])434 if (!array_key_exists('table', $_GET)) $_GET['table'] = ''; 435 switch ($_GET['table']) 436 436 { 437 437 case 'AnnualBalance': … … 478 478 $Output = $this->ShowDefault(); 479 479 } 480 return ($Output);480 return ($Output); 481 481 } 482 482 … … 485 485 $Output = 'Roky: '; 486 486 $DbRows = $this->Database->select('FinanceYear', '*'); 487 while ($DbRow = $DbRows->fetch_assoc())487 while ($DbRow = $DbRows->fetch_assoc()) 488 488 $Output .= '<a href="?year='.$DbRow['Id'].'">'.$DbRow['Year'].'</a> '; 489 489 $Output .= '<br/>'; 490 return ($Output);490 return ($Output); 491 491 } 492 492 -
trunk/Modules/Finance/UserState.php
r825 r873 44 44 $DbResult = $this->Database->query($Query); 45 45 $SumValue = 0; 46 while ($Row = $DbResult->fetch_assoc())46 while ($Row = $DbResult->fetch_assoc()) 47 47 { 48 48 $Row['State'] = round($Row['State'], 2); 49 if ($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>';50 if ($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>';51 if ($Row['Value'] == -0) $Row['Value'] = 0;52 if ($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value'];53 if ($Row['BillName'] == '') $Row['BillName'] = 'PDF';54 if ($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>';49 if ($Row['State'] > 0) $Row['State'] = '<span style="color:green;">'.$Row['State'].'</span>'; 50 if ($Row['State'] < 0) $Row['State'] = '<span style="color:red;">'.$Row['State'].'</span>'; 51 if ($Row['Value'] == -0) $Row['Value'] = 0; 52 if ($Row['Value'] > 0) $Row['Value'] = '+'.$Row['Value']; 53 if ($Row['BillName'] == '') $Row['BillName'] = 'PDF'; 54 if ($Row['File'] > 0) $Invoice = '<a href="'.$this->System->Link('/file?id='.$Row['File']).'">'.$Row['BillName'].'</a>'; 55 55 else $Invoice = NotBlank($Row['BillName']); 56 if ($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']);56 if ($Row['PeriodFrom'] != '') $Period = HumanDate($Row['PeriodFrom']).' - '.HumanDate($Row['PeriodTo']); 57 57 else $Period = ' '; 58 58 $Output .= '<tr><td style="text-align: right;">'.HumanDate($Row['Time']).'</td>'. … … 66 66 $Output .= '</table>'; 67 67 $Output .= $PageList['Output']; 68 return ($Output);68 return ($Output); 69 69 } 70 70 … … 75 75 76 76 // Determine which customer should be displayed 77 if (array_key_exists('i', $_GET))77 if (array_key_exists('i', $_GET)) 78 78 { 79 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return('Nemáte oprávnění');79 if (!$this->System->User->CheckPermission('Finance', 'Manage')) return ('Nemáte oprávnění'); 80 80 $CustomerId = $_GET['i']; 81 81 } else 82 82 { 83 if (!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return('Nemáte oprávnění');83 if (!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return ('Nemáte oprávnění'); 84 84 $UserId = $this->System->User->User['Id']; 85 85 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1'); 86 if ($DbResult->num_rows > 0)86 if ($DbResult->num_rows > 0) 87 87 { 88 88 $CustomerUserRel = $DbResult->fetch_assoc(); 89 89 $CustomerId = $CustomerUserRel['Customer']; 90 } else return ($this->SystemMessage('Chyba', 'Nejste zákazníkem'));90 } else return ($this->SystemMessage('Chyba', 'Nejste zákazníkem')); 91 91 } 92 92 93 93 // Load customer info 94 94 $DbResult = $this->Database->query('SELECT * FROM `Member` WHERE `Id`='.$CustomerId); 95 if ($DbResult->num_rows == 1)95 if ($DbResult->num_rows == 1) 96 96 { 97 97 $Customer = $DbResult->fetch_assoc(); 98 } else return ($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen'));98 } else return ($this->SystemMessage('Položka nenalezena', 'Zákazník nenalezen')); 99 99 100 100 101 101 // Load subject info 102 102 $DbResult = $this->Database->query('SELECT * FROM `Subject` WHERE `Id`='.$Customer['Subject']); 103 if ($DbResult->num_rows == 1)103 if ($DbResult->num_rows == 1) 104 104 { 105 105 $Subject = $DbResult->fetch_assoc(); 106 } else return ($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen'));106 } else return ($this->SystemMessage('Položka nenalezena', 'Subjekt nenalezen')); 107 107 108 108 … … 141 141 'LEFT JOIN `Service` ON `Service`.`Id`=`ServiceCustomerRel`.`Service` '. 142 142 'WHERE (`ServiceCustomerRel`.`Customer`='.$Customer['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL)'); 143 while ($DbRow = $DbResult->fetch_assoc())143 while ($DbRow = $DbResult->fetch_assoc()) 144 144 { 145 145 $Output .= '<tr><td>'.$DbRow['Name'].'</td><td>'.$DbRow['Price'].'</td></tr>'; … … 152 152 153 153 $Output .= '</td></tr></table>'; 154 return ($Output);154 return ($Output); 155 155 } 156 156 } -
trunk/Modules/FinanceBankAPI/FileImport.php
r765 r873 26 26 { 27 27 $DbResult = $this->Database->select('FinanceBankImport', '*', 'FinanceOperation IS NULL'); 28 while ($DbRow = $DbResult->fetch_assoc())28 while ($DbRow = $DbResult->fetch_assoc()) 29 29 { 30 if (is_numeric($DbRow['VariableSymbol']))30 if (is_numeric($DbRow['VariableSymbol'])) 31 31 { 32 32 $DbResult2 = $this->Database->select('Subject', 'Id', 'Id='.$DbRow['VariableSymbol']); 33 if ($DbResult2->num_rows == 1)33 if ($DbResult2->num_rows == 1) 34 34 { 35 35 $DbRow2 = $DbResult2->fetch_assoc(); 36 if ($DbRow['Value'] >= 0) {36 if ($DbRow['Value'] >= 0) { 37 37 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup'); 38 38 } else { … … 51 51 $Form->SetClass('FinanceOperation'); 52 52 $Form->LoadValuesFromDatabase($Id); 53 if (array_key_exists('AfterInsert', $Form->Definition))53 if (array_key_exists('AfterInsert', $Form->Definition)) 54 54 { 55 55 $Class = $Form->Definition['AfterInsert'][0]; … … 80 80 $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'."\n"; 81 81 82 if ($Bank['Code'] == '2010') $Import = new ImportFio($this->System);83 else if ($Bank['Code'] == '0300') $Import = new ImportPS($this->System);82 if ($Bank['Code'] == '2010') $Import = new ImportFio($this->System); 83 else if ($Bank['Code'] == '0300') $Import = new ImportPS($this->System); 84 84 else $Output = $this->SystemMessage('Nepodporované API', 'Pro zvolenou banku není import podporován'); 85 if (isset($Import))85 if (isset($Import)) 86 86 { 87 87 $Import->BankAccount = $BankAccount; … … 89 89 $Import->PairOperations(); 90 90 } 91 return ($Output);91 return ($Output); 92 92 } 93 93 94 94 function Show() 95 95 { 96 if (!$this->System->User->CheckPermission('Finance', 'SubjectList'))97 return ('Nemáte oprávnění');96 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) 97 return ('Nemáte oprávnění'); 98 98 99 99 $Output = $this->Import($_GET['i']); 100 return ($Output);100 return ($Output); 101 101 } 102 102 } … … 111 111 { 112 112 $Output = ''; 113 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return('Nemáte oprávnění');114 if (array_key_exists('Operation', $_GET))113 if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return ('Nemáte oprávnění'); 114 if (array_key_exists('Operation', $_GET)) 115 115 { 116 if ($_GET['Operation'] == 'prepare') $Output .= $this->Prepare();117 else if ($_GET['Operation'] == 'insert') $Output .= $this->Insert();116 if ($_GET['Operation'] == 'prepare') $Output .= $this->Prepare(); 117 else if ($_GET['Operation'] == 'insert') $Output .= $this->Insert(); 118 118 else $Output .= 'Neplatná akce'; 119 119 } else $Output .= $this->ShowForm(); 120 return ($Output);120 return ($Output); 121 121 } 122 122 … … 128 128 $Form->Values['BankAccount'] = $_GET['id']; 129 129 $Output = $Form->ShowEditForm(); 130 return ($Output);130 return ($Output); 131 131 } 132 132 … … 147 147 $Output .= 'Účet: '.$BankAccount['Number'].'/'.$Bank['Code'].' ('.$Bank['Name'].')'; 148 148 149 if ($Bank['Code'] == '2010') $Import = new ImportFio($this->System);150 else if ($Bank['Code'] == '0300') $Import = new ImportPS($this->System);149 if ($Bank['Code'] == '2010') $Import = new ImportFio($this->System); 150 else if ($Bank['Code'] == '0300') $Import = new ImportPS($this->System); 151 151 else $Output = $this->SystemMessage('Nepodporované API', 'Pro zvolenou banku není import podporován'); 152 152 $Import->BankAccount = $BankAccount; 153 153 $Output .= $Import->ImportFile($File->GetContent(), $File->GetExt()); 154 154 155 return ($Output);155 return ($Output); 156 156 } 157 157 … … 171 171 $Output = ''; 172 172 173 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)173 for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--) 174 174 { 175 if ($_POST['Money'.$I] >= 0) {175 if ($_POST['Money'.$I] >= 0) { 176 176 $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 177 177 'FinanceOperationGroup'); … … 187 187 $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted'); 188 188 } 189 return ($Output);189 return ($Output); 190 190 } 191 191 } -
trunk/Modules/FinanceBankAPI/FinanceBankAPI.php
r799 r873 76 76 $DbRow = $DbResult->fetch_row(); 77 77 $Output = 'Nezpárovaných plateb: '.$DbRow['0'].'<br/>'; 78 return ($Output);78 return ($Output); 79 79 } 80 80 … … 82 82 { 83 83 $Preset = array(); 84 if ($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT;84 if ($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT; 85 85 else $OperationGroupId = OPERATION_GROUP_ACCOUNT_IN; 86 86 $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup'); … … 94 94 'presetBankAccount' => $Item['BankAccount'], 95 95 'presetGroup' => $FinanceGroup['Id']); 96 return ($Preset);96 return ($Preset); 97 97 } 98 98 } … … 106 106 '(`AutoImport`=1) AND (`TimeCreate` < NOW()) AND '. 107 107 '((`TimeEnd` IS NULL) OR (`TimeEnd` > NOW()))'); 108 while ($DbRow = $DbResult->fetch_assoc())108 while ($DbRow = $DbResult->fetch_assoc()) 109 109 { 110 110 echo($DbRow['Comment']."\n"); … … 112 112 $Output .= $Page->Import($DbRow['Id']); 113 113 } 114 return ($Output);114 return ($Output); 115 115 } 116 116 } -
trunk/Modules/FinanceBankAPI/Fio.php
r738 r873 11 11 function Import($TimeFrom, $TimeTo) 12 12 { 13 if ($this->UserName == '') throw new Exception('Missing value for UserName property.');14 if ($this->Password == '') throw new Exception('Missing value for Password property.');15 if (!is_numeric($this->Account)) throw new Exception('Missing or not numeric value for Account property.');13 if ($this->UserName == '') throw new Exception('Missing value for UserName property.'); 14 if ($this->Password == '') throw new Exception('Missing value for Password property.'); 15 if (!is_numeric($this->Account)) throw new Exception('Missing or not numeric value for Account property.'); 16 16 17 17 $fp = fsockopen('ssl://www.fio.cz', 443, $errno, $errstr, 30); 18 if (!$fp)18 if (!$fp) 19 19 { 20 20 throw new Exception('Connection error: '.$errstr); … … 35 35 // Read response 36 36 $Response = array(); 37 while (!feof($fp))37 while (!feof($fp)) 38 38 { 39 39 $Response[] = trim(fgets($fp, 1024)); … … 42 42 43 43 // Strip HTTP header 44 while ($Response[0] != '') array_shift($Response);44 while ($Response[0] != '') array_shift($Response); 45 45 array_shift($Response); // Remove empty line 46 46 //echo(implode("\n", $Response)); … … 49 49 $GPC = new GPC(); 50 50 $Result = array(); 51 foreach ($Response as $Index => $Line)51 foreach ($Response as $Index => $Line) 52 52 { 53 if (($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response);53 if (($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response); 54 54 $GPCLine = $GPC->ParseLine($Line); 55 if ($GPCLine != NULL) $Result[] = $GPCLine;55 if ($GPCLine != NULL) $Result[] = $GPCLine; 56 56 } 57 return ($Result);57 return ($Result); 58 58 } 59 59 } … … 65 65 $Response = implode('', $Response); 66 66 $ErrorMessageStart = '<div id="oldform_warning">'; 67 if (strpos($Response, $ErrorMessageStart) !== false)67 if (strpos($Response, $ErrorMessageStart) !== false) 68 68 { 69 69 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart)); -
trunk/Modules/FinanceBankAPI/FioAPI.php
r836 r873 7 7 function RemoveComma($Text) 8 8 { 9 if ((mb_strlen($Text) >= 2) and ($Text[0] == '"') and (mb_substr($Text, -1, 1) == '"')) return(mb_substr($Text, 1, -1));10 else return ($Text);9 if ((mb_strlen($Text) >= 2) and ($Text[0] == '"') and (mb_substr($Text, -1, 1) == '"')) return (mb_substr($Text, 1, -1)); 10 else return ($Text); 11 11 } 12 12 … … 25 25 function Import($TimeFrom, $TimeTo) 26 26 { 27 if ($this->Token == '') throw new Exception('Missing value for Token property.');27 if ($this->Token == '') throw new Exception('Missing value for Token property.'); 28 28 29 29 // URL format: https://www.fio.cz/ib_api/rest/periods/{token}/{datum od}/{datum do}/transactions.{format} … … 33 33 $Response = ''; 34 34 $Response = @file_get_contents('https://www.fio.cz'.$RequestURL); 35 if ($Response == FALSE)35 if ($Response == FALSE) 36 36 { 37 37 throw new Exception('Connection error'); 38 38 } else 39 39 { 40 if ($this->Format == 'gpc') $Response = iconv('windows-1250', $this->Encoding, $Response);40 if ($this->Format == 'gpc') $Response = iconv('windows-1250', $this->Encoding, $Response); 41 41 $Response = explode("\n", $Response); 42 42 43 if ($this->Format == 'gpc')43 if ($this->Format == 'gpc') 44 44 { 45 45 // Parse all GPC lines 46 46 $GPC = new GPC(); 47 47 $Result = array(); 48 foreach ($Response as $Index => $Line)48 foreach ($Response as $Index => $Line) 49 49 { 50 if (($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response);50 if (($Index == 0) and (substr($Line, 0, strlen(GPC_TYPE_REPORT)) != GPC_TYPE_REPORT)) $this->NoValidDataError($Response); 51 51 $GPCLine = $GPC->ParseLine($Line); 52 if ($GPCLine != NULL) $Result[] = $GPCLine;52 if ($GPCLine != NULL) $Result[] = $GPCLine; 53 53 } 54 54 } else 55 if ($this->Format == 'csv')55 if ($this->Format == 'csv') 56 56 { 57 57 $Result = array( … … 60 60 61 61 // CVS header 62 while ((count($Response) > 0) and ($Response[0] != ''))62 while ((count($Response) > 0) and ($Response[0] != '')) 63 63 { 64 64 $Line = explode(';', $Response[0]); 65 if ($Line[0] == 'accountId') $Result['AccountNumber'] = $Line[0];66 else if ($Line[0] == 'bankId') $Result['BankId'] = $Line[0];67 else if ($Line[0] == 'currency') $Result['Currency'] = $Line[0];68 else if ($Line[0] == 'iban') $Result['IBAN'] = $Line[0];69 else if ($Line[0] == 'bic') $Result['BIC'] = $Line[0];70 else if ($Line[0] == 'openingBalance') $Result['OpeningBalance'] = $Line[0];71 else if ($Line[0] == 'closingBalance') $Result['ClosingBalance'] = $Line[0];72 else if ($Line[0] == 'dateStart') $Result['DateStart'] = $Line[0];73 else if ($Line[0] == 'dateEnd') $Result['DateEnd'] = $Line[0];74 else if ($Line[0] == 'idFrom') $Result['IdFrom'] = $Line[0];75 else if ($Line[0] == 'idTo') $Result['IdTo'] = $Line[0];65 if ($Line[0] == 'accountId') $Result['AccountNumber'] = $Line[0]; 66 else if ($Line[0] == 'bankId') $Result['BankId'] = $Line[0]; 67 else if ($Line[0] == 'currency') $Result['Currency'] = $Line[0]; 68 else if ($Line[0] == 'iban') $Result['IBAN'] = $Line[0]; 69 else if ($Line[0] == 'bic') $Result['BIC'] = $Line[0]; 70 else if ($Line[0] == 'openingBalance') $Result['OpeningBalance'] = $Line[0]; 71 else if ($Line[0] == 'closingBalance') $Result['ClosingBalance'] = $Line[0]; 72 else if ($Line[0] == 'dateStart') $Result['DateStart'] = $Line[0]; 73 else if ($Line[0] == 'dateEnd') $Result['DateEnd'] = $Line[0]; 74 else if ($Line[0] == 'idFrom') $Result['IdFrom'] = $Line[0]; 75 else if ($Line[0] == 'idTo') $Result['IdTo'] = $Line[0]; 76 76 array_shift($Response); 77 77 } 78 78 array_shift($Response); // Remove empty line 79 79 80 if ((count($Response) == 0) or80 if ((count($Response) == 0) or 81 81 ($Response[0] != 'ID pohybu;Datum;Objem;Měna;Protiúčet;Název protiúčtu;Kód banky;Název banky;KS;VS;SS;Uživatelská identifikace;Zpráva pro příjemce;Typ;Provedl;Upřesnění;Komentář;BIC;ID pokynu') 82 82 ) throw new Exception('Unsupported CSV header'); 83 83 array_shift($Response); 84 84 array_pop($Response); 85 foreach ($Response as $Index => $Line)85 foreach ($Response as $Index => $Line) 86 86 { 87 87 $Line = explode(';', $Line); … … 97 97 } 98 98 } 99 return ($Result);99 return ($Result); 100 100 } 101 101 } … … 107 107 $Response = implode('', $Response); 108 108 $ErrorMessageStart = '<div id="oldform_warning">'; 109 if (strpos($Response, $ErrorMessageStart) !== false)109 if (strpos($Response, $ErrorMessageStart) !== false) 110 110 { 111 111 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart)); -
trunk/Modules/FinanceBankAPI/FioDemo.php
r738 r873 11 11 echo('<html><head><meta charset="utf-8"></head><body>'); 12 12 echo('<table border="1">'); 13 foreach ($Records as $Record)13 foreach ($Records as $Record) 14 14 { 15 15 echo('<tr>'); 16 if ($Record['Type'] == GPC_TYPE_REPORT)16 if ($Record['Type'] == GPC_TYPE_REPORT) 17 17 { 18 18 echo('<td>Jméno účtu: '.$Record['AccountName'].'</td>'); … … 35 35 echo('<th>Uživatelská identifikace</th>'); 36 36 } else 37 if ($Record['Type'] == GPC_TYPE_ITEM)37 if ($Record['Type'] == GPC_TYPE_ITEM) 38 38 { 39 39 echo('<td>'.date('j.n.Y', $Record['DueDate']).'</td>'); -
trunk/Modules/FinanceBankAPI/GPC.php
r738 r873 11 11 $Type = mb_substr($Line, 1, 3); 12 12 13 if ($Type == GPC_TYPE_REPORT)13 if ($Type == GPC_TYPE_REPORT) 14 14 { 15 15 $GPCLine = array … … 29 29 ); 30 30 } else 31 if ($Type == GPC_TYPE_ITEM)31 if ($Type == GPC_TYPE_ITEM) 32 32 { 33 33 $GPCLine = array … … 53 53 $GPCLine = NULL; 54 54 55 return ($GPCLine);55 return ($GPCLine); 56 56 } 57 57 } -
trunk/Modules/FinanceBankAPI/ImportFio.php
r765 r873 9 9 $Fio = new FioAPI(); 10 10 $Fio->Token = $this->BankAccount['LoginName']; 11 if ($this->BankAccount['LastImportDate'] == '') $PeriodStart = time();11 if ($this->BankAccount['LastImportDate'] == '') $PeriodStart = time(); 12 12 else $PeriodStart = MysqlDateToTime($this->BankAccount['LastImportDate']); 13 13 $PeriodEnd = time(); … … 22 22 //$Output .= '<td>Suma výdajů: '.$Records['DebitValue'].' Kč</td>'; 23 23 //$Output .= '</tr>'; 24 foreach ($Records['Items'] as $Record)24 foreach ($Records['Items'] as $Record) 25 25 { 26 26 $DbResult = $this->Database->select('FinanceBankImport', 'ID', 'Identification='.$Record['ID']); 27 if ($DbResult->num_rows == 0)27 if ($DbResult->num_rows == 0) 28 28 { 29 29 $Output .= '<tr>'; … … 44 44 $this->Database->update('FinanceBankAccount', 'Id='.$this->BankAccount['Id'], 45 45 array('LastImportDate' => TimeToMysqlDate($PeriodEnd))); 46 return ($Output);46 return ($Output); 47 47 } 48 48 } -
trunk/Modules/FinanceBankAPI/ImportPS.php
r738 r873 5 5 function ImportFile($Content, $Ext) 6 6 { 7 if ($Ext == 'txt') $this->ImportTxt($Content);8 else if ($Ext == 'cvs') $this->ImportCVS($Content);7 if ($Ext == 'txt') $this->ImportTxt($Content); 8 else if ($Ext == 'cvs') $this->ImportCVS($Content); 9 9 } 10 10 … … 20 20 21 21 $Data = explode("\n", $Content); 22 foreach ($Data as $Key => $Value)22 foreach ($Data as $Key => $Value) 23 23 { 24 24 $Value = str_replace('\"', '"', $Value); 25 25 $Data[$Key] = str_getcsv($Value, ',', '"', "\\"); 26 26 //print_r($Data[$Key]); 27 foreach ($Data[$Key] as $Key2 => $Value2)27 foreach ($Data[$Key] as $Key2 => $Value2) 28 28 { 29 if (substr($Data[$Key][$Key2], 0, 2) == '\"')29 if (substr($Data[$Key][$Key2], 0, 2) == '\"') 30 30 $Data[$Key][$Key2] = substr($Data[$Key][$Key2], 2, -2); 31 31 } … … 46 46 ); 47 47 48 if ($Header != $Data[0]) $Output = 'Nekompatibilní struktura CSV';48 if ($Header != $Data[0]) $Output = 'Nekompatibilní struktura CSV'; 49 49 else 50 50 { … … 54 54 $Output = '<form action="?Operation=insert" method="post">'; 55 55 $I = 0; 56 foreach ($Data as $Key => $Value)56 foreach ($Data as $Key => $Value) 57 57 { 58 if (count($Value) <= 1) continue;59 if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna58 if (count($Value) <= 1) continue; 59 if ($Value[9] == '') $Value[5] = 128; // Žádný účet => Poštovní spořitelna 60 60 $Time = explode('.', $Value[0]); 61 61 $Time = $Time[2].'-'.$Time[1].'-'.$Time[0]; 62 62 $Money = $Value[1]; 63 if (is_numeric($Value[5]))63 if (is_numeric($Value[5])) 64 64 { 65 65 $Subject = $Value[5] * 1; 66 66 $DbResult = $this->Database->query('SELECT Id FROM Subject WHERE Id='.$this->Database->real_escape_string($Subject)); 67 if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')';67 if ($DbResult->num_rows == 0) $Subject = '? ('.($Value[5] * 1).')'; 68 68 } else 69 69 { 70 70 $Subject = '? ('.$Value[5].')'; 71 71 } 72 if (!is_numeric($Subject))72 if (!is_numeric($Subject)) 73 73 { 74 74 $Mode = 'Ručně'; … … 80 80 } 81 81 82 if ($Money < 0) $Text = 'Platba převodem';82 if ($Money < 0) $Text = 'Platba převodem'; 83 83 else $Text = 'Přijatá platba'; 84 84 $Automatic .= '<tr>'. -
trunk/Modules/IS/IS.php
r871 r873 309 309 $DbRow = $DbResult->fetch_assoc(); 310 310 $Actions[] = '<a href="javascript:window.close();" onclick="add_select_item('.$Id.',"'.$DbRow['Name'].'","'. 311 $_GET['r'].'"); set_return ('.$Id.',"'.311 $_GET['r'].'"); set_return ('.$Id.',"'. 312 312 $_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'. 313 313 $this->System->Link('/images/select.png').'"/> Vybrat</a>'; … … 679 679 $this->BasicHTML = true; 680 680 $this->HideMenu = true; 681 $RowActions = '<a href="javascript:window.close();" onclick="set_return (#RowId,"'.681 $RowActions = '<a href="javascript:window.close();" onclick="set_return (#RowId,"'. 682 682 $_GET['r'].'");"><img alt="Vybrat" title="Vybrat" src="'. 683 683 $this->System->Link('/images/select.png').'"/></a>'; … … 706 706 if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read')) 707 707 return 'Nemáte oprávnění'; 708 if (!array_key_exists($Table, $this->System->FormManager->Classes))708 if (!array_key_exists($Table, $this->System->FormManager->Classes)) 709 709 return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena'); 710 710 $FormClass = $this->System->FormManager->Classes[$Table]; -
trunk/Modules/Log/Log.php
r681 r873 49 49 function NewRecord($Module, $Operation, $Value = '') 50 50 { 51 if (array_key_exists('User', $this->System->ModuleManager->Modules) and51 if (array_key_exists('User', $this->System->ModuleManager->Modules) and 52 52 array_key_exists('Id', $this->System->User->User)) 53 53 $UserId = $this->System->User->User['Id']; 54 54 else $UserId = NULL; 55 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR'];55 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR']; 56 56 else $IPAddress = ''; 57 57 $this->Database->insert('Log', array('Time' => 'NOW()', … … 69 69 $Output = ''; 70 70 $Items = array(); 71 if (array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"';71 if (array_key_exists('type', $_GET)) $Where = ' WHERE `Type` = "'.($_GET['type'] * 1).'"'; 72 72 else $Where = ''; 73 73 $sql = 'SELECT *, UNIX_TIMESTAMP(`Time`) AS `TimeCreate`, (SELECT `User`.`Name` FROM `User` WHERE `User`.`Id` = `Log`.`User`) AS `UserName`, `Time` FROM `Log`'. 74 74 $Where.' ORDER BY `Time` DESC LIMIT '.$Count; 75 75 $DbResult = $this->System->Database->query($sql); 76 while ($Line = $DbResult->fetch_assoc())76 while ($Line = $DbResult->fetch_assoc()) 77 77 { 78 78 $Line['Value'] = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $Line['Value']); … … 96 96 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 97 97 $RSS->Items = $Items; 98 return ($RSS->Generate());98 return ($RSS->Generate()); 99 99 } 100 100 } -
trunk/Modules/Map/Map.php
r865 r873 13 13 function Show() 14 14 { 15 if (!$this->System->User->CheckPermission('Map', 'Show'))16 return ('Nemáte oprávnění');17 18 if (count($this->System->PathItems) > 1)19 { 20 if ($this->System->PathItems[1] == 'show-position') return($this->ShowPosition());21 else return (PAGE_NOT_FOUND);22 } else return ($this->ShowMain());15 if (!$this->System->User->CheckPermission('Map', 'Show')) 16 return ('Nemáte oprávnění'); 17 18 if (count($this->System->PathItems) > 1) 19 { 20 if ($this->System->PathItems[1] == 'show-position') return ($this->ShowPosition()); 21 else return (PAGE_NOT_FOUND); 22 } else return ($this->ShowMain()); 23 23 } 24 24 … … 26 26 { 27 27 $DbResult = $this->Database->select('MapPosition', '*', '`Id`='.$_GET['i']); 28 if ($DbResult->num_rows > 0)28 if ($DbResult->num_rows > 0) 29 29 { 30 30 $DbRow = $DbResult->fetch_assoc(); … … 40 40 $MapApi->Markers[] = $Marker; 41 41 $Output = $MapApi->ShowPage($this); 42 return ($Output);43 } else return ('Položka nenalezena');42 return ($Output); 43 } else return ('Položka nenalezena'); 44 44 } 45 45 … … 59 59 'WHERE (`NetworkDevice`.`Used`=1) AND (`NetworkDevice`.`MapPosition` IS NOT NULL) '. 60 60 'GROUP BY `NetworkDevice`.`MapPosition`'); 61 while ($Device = $DbResult->fetch_assoc())61 while ($Device = $DbResult->fetch_assoc()) 62 62 { 63 63 $Pos = explode(';', $Device['Pos']); … … 69 69 70 70 $DbResult = $this->Database->query('SELECT * FROM `NetworkLink` WHERE (`Interface1` <> 0) AND (`Interface2` <> 0)'); 71 while ($Link = $DbResult->fetch_assoc())71 while ($Link = $DbResult->fetch_assoc()) 72 72 { 73 73 $DbResult2 = $this->Database->query('SELECT `NetworkDevice`.`Used`, `MapPosition`.`Pos` FROM `NetworkDevice` '. … … 77 77 'JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '. 78 78 'WHERE `NetworkDevice`.`Id` = (SELECT `NetworkInterface`.`Device` FROM `NetworkInterface` WHERE `NetworkInterface`.`Id` = '.$Link['Interface2'].')'); 79 if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))79 if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0)) 80 80 { 81 81 $Device1 = $DbResult2->fetch_assoc(); … … 83 83 $Device2 = $DbResult3->fetch_assoc(); 84 84 $Pos2 = explode(';', $Device2['Pos']); 85 if (($Device1['Used'] == 1) and ($Device2['Used'] == 1))85 if (($Device1['Used'] == 1) and ($Device2['Used'] == 1)) 86 86 { 87 87 $PolyLine = new MapPolyLine(); … … 146 146 NetworkLinks = ['; 147 147 $DbResult = $this->Database->query('SELECT * FROM `NetworkLink` WHERE (`Interface1` <> 0) AND (`Interface2` <> 0)'); 148 while ($Link = $DbResult->fetch_assoc())148 while ($Link = $DbResult->fetch_assoc()) 149 149 { 150 150 $DbResult2 = $this->Database->query('SELECT `NetworkDevice`.`Used`, `MapPosition`.`Pos` FROM `NetworkDevice` '. … … 154 154 'JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '. 155 155 'WHERE `NetworkDevice`.`Id` = (SELECT `NetworkInterface`.`Device` FROM `NetworkInterface` WHERE `NetworkInterface`.`Id` = '.$Link['Interface2'].')'); 156 if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))156 if (($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0)) 157 157 { 158 158 $Device1 = $DbResult2->fetch_assoc(); … … 160 160 $Device2 = $DbResult3->fetch_assoc(); 161 161 $Pos2 = explode(';', $Device2['Pos']); 162 if (($Device1['Used'] == 1) and ($Device2['Used'] == 1))162 if (($Device1['Used'] == 1) and ($Device2['Used'] == 1)) 163 163 $Output .= 'new google.maps.Polyline([new google.maps.LatLng('.$Pos1[0].', '. 164 164 $Pos1[1].'),new google.maps.LatLng('.$Pos2[0].', '.$Pos2[1].')], "#4F4FBF", 3, 0.8), '; … … 198 198 'WHERE (`NetworkDevice`.`Used`=1) AND (`NetworkDevice`.`MapPosition` IS NOT NULL) '. 199 199 'GROUP BY `NetworkDevice`.`MapPosition`'); 200 while ($Device = $DbResult->fetch_assoc())200 while ($Device = $DbResult->fetch_assoc()) 201 201 { 202 202 $Pos = explode(';', $Device['Pos']); … … 236 236 </table>'; 237 237 */ 238 return ($Output);238 return ($Output); 239 239 } 240 240 } … … 245 245 { 246 246 $Output = parent::OnEdit($Item); 247 if ($this->FormManager->ShowRelation)247 if ($this->FormManager->ShowRelation) 248 248 $Output .= '<img src="'.$this->FormManager->Root.'/images/select.png" alf="Vybrat" language="javascript" '. 249 249 'onclick="return popupwindow("'.$this->FormManager->Root.'/is/?a=mapselect&r='. 250 250 $Item['Name'].'","test");" style="cursor:hand;cursor:pointer"/>'; 251 return ($Output);251 return ($Output); 252 252 } 253 253 } -
trunk/Modules/Map/MapAPI.php
r864 r873 37 37 function Show() 38 38 { 39 return ('');39 return (''); 40 40 } 41 41 } … … 78 78 if (point) 79 79 { 80 set_return (point.lat() + ";" + point.lng(),"'.$this->OnClickObject.'");80 set_return (point.lat() + ";" + point.lng(),"'.$this->OnClickObject.'"); 81 81 window.close(); 82 82 } … … 102 102 </script>'; 103 103 $Output .= '<div id="map_canvas" style="width: 100%; height: 98%;"></div>'; 104 return ($Output);104 return ($Output); 105 105 } 106 106 } … … 162 162 if (e) 163 163 { 164 set_return (e.latlng.lat + ";" + e.latlng.lng,"'.$this->OnClickObject.'");164 set_return (e.latlng.lat + ";" + e.latlng.lng,"'.$this->OnClickObject.'"); 165 165 window.close(); 166 166 } -
trunk/Modules/Meals/Meals.php
r790 r873 13 13 function Show() 14 14 { 15 if (count($this->System->PathItems) > 1)16 { 17 if ($this->System->PathItems[1] == 'tisk') return($this->ShowPrint());18 else if ($this->System->PathItems[1] == 'menuedit.php') return($this->ShowEdit());19 else return (PAGE_NOT_FOUND);20 } else return ($this->ShowMenu());15 if (count($this->System->PathItems) > 1) 16 { 17 if ($this->System->PathItems[1] == 'tisk') return ($this->ShowPrint()); 18 else if ($this->System->PathItems[1] == 'menuedit.php') return ($this->ShowEdit()); 19 else return (PAGE_NOT_FOUND); 20 } else return ($this->ShowMenu()); 21 21 } 22 22 … … 26 26 $Output = '<table align="center" class="WideTable"><tr><th>Den</th><th>Datum</th><th>Polévka</th><th>Hlavní jídlo</th></tr>'; 27 27 $DbResult = $this->Database->select('Meals', '*, UNIX_TIMESTAMP(Date)','Date >= NOW() ORDER BY Date'); 28 while ($Row = $DbResult->fetch_array())29 { 30 if ($Row['Status'] == 1) $Output .= '<tr><td>'.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].'</td><td align="right">'.HumanDate($Row['Date']).'</td><td>'.$Row['Soup'].'</td><td>'.$Row['Meal'].'</td></tr>';31 else if (($Row['Status' ] == 2) or ($Row['Status'] == 3))28 while ($Row = $DbResult->fetch_array()) 29 { 30 if ($Row['Status'] == 1) $Output .= '<tr><td>'.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].'</td><td align="right">'.HumanDate($Row['Date']).'</td><td>'.$Row['Soup'].'</td><td>'.$Row['Meal'].'</td></tr>'; 31 else if (($Row['Status' ] == 2) or ($Row['Status'] == 3)) 32 32 { 33 33 $Output .= '<tr><td>'.$this->DayNames[date('w', $Row['UNIX_TIMESTAMP(Date)'])].'</td><td align="right">'.HumanDate($Row['Date']).'</td><td colspan="2" align="center">'.$this->Status[$Row['Status']].'</td></tr>'; … … 40 40 $Output .= 'Cena jednoho menu: '.$Row['Price'].' Kč<br />'; 41 41 $Output .= $Row['Info']; 42 return ($Output);42 return ($Output); 43 43 } 44 44 … … 66 66 $Date = explode('-', $_GET['date']); 67 67 $Time2 = mktime(0, 0, 0, $Date[1], $Date[2], $Date[0]); 68 for ($I = 0; $I < 5; $I++)68 for ($I = 0; $I < 5; $I++) 69 69 { 70 70 $Time = $Time2 + $I * 86400; … … 74 74 $Row = $DbResult->fetch_array(); 75 75 $Output .= '<tr><td style="border-style: solid; border-color: black; border-width: 2; font-size: xx-large;" width="10%">'.$this->DayNamesShort[$DayOfWeek].'</td><td style="font-size: x-large; border-style: solid; border-color: black; border-width: 2;" width="90%">'; 76 if ($Row['Status'] == 0) $Output .= ' <br><br> ';77 if ($Row['Status'] == 1) $Output .= 'Polévka: '.$Row['Soup'].'<br><br>'.$Row['Meal'];78 else if (($Row['Status'] == 2) or ($Row['Status'] == 3))76 if ($Row['Status'] == 0) $Output .= ' <br><br> '; 77 if ($Row['Status'] == 1) $Output .= 'Polévka: '.$Row['Soup'].'<br><br>'.$Row['Meal']; 78 else if (($Row['Status'] == 2) or ($Row['Status'] == 3)) 79 79 { 80 80 $Output .= '<br>'.$this->Status[$Row['Status']].'<br> '; … … 91 91 92 92 $Output .= '</body></html>'; 93 return ($Output);93 return ($Output); 94 94 } 95 95 … … 103 103 $Week = date('w', mktime(0, 0, 0, $Date[1], $Date[2], $Date[0])); 104 104 $WeekOfYear = date('W', mktime(0, 0, 0, $Date[1], $Date[2], $Date[0])); 105 if ($WeekOfYear != $LastWeekOfYear)105 if ($WeekOfYear != $LastWeekOfYear) 106 106 $WeekRowSpan = '<td align="center" rowspan="'.(7 - (($Week + 7 - 1) % 7)).'">'. 107 107 $WeekOfYear.'<br /><a href="tisk/?date='. … … 109 109 '">Tisk</a></td>'; 110 110 else $WeekRowSpan = ''; 111 if ($Week == 0) $Color = ' style="color: #ff0000;" '; else $Color = '';111 if ($Week == 0) $Color = ' style="color: #ff0000;" '; else $Color = ''; 112 112 $Output = '<tr><td'.$Color.'>'.$this->DayNames[$Week].'</td><td>'.HumanDate($Row['Date']).'</td>'.$WeekRowSpan.' 113 113 <td><input name="soup_'.$Row['Date'].'" size="30" value="'.$Row['Soup'].'"></td> 114 114 <td><input name="meal_'.$Row['Date'].'" size="30" value="'.$Row['Meal'].'"></td> 115 115 <td><select name="status_'.$Row['Date'].'">'; 116 for ($I = 0; $I < 4; $I++) $Output .= ' <option '.$Selected[$I].'value="'.$I.'">'.$this->Status[$I].'</option>';116 for ($I = 0; $I < 4; $I++) $Output .= ' <option '.$Selected[$I].'value="'.$I.'">'.$this->Status[$I].'</option>'; 117 117 $Output .= '</select></td></tr>'; 118 118 $LastWeekOfYear = $WeekOfYear; 119 return ($Output);119 return ($Output); 120 120 } 121 121 … … 125 125 126 126 $Output = ''; 127 if (array_key_exists('action', $_GET))128 { 129 if ($_GET['action'] == 'savemenu')130 { 131 for ($I = 0; $I < $this->DayCount; $I++)127 if (array_key_exists('action', $_GET)) 128 { 129 if ($_GET['action'] == 'savemenu') 130 { 131 for ($I = 0; $I < $this->DayCount; $I++) 132 132 { 133 133 $Time = time() + $I * 86400; … … 138 138 $this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'MenuSave'); 139 139 } 140 if ($_GET['action'] == 'saveinfo')140 if ($_GET['action'] == 'saveinfo') 141 141 { 142 142 $this->Database->delete('MealsInfo', '1'); … … 149 149 <fieldset><legend>Jídlo pro jednotlivé dny</legend> 150 150 <table align="center" class="WideTable"><tr><th>Den</th><th>Datum</th><th>Týden</th><th>Polévka</th><th>Hlavní jídlo</th><th>Stav</th></tr>'; 151 for ($I = 0; $I < $this->DayCount; $I++)151 for ($I = 0; $I < $this->DayCount; $I++) 152 152 { 153 153 $Time = time() + $I * 86400; 154 154 $DbResult = $this->Database->select('Meals', '*', 'Date = "'.date('Y-m-d', $Time).'"'); 155 if ($Row = $DbResult->fetch_array())155 if ($Row = $DbResult->fetch_array()) 156 156 $Output .= $this->PrintTableRow($Row); 157 157 else … … 173 173 '<div align="center"><input type="submit" value="Uložit údaje"></div> 174 174 </fieldset></form>'; 175 return ($Output);175 return ($Output); 176 176 } 177 177 } -
trunk/Modules/Meteostation/Download.php
r548 r873 4 4 5 5 $MeteoStation = new MeteoStation($System->Database, $System); 6 while (true)6 while (true) 7 7 { 8 8 $MeteoStation->DownloadAll(); -
trunk/Modules/Meteostation/Meteostation.php
r747 r873 11 11 $Output = 'Stav meteostanice:<br/>'; 12 12 $Output .= '<img src="'.$this->System->Link('/Modules/Meteostation/cache/1.png').'" alt="stav meteostanice"/>'; 13 return ($Output);13 return ($Output); 14 14 } 15 15 } … … 91 91 { 92 92 $DbResult = $this->Database->select('MeteoStation', '*'); 93 while ($DbRow = $DbResult->fetch_assoc())93 while ($DbRow = $DbResult->fetch_assoc()) 94 94 { 95 95 $MeteoStation = new MeteoStation(); -
trunk/Modules/Network/HostList.php
r833 r873 11 11 function Show() 12 12 { 13 if (!$this->System->User->CheckPermission('Network', 'ShowHostList'))14 return ('Nemáte oprávnění');13 if (!$this->System->User->CheckPermission('Network', 'ShowHostList')) 14 return ('Nemáte oprávnění'); 15 15 16 if (array_key_exists('admin', $_GET)) $Where = 'AND NetworkDevice.Type IN (1,4,5) ';16 if (array_key_exists('admin', $_GET)) $Where = 'AND NetworkDevice.Type IN (1,4,5) '; 17 17 else $Where = ''; 18 18 $Output = '<div align="center" style="font-size: small;"><table class="WideTable">'; … … 22 22 'LEFT JOIN User ON Member.ResponsibleUser = User.Id '. 23 23 'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 '.$Where.'ORDER BY NetworkDevice.Name'); 24 while ($Device = $DbResult->fetch_assoc())24 while ($Device = $DbResult->fetch_assoc()) 25 25 { 26 if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';26 if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = ''; 27 27 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE Device = '.$Device['Id']); 28 28 $DbRow = $DbResult2->fetch_row(); 29 if ($DbRow[0] == 1)29 if ($DbRow[0] == 1) 30 30 { 31 31 $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']); 32 32 $Interface = $DbResult2->fetch_assoc(); 33 if ($Interface['ExternalIP'] == '') $Interface['ExternalIP'] = ' ';34 if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = ' ';35 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';33 if ($Interface['ExternalIP'] == '') $Interface['ExternalIP'] = ' '; 34 if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = ' '; 35 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = ''; 36 36 $InterfaceName = $Device['Name']; 37 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];37 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name']; 38 38 $Output .= '<tr><td style="text-align: left; '.$Style.'">'.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td>'.$Interface['ExternalIP'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>'; 39 39 } else … … 41 41 $Output .= '<tr><td colspan="3" style="text-align: left; font-weight: bold; '.$Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>'; 42 42 $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']); 43 while ($Interface = $DbResult2->fetch_assoc())43 while ($Interface = $DbResult2->fetch_assoc()) 44 44 { 45 if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = ' ';46 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';45 if ($Interface['LocalIP'] == '') $Interface['LocalIP'] = ' '; 46 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = ''; 47 47 $InterfaceName = $Device['Name']; 48 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];48 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name']; 49 49 $Output .= '<tr><td style="text-align: left; '.$Style.'"> '.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td> </td><td> </td><td> </td><td> </td></tr>'; 50 50 } … … 52 52 } 53 53 $Output .= '</table></div>'; 54 return ($Output);54 return ($Output); 55 55 } 56 56 } -
trunk/Modules/Network/Hosting.php
r790 r873 11 11 $Output = '<br /><table class="WideTable"><tr><th>Název projektu</th><th>Založeno</th><th>Umístění na serveru</th><th>Zodpovědná osoba</th></tr>'; 12 12 $DbResult = $this->Database->query('SELECT NetworkDevice.Name as ServerName, HostedProject.Name, HostedProject.Homepage, HostedProject.TimeCreate, User.Name AS UserName FROM HostedProject JOIN User ON User.Id = HostedProject.User JOIN NetworkDevice ON NetworkDevice.Id = HostedProject.Server ORDER BY HostedProject.Name'); 13 while ($DbRow = $DbResult->fetch_assoc())13 while ($DbRow = $DbResult->fetch_assoc()) 14 14 { 15 15 $Output .= '<tr><td><a href="'.$DbRow['Homepage'].'">'.$DbRow['Name'].'</a></td><td>'.HumanDate($DbRow['TimeCreate']).'</td><td>'.$DbRow['ServerName'].'</td><td>'.$DbRow['UserName'].'</td></tr>'; 16 16 } 17 17 $Output .= '</table>'; 18 return ($Output);18 return ($Output); 19 19 } 20 20 } -
trunk/Modules/Network/Network.php
r871 r873 25 25 '<tr><th/><br/>SSID<br/><br/></th>'; 26 26 $ChannelList = array(); 27 if (!array_key_exists('range', $_GET)) $_GET['range'] = 'a';28 if ($_GET['range'] == 'a')27 if (!array_key_exists('range', $_GET)) $_GET['range'] = 'a'; 28 if ($_GET['range'] == 'a') 29 29 { 30 30 $Where = '(Frequency < 5000)'; 31 for ($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq;31 for ($Freq = 2402; $Freq <= 2482; $Freq = $Freq + 5) $ChannelList[] = $Freq; 32 32 } 33 if ($_GET['range'] == 'bc')33 if ($_GET['range'] == 'bc') 34 34 { 35 35 $Where = '(Frequency >= 5000) AND (Frequency <= 5350)'; 36 for ($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq;36 for ($Freq = 5150; $Freq <= 5350; $Freq = $Freq + 5) $ChannelList[] = $Freq; 37 37 } 38 if ($_GET['range'] == 'd')38 if ($_GET['range'] == 'd') 39 39 { 40 40 $Where = '(Frequency >= 5470)'; 41 for ($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq;41 for ($Freq = 5470; $Freq <= 5725; $Freq = $Freq + 5) $ChannelList[] = $Freq; 42 42 } 43 43 44 foreach ($ChannelList as $Frequency)44 foreach ($ChannelList as $Frequency) 45 45 { 46 46 $Output .= '<th><div class="RotatedHeader">'.$Frequency.'<div></th>'; … … 48 48 $Output .= '</tr>'; 49 49 $DbResult = $this->Database->query('SELECT `Frequency` FROM `NetworkInterfaceWireless` WHERE '.$Where.' AND (`Mode`=0) GROUP BY `Frequency`'); 50 while ($DbRow = $DbResult->fetch_assoc())50 while ($DbRow = $DbResult->fetch_assoc()) 51 51 { 52 52 $DbResult2 = $this->Database->query('SELECT * FROM `NetworkInterfaceWireless` WHERE (`Frequency`='.$DbRow['Frequency'].') AND '.$Where); 53 while ($DbRow2 = $DbResult2->fetch_assoc())53 while ($DbRow2 = $DbResult2->fetch_assoc()) 54 54 { 55 55 $LowFrequency = $DbRow['Frequency'] - $DbRow2['ChannelWidth'] / 2 - $DbRow2['ChannelWidthLower']; 56 56 $HighFrequency = $DbRow['Frequency'] + $DbRow2['ChannelWidth'] / 2 + $DbRow2['ChannelWidthUpper']; 57 57 $Output .= '<tr><td>'.$DbRow2['SSID'].'</td>'; 58 foreach ($ChannelList as $Frequency)58 foreach ($ChannelList as $Frequency) 59 59 { 60 if (($DbRow2['Frequency'] == $Frequency)) $Color = '#000000';61 else if (($LowFrequency <= ($Frequency - 2.5)) and ($HighFrequency >= ($Frequency + 2.5))) $Color = '#808080';62 else if (($LowFrequency == $Frequency) or ($HighFrequency == $Frequency)) $Color = '#c0c0c0';60 if (($DbRow2['Frequency'] == $Frequency)) $Color = '#000000'; 61 else if (($LowFrequency <= ($Frequency - 2.5)) and ($HighFrequency >= ($Frequency + 2.5))) $Color = '#808080'; 62 else if (($LowFrequency == $Frequency) or ($HighFrequency == $Frequency)) $Color = '#c0c0c0'; 63 63 else $Color = '#ffffff'; 64 64 $Output .= '<td style="background-color: '.$Color.';"> </td>'; … … 69 69 } 70 70 $Output .= '</table>'; 71 return ($Output);71 return ($Output); 72 72 } 73 73 } … … 81 81 function Show() 82 82 { 83 if (count($this->System->PathItems) > 1)83 if (count($this->System->PathItems) > 1) 84 84 { 85 85 $Output = $this->PageNotFound(); 86 86 } else $Output = $this->ShowInformation(); 87 return ($Output);87 return ($Output); 88 88 } 89 89 90 90 function ShowInformation() 91 91 { 92 if (!$this->System->User->CheckPermission('Network', 'ShowInfo'))93 return ('Nemáte oprávnění');92 if (!$this->System->User->CheckPermission('Network', 'ShowInfo')) 93 return ('Nemáte oprávnění'); 94 94 95 95 $Output = '<a href="'.$this->System->Link('/network/frequency-plan/').'">Frekvenční plán</a><br />'; 96 96 $Output .= '<a href="'.$this->System->Link('/network/subnet/').'">Výpis registrovaných podsítí</a><br />'; 97 97 $Output .= '<a href="'.$this->System->Link('/network/hosts/').'">Registrované zařízení</a><br />'; 98 return ($Output);98 return ($Output); 99 99 } 100 100 } … … 862 862 '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkInterface`.`Enabled`=1)'. 863 863 'ORDER BY `Name` ASC'); 864 if ($DbResult3->num_rows > 0)864 if ($DbResult3->num_rows > 0) 865 865 { 866 866 $Output .= $Title.'<br/>'; 867 867 $Output .= '<table>'. 868 868 '<tr><th align="center">Jméno</th><th align="center">Stav</th><th align="center">Čas</th><th align="center">Trvání</th></tr>'."\n"; 869 while ($Item = $DbResult3->fetch_assoc())869 while ($Item = $DbResult3->fetch_assoc()) 870 870 { 871 871 $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']); … … 874 874 sprintf('%02d', floor($Duration % 60)); 875 875 $Days = floor($Duration / (60 * 60 * 24)); 876 if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText;876 if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText; 877 877 878 878 $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']]. … … 895 895 $Output .= $StillOffline['Report']; 896 896 $Offline = $this->OnlineList('Offline', 0, -1, 0); 897 return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva'));897 return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva')); 898 898 } 899 899 … … 918 918 $Output .= '<table>'. 919 919 '<tr><th align="center">Jméno</th><th align="center">Stav</th><th align="center">Čas</th><th align="center">Trvání</th></tr>'."\n"; 920 while ($Item = $DbResult3->fetch_assoc())920 while ($Item = $DbResult3->fetch_assoc()) 921 921 { 922 922 $Duration = $Time - MysqlDateTimeToTime($Item['LastOnline']); … … 925 925 sprintf('%02d', floor($Duration % 60)); 926 926 $Days = floor($Duration / (60 * 60 * 24)); 927 if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText;927 if ($Days > 0) $DurationText = $Days.' dnů '.$DurationText; 928 928 929 929 $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']]. … … 947 947 $Output .= $StillOffline['Report']; 948 948 $Offline = $this->PortCheckList('Offline', 0, -1, 0); 949 return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port'));949 return (array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port')); 950 950 } 951 951 } -
trunk/Modules/Network/Subnet.php
r825 r873 36 36 37 37 $DbResult = $this->Database->query($Query); 38 while ($Subnet = $DbResult->fetch_assoc())38 while ($Subnet = $DbResult->fetch_assoc()) 39 39 { 40 40 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE CompareNetworkPrefix(INET_ATON("'.$Subnet['AddressRange'].'"), INET_ATON(LocalIP), '.$Subnet['Mask'].')'); … … 54 54 $Output .= '</table>'; 55 55 $Output .= $PageList['Output']; 56 return ($Output);56 return ($Output); 57 57 } 58 58 } -
trunk/Modules/Network/UserHosts.php
r738 r873 15 15 global $Config; 16 16 17 if ($this->System->User->User['Id'] == '') return($this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci'));17 if ($this->System->User->User['Id'] == '') return ($this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci')); 18 18 $Output = '<div align="center" style="font-size: small;"><table class="WideTable">'; 19 19 $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>'; … … 21 21 'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '. 22 22 'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->User->User['Id'].') ORDER BY NetworkDevice.Name'); 23 while ($Device = $DbResult->fetch_assoc())23 while ($Device = $DbResult->fetch_assoc()) 24 24 { 25 if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';25 if ($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = ''; 26 26 $Output .= '<tr><td colspan="4" style="text-align: left; font-weight: bold; '. 27 27 $Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td></tr>'; 28 28 $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']); 29 while ($Interface = $DbResult2->fetch_assoc())29 while ($Interface = $DbResult2->fetch_assoc()) 30 30 { 31 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';31 if ($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = ''; 32 32 $InterfaceName = $Device['Name']; 33 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];33 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name']; 34 34 $Output .= '<tr><td style="text-align: left; '.$Style.'"> '. 35 35 $InterfaceName.'</td><td>'.NotBlank($Interface['LocalIP']).'</td><td>'. … … 39 39 } 40 40 $Output .= '</table></div>'; 41 return ($Output);41 return ($Output); 42 42 } 43 43 } -
trunk/Modules/NetworkConfig/Generate.php
r848 r873 1 1 <?php 2 2 3 if (isset($_SERVER['REMOTE_ADDR'])) die();3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 include_once(dirname(__FILE__).'/../../Application/System.php'); 5 5 $System = new Core(); … … 9 9 $Now = time(); 10 10 $DbResult = $System->Database->select('NetworkConfiguration', '*, UNIX_TIMESTAMP(`LastTime`)', '(`Changed` = 1) AND (`Enabled` = 1)'); 11 while ($Service = $DbResult->fetch_assoc())11 while ($Service = $DbResult->fetch_assoc()) 12 12 { 13 if ($Service['UNIX_TIMESTAMP(LastTime)'] < (time() - $Service['Period']))13 if ($Service['UNIX_TIMESTAMP(LastTime)'] < (time() - $Service['Period'])) 14 14 { 15 15 $System->Database->update('NetworkConfiguration', '`Id`='.$Service['Id'], array('Changed' => 2)); … … 19 19 $ExecuteParts = explode('|', $Service['Execute']); 20 20 $Output = array(); 21 foreach ($ExecuteParts as $Command)22 if ($Command != '')21 foreach ($ExecuteParts as $Command) 22 if ($Command != '') 23 23 { 24 24 exec($Command, $Output); -
trunk/Modules/NetworkConfig/NetworkConfig.php
r820 r873 80 80 { 81 81 $Output = ''; 82 if ($Parameters >= 3)82 if ($Parameters >= 3) 83 83 { 84 84 $ConfigItemName = $Parameters[2]; 85 if (array_key_exists($ConfigItemName, $this->ConfigItems))85 if (array_key_exists($ConfigItemName, $this->ConfigItems)) 86 86 { 87 87 $ClassName = $this->ConfigItems[$ConfigItemName]; … … 90 90 } else $Output = 'Config item '.$ConfigItemName.' not found'; 91 91 } else $Output = 'Not enough parameters'; 92 return ($Output);92 return ($Output); 93 93 } 94 94 } -
trunk/Modules/NetworkConfigAirOS/Generators/SSHClient.php
r856 r873 25 25 { 26 26 $Commands = trim($Commands); 27 if ($Commands != '')27 if ($Commands != '') 28 28 { 29 29 $Commands = addslashes($Commands); … … 34 34 $Command = $this->SSHPath.' -oBatchMode=yes -o ConnectTimeout='.$this->Timeout.' -l '. 35 35 $this->UserName.$PrivKey.' '.$this->HostName.' "'.$Commands.'"'; 36 if ($this->Debug) echo($Command);36 if ($this->Debug) echo($Command); 37 37 $Output = array(); 38 38 exec($Command, $Output); 39 39 } else $Output = ''; 40 if ($this->Debug) print_r($Output);41 return ($Output);40 if ($this->Debug) print_r($Output); 41 return ($Output); 42 42 } 43 43 } -
trunk/Modules/NetworkConfigAirOS/Generators/Signal.php
r856 r873 13 13 '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '. 14 14 'FROM `NetworkDevice` WHERE (`API` = 2) AND (`Used` = 1)'); 15 while ($Device = $DbResult3->fetch_assoc())15 while ($Device = $DbResult3->fetch_assoc()) 16 16 { 17 17 echo($Device['LocalIP'].""); … … 25 25 //print_r($Array); 26 26 echo('-'); 27 foreach ($Array as $Properties)27 foreach ($Array as $Properties) 28 28 { 29 29 $DbResult = $this->Database->select('NetworkInterface', 'Id', '`MAC`="'.$Properties['mac'].'"'); 30 if ($DbResult->num_rows > 0)30 if ($DbResult->num_rows > 0) 31 31 { 32 32 $DbRow = $DbResult->fetch_assoc(); -
trunk/Modules/NetworkConfigLinux/Generators/CheckPorts.php
r819 r873 7 7 $Timeout = 1; 8 8 $State = 0; 9 if ($Protocol == 'tcp') $Prefix = '';10 else if ($Protocol == 'udp') $Prefix = 'udp://';9 if ($Protocol == 'tcp') $Prefix = ''; 10 else if ($Protocol == 'udp') $Prefix = 'udp://'; 11 11 else throw new Exception('Unsupported protocol "'.$Protocol.'"'); 12 if ($Socket = @fsockopen($Prefix.$IP, $Port, $ErrorNumber, $ErrorString, $Timeout))12 if ($Socket = @fsockopen($Prefix.$IP, $Port, $ErrorNumber, $ErrorString, $Timeout)) 13 13 { 14 14 fclose($Socket); 15 15 $State = 1; 16 16 } 17 return ($State);17 return ($State); 18 18 } 19 19 … … 29 29 'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id`=`NetworkPort`.`Interface` '. 30 30 'WHERE (`NetworkPort`.`Enabled`=1) AND (`NetworkInterface`.`LocalIP` !="")'); 31 while ($DbRow = $DbResult->fetch_assoc())31 while ($DbRow = $DbResult->fetch_assoc()) 32 32 $Ports[$DbRow['Id']] = $DbRow; 33 33 34 foreach ($Ports as $Index => $Port)34 foreach ($Ports as $Index => $Port) 35 35 { 36 if ($Port['Protocol'] == 0) $Port['Protocol'] = 'tcp';37 if ($Port['Protocol'] == 1) $Port['Protocol'] = 'udp';36 if ($Port['Protocol'] == 0) $Port['Protocol'] = 'tcp'; 37 if ($Port['Protocol'] == 1) $Port['Protocol'] = 'udp'; 38 38 $Port['NewOnline'] = $this->CheckPortStatus($Port['LocalIP'], $Port['Number'], $Port['Protocol']); 39 39 40 40 // Update last online time if still online 41 if ($Port['NewOnline'])41 if ($Port['NewOnline']) 42 42 { 43 43 $DbResult = $this->Database->update('NetworkPort', '`Id` = "'.$Port['Id'].'"', … … 46 46 47 47 // Update UpDown table 48 if ($Port['Online'] != $Port['NewOnline'])48 if ($Port['Online'] != $Port['NewOnline']) 49 49 { 50 50 // Online state changed … … 65 65 $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 1) AND '. 66 66 '(`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'")'); 67 while ($DbRow = $DbResult->fetch_assoc())67 while ($DbRow = $DbResult->fetch_assoc()) 68 68 { 69 69 echo('Port '.$DbRow['Number'].' online but time not updated.'."\n"); … … 71 71 $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 0) AND '. 72 72 '(`LastOnline` >= "'.TimeToMysqlDateTime($StartTime).'")'); 73 while ($DbRow = $DbResult->fetch_assoc())73 while ($DbRow = $DbResult->fetch_assoc()) 74 74 { 75 75 echo('Port '.$DbRow['Number'].' not online but time updated.'."\n"); -
trunk/Modules/NetworkConfigLinux/Generators/DHCP.php
r790 r873 1 1 <?php 2 2 3 if (isset($_SERVER['REMOTE_ADDR'])) die();3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 /* 5 5 include_once('../../global.php'); … … 23 23 'option netbios-scope "";'."\n". 24 24 "server-identifier 192.168.0.1;\n\n"); 25 for ($i = 0; $i <= $MaxSubnet; $i++)25 for ($i = 0; $i <= $MaxSubnet; $i++) 26 26 { 27 27 fputs($File, "subnet 192.168.".$i.".0 netmask 255.255.255.0 {\n". … … 30 30 " option routers 192.168.".$i.".1;\n"); 31 31 $DbResult = $Database->select('hosts', '*', "IP LIKE '192.168.".$i."%' ORDER BY IP"); 32 while ($Row = $DbResult->fetch_array())32 while ($Row = $DbResult->fetch_array()) 33 33 { 34 34 $Data = $Row['name']; 35 if (strlen($Data) < 9) $Data .= "\t";35 if (strlen($Data) < 9) $Data .= "\t"; 36 36 fputs($File, " host ".$Data."\t{ fixed-address ".$Row['IP'].";\thardware ethernet ".$Row['MAC']."; }\n"); 37 37 } -
trunk/Modules/NetworkConfigLinux/Generators/DNS.php
r854 r873 18 18 "\t\t\t".$DNS['Minimum']."\t; minimum\n". 19 19 "\t\t\t)\n"; 20 foreach ($DNS['NameServer'] as $NameServer)20 foreach ($DNS['NameServer'] as $NameServer) 21 21 { 22 22 $Output .= "\t\tIN\tNS\t".strtolower($NameServer).".\n"; … … 26 26 // Mail server records 27 27 $Priority = 10; 28 foreach ($DNS['MailServer'] as $MailServer)28 foreach ($DNS['MailServer'] as $MailServer) 29 29 { 30 30 $Output .="\t\t\tMX\t".$Priority." ".strtolower($MailServer).".\n"; … … 34 34 $DNS['Domain'].".\tIN\tTXT\t\"v=spf1 mx -all\"\n". 35 35 $DNS['Domain'].".\tIN\tSPF\t\"v=spf1 mx -all\"\n"; 36 foreach ($DNS['MailServer'] as $MailServer)36 foreach ($DNS['MailServer'] as $MailServer) 37 37 { 38 38 $Output .= $MailServer.".\tIN\tTXT\t\"v=spf1 a -all\"\n". … … 45 45 46 46 // IPv4 host list 47 foreach ($DNS['Host'] as $Host)48 { 49 if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t";47 foreach ($DNS['Host'] as $Host) 48 { 49 if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t"; 50 50 $Output .= strtolower($Host['Name'])."\tIN\tA\t".$Host['Address']."\n"; 51 51 } 52 52 53 53 // IPv6 host list 54 foreach ($DNS['Host'] as $Host)55 { 56 if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t";57 if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))54 foreach ($DNS['Host'] as $Host) 55 { 56 if (strlen($Host['Name']) < 8) $Host['Name'] .= "\t"; 57 if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != '')) 58 58 $Output .= strtolower($Host['Name'])."\tIN\tAAAA\t".$Host['IPv6']."\n"; 59 59 } 60 60 61 61 // Alias list 62 foreach ($DNS['Alias'] as $Alias)63 { 64 if (strlen($Alias['Name']) < 8) $Alias['Name'] .= "\t";62 foreach ($DNS['Alias'] as $Alias) 63 { 64 if (strlen($Alias['Name']) < 8) $Alias['Name'] .= "\t"; 65 65 $Output .= strtolower($Alias['Name'])."\tIN\tCNAME\t".strtolower($Alias['Target'])."\n"; 66 66 } … … 71 71 72 72 // Generate reverse DNS records 73 foreach ($DNS['Network'] as $Network)73 foreach ($DNS['Network'] as $Network) 74 74 { 75 75 $Parts = explode('.', $Network); … … 83 83 "\t\t\t\t".$DNS['Minimum']."\t; minimum\n". 84 84 "\t\t\t\t)\n"; 85 foreach ($DNS['ReverseNameServer'] as $NameServer)85 foreach ($DNS['ReverseNameServer'] as $NameServer) 86 86 { 87 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])87 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain']) 88 88 $Output .= "@\tIN\tNS\t".$NameServer.".\n"; 89 89 else $Output .= "\tIN\tNS\t".$NameServer.".\n"; 90 90 } 91 foreach ($DNS['Host'] as $Host)92 if (substr($Host['Address'], 0, strlen($Network)) == $Network)91 foreach ($DNS['Host'] as $Host) 92 if (substr($Host['Address'], 0, strlen($Network)) == $Network) 93 93 { 94 94 $AddressParts = explode('.', $Host['Address']); … … 103 103 104 104 // Generate reverse DNS IPv6 records 105 foreach ($DNS['IPv6Network'] as $Network)105 foreach ($DNS['IPv6Network'] as $Network) 106 106 { 107 107 $Parts = explode('/', $Network); … … 117 117 "\t\t\t\t".$DNS['Minimum']."\t; minimum\n". 118 118 "\t\t\t\t)\n"; 119 foreach ($DNS['ReverseNameServer'] as $NameServer)119 foreach ($DNS['ReverseNameServer'] as $NameServer) 120 120 { 121 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain'])121 if (substr($NameServer, -strlen($DNS['Domain'])) == $DNS['Domain']) 122 122 $Output .= "@\tIN\tNS\t".$NameServer.".\n"; 123 123 else $Output .= "\tIN\tNS\t".$NameServer.".\n"; 124 124 } 125 foreach ($DNS['Host'] as $Host)126 if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != ''))125 foreach ($DNS['Host'] as $Host) 126 if (array_key_exists('IPv6', $Host) and ($Host['IPv6'] != '')) 127 127 { 128 128 $Addr = new NetworkAddressIPv6(); … … 161 161 $BaseDir = '/var/cache/bind'; 162 162 //$BaseDir = '/home/chronos/Projekty/centrala/trunk/var/named'; 163 if (!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.');163 if (!file_exists($BaseDir)) die('Base directory "'.$BaseDir.'" not exists.'); 164 164 $MailServer = 'centrala'; 165 165 … … 193 193 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '. 194 194 'WHERE (`NetworkInterface`.`LocalIP` <> "") AND (`NetworkDevice`.`Used` = 1)'); 195 while ($Interface = $DbResult->fetch_assoc())196 { 197 $Name = $Interface['DeviceName']; 198 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];195 while ($Interface = $DbResult->fetch_assoc()) 196 { 197 $Name = $Interface['DeviceName']; 198 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 199 199 $LocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP'], 200 200 'IPv6' => $Interface['IPv6']); … … 205 205 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '. 206 206 'WHERE (`NetworkInterface`.`ExternalIP` <> "") AND (`NetworkDevice`.`Used` = 1)'); 207 while ($Interface = $DbResult->fetch_assoc())208 { 209 $Name = $Interface['DeviceName']; 210 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];207 while ($Interface = $DbResult->fetch_assoc()) 208 { 209 $Name = $Interface['DeviceName']; 210 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 211 211 $LocalDNS['Host'][] = array('Name' => $Name.'-ext', 'Address' => $Interface['ExternalIP']); 212 212 } … … 216 216 $DbResult = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface '. 217 217 'JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE NetworkInterface.CZFreeIP <> ""'); 218 while ($Interface = $DbResult->fetch_assoc())218 while ($Interface = $DbResult->fetch_assoc()) 219 219 { 220 220 $Name = $Interface['DeviceName']; 221 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];221 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 222 222 $LocalDNS['Host'][] = array('Name' => $Name.'-czfree', 'Address' => $Interface['CZFreeIP']); 223 223 } … … 226 226 // Domain aliases 227 227 $DbResult = $this->Database->select('NetworkDomainAlias', '*'); 228 while ($Alias = $DbResult->fetch_assoc())228 while ($Alias = $DbResult->fetch_assoc()) 229 229 { 230 230 $LocalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); … … 257 257 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE '. 258 258 '(`NetworkInterface`.`ExternalIP` != "") AND (`NetworkDevice`.`Used` = 1)'); 259 while ($Interface = $DbResult->fetch_assoc())260 { 261 $Name = $Interface['DeviceName']; 262 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];259 while ($Interface = $DbResult->fetch_assoc()) 260 { 261 $Name = $Interface['DeviceName']; 262 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 263 263 $ExternalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['ExternalIP'], 264 264 'IPv6' => $Interface['IPv6']); … … 268 268 $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`'); 269 269 // JOIN `NetworkDevice` ON NetworkDomainAlias.Target LIKE NetworkDevice.Name AND NetworkInterface.ExternalIP != ""'); 270 while ($Alias = $DbResult->fetch_assoc())270 while ($Alias = $DbResult->fetch_assoc()) 271 271 { 272 272 $ExternalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); … … 302 302 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '. 303 303 'WHERE (`NetworkInterface`.`LocalIP` != "") AND (`NetworkDevice`.`Used` = 1)'); 304 while ($Interface = $DbResult->fetch_assoc())305 { 306 $Name = $Interface['DeviceName']; 307 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];304 while ($Interface = $DbResult->fetch_assoc()) 305 { 306 $Name = $Interface['DeviceName']; 307 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 308 308 $CZFreeDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']); 309 309 } … … 312 312 $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`'); 313 313 // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""'); 314 while ($Alias = $DbResult->fetch_assoc())314 while ($Alias = $DbResult->fetch_assoc()) 315 315 { 316 316 $CZFreeDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); … … 344 344 $DbResult = $this->Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface` '. 345 345 'JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE `NetworkInterface`.`LocalIP` != ""'); 346 while ($Interface = $DbResult->fetch_assoc())347 { 348 $Name = $Interface['DeviceName']; 349 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];346 while ($Interface = $DbResult->fetch_assoc()) 347 { 348 $Name = $Interface['DeviceName']; 349 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 350 350 // $CZFreeLocalDNS['Host'][] = array('Name' => $Name.'-czfree', 'Address' => $Interface['LocalIP']); 351 351 $CZFreeLocalDNS['Host'][] = array('Name' => $Name, 'Address' => $Interface['LocalIP']); … … 355 355 $DbResult = $this->Database->query('SELECT `NetworkDomainAlias`.* FROM `NetworkDomainAlias`'); 356 356 // JOIN `hosts` ON NetworkDomainAlias.Target LIKE hosts.name AND hosts.czfree_ip != ""'); 357 while ($Alias = $DbResult->fetch_assoc())357 while ($Alias = $DbResult->fetch_assoc()) 358 358 { 359 359 $CZFreeLocalDNS['Alias'][] = array('Name' => $Alias['Name'], 'Target' => $Alias['Target']); -
trunk/Modules/NetworkConfigLinux/Generators/IPTables.php
r790 r873 1 1 <?php 2 if (isset($_SERVER['REMOTE_ADDR'])) die();2 if (isset($_SERVER['REMOTE_ADDR'])) die(); 3 3 include_once('../../../Common/Global.php'); 4 4 … … 14 14 // Blocking according IP address 15 15 $DbResult = $Database->select('users', '*', 'inet = 0'); 16 while ($User = $DbResult->fetch_array())16 while ($User = $DbResult->fetch_array()) 17 17 { 18 18 $DbResult2 = $Database->select('hosts', '*', "block<2 AND MAC!='' AND user=".$User['id']); 19 while ($Row = $DbResult2->fetch_array())19 while ($Row = $DbResult2->fetch_array()) 20 20 { 21 21 exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local'); … … 23 23 } 24 24 $DbResult = $Database->select('users', '*', 'inet = 1'); 25 while ($User = $DbResult->fetch_array())25 while ($User = $DbResult->fetch_array()) 26 26 { 27 27 $DbResult2 = $Database->select('hosts','*',"block<2 AND MAC!='' AND vpn=1 AND user=".$User['id']); 28 while ($Row = $DbResult2->fetch_array())28 while ($Row = $DbResult2->fetch_array()) 29 29 { 30 30 exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local'); … … 36 36 // Blocking according MAC address 37 37 $DbResult = $Database->select('users', '*'); 38 while ($User = $DbResult->fetch_array())38 while ($User = $DbResult->fetch_array()) 39 39 { 40 40 //echo($User['fullname']."\n"); 41 41 $DbResult2 = $Database->select('hosts', '*', '(block < 2) AND (MAC != "") AND (user='.$User['id'].') AND (IP != external_ip) ORDER BY id DESC'); 42 while ($Row = $DbResult2->fetch_array())42 while ($Row = $DbResult2->fetch_array()) 43 43 { 44 44 //echo(' '.$Row['name']." ".$Row['MAC']." "); 45 if ($User['inet'] == 0)45 if ($User['inet'] == 0) 46 46 { 47 //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");47 //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 48 48 // else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 49 49 } else { 50 if ($Row['vpn'] == 0)50 if ($Row['vpn'] == 0) 51 51 { 52 52 $CZFreeLocalIP = $Row['IP']; 53 53 //echo($Row['external_ip']."\n"); 54 //if ($Row['name'] == 'TBC')54 //if ($Row['name'] == 'TBC') 55 55 //{ 56 56 // exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725'); 57 57 // exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o '.$InetInterface.' -j SNAT --to-source '.$Row['external_ip'].':3724'); 58 58 //} 59 if (strtolower($Row['name']) != 'gate')59 if (strtolower($Row['name']) != 'gate') 60 60 { 61 if ($Row['external_ip'] != '')61 if ($Row['external_ip'] != '') 62 62 { 63 63 echo($Row['name'].'='.$Row['external_ip']."\n"); … … 75 75 //echo('vpn'); 76 76 //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP'); 77 if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');77 if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT'); 78 78 exec('/sbin/iptables -t nat -A Block -s '.ToVpnIp($Row)." -j Proxy"); 79 79 80 //if ($Row['vpn'] == 1)80 //if ($Row['vpn'] == 1) 81 81 //{ 82 82 //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 83 //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");83 //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 84 84 } 85 if ($Row['czfree_ip'] != '')85 if ($Row['czfree_ip'] != '') 86 86 { 87 87 // CZFree -
trunk/Modules/NetworkConfigLinux/Generators/Latency.php
r852 r873 14 14 'FROM `NetworkInterface` '. 15 15 'WHERE (`NetworkInterface`.`Enabled`=1) AND (`NetworkInterface`.`LocalIP` !="")'); 16 while ($DbRow = $DbResult->fetch_assoc())16 while ($DbRow = $DbResult->fetch_assoc()) 17 17 { 18 18 $Hosts[] = $DbRow['LocalIP']; … … 23 23 24 24 $Queries = array(); 25 foreach ($Output as $Index => $Line)25 foreach ($Output as $Index => $Line) 26 26 { 27 27 $IP = substr($Line, 0, strPos($Line, ' ')); -
trunk/Modules/NetworkConfigLinux/Generators/NAT.php
r790 r873 1 1 <?php 2 if (isset($_SERVER['REMOTE_ADDR'])) die();2 if (isset($_SERVER['REMOTE_ADDR'])) die(); 3 3 include_once('../../../Common/Global.php'); 4 4 … … 14 14 // Blocking according IP address 15 15 $DbResult = $Database->select('users', '*', 'inet = 0'); 16 while ($User = $DbResult->fetch_array())16 while ($User = $DbResult->fetch_array()) 17 17 { 18 18 $DbResult2 = $Database->select('hosts', '*', "block<2 AND MAC!='' AND user=".$User['id']); 19 while ($Row = $DbResult2->fetch_array())19 while ($Row = $DbResult2->fetch_array()) 20 20 { 21 21 exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local'); … … 23 23 } 24 24 $DbResult = $Database->select('users', '*', 'inet = 1'); 25 while ($User = $DbResult->fetch_array())25 while ($User = $DbResult->fetch_array()) 26 26 { 27 27 $DbResult2 = $Database->select('hosts','*',"block<2 AND MAC!='' AND vpn=1 AND user=".$User['id']); 28 while ($Row = $DbResult2->fetch_array())28 while ($Row = $DbResult2->fetch_array()) 29 29 { 30 30 exec('/sbin/iptables -t nat -A Block -s '.$Row['IP'].' -j Local'); … … 36 36 // Blocking according MAC address 37 37 $DbResult = $Database->select('users', '*'); 38 while ($User = $DbResult->fetch_array())38 while ($User = $DbResult->fetch_array()) 39 39 { 40 40 //echo($User['fullname']."\n"); 41 41 $DbResult2 = $Database->select('hosts','*','block<2 AND MAC!="" AND user='.$User['id'].' ORDER BY id DESC'); 42 while ($Row = $DbResult2->fetch_array())42 while ($Row = $DbResult2->fetch_array()) 43 43 { 44 44 //echo(' '.$Row['name']." ".$Row['MAC']." "); 45 if ($User['inet'] == 0)45 if ($User['inet'] == 0) 46 46 { 47 //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");47 //if (($Row['block'] == 0) and ($Row['type'] == 1)) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 48 48 // else exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 49 49 } else { 50 if ($Row['vpn'] == 0)50 if ($Row['vpn'] == 0) 51 51 { 52 52 $CZFreeLocalIP = $Row['IP']; 53 53 //echo($Row['external_ip']."\n"); 54 //if ($Row['name'] == 'TBC')54 //if ($Row['name'] == 'TBC') 55 55 //{ 56 56 // exec('/sbin/iptables -t nat -A PreroutingDNAT -m tcp -p tcp --dport 3724 -d '.$Row['external_ip'].' -j DNAT --to-destination '.$Row['IP'].':3725'); 57 57 // exec('/sbin/iptables -t nat -A POSTROUTING -m tcp -p tcp -s '.$Row['IP'].' --sport 3725 -o eth1 -j SNAT --to-source '.$Row['external_ip'].':3724'); 58 58 //} 59 if (strtolower($Row['name']) != 'centrala')59 if (strtolower($Row['name']) != 'centrala') 60 60 { 61 if ($Row['external_ip'] != '')61 if ($Row['external_ip'] != '') 62 62 { 63 63 echo($Row['name'].'='.$Row['external_ip']."\n"); … … 75 75 //echo('vpn'); 76 76 //exec('/sbin/iptables -t nat -A PreroutingDNAT -s '.$Row['IP'].' -p udp -m udp --dport 55556 -j DROP'); 77 if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT');77 if ($Row['external_ip'] != '') exec('/sbin/iptables -t nat -A PreroutingDNAT -d '.$Row['external_ip'].' -j ACCEPT'); 78 78 exec('/sbin/iptables -t nat -A Block -s '.ToVpnIp($Row)." -j Proxy"); 79 79 80 //if ($Row['vpn'] == 1)80 //if ($Row['vpn'] == 1) 81 81 //{ 82 82 //exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Local"); 83 //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy");83 //} else if ($Row['vpn'] == 2) exec('/sbin/iptables -t nat -A Block -m mac --mac-source '.$Row['MAC']." -j Proxy"); 84 84 } 85 if ($Row['czfree_ip'] != '')85 if ($Row['czfree_ip'] != '') 86 86 { 87 87 // CZFree -
trunk/Modules/NetworkConfigLinux/Generators/TrafficShaping.php
r790 r873 1 1 <?php 2 2 3 if (isset($_SERVER['REMOTE_ADDR'])) die();3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 5 5 $Enabled = 1; … … 37 37 exec('/sbin/iptables -t mangle -F PREROUTING'); 38 38 exec('/sbin/iptables -t mangle -F POSTROUTING'); 39 if ($Enabled)39 if ($Enabled) 40 40 { 41 41 //exec('/sbin/iptables -t mangle -A FORWARD -j MARK --set-mark 0'); … … 48 48 // In going traffic 49 49 fputs($File, "/sbin/tc qdisc del dev ".$InInterface." root\n"); 50 if ($Enabled)50 if ($Enabled) 51 51 { 52 52 fputs($File, "/sbin/tc qdisc add dev ".$InInterface." root handle 1:0 htb default 2\n"); … … 59 59 // Out going traffic 60 60 fputs($File, "/sbin/tc qdisc del dev ".$OutInterface." root\n"); 61 if ($Enabled)61 if ($Enabled) 62 62 { 63 63 fputs($File, "/sbin/tc qdisc add dev ".$OutInterface." root handle 1:0 htb default 2\n"); … … 69 69 } 70 70 71 if (!$Enabled) die("Traffic shaping disabled\n");72 73 if ($ClassesEnabled)71 if (!$Enabled) die("Traffic shaping disabled\n"); 72 73 if ($ClassesEnabled) 74 74 { 75 75 $ClassId = 3; … … 124 124 125 125 $DbResult = $Database->select('users', '*, CONCAT(second_name, " ", first_name) as fullname', '(inet=1)'); 126 while ($User = $DbResult->fetch_array())126 while ($User = $DbResult->fetch_array()) 127 127 { 128 128 $UserClassId = $ClassId; … … 152 152 153 153 $DbResult2 = $Database->select('hosts','*',"block=0 AND MAC!='' AND user=".$User['id']); 154 while ($Host = $DbResult2->fetch_array())155 //if ($Row['name'] != 'WOW')154 while ($Host = $DbResult2->fetch_array()) 155 //if ($Row['name'] != 'WOW') 156 156 { 157 157 $HostClassId = $ClassId; … … 160 160 fputs($FileClassInfo, '1:'.$HostClassId.' '.$Host['name']."\n"); 161 161 //echo(' Host class id: '.$HostClassId."\n"); 162 //if ($User['inet'] == 1)162 //if ($User['inet'] == 1) 163 163 { 164 164 $Prio = 1; 165 if ($Host['vpn'] == 1)165 if ($Host['vpn'] == 1) 166 166 { 167 if ($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip'];167 if ($Host['external_ip'] != '') $Host['IP'] = $Host['external_ip']; 168 168 else $Host['IP'] = ToVpnIp($Host); 169 169 } 170 170 171 //if ($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5;171 //if ($Host['name'] == 'TERMINAL') $SpeedDivider = 0.5; 172 172 //else 173 173 $SpeedDivider = 1; 174 174 175 if ($Host['name'] == 'centrala')175 if ($Host['name'] == 'centrala') 176 176 { 177 177 $Host['IP'] = $Host['external_ip']; … … 183 183 $TableIn = 'FORWARD'; 184 184 } 185 //if ($Row['name'] == 'TERMINAL2') $Prio = 0;186 // if ($Row['name'] = 'TERMINAL2') $Prio = 0;187 if ($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp';185 //if ($Row['name'] == 'TERMINAL2') $Prio = 0; 186 // if ($Row['name'] = 'TERMINAL2') $Prio = 0; 187 if ($Host['name'] == 'voip-hajda') $Protocol = ' -p tcp'; 188 188 else $Protocol = ''; 189 // if ($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000;189 // if ($Host['name'] == 'KARLOS') $UserMaxSpeedIn = 128000; 190 190 /* 191 if ($Host['name'] == 'GAME')191 if ($Host['name'] == 'GAME') 192 192 { 193 193 exec('/sbin/iptables -t mangle -F game-server'); … … 195 195 $TableIn = 'game-server'; 196 196 }*/ 197 //if ($Host['name'] == 'TBC') continue;197 //if ($Host['name'] == 'TBC') continue; 198 198 199 199 // In going traffic … … 213 213 } 214 214 // Free inet 215 if ($Tarify[$User['inet_tarif_now']]['group_id'] == 3)215 if ($Tarify[$User['inet_tarif_now']]['group_id'] == 3) 216 216 { 217 217 //exec('/sbin/iptables -t mangle -A '.$TableIn.' -i eth1 -d '.$Host['IP'].$Protocol." -j MARK --set-mark ".$FreeInetClass); … … 220 220 // VoIP devices 221 221 /* 222 if (($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP'))222 if (($Host['name'] == 'HAJDA-VOIP') || ($Host['name'] == 'NAVRATIL-VOIP')) 223 223 { 224 224 exec('/sbin/iptables -t mangle -A '.$TableIn." -i eth1 -d ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId); 225 225 exec('/sbin/iptables -t mangle -A '.$TableOut." -o eth1 -s ".$Host['IP']." -p udp -j MARK --set-mark ".$VoipClassId); 226 226 } else 227 if ($Host['name'] == 'GAME')227 if ($Host['name'] == 'GAME') 228 228 { 229 229 exec('/sbin/iptables -t mangle -A FORWARD -o eth1 -s '.$Host['IP']." -j game-server"); -
trunk/Modules/NetworkConfigRouterOS/Generators/AddressPortability.php
r738 r873 1 1 <?php 2 2 3 if (isset($_SERVER['REMOTE_ADDR'])) die();3 if (isset($_SERVER['REMOTE_ADDR'])) die(); 4 4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 5 include_once(dirname(__FILE__).'/../Routerboard.php'); … … 11 11 { 12 12 $TimeParts = explode(':', $Time); 13 return ($TimeParts[0] * 3600 + $TimeParts[1] * 60 + $TimeParts[2]);13 return ($TimeParts[0] * 3600 + $TimeParts[1] * 60 + $TimeParts[2]); 14 14 } 15 15 … … 19 19 20 20 $DbResult3 = $System->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0 GROUP BY `DHCP`'); 21 while ($Subnet = $DbResult3->fetch_assoc())21 while ($Subnet = $DbResult3->fetch_assoc()) 22 22 { 23 23 echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n"); 24 24 $Routerboard->HostName = $Subnet['DHCP']; 25 25 $List = $Routerboard->ListGet($Path, array('address', 'active-mac-address', 'active-address', 'expires-after', 'server', 'dynamic')); 26 foreach ($List as $Properties)26 foreach ($List as $Properties) 27 27 { 28 if ($Properties['dynamic'] == 'true')28 if ($Properties['dynamic'] == 'true') 29 29 //and ($Properties['address'] != $Properties['active-address'])) 30 30 { … … 32 32 echo('MAC: '.$Properties['active-mac-address']."\n"); 33 33 $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterface` WHERE `MAC`="'.$Properties['active-mac-address'].'"'); 34 if ($DbRows2->num_rows > 0)34 if ($DbRows2->num_rows > 0) 35 35 { 36 36 $Interface = $DbRows2->fetch_assoc(); 37 37 $InterfaceId = $Interface['Id']; 38 38 $DbRows2 = $System->Database->query('SELECT `Id` FROM `NetworkInterfacePortable` WHERE `NetworkInterface`='.$InterfaceId); 39 if ($DbRows2->num_rows > 0)39 if ($DbRows2->num_rows > 0) 40 40 { 41 41 $System->Database->update('NetworkInterfacePortable', '`Time` < "'.TimeToMysqlDateTime($Properties['expires-after']).'" AND `NetworkInterface`='.$InterfaceId, array('DynamicIP' => $Properties['active-address'], 'Update' => 1)); … … 53 53 $NATRule = array(); 54 54 $DbRows = $System->Database->query('SELECT NetworkDevice.Name AS DeviceName, NetworkInterface.Name AS InterfaceName, DynamicIP FROM `NetworkInterfacePortable` JOIN NetworkInterface ON NetworkInterface.Id=NetworkInterfacePortable.NetworkInterface JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE `Update`=1'); 55 while ($Portable = $DbRows->fetch_assoc())55 while ($Portable = $DbRows->fetch_assoc()) 56 56 { 57 57 $Name = $Portable['DeviceName']; 58 if ($Portable['InterfaceName'] != '') $Name .= '-'.$Portable['InterfaceName'];58 if ($Portable['InterfaceName'] != '') $Name .= '-'.$Portable['InterfaceName']; 59 59 array_push($NATRule, implode(' ', $PathNAT).' set [find comment="'.$Name.'-in"] to-addresses='.$Portable['DynamicIP']); 60 60 array_push($NATRule, implode(' ', $PathNAT).' set [find comment="'.$Name.'-out"] src-address='.$Portable['DynamicIP']); -
trunk/Modules/NetworkConfigRouterOS/Generators/Common.php
r870 r873 6 6 7 7 $DbResult = $Database->query('SELECT `Id` FROM `NetworkMark` WHERE `Comment`="'.$Comment.'"'); 8 if ($DbResult->num_rows > 0)8 if ($DbResult->num_rows > 0) 9 9 { 10 10 $DbRow = $DbResult->fetch_assoc(); 11 return ($DbRow['Id']);11 return ($DbRow['Id']); 12 12 } else 13 13 { 14 14 $DbResult = $Database->query('INSERT INTO `NetworkMark` (`Comment`) VALUES ("'.$Comment.'")'); 15 return ($Database->insert_id);15 return ($Database->insert_id); 16 16 } 17 17 } … … 22 22 23 23 $DbResult = $Database->query('SELECT `Id` FROM `NetworkMangleSubgroup` WHERE `AddressRange`="'.$AddressRange.'"'); 24 if ($DbResult->num_rows > 0)24 if ($DbResult->num_rows > 0) 25 25 { 26 26 $DbRow = $DbResult->fetch_assoc(); 27 return ($DbRow['Id']);27 return ($DbRow['Id']); 28 28 } else 29 29 { 30 30 $DbResult = $Database->query('INSERT INTO `NetworkMangleSubgroup` (`AddressRange`) VALUES ("'.$AddressRange.'")'); 31 return ($Database->insert_id);31 return ($Database->insert_id); 32 32 } 33 33 } … … 38 38 39 39 $Found = false; 40 foreach ($Tree['Items'] as $Index => $Node)40 foreach ($Tree['Items'] as $Index => $Node) 41 41 { 42 if ($Node['Address']->Contain($Address))42 if ($Node['Address']->Contain($Address)) 43 43 { 44 44 InsertToAddressTreeIPv4($Tree['Items'][$Index], $Address, $Name, true); … … 46 46 } 47 47 } 48 if ($Found == false)48 if ($Found == false) 49 49 { 50 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and50 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and 51 51 ($Address->Prefix > ($Tree['Address']->Prefix + 1))) 52 52 { … … 62 62 // Should be existed items placed under new node? 63 63 $Found = false; 64 foreach ($Tree['Items'] as $Index => $Node)64 foreach ($Tree['Items'] as $Index => $Node) 65 65 { 66 if (($Node['Address']->Address == $NewNode['Address']->Address) and66 if (($Node['Address']->Address == $NewNode['Address']->Address) and 67 67 ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true; 68 68 69 if ($Address->Contain($Node['Address']))69 if ($Address->Contain($Node['Address'])) 70 70 { 71 71 $NewNode['Items'][] = $Node; … … 73 73 } 74 74 } 75 if ($Found == false) $Tree['Items'][] = $NewNode;75 if ($Found == false) $Tree['Items'][] = $NewNode; 76 76 } 77 77 } … … 83 83 84 84 $Found = false; 85 foreach ($Tree['Items'] as $Index => $Node)85 foreach ($Tree['Items'] as $Index => $Node) 86 86 { 87 if ($Node['Address']->Contain($Address))87 if ($Node['Address']->Contain($Address)) 88 88 { 89 89 InsertToAddressTreeIPv6($Tree['Items'][$Index], $Address, $Name, true); … … 91 91 } 92 92 } 93 if ($Found == false)93 if ($Found == false) 94 94 { 95 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and95 if ($InterSubnets and ($Tree['Address']->Prefix < $Config['MainRouter']['MangleRuleSubgroupMinPrefix']) and 96 96 ($Address->Prefix > ($Tree['Address']->Prefix + 1))) 97 97 { … … 107 107 // Should be existed items placed under new node? 108 108 $Found = false; 109 foreach ($Tree['Items'] as $Index => $Node)109 foreach ($Tree['Items'] as $Index => $Node) 110 110 { 111 if (($Node['Address']->Address == $NewNode['Address']->Address) and111 if (($Node['Address']->Address == $NewNode['Address']->Address) and 112 112 ($Node['Address']->Prefix == $NewNode['Address']->Prefix)) $Found = true; 113 113 114 if ($Address->Contain($Node['Address']))114 if ($Address->Contain($Node['Address'])) 115 115 { 116 116 $NewNode['Items'][] = $Node; … … 118 118 } 119 119 } 120 if ($Found == false) $Tree['Items'][] = $NewNode;120 if ($Found == false) $Tree['Items'][] = $NewNode; 121 121 } 122 122 } … … 126 126 { 127 127 echo(str_repeat(' ', $Indent).$Node['Address']->AddressToString().'/'.$Node['Address']->Prefix.' '.$Node['Name']."\n"); 128 foreach ($Node['Items'] as $Index => $Item)128 foreach ($Node['Items'] as $Index => $Item) 129 129 { 130 130 ShowSubnetNode($Item, $Indent + 1); -
trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php
r861 r873 14 14 15 15 $DbResult = $this->Database->query('SELECT * FROM `NetworkSubnet` WHERE `Configure`=1'); 16 while ($Subnet = $DbResult->fetch_assoc())16 while ($Subnet = $DbResult->fetch_assoc()) 17 17 { 18 18 echo($Subnet['DHCP']); … … 24 24 'WHERE CompareNetworkPrefix(INET_ATON(`LocalIP`), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].') '. 25 25 'AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`'); 26 while ($Interface = $DbResult2->fetch_assoc())26 while ($Interface = $DbResult2->fetch_assoc()) 27 27 { 28 28 $Name = $Interface['DeviceName']; 29 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];29 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 30 30 $Items[] = array('mac-address' => $Interface['MAC'], 'address' => $Interface['LocalIP'], 'server' => $Server, 'comment' => $Name, 'lease-time' => '1d'); 31 31 } -
trunk/Modules/NetworkConfigRouterOS/Generators/DNS.php
r781 r873 13 13 14 14 $DbResult = $this->Database->query('SELECT * FROM `NetworkDomain`'); 15 while ($Domain = $DbResult->fetch_assoc())15 while ($Domain = $DbResult->fetch_assoc()) 16 16 { 17 17 $DomainName = $Domain['Name']; … … 19 19 // Get full domain name from parent items 20 20 $CurrentDomain = $Domain; 21 while ($CurrentDomain['Parent'] > 0)21 while ($CurrentDomain['Parent'] > 0) 22 22 { 23 23 $DbResult2 = $this->Database->query('SELECT * FROM `NetworkDomain` WHERE `Id`='.$CurrentDomain['Parent']); … … 32 32 'JOIN `NetworkDevice` ON `NetworkInterface`.`Device`=`NetworkDevice`.`Id` '. 33 33 'WHERE (`NetworkDevice`.`Used`=1)'); 34 while ($Interface = $DbResult2->fetch_assoc())34 while ($Interface = $DbResult2->fetch_assoc()) 35 35 { 36 36 $Name = $Interface['DeviceName']; 37 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];37 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 38 38 $NameFull = $Name.'.'.$DomainName; 39 39 $NameExtFull = $Name.'-ext.'.$DomainName; 40 if ($Interface['LocalIP'] != '')40 if ($Interface['LocalIP'] != '') 41 41 $Items[] = array('name' => $NameFull, 'address' => $Interface['LocalIP']); 42 if ($Interface['IPv6'] != '')42 if ($Interface['IPv6'] != '') 43 43 $Items[] = array('name' => $NameFull, 'address' => $Interface['IPv6']); 44 if ($Interface['ExternalIP'] != '')44 if ($Interface['ExternalIP'] != '') 45 45 $Items[] = array('name' => $NameExtFull, 'address' => $Interface['ExternalIP']); 46 46 } … … 53 53 'WHERE (`NetworkDevice`.`Used`=1) AND '. 54 54 '(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")) = `NetworkDomainAlias`.`Target`)'); 55 while ($Alias = $DbResult2->fetch_assoc())55 while ($Alias = $DbResult2->fetch_assoc()) 56 56 { 57 57 $Name = $Alias['Name']; 58 58 $NameFull = $Name.'.'.$DomainName; 59 59 $NameExtFull = $Name.'-ext.'.$DomainName; 60 if ($Alias['LocalIP'] != '')60 if ($Alias['LocalIP'] != '') 61 61 $Items[] = array('name' => $NameFull, 'address' => $Alias['LocalIP']); 62 if ($Alias['IPv6'] != '')62 if ($Alias['IPv6'] != '') 63 63 $Items[] = array('name' => $NameFull, 'address' => $Alias['IPv6']); 64 if ($Alias['ExternalIP'] != '')64 if ($Alias['ExternalIP'] != '') 65 65 $Items[] = array('name' => $NameExtFull, 'address' => $Alias['ExternalIP']); 66 66 } 67 67 68 68 $DbResult2 = $this->Database->query('SELECT * FROM `NetworkDomainServer` WHERE `Domain`='.$Domain['Id']); 69 while ($Server = $DbResult2->fetch_assoc())69 while ($Server = $DbResult2->fetch_assoc()) 70 70 { 71 71 $Routerboard->HostName = $Server['Address']; -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallFilter.php
r831 r873 42 42 // Insert blocked addresses 43 43 $DbResult = $this->Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id WHERE Member.Blocked=1'); 44 while ($Member = $DbResult->fetch_assoc())44 while ($Member = $DbResult->fetch_assoc()) 45 45 { 46 46 echo($Member['Name'].': '); 47 47 // Hosts 48 48 $DbResult2 = $this->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.ExternalIP <> "") AND (NetworkDevice.Member = '.$Member['Id'].') AND (NetworkInterface.LocalIP != NetworkInterface.ExternalIP) ORDER BY id DESC'); 49 while ($Interface = $DbResult2->fetch_assoc())49 while ($Interface = $DbResult2->fetch_assoc()) 50 50 { 51 51 $Name = $Interface['DeviceName']; 52 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];52 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 53 53 $Name = RouterOSIdent($Name); 54 54 echo($Name.'('.$Interface['LocalIP'].'), '); … … 59 59 // Subnets 60 60 $DbResult2 = $this->Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']); 61 while ($Subnet = $DbResult2->fetch_assoc())61 while ($Subnet = $DbResult2->fetch_assoc()) 62 62 { 63 63 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); … … 67 67 $NewAddress->Prefix = $Subnet['ExtMask']; 68 68 $Range = $NewAddress->GetRange(); 69 if ($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();69 if ($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString(); 70 70 else $Range = $Range['From']->AddressToString(); 71 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];71 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange']; 72 72 else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask']; 73 73 $Items[] = array('chain' => 'forward', 'out-interface' => $InetInterface, 'src-address' => $Src, 'action' => 'drop','comment' => $Subnet['Name'].'-out-drop'); … … 77 77 $NewAddress->Prefix = $Subnet['Mask']; 78 78 $Range = $NewAddress->GetRange(); 79 if ($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();79 if ($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString(); 80 80 else $Range = $Range['From']->AddressToString(); 81 if ($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange'];81 if ($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange']; 82 82 else $Dest = $Subnet['ExtAddressRange'].'/'.$Subnet['ExtMask']; 83 83 $Items[] = array('chain' => 'forward', 'in-interface' => $InetInterface, 'dst-address' => $Dest, 'action' => 'drop', 'comment' => $Subnet['Name'].'-in-drop'); -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php
r870 r873 7 7 global $InetInterface, $ItemsFirewall; 8 8 9 foreach ($Node['Items'] as $Index => $Item)10 { 11 if (count($Item['Items']) == 0)9 foreach ($Node['Items'] as $Index => $Item) 10 { 11 if (count($Item['Items']) == 0) 12 12 { 13 13 // Hosts 14 14 $ParentSubnetId = GetSubgroupByRange($Node['Address']->AddressToString().'/'.$Node['Address']->Prefix); 15 15 $Address = $Item['Address']->AddressToString(); 16 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;16 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix; 17 17 18 18 $PacketMark = GetMarkByComment($Item['Name'].'-out'); … … 28 28 29 29 $Address = $Item['Address']->AddressToString(); 30 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix;30 if ($Item['Address']->Prefix != 32) $Address .= '/'.$Item['Address']->Prefix; 31 31 32 32 $ItemsFirewall[] = array('chain' => 'inet-'.$ParentSubnetId.'-out', 'src-address' => $Address, 'out-interface' => $InetInterface, 'action' => 'jump', 'jump-target' => 'inet-'.$SubnetId.'-out', 'comment' => $Item['Name'].'-out'); … … 36 36 } 37 37 } 38 if ($Node['ForceMark'] == true)38 if ($Node['ForceMark'] == true) 39 39 { 40 40 // Mark member subnets … … 72 72 // Divide rules by subnet number 73 73 $DbResult = $this->System->Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet` WHERE `Member` IS NULL'); 74 while ($Subnet = $DbResult->fetch_assoc())74 while ($Subnet = $DbResult->fetch_assoc()) 75 75 { 76 76 $NewAddress = new NetworkAddressIPv4(); … … 84 84 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 85 85 'WHERE `Member`.`Blocked` = 0'); 86 while ($Member = $DbResult->fetch_assoc())86 while ($Member = $DbResult->fetch_assoc()) 87 87 { 88 88 $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] ); … … 90 90 91 91 $DbResult2 = $this->System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']); 92 while ($Device = $DbResult2->fetch_assoc())92 while ($Device = $DbResult2->fetch_assoc()) 93 93 { 94 94 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""'); 95 while ($Interface = $DbResult3->fetch_assoc())95 while ($Interface = $DbResult3->fetch_assoc()) 96 96 { 97 97 $Name = $Device['Name']; 98 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];98 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 99 99 $Name = RouterOSIdent($Name); 100 100 echo($Name.', '); … … 107 107 108 108 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '(`Member`='.$Member['Id'].') AND (AddressRange != "")'); 109 while ($Subnet = $DbResult2->fetch_assoc())109 while ($Subnet = $DbResult2->fetch_assoc()) 110 110 { 111 111 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); … … 114 114 $NewAddress->AddressFromString($Subnet['AddressRange']); 115 115 $NewAddress->Prefix = $Subnet['Mask']; 116 if ($Subnet['Member'] != 0) $ForceMark = true;116 if ($Subnet['Member'] != 0) $ForceMark = true; 117 117 else $ForceMark = false; 118 118 echo($ForceMark.', '); … … 169 169 $DbResult = $this->System->Database->query('SELECT `Id`, `Name`, `AddressRangeIPv6`, `MaskIPv6` FROM `NetworkSubnet` '. 170 170 'WHERE (`Member` IS NULL) AND (`AddressRangeIPv6` != "")'); 171 while ($Subnet = $DbResult->fetch_assoc())171 while ($Subnet = $DbResult->fetch_assoc()) 172 172 { 173 173 $NewAddress = new NetworkAddressIPv6(); … … 181 181 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 182 182 'WHERE `Member`.`Blocked` = 0'); 183 while ($Member = $DbResult->fetch_assoc())183 while ($Member = $DbResult->fetch_assoc()) 184 184 { 185 185 $Member['Name'] = RouterOSIdent($Member['Name'].'-'.$Member['Id'] ); … … 187 187 188 188 $DbResult2 = $this->System->Database->select('NetworkDevice', '*', '`Used` = 1 AND `Member` = '.$Member['Id']); 189 while ($Device = $DbResult2->fetch_assoc())189 while ($Device = $DbResult2->fetch_assoc()) 190 190 { 191 191 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `IPv6` != ""'); 192 while ($Interface = $DbResult3->fetch_assoc())192 while ($Interface = $DbResult3->fetch_assoc()) 193 193 { 194 194 $Name = $Device['Name']; 195 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];195 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 196 196 $Name = RouterOSIdent($Name); 197 197 echo($Name.', '); … … 204 204 205 205 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '(`Member`='.$Member['Id'].') AND (AddressRangeIPv6 != "")'); 206 while ($Subnet = $DbResult2->fetch_assoc())206 while ($Subnet = $DbResult2->fetch_assoc()) 207 207 { 208 208 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); … … 211 211 $NewAddress->AddressFromString($Subnet['AddressRangeIPv6']); 212 212 $NewAddress->Prefix = $Subnet['MaskIPv6']; 213 if ($Subnet['Member'] != 0) $ForceMark = true;213 if ($Subnet['Member'] != 0) $ForceMark = true; 214 214 else $ForceMark = false; 215 215 echo($ForceMark.', '); -
trunk/Modules/NetworkConfigRouterOS/Generators/FirewallNAT.php
r860 r873 39 39 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` '. 40 40 'WHERE `Member`.`Blocked` = 0'); 41 while ($Member = $DbResult->fetch_assoc())41 while ($Member = $DbResult->fetch_assoc()) 42 42 { 43 43 echo($Member['Name'].': '); … … 47 47 ' AND (`NetworkInterface`.`LocalIP` <> "")'. 48 48 ' AND (`NetworkDevice`.`Member` = '.$Member['Id'].') AND (`NetworkInterface`.`LocalIP` != `NetworkInterface`.`ExternalIP`) ORDER BY `id` DESC'); 49 while ($Interface = $DbResult2->fetch_assoc())49 while ($Interface = $DbResult2->fetch_assoc()) 50 50 { 51 51 $Name = $Interface['DeviceName']; 52 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];52 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 53 53 $Name = RouterOSIdent($Name); 54 54 echo($Name.'('.$Interface['LocalIP'].'), '); 55 if ($Member['Blocked'] == 0)55 if ($Member['Blocked'] == 0) 56 56 { 57 57 $Items[] = array('chain' => 'inet-out', 'src-address' => $Interface['LocalIP'], 'action' => 'src-nat', 'to-addresses' => $Interface['ExternalIP'], 'comment' => $Name.'-out'); 58 if ($Interface['InboundNATPriority'] > 0)58 if ($Interface['InboundNATPriority'] > 0) 59 59 $Items[] = array('chain' => 'inet-in', 'dst-address' => $Interface['ExternalIP'], 'action' => 'dst-nat', 'to-addresses' => $Interface['LocalIP'], 'comment' => $Name.'-in'); 60 60 } else … … 66 66 // Subnets 67 67 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']); 68 while ($Subnet = $DbResult2->fetch_assoc())68 while ($Subnet = $DbResult2->fetch_assoc()) 69 69 { 70 70 $Subnet['Name'] = RouterOSIdent('subnet-'.$Subnet['Name']); 71 71 echo($Subnet['Name'].'('.$Subnet['AddressRange'].'/'.$Subnet['Mask'].'), '); 72 if ($Member['Blocked'] == 0)72 if ($Member['Blocked'] == 0) 73 73 { 74 74 $NewAddress = new NetworkAddressIPv4(); … … 76 76 $NewAddress->Prefix = $Subnet['ExtMask']; 77 77 $Range = $NewAddress->GetRange(); 78 if ($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();78 if ($Subnet['ExtMask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString(); 79 79 else $Range = $Range['From']->AddressToString(); 80 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];80 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange']; 81 81 else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask']; 82 82 $Items[] = array('chain' => 'inet-out', 'src-address' => $Src, 'action' => 'src-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-out'); … … 86 86 $NewAddress->Prefix = $Subnet['Mask']; 87 87 $Range = $NewAddress->GetRange(); 88 if ($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString();88 if ($Subnet['Mask'] != 32) $Range = $Range['From']->AddressToString().'-'.$Range['To']->AddressToString(); 89 89 else $Range = $Range['From']->AddressToString(); 90 if ($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange'];90 if ($Subnet['ExtMask'] == 32) $Dest = $Subnet['ExtAddressRange']; 91 91 else $Dest = $Subnet['ExtAddressRange'].'/'.$Subnet['ExtMask']; 92 92 $Items[] = array('chain' => 'inet-in', 'dst-address' => $Dest, 'action' => 'dst-nat', 'to-addresses' => $Range, 'comment' => $Subnet['Name'].'-in'); 93 93 } else 94 94 { 95 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange'];95 if ($Subnet['Mask'] == 32) $Src = $Subnet['AddressRange']; 96 96 else $Src = $Subnet['AddressRange'].'/'.$Subnet['Mask']; 97 97 $Items[] = array('chain' => 'dstnat', 'src-address' => $Src, 'protocol' => 'tcp', 'dst-port' => 80, 'action' => 'dst-nat', 'to-addresses' => $IPCentrala, 'to-ports' => 81, 'comment' => $Subnet['Name'].'-out'); … … 124 124 // Route public addresses localy 125 125 $DbResult = $this->Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id'); 126 while ($Member = $DbResult->fetch_assoc())126 while ($Member = $DbResult->fetch_assoc()) 127 127 { 128 128 echo($Member['Name'].': '); 129 129 // Hosts 130 130 $DbResult2 = $this->Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.ExternalIP <> "") AND (NetworkDevice.Member = '.$Member['Id'].') AND (NetworkInterface.LocalIP != NetworkInterface.ExternalIP) ORDER BY id DESC'); 131 while ($Interface = $DbResult2->fetch_assoc())131 while ($Interface = $DbResult2->fetch_assoc()) 132 132 { 133 133 $Name = $Interface['DeviceName']; 134 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];134 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 135 135 $Name = RouterOSIdent($Name); 136 136 echo($Name.'('.$Interface['LocalIP'].'), '); -
trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php
r835 r873 13 13 14 14 $DbResult3 = $this->Database->query('SELECT DISTINCT (`DHCP`) FROM `NetworkSubnet` WHERE `Configure` = 1'); // WHERE `Member` = 0'); 15 while ($Router = $DbResult3->fetch_assoc())15 while ($Router = $DbResult3->fetch_assoc()) 16 16 { 17 17 echo($Router['DHCP']."\n"); … … 19 19 $Items = array(); 20 20 $DbResult = $this->Database->query('SELECT * FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`DHCP`="'.$Router['DHCP'].'")'); 21 while ($Subnet = $DbResult->fetch_assoc())21 while ($Subnet = $DbResult->fetch_assoc()) 22 22 { 23 23 $I = explode('.', $Subnet['AddressRange']); … … 26 26 ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE CompareNetworkPrefix(INET_ATON(`LocalIP`), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].')'. 27 27 ' AND (`NetworkDevice`.`Used` = 1) ORDER BY `NetworkInterface`.`LocalIP`'); 28 while ($Interface = $DbResult2->fetch_assoc())28 while ($Interface = $DbResult2->fetch_assoc()) 29 29 { 30 30 $Name = $Interface['DeviceName']; 31 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];31 if ($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 32 32 echo($Name.', '); 33 33 $Items[] = array('host' => $Interface['LocalIP'], 'interval' => '00:00:10', 'comment' => $Name); -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r863 r873 10 10 $Interfaces = array(); 11 11 $DbResult = $this->Database->select('NetworkInterface', '`Id`, `LocalIP` AS `IP`, `Online`, 0 AS `NewOnline`'); 12 while ($DbRow = $DbResult->fetch_assoc())12 while ($DbRow = $DbResult->fetch_assoc()) 13 13 $Interfaces[$DbRow['IP']] = $DbRow; 14 14 … … 16 16 $DbResult3 = $this->Database->query('SELECT `DHCP` FROM `NetworkSubnet` '. 17 17 'WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY `DHCP`'); 18 while ($Subnet = $DbResult3->fetch_assoc())18 while ($Subnet = $DbResult3->fetch_assoc()) 19 19 { 20 20 echo('router '.$Subnet['DHCP']."\n"); … … 22 22 $Routerboard->Connect($Subnet['DHCP'], $this->System->Config['API']['UserName'], 23 23 $this->System->Config['API']['Password']); 24 if (!$Routerboard->Connected) continue;24 if (!$Routerboard->Connected) continue; 25 25 $Routerboard->Write('/tool/netwatch/getall', false); 26 26 $Routerboard->Write('=.proplist=host,status'); 27 27 $Read = $Routerboard->Read(false); 28 28 $List = $Routerboard->ParseResponse($Read); 29 foreach ($List as $Properties)29 foreach ($List as $Properties) 30 30 { 31 31 $IP = $Properties['host']; 32 if ($Properties['status'] == 'up') $Online = 1;32 if ($Properties['status'] == 'up') $Online = 1; 33 33 else $Online = 0; 34 34 35 if ($Online)35 if ($Online) 36 36 { 37 if (array_key_exists($IP, $Interfaces))37 if (array_key_exists($IP, $Interfaces)) 38 38 $Interfaces[$IP]['NewOnline'] = 1; 39 39 else echo('IP '.$IP.' not found.'."\n"); … … 44 44 $Queries = array(); 45 45 $QueriesInsert = array(); 46 foreach ($Interfaces as $Index => $Interface)46 foreach ($Interfaces as $Index => $Interface) 47 47 { 48 48 // Update last online time if still online 49 if ($Interface['NewOnline'])49 if ($Interface['NewOnline']) 50 50 $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = '.$Interface['Id'], 51 51 array('LastOnline' => TimeToMysqlDateTime($StartTime))); 52 52 53 if ($Interface['Online'] != $Interface['NewOnline'])53 if ($Interface['Online'] != $Interface['NewOnline']) 54 54 { 55 55 // Online state changed … … 78 78 $DbResult = $this->Database->select('NetworkInterface', '*', '(`Online` = 1) AND '. 79 79 '(`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'")'); 80 while ($DbRow = $DbResult->fetch_assoc())80 while ($DbRow = $DbResult->fetch_assoc()) 81 81 { 82 82 echo('IP '.$DbRow['LocalIP'].' online but time not updated.'."\n"); … … 84 84 $DbResult = $this->Database->select('NetworkInterface', '*', '(`Online` = 0) AND '. 85 85 '(`LastOnline` >= "'.TimeToMysqlDateTime($StartTime).'")'); 86 while ($DbRow = $DbResult->fetch_assoc())86 while ($DbRow = $DbResult->fetch_assoc()) 87 87 { 88 88 echo('IP '.$DbRow['LocalIP'].' not online but time updated.'."\n"); … … 92 92 // Update device online state 93 93 $DbResult = $this->Database->select('NetworkInterface', '`Device`, SUM(`Online`) AS `SumOnline`', '`Online` = 1 GROUP BY `Device`'); 94 while ($Device = $DbResult->fetch_assoc())94 while ($Device = $DbResult->fetch_assoc()) 95 95 { 96 if ($Device['SumOnline'] > 0)96 if ($Device['SumOnline'] > 0) 97 97 $Queries[] = $this->Database->GetUpdate('NetworkDevice', 'Id='.$Device['Device'], array('LastOnline' => TimeToMysqlDateTime($StartTime), 'Online' => 1)); 98 98 } -
trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php
r869 r873 48 48 function CheckName($Name, &$UsedNames) 49 49 { 50 if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name);50 if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name); 51 51 else $UsedNames[] = $Name; 52 52 } … … 189 189 $DbResult = $this->Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` '. 190 190 'LEFT JOIN `Subject` ON `Subject`.`Id` = `Member`.`Subject` WHERE `Member`.`Blocked`=0'); 191 while ($Member = $DbResult->fetch_assoc())191 while ($Member = $DbResult->fetch_assoc()) 192 192 { 193 193 $ServiceIndex = 1; … … 198 198 'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '. 199 199 'AND (`Service`.`InternetSpeedMax` > 0) AND (`Service`.`InternetSpeedMin` > 0)'); 200 while ($Service = $DbResult4->fetch_assoc())200 while ($Service = $DbResult4->fetch_assoc()) 201 201 { 202 202 echo('Služba '.$Service['Name'].': '); … … 231 231 $Row = $DbResult2->fetch_row(); 232 232 $HostCount = $Row[0]; 233 if ($HostCount > 0)233 if ($HostCount > 0) 234 234 { 235 235 $HostSpeedIn = round($SpeedIn / $HostCount); … … 242 242 243 243 $DbResult2 = $this->Database->select('NetworkDevice', '*', $Filter); 244 while ($Device = $DbResult2->fetch_assoc())244 while ($Device = $DbResult2->fetch_assoc()) 245 245 { 246 246 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$Device['Id'].' AND `LocalIP` != ""'); 247 while ($Interface = $DbResult3->fetch_assoc())247 while ($Interface = $DbResult3->fetch_assoc()) 248 248 { 249 249 $DeviceName = $Device['Name']; 250 if ($Interface['Name'] != '') $DeviceName .= '-'.$Interface['Name'];250 if ($Interface['Name'] != '') $DeviceName .= '-'.$Interface['Name']; 251 251 $DeviceName = RouterOSIdent($DeviceName); 252 252 echo($DeviceName.', '); … … 258 258 259 259 $DbResult2 = $this->Database->select('NetworkSubnet', '*', '`Service`='.$Service['RelId']); 260 while ($Subnet = $DbResult2->fetch_assoc())260 while ($Subnet = $DbResult2->fetch_assoc()) 261 261 { 262 262 $SubnetName = RouterOSIdent('subnet-'.$Subnet['Name']); … … 329 329 { 330 330 $MinSpeed = 0; 331 foreach ($this->Devices[$DeviceId]['Childs'] as $DeviceChild)331 foreach ($this->Devices[$DeviceId]['Childs'] as $DeviceChild) 332 332 { 333 333 $this->UpdateMinSpeed($DeviceChild); … … 335 335 } 336 336 $this->Devices[$DeviceId]['MinSpeed'] = $MinSpeed; 337 if ($this->Devices[$DeviceId]['DeviceCount'] > 0)337 if ($this->Devices[$DeviceId]['DeviceCount'] > 0) 338 338 $this->Devices[$DeviceId]['MinSpeed'] += round($this->Devices[$DeviceId]['InternetSpeedMin'] / $this->Devices[$DeviceId]['DeviceCount']); 339 339 } … … 349 349 'LEFT JOIN `ServiceCustomerRel` ON `ServiceCustomerRel`.`Id`=`NetworkDevice`.`Service` '. 350 350 'LEFT JOIN `Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service`'); 351 while ($Device = $DbResult->fetch_assoc())351 while ($Device = $DbResult->fetch_assoc()) 352 352 { 353 353 $Device['Interfaces'] = array(); … … 364 364 $Interfaces = array(); 365 365 $DbResult = $this->Database->query('SELECT `Device`,`Name`,`Id` FROM `NetworkInterface`'); 366 while ($Interface = $DbResult->fetch_assoc())366 while ($Interface = $DbResult->fetch_assoc()) 367 367 { 368 368 $Interface['Links'] = array(); … … 376 376 '`NetworkLink`.`Interface2`,`NetworkLinkType`.`MaxRealSpeed` FROM `NetworkLink` '. 377 377 'LEFT JOIN `NetworkLinkType` ON `NetworkLinkType`.`Id`=`NetworkLink`.`Type`'); 378 while ($Link = $DbResult->fetch_assoc())378 while ($Link = $DbResult->fetch_assoc()) 379 379 { 380 380 $Links[$Link['Id']] = $Link; … … 388 388 $this->Devices[$RootDeviceId]['Calculated'] = true; 389 389 390 while (count($DevicesToCheck) > 0)390 while (count($DevicesToCheck) > 0) 391 391 { 392 392 //echo('Pass'."\n"); 393 393 $NewDevicesToCheck = array(); 394 foreach ($DevicesToCheck as $DeviceId)394 foreach ($DevicesToCheck as $DeviceId) 395 395 { 396 396 //echo($this->Devices[$DeviceId]['Name'].': '); 397 foreach ($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId)397 foreach ($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId) 398 398 { 399 foreach ($Interfaces[$InterfaceId]['Links'] as $LinkId)399 foreach ($Interfaces[$InterfaceId]['Links'] as $LinkId) 400 400 { 401 401 $Link = $Links[$LinkId]; 402 402 $Interface2Id = $Link['Interface1']; 403 if ($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2'];403 if ($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2']; 404 404 405 405 $Device2Id = $Interfaces[$Interface2Id]['Device']; 406 if ($this->Devices[$Device2Id]['Calculated'] == false)406 if ($this->Devices[$Device2Id]['Calculated'] == false) 407 407 { 408 408 $this->Devices[$Device2Id]['Calculated'] = true; 409 409 $NewMaxSpeed = $this->Devices[$DeviceId]['MaxSpeed']; 410 if ($NewMaxSpeed > $Link['MaxRealSpeed'])410 if ($NewMaxSpeed > $Link['MaxRealSpeed']) 411 411 $NewMaxSpeed = $Link['MaxRealSpeed']; 412 412 //echo($this->Devices[$Device2Id]['Name'].' '.$Device2Id.', '); … … 431 431 432 432 echo('Not linked network devices: '); 433 foreach ($this->Devices as $Device)434 { 435 if ($Device['MaxSpeed'] == 0) echo($Device['Name'].', ');433 foreach ($this->Devices as $Device) 434 { 435 if ($Device['MaxSpeed'] == 0) echo($Device['Name'].', '); 436 436 } 437 437 echo("\n"); … … 455 455 $DbResult3 = $this->Database->select('NetworkInterface', '*', '`Device` = '.$DeviceId.' AND `LocalIP` != ""'); 456 456 $IntCount = $DbResult3->num_rows; 457 while ($Interface = $DbResult3->fetch_assoc())457 while ($Interface = $DbResult3->fetch_assoc()) 458 458 { 459 459 $InterfaceName = $Device['Name']; 460 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];460 if ($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name']; 461 461 else $InterfaceName .= '-'; 462 462 $InterfaceName = RouterOSIdent($InterfaceName); … … 469 469 470 470 // Process childs 471 foreach ($Device['Childs'] as $DeviceChild)471 foreach ($Device['Childs'] as $DeviceChild) 472 472 { 473 473 $this->BuildQueueItems($DeviceChild, $LimitDevice); … … 505 505 506 506 $DbResult = $this->Database->select('Service', '*', '(`ChangeAction` IS NULL) AND (`Id`='.TARIFF_FREE.')'); 507 if ($DbResult->num_rows == 1)507 if ($DbResult->num_rows == 1) 508 508 { 509 509 $Service = $DbResult->fetch_array(); -
trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php
r851 r873 12 12 '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '. 13 13 'FROM `NetworkDevice` WHERE (`API` = 1) AND (`Used` = 1)'); 14 while ($Device = $DbResult3->fetch_assoc())14 while ($Device = $DbResult3->fetch_assoc()) 15 15 { 16 16 echo($Device['LocalIP']."\n"); … … 19 19 //$Routerboard->Port = 8729; 20 20 $Routerboard->Connect($Device['LocalIP'], $this->System->Config['API']['UserName'], $this->System->Config['API']['Password']); 21 if (!$Routerboard->Connected) continue;21 if (!$Routerboard->Connected) continue; 22 22 $Routerboard->Write('/interface/wireless/registration-table/getall', false); 23 23 $Routerboard->Write('=.proplist=signal-strength,mac-address,rx-rate,tx-rate', false); … … 25 25 $Read = $Routerboard->Read(false); 26 26 $Array = $Routerboard->ParseResponse($Read); 27 foreach ($Array as $Properties)27 foreach ($Array as $Properties) 28 28 { 29 29 $DbResult = $this->Database->select('NetworkInterface', 'Id', 'MAC="'.$Properties['mac-address'].'"'); 30 if ($DbResult->num_rows > 0)30 if ($DbResult->num_rows > 0) 31 31 { 32 32 $DbRow = $DbResult->fetch_assoc(); … … 34 34 } else $Interface = 'NULL'; 35 35 36 if (strpos($Properties['signal-strength'], '@') === false)36 if (strpos($Properties['signal-strength'], '@') === false) 37 37 { 38 38 $Strength = $Properties['signal-strength']; 39 39 } else { 40 40 $Parts = explode('@', $Properties['signal-strength']); 41 if (substr($Parts[0], -3) == 'dBm')41 if (substr($Parts[0], -3) == 'dBm') 42 42 $Strength = substr($Parts[0], 0, -3); // without dBm 43 43 else $Strength = $Parts[0]; … … 50 50 /* 51 51 $DbResult = $this->Database->select('Measure', 'Id', '`Name` = "'.$Properties['mac-address'].'"'); 52 if ($DbResult->num_rows > 0)52 if ($DbResult->num_rows > 0) 53 53 { 54 54 $this->Database->insert('Measure', array('Name' => $Properties['mac-address'])); … … 74 74 if (substr($Value, -3, 3) == "Mbp") $Value = substr($Value, 0, -3); // without Mbp unit 75 75 if (substr($Value, -1, 1) == "M") $Value = substr($Value, 0, -1); // without M unit 76 return ($Value);76 return ($Value); 77 77 } 78 78 -
trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php
r860 r873 70 70 $IPAddress = GetRemoteAddress(); 71 71 $Output = 'Vaše IP adresa je: '.$IPAddress.'<br/>'; 72 if (IsInternetAddr($IPAddress)) {72 if (IsInternetAddr($IPAddress)) { 73 73 $Output .= '<p>Internet zdarma je dostupný pouze z vnitřní sítě.</p>'; 74 return ($Output);74 return ($Output); 75 75 } 76 76 $Time = time(); … … 78 78 $DbResult = $this->Database->select('NetworkFreeAccess', '*', '(IPAddress="'.$IPAddress. 79 79 '") ORDER BY Time DESC LIMIT 1'); 80 if ($DbResult->num_rows > 0)80 if ($DbResult->num_rows > 0) 81 81 { 82 82 $DbRow = $DbResult->fetch_assoc(); 83 83 $ActivationTime = MysqlDateTimeToTime($DbRow['Time']); 84 if (($ActivationTime + $this->Timeout) < $Time)84 if (($ActivationTime + $this->Timeout) < $Time) 85 85 { 86 86 $Activated = false; … … 88 88 } else $Activated = false; 89 89 90 if (array_key_exists('a', $_GET))90 if (array_key_exists('a', $_GET)) 91 91 { 92 if ($_GET['a'] == 'activate')92 if ($_GET['a'] == 'activate') 93 93 { 94 if ($Activated == false)94 if ($Activated == false) 95 95 { 96 96 $DbResult = $this->Database->insert('NetworkFreeAccess', … … 108 108 109 109 $PrefixMultiplier = new PrefixMultiplier(); 110 if ($Activated) $Output .= 'Aktivováno. Vyprší za '.$PrefixMultiplier->Add($ActivationTime + $this->Timeout - $Time, '', 4, 'Time');110 if ($Activated) $Output .= 'Aktivováno. Vyprší za '.$PrefixMultiplier->Add($ActivationTime + $this->Timeout - $Time, '', 4, 'Time'); 111 111 else $Output .= '<a href="?a=activate">Aktivovat</a>'; 112 112 113 return ($Output);113 return ($Output); 114 114 } 115 115 } … … 122 122 $Commands = array(); 123 123 $DbResult = $this->Database->select('NetworkFreeAccess', '`Id`, `IPAddress`', '(`Configured`=0)'); 124 while ($DbRow = $DbResult->fetch_assoc())124 while ($DbRow = $DbResult->fetch_assoc()) 125 125 { 126 126 $Commands[] = '/ip firewall address-list add address='.$DbRow['IPAddress']. … … 135 135 $Routerboard->ExecuteBatch(implode(';', $Commands)); 136 136 137 return ($Output);137 return ($Output); 138 138 } 139 139 } -
trunk/Modules/NetworkConfigRouterOS/Routerboard.php
r860 r873 22 22 { 23 23 $Output = array(); 24 if (is_array($Commands))24 if (is_array($Commands)) 25 25 { 26 26 $I = 0; 27 27 $Batch = array(); 28 while ($I < count($Commands))29 { 30 if (($I % $this->MaxBurstLineCount) == 0)31 { 32 if (count($Batch) > 0)28 while ($I < count($Commands)) 29 { 30 if (($I % $this->MaxBurstLineCount) == 0) 31 { 32 if (count($Batch) > 0) 33 33 $Output = array_merge($Output, $this->ExecuteBatch(implode(';', $Batch))); 34 34 $Batch = array(); … … 37 37 $I++; 38 38 } 39 if (count($Batch) > 0)39 if (count($Batch) > 0) 40 40 $Output = array_merge($Output, $this->ExecuteBatch(implode(';', $Batch))); 41 41 } else 42 42 $Output = array_merge($Output, $this->ExecuteBatch($Commands)); 43 return ($Output);43 return ($Output); 44 44 } 45 45 … … 47 47 { 48 48 $Commands = trim($Commands); 49 if ($Commands != '')49 if ($Commands != '') 50 50 { 51 51 $Commands = addslashes($Commands); … … 57 57 $Command = $this->SSHPath.' -oBatchMode=no -o ConnectTimeout='.$this->Timeout.' -l '.$this->UserName. 58 58 $PrivKey.' '.$this->HostName.' "'.$Commands.'"'; 59 if ($this->Debug) echo($Command);59 if ($this->Debug) echo($Command); 60 60 $Output = array(); 61 61 exec($Command, $Output); 62 62 } else $Output = ''; 63 if ($this->Debug) print_r($Output);64 return ($Output);63 if ($this->Debug) print_r($Output); 64 return ($Output); 65 65 } 66 66 … … 70 70 array_pop($Result); 71 71 $List = array(); 72 foreach ($Result as $ResultLine)72 foreach ($Result as $ResultLine) 73 73 { 74 74 $ResultLineParts = explode(' ', trim($ResultLine)); 75 if (count($ResultLineParts) > 1)76 { 77 if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes75 if (count($ResultLineParts) > 1) 76 { 77 if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes 78 78 $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1]; 79 79 } else $List[substr($ResultLineParts[0], 0, -1)] = ''; 80 80 } 81 return ($List);81 return ($List); 82 82 } 83 83 … … 85 85 { 86 86 $PropertyList = '"'; 87 foreach ($Properties as $Index => $Property)87 foreach ($Properties as $Index => $Property) 88 88 { 89 89 $PropertyList .= $Index.'=".[get $i '.$Property.']." '; … … 92 92 93 93 $ConditionList = ''; 94 foreach ($Conditions as $Index => $Item)95 { 96 if ($Item == 'no') $ConditionList .= $Index.'='.$Item.' ';94 foreach ($Conditions as $Index => $Item) 95 { 96 if ($Item == 'no') $ConditionList .= $Index.'='.$Item.' '; 97 97 else $ConditionList .= $Index.'="'.$Item.'" '; 98 98 } … … 101 101 $Result = $this->Execute(implode(' ', $Path).' {:foreach i in=[find '.$ConditionList.'] do={:put ('.$PropertyList.')}}'); 102 102 $List = array(); 103 foreach ($Result as $ResultLine)103 foreach ($Result as $ResultLine) 104 104 { 105 105 $ResultLineParts = explode(' ', $ResultLine); 106 106 $ListItem = array(); 107 foreach ($ResultLineParts as $ResultLinePart)107 foreach ($ResultLineParts as $ResultLinePart) 108 108 { 109 109 $Value = explode('=', $ResultLinePart); 110 if (count($Value) > 1) $ListItem[$Properties[$Value[0]]] = $Value[1];110 if (count($Value) > 1) $ListItem[$Properties[$Value[0]]] = $Value[1]; 111 111 else $ListItem[$Properties[$Value[0]]] = ''; 112 112 } 113 113 $List[] = $ListItem; 114 114 } 115 return ($List);115 return ($List); 116 116 } 117 117 … … 119 119 { 120 120 $ConditionList = ''; 121 foreach ($Conditions as $Index => $Item)121 foreach ($Conditions as $Index => $Item) 122 122 { 123 123 $ConditionList .= $Index.'="'.$Item.'" '; 124 124 } 125 125 $ConditionList = substr($ConditionList, 0, -1); 126 if (trim($ConditionList) != '')126 if (trim($ConditionList) != '') 127 127 $ConditionList = ' where '.$ConditionList; 128 128 129 129 $Result = $this->Execute(implode(' ', $Path).' print terse'.$ConditionList); 130 130 $List = array(); 131 foreach ($Result as $ResultLine)131 foreach ($Result as $ResultLine) 132 132 { 133 133 $ResultLineParts = explode(' ', $ResultLine); 134 134 $ListItem = array(); 135 foreach ($ResultLineParts as $ResultLinePart)135 foreach ($ResultLineParts as $ResultLinePart) 136 136 { 137 137 $Value = explode('=', $ResultLinePart); 138 if (in_array($Value[0], $Properties))139 { 140 if (count($Value) > 1)138 if (in_array($Value[0], $Properties)) 139 { 140 if (count($Value) > 1) 141 141 { 142 if ($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1);143 //if (strlen($Value[1]) > 0)142 if ($Value[1]{0} == '"') $Value[1] = substr($Value[1], 1, -1); 143 //if (strlen($Value[1]) > 0) 144 144 $ListItem[$Value[0]] = $Value[1]; 145 145 } else $ListItem[$Value[0]] = ''; 146 146 } 147 147 } 148 if (count($ListItem) > 0) $List[] = $ListItem;149 } 150 return ($List);148 if (count($ListItem) > 0) $List[] = $ListItem; 149 } 150 return ($List); 151 151 } 152 152 … … 159 159 { 160 160 // Get current list from routerboard 161 if ($UsePrint == 0)161 if ($UsePrint == 0) 162 162 { 163 163 $List = $this->ListGet($Path, $Properties, $Condition); 164 164 // Change boolean values yes/no to true/false 165 foreach ($List as $Index => $ListItem)166 { 167 foreach ($ListItem as $Index2 => $Item2)168 { 169 if ($Item2 == 'true') $List[$Index][$Index2] = 'yes';170 if ($Item2 == 'false') $List[$Index][$Index2] = 'no';165 foreach ($List as $Index => $ListItem) 166 { 167 foreach ($ListItem as $Index2 => $Item2) 168 { 169 if ($Item2 == 'true') $List[$Index][$Index2] = 'yes'; 170 if ($Item2 == 'false') $List[$Index][$Index2] = 'no'; 171 171 } 172 172 } … … 178 178 179 179 // Add empty properties to values 180 foreach ($Values as $Index => $Item)181 { 182 foreach ($Properties as $Property)183 { 184 if (!array_key_exists($Property, $Item))180 foreach ($Values as $Index => $Item) 181 { 182 foreach ($Properties as $Property) 183 { 184 if (!array_key_exists($Property, $Item)) 185 185 $Item[$Property] = ''; 186 186 } 187 187 $Values[$Index] = $Item; 188 188 } 189 foreach ($List as $Index => $Item)190 { 191 foreach ($Properties as $Property)192 { 193 if (!array_key_exists($Property, $Item))189 foreach ($List as $Index => $Item) 190 { 191 foreach ($Properties as $Property) 192 { 193 if (!array_key_exists($Property, $Item)) 194 194 $Item[$Property] = ''; 195 195 } … … 198 198 199 199 // Sort properties 200 foreach ($Values as $Index => $Item)200 foreach ($Values as $Index => $Item) 201 201 { 202 202 ksort($Values[$Index]); 203 203 } 204 foreach ($List as $Index => $Item)204 foreach ($List as $Index => $Item) 205 205 { 206 206 ksort($List[$Index]); 207 207 } 208 if ($this->Debug) print_r($List);209 if ($this->Debug) print_r($Values);208 if ($this->Debug) print_r($List); 209 if ($this->Debug) print_r($Values); 210 210 211 211 // Erase all items not existed in $Values 212 foreach ($List as $Index => $ListItem)213 { 214 if (!in_array($ListItem, $Values))212 foreach ($List as $Index => $ListItem) 213 { 214 if (!in_array($ListItem, $Values)) 215 215 { 216 216 $Prop = ''; 217 foreach ($ListItem as $Index => $Property)218 { 219 if ($Property != '')217 foreach ($ListItem as $Index => $Property) 218 { 219 if ($Property != '') 220 220 { 221 if (($Property == 'yes') or ($Property == 'no')) $Prop .= $Index.'='.$Property.' ';221 if (($Property == 'yes') or ($Property == 'no')) $Prop .= $Index.'='.$Property.' '; 222 222 else $Prop .= $Index.'="'.$Property.'" '; 223 223 } 224 224 } 225 225 $Prop = substr($Prop, 0, -1); 226 if (trim($Prop) != '')226 if (trim($Prop) != '') 227 227 $Commands[] = implode(' ', $Path).' remove [find '.$Prop.']'; 228 228 } … … 230 230 231 231 // Add new items 232 foreach ($Values as $ListItem)233 { 234 if (!in_array($ListItem, $List))232 foreach ($Values as $ListItem) 233 { 234 if (!in_array($ListItem, $List)) 235 235 { 236 236 $Prop = ''; 237 foreach ($ListItem as $Index => $Property)238 { 239 if ($Property != '') $Prop .= $Index.'="'.$Property.'" ';237 foreach ($ListItem as $Index => $Property) 238 { 239 if ($Property != '') $Prop .= $Index.'="'.$Property.'" '; 240 240 } 241 241 $Prop = substr($Prop, 0, -1); … … 243 243 } 244 244 } 245 if ($this->Debug) print_r($Commands);246 return ($this->Execute($Commands));245 if ($this->Debug) print_r($Commands); 246 return ($this->Execute($Commands)); 247 247 } 248 248 } -
trunk/Modules/NetworkConfigRouterOS/Routerboard2.php
r738 r873 13 13 function Execute($Commands) 14 14 { 15 if (is_array($Commands)) $Commands = implode(';', $Commands);16 return (parent::Execute($Commands));15 if (is_array($Commands)) $Commands = implode(';', $Commands); 16 return (parent::Execute($Commands)); 17 17 } 18 18 … … 22 22 array_pop($Result); 23 23 $List = array(); 24 foreach ($Result as $ResultLine)24 foreach ($Result as $ResultLine) 25 25 { 26 26 $ResultLineParts = explode(' ', trim($ResultLine)); 27 if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes27 if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes 28 28 $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1]; 29 29 } 30 return ($List);30 return ($List); 31 31 } 32 32 … … 34 34 { 35 35 $PropertyList = '"'; 36 foreach ($Properties as $Property)36 foreach ($Properties as $Property) 37 37 { 38 38 $PropertyList .= $Property.'=".[get $i '.$Property.']." '; … … 41 41 $Result = $this->Execute($Command.' {:foreach i in=[find] do={:put ('.$PropertyList.')}}'); 42 42 $List = array(); 43 foreach ($Result as $ResultLine)43 foreach ($Result as $ResultLine) 44 44 { 45 45 $ResultLineParts = explode(' ', $ResultLine); 46 46 $ListItem = array(); 47 foreach ($ResultLineParts as $ResultLinePart)47 foreach ($ResultLineParts as $ResultLinePart) 48 48 { 49 49 $Value = explode('=', $ResultLinePart); … … 52 52 $List[] = $ListItem; 53 53 } 54 return ($List);54 return ($List); 55 55 } 56 56 57 57 function GetSystemResource() 58 58 { 59 return ($this->GetItem('/system resource print'));59 return ($this->GetItem('/system resource print')); 60 60 } 61 61 62 62 function GetFirewallFilterList() 63 63 { 64 return ($this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes')));64 return ($this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes'))); 65 65 } 66 66 67 67 function GetDHCPServerLeasesList() 68 68 { 69 return ($this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name')));69 return ($this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name'))); 70 70 } 71 71 } -
trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
r861 r873 40 40 } else if ($Length >= 0x10000000) 41 41 $Length = chr(0xF0).chr(($Length >> 24) & 0xFF).chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF); 42 return ($Length);42 return ($Length); 43 43 } 44 44 45 45 function ConnectOnce($IP, $Login, $Password) 46 46 { 47 if ($this->Connected) $this->Disconnect();48 if ($this->SSL)47 if ($this->Connected) $this->Disconnect(); 48 if ($this->SSL) 49 49 { 50 50 $IP = 'ssl://'.$IP; 51 51 } 52 52 $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout); 53 if ($this->Socket)53 if ($this->Socket) 54 54 { 55 55 socket_set_timeout($this->Socket, $this->Timeout); … … 58 58 $this->Write('=password='.$Password); 59 59 $Response = $this->Read(false); 60 if ((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true;61 if (!$this->Connected) fclose($this->Socket);60 if ((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true; 61 if (!$this->Connected) fclose($this->Socket); 62 62 } 63 63 } … … 65 65 function Connect($IP, $Login, $Password) 66 66 { 67 for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++)67 for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++) 68 68 { 69 69 $this->ConnectOnce($IP, $Login, $Password); 70 if ($this->Connected) break;70 if ($this->Connected) break; 71 71 sleep($this->Delay); 72 72 } 73 return ($this->Connected);73 return ($this->Connected); 74 74 } 75 75 76 76 function Disconnect() 77 77 { 78 if ($this->Connected)78 if ($this->Connected) 79 79 { 80 80 fclose($this->Socket); … … 183 183 $Response[] = $Line; 184 184 } 185 if ($this->Debug) echo($Line);185 if ($this->Debug) echo($Line); 186 186 // If we get a !done, make a note of it. 187 187 if ($Line == "!done") $ReceivedDone = true; … … 192 192 break; 193 193 } 194 if ($Parse) $Response = $this->ParseResponse($Response);194 if ($Parse) $Response = $this->ParseResponse($Response); 195 195 return $Response; 196 196 } … … 198 198 function Write($Command, $Param2 = true) 199 199 { 200 if ($Command)200 if ($Command) 201 201 { 202 202 $Data = explode("\n", $Command); … … 234 234 $this->Write($el, $Last); 235 235 } 236 return ($this->Read());236 return ($this->Read()); 237 237 } 238 238 } -
trunk/Modules/NetworkConfigRouterOS/SSH.php
r738 r873 18 18 { 19 19 echo($Commands); 20 if (!function_exists("ssh2_connect")) die("Function ssh2_connect doesn't exist");21 if (!($this->Session = ssh2_connect($this->HostName, 22, $this->Methods))) echo("Fail: Unable to establish connection to host\n");20 if (!function_exists("ssh2_connect")) die("Function ssh2_connect doesn't exist"); 21 if (!($this->Session = ssh2_connect($this->HostName, 22, $this->Methods))) echo("Fail: Unable to establish connection to host\n"); 22 22 else 23 23 { 24 if (!ssh2_auth_password($this->Session, $this->UserName, $this->Password)) echo("Fail: unable to authenticate\n");24 if (!ssh2_auth_password($this->Session, $this->UserName, $this->Password)) echo("Fail: unable to authenticate\n"); 25 25 else 26 26 { 27 //if (!($Stream = ssh2_shell($this->Session, 'xterm', null, 80, 40, SSH2_TERM_UNIT_CHARS))) echo("Fail: unable to execute command\n");28 if (!($Stream = ssh2_exec($this->Session, $Commands))) echo("Fail: unable to execute command\n");27 //if (!($Stream = ssh2_shell($this->Session, 'xterm', null, 80, 40, SSH2_TERM_UNIT_CHARS))) echo("Fail: unable to execute command\n"); 28 if (!($Stream = ssh2_exec($this->Session, $Commands))) echo("Fail: unable to execute command\n"); 29 29 else 30 30 { 31 31 $Response = ''; 32 32 stream_set_blocking($Stream, true); 33 while ($Buffer = fread($Stream, 4000))33 while ($Buffer = fread($Stream, 4000)) 34 34 { 35 35 $Response .= $Buffer; … … 37 37 /* 38 38 //echo(') '.strlen($Buffer).' '.ord($Buffer{0}).'('); 39 for ($I = 0; $I < strlen($Buffer); $I++)39 for ($I = 0; $I < strlen($Buffer); $I++) 40 40 { 41 if (((ord($Buffer{$I}) >= 32) and (ord($Buffer{$I}) <= 128)) or ($Buffer{$I} = "\n") or ($Buffer{$I} = "\r")) echo($Buffer{$I});42 if ($Buffer{$I} == '>')41 if (((ord($Buffer{$I}) >= 32) and (ord($Buffer{$I}) <= 128)) or ($Buffer{$I} = "\n") or ($Buffer{$I} = "\r")) echo($Buffer{$I}); 42 if ($Buffer{$I} == '>') 43 43 { 44 44 fwrite($Stream, $Commands."\n\r"); … … 54 54 } 55 55 echo($Response); 56 return (explode("\n", substr($Response, 0, -1)));56 return (explode("\n", substr($Response, 0, -1))); 57 57 } 58 58 } -
trunk/Modules/NetworkShare/SharePage.php
r790 r873 22 22 function ShowTime() 23 23 { 24 return (date("H:i:s")."<br />\n");24 return (date("H:i:s")."<br />\n"); 25 25 } 26 26 … … 41 41 $Cesta = ''; //$Row['name']; 42 42 $i = 0; 43 while (($Otec > 1) && ($i < $this->MaxNesting))43 while (($Otec > 1) && ($i < $this->MaxNesting)) 44 44 { 45 45 $DbResult = $this->Database->query('SELECT Id,Name,Parent FROM NetworkShareItem WHERE Id='.$Otec); … … 50 50 $i++; 51 51 } 52 if ($i >= $this->MaxNesting) $Cesta = '?'.'\\'.$Cesta;53 return ('\\\\'.$Cesta);52 if ($i >= $this->MaxNesting) $Cesta = '?'.'\\'.$Cesta; 53 return ('\\\\'.$Cesta); 54 54 } 55 55 … … 58 58 { 59 59 $Jednotky = array('B','kB','MB','GB','TB','PB','EB'); 60 while ($Velikost >= 1024)60 while ($Velikost >= 1024) 61 61 { 62 62 $Velikost = round($Velikost / 1024 * 10) / 10; 63 63 array_shift($Jednotky); 64 64 } 65 return ($Velikost.' '.$Jednotky[0]);65 return ($Velikost.' '.$Jednotky[0]); 66 66 } 67 67 68 68 function Show() 69 69 { 70 if (!$this->System->User->CheckPermission('NetworkShare', 'Display')) return('Nemáte oprávnění');70 if (!$this->System->User->CheckPermission('NetworkShare', 'Display')) return ('Nemáte oprávnění'); 71 71 72 72 // If not only online checkbox checked 73 if (array_key_exists('view', $_POST) and !array_key_exists('online', $_POST)) $_POST['online'] = 'off';73 if (array_key_exists('view', $_POST) and !array_key_exists('online', $_POST)) $_POST['online'] = 'off'; 74 74 75 75 // Default host list view 76 if ((count($_POST) == 0) and (count($_GET) == 0))76 if ((count($_POST) == 0) and (count($_GET) == 0)) 77 77 { 78 78 $_POST['view'] = 1; … … 81 81 82 82 // Toggle order direction 83 if (array_key_exists('order', $_GET) and ($_SESSION['order'] == $_GET['order'])) $_GET['order'] .= ' DESC';83 if (array_key_exists('order', $_GET) and ($_SESSION['order'] == $_GET['order'])) $_GET['order'] .= ' DESC'; 84 84 85 85 //print_r($_POST); 86 foreach ($this->Promene as $Index => $Prvek)87 { 88 if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $this->Promene[$Index];89 if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];90 if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];91 if (($Index == 'keyword') and (array_key_exists('view', $_GET))) $_SESSION[$Index] = $this->Promene[$Index];92 if (($Index == 'view') and ((array_key_exists('keyword', $_POST)) or (array_key_exists('keyword', $_GET)))) $_SESSION[$Index] = '';86 foreach ($this->Promene as $Index => $Prvek) 87 { 88 if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $this->Promene[$Index]; 89 if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index]; 90 if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index]; 91 if (($Index == 'keyword') and (array_key_exists('view', $_GET))) $_SESSION[$Index] = $this->Promene[$Index]; 92 if (($Index == 'view') and ((array_key_exists('keyword', $_POST)) or (array_key_exists('keyword', $_GET)))) $_SESSION[$Index] = ''; 93 93 $$Index = $_SESSION[$Index]; 94 94 //echo('$'.$Index.' = '.$_SESSION[$Index].'<br>'); 95 95 } 96 96 //echo($keyword); 97 //if ($keyword)98 //if ($keyword != '') $view = '';97 //if ($keyword) 98 //if ($keyword != '') $view = ''; 99 99 100 100 //$this->Database->select_db('share'); 101 101 102 102 // Log search 103 if (array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET))103 if (array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET)) 104 104 $this->System->ModuleManager->Modules['Log']->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']); 105 105 … … 139 139 </select> '; 140 140 141 if ($online == 'on') $Selected = 'checked '; else $Selected = '';141 if ($online == 'on') $Selected = 'checked '; else $Selected = ''; 142 142 $Output .= '<input type="checkbox" '.$Selected.'name="online">Pouze aktivní uživatele<br> 143 143 </form>'; 144 144 145 145 //$Output .= $view; 146 if ($view != '')146 if ($view != '') 147 147 { 148 148 // Zobrazení obsahu vybrané složky … … 170 170 "(ext LIKE 'iso') OR (ext LIKE 'nrg') OR (ext LIKE 'ccd') OR (ext LIKE 'bin') OR (ext LIKE 'mds')", 171 171 ); 172 if ($file_type > 0) $Podminka .= ' AND ('.$Pripony[$file_type].')';172 if ($file_type > 0) $Podminka .= ' AND ('.$Pripony[$file_type].')'; 173 173 174 174 //Hledání podle velikosti 175 175 $Jednotky = array(1, 1024, 1048576, 1073741824); 176 if (is_numeric($size))176 if (is_numeric($size)) 177 177 { 178 178 $Metoda = array('=', '>', '<'); … … 184 184 // Omezení na online/offline uživatele 185 185 //$this->Database->select_db('is'); 186 if ($online == 'on') $DbResult = $this->Database->query('SELECT Id FROM NetworkDevice WHERE Online=1 AND Member IS NOT NULL');186 if ($online == 'on') $DbResult = $this->Database->query('SELECT Id FROM NetworkDevice WHERE Online=1 AND Member IS NOT NULL'); 187 187 else $DbResult = $this->Database->query('SELECT Id FROM NetworkDevice'); 188 188 $Vyber = ''; 189 while ($Row = $DbResult->fetch_array()) $Vyber .= $Row['Id'].',';189 while ($Row = $DbResult->fetch_array()) $Vyber .= $Row['Id'].','; 190 190 $Podminka .= ' AND (Host IN ('.substr($Vyber, 0, -1).'))'; 191 191 //echo($Podminka.'<br>'); … … 200 200 201 201 // Zobrazení [..] 202 if (($view != '') && ($page == 0) && ($Nahoru > 0))202 if (($view != '') && ($page == 0) && ($Nahoru > 0)) 203 203 { 204 204 $DbResult = $this->Database->query('SELECT * FROM NetworkShareItem WHERE Id='.$view); … … 212 212 $PerPage = 30; 213 213 $Dotaz = "SELECT COUNT(*) FROM NetworkShareItem WHERE (".$Podminka.")"; 214 if ($order != '') $Dotaz .= ' ORDER BY '.$order;214 if ($order != '') $Dotaz .= ' ORDER BY '.$order; 215 215 $Dotaz .= " LIMIT ".($page * $PerPage).",".$PerPage; 216 216 $DbResult = $this->Database->query($Dotaz); … … 218 218 $Pocet = $Row[0]; 219 219 220 if ($Pocet > 0)220 if ($Pocet > 0) 221 221 { 222 222 $Output .= 'Nalezeno celkem: '.$Pocet.' položek<br />'; 223 223 } else 224 224 $Output .= 'Podle zadaných podmínek nic nenalezeno'; 225 if (($Pocet > 0) || ($upstr))225 if (($Pocet > 0) || ($upstr)) 226 226 { 227 227 $Output .= '<table width="100%" style="font-size: 8pt;" border="0" cellpadding="2" cellspacing="2"> 228 228 <tr><th bgcolor="#E0E0FF"><a href="index.php?order=name">Soubor</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=ext">Přípona</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=size">Velikost</a></th><th bgcolor="#E0E0FF"><a href="index.php?order=date">Datum</a></th><th bgcolor="#E0E0FF">Umístění</th></tr>'; 229 229 $Output .= $upstr; 230 if ($Pocet > 0)230 if ($Pocet > 0) 231 231 { 232 232 // Zobrazení tabulky s výsledky … … 235 235 236 236 // Zobrazení poloľek 237 while ($Row = $DbResult->fetch_array())237 while ($Row = $DbResult->fetch_array()) 238 238 { 239 239 // Loguj('Radek '.$Row['name']); … … 244 244 // Zobrazení řádku 245 245 $Cesta2 = strtr($Cesta.$Radek['Name'], '\\', '/'); 246 if ($Radek['Ext'] != '') $Cesta2 .= '.'.$Radek['Ext'];247 if ($Radek['Type'] != 0) $Adresa = 'index.php?view='.$Radek['Id'].'">['.$Radek['Name'].']';246 if ($Radek['Ext'] != '') $Cesta2 .= '.'.$Radek['Ext']; 247 if ($Radek['Type'] != 0) $Adresa = 'index.php?view='.$Radek['Id'].'">['.$Radek['Name'].']'; 248 248 else 249 249 { 250 if (strstr($_SERVER['HTTP_USER_AGENT'], 'Linux')) $Adresa = 'smb:'.$Cesta2.'">'.$Radek['Name'];250 if (strstr($_SERVER['HTTP_USER_AGENT'], 'Linux')) $Adresa = 'smb:'.$Cesta2.'">'.$Radek['Name']; 251 251 else $Adresa = 'file:///'.$Cesta2.'">'.$Radek['Name']; 252 252 } … … 260 260 } 261 261 } 262 if ($Pocet > 0)262 if ($Pocet > 0) 263 263 { 264 264 // Celkový přehled 265 if ($view == 1)265 if ($view == 1) 266 266 { 267 267 $DbResult = $this->Database->query('SELECT SUM(Size) FROM NetworkShareItem WHERE (Parent=1) AND (Host IN ('.substr($Vyber,0,-1).'))'); … … 285 285 $Host = strtoupper(substr($Host, 0, strpos($Host, '.'))); 286 286 $DbResult = $this->Database->select('NetworkShareError', '*', 'Host="'.$Host.'"'); 287 if ($DbResult->num_rows > 0) $Output .= '<strong>Výpis chybových hlášení pro počítač '.$Host.':</strong><br />';287 if ($DbResult->num_rows > 0) $Output .= '<strong>Výpis chybových hlášení pro počítač '.$Host.':</strong><br />'; 288 288 //echo('host="'.$Host.'"'); 289 while ($Row = $DbResult->fetch_array())289 while ($Row = $DbResult->fetch_array()) 290 290 { 291 291 $Row['Message'] = str_replace('/', '\\', $Row['Message']); … … 295 295 296 296 // Zobrazení seznamu stránek 297 if ($Pages > 1)297 if ($Pages > 1) 298 298 { 299 if ($page > 0) $Output .= '<a href="index.php?page=0"><<</a> ';300 if ($page > 0) $Output .= '<a href="index.php?page='.($page-1).'"><</a> ';299 if ($page > 0) $Output .= '<a href="index.php?page=0"><<</a> '; 300 if ($page > 0) $Output .= '<a href="index.php?page='.($page-1).'"><</a> '; 301 301 $PagesMax = $Pages; 302 302 $PagesMin = 0; 303 if ($PagesMax > ($page + 10)) $PagesMax = $page + 10;304 if ($PagesMin < ($page - 10))303 if ($PagesMax > ($page + 10)) $PagesMax = $page + 10; 304 if ($PagesMin < ($page - 10)) 305 305 { 306 306 $Output .= ' .. '; 307 307 $PagesMin = $page - 10; 308 308 } 309 for ($i = $PagesMin; $i <= $PagesMax; $i++)309 for ($i = $PagesMin; $i <= $PagesMax; $i++) 310 310 { 311 if ($i == $page) $Output .= '<strong>';311 if ($i == $page) $Output .= '<strong>'; 312 312 $Output .= '<a href="index.php?page='.$i.'">'.($i + 1).'</a> '; 313 if ($i == $page) $Output .= '</strong>';313 if ($i == $page) $Output .= '</strong>'; 314 314 } 315 if ($PagesMax < $Pages) $Output .= ' .. ';316 if ($page < $Pages) $Output .= '<a href="index.php?page='.($page + 1).'">></a> ';317 if ($page < $Pages) $Output .= '<a href="index.php?page='.$Pages.'">>></a>';315 if ($PagesMax < $Pages) $Output .= ' .. '; 316 if ($page < $Pages) $Output .= '<a href="index.php?page='.($page + 1).'">></a> '; 317 if ($page < $Pages) $Output .= '<a href="index.php?page='.$Pages.'">>></a>'; 318 318 } 319 319 } 320 return ($Output);320 return ($Output); 321 321 } 322 322 } -
trunk/Modules/NetworkShare/browse.php
r790 r873 9 9 $MountDir = '/tmp/browse/host'; // Složka, kde se dočasně připojují síťové disky 10 10 $TempDir = '/tmp/browse/'; // Složka, kde se dočasně připojují síťové disky 11 if (!is_dir($TempDir)) mkdir($TempDir, 0777);12 if (!is_dir($MountDir)) mkdir($MountDir, 0777);11 if (!is_dir($TempDir)) mkdir($TempDir, 0777); 12 if (!is_dir($MountDir)) mkdir($MountDir, 0777); 13 13 14 14 // Nacteni seznamu sdileni 15 15 $Host = strtoupper(getenv('browse_host')); 16 if ($Host=='') die("Musite nastavit browse_host!\n");16 if ($Host=='') die("Musite nastavit browse_host!\n"); 17 17 $HostID = getenv('browse_id'); 18 if ($HostID=='') die("Musite nastavit browse_id!\n");18 if ($HostID=='') die("Musite nastavit browse_id!\n"); 19 19 //echo("\n================== Prochazec sdileni =================\n\n"); 20 20 echo("Nacitam seznam sdileni pro ".$Host.'('.$HostID.')...'); … … 23 23 echo("OK\n"); 24 24 //print_r($Output); 25 if ($Output[0]=='Connection to '.$Host.' failed') die('Pocitac '.$Host." nenalezen!\n");25 if ($Output[0]=='Connection to '.$Host.' failed') die('Pocitac '.$Host." nenalezen!\n"); 26 26 $Output = array_slice($Output,3); 27 27 $Shares = array(); 28 foreach ($Output as $Radek)29 { 30 if ($Radek=='') break;28 foreach ($Output as $Radek) 29 { 30 if ($Radek=='') break; 31 31 //$Radek = iconv('UTF-8','ISO-8859-2',$Radek); 32 32 $Title = trim(substr($Radek,1,16)); … … 34 34 $Desc = trim(substr($Radek,26)); 35 35 //echo($Title.','.$Type.','.$Desc."\n"); 36 if (($Type=='Disk') && (substr($Title,-1,1)!='$')) array_push($Shares,$Title);36 if (($Type=='Disk') && (substr($Title,-1,1)!='$')) array_push($Shares,$Title); 37 37 //ShowArray($Radek); 38 38 } … … 61 61 //echo(strlen($Nazev).","); 62 62 array_push($Files,$Nazev); 63 } while (($Nazev != "\n") && (!feof($Soubor)));63 } while (($Nazev != "\n") && (!feof($Soubor))); 64 64 array_pop($Files); 65 //if (($Pocet-floor($Pocet/10)*10)==9)65 //if (($Pocet-floor($Pocet/10)*10)==9) 66 66 $Hotovo = floor(ftell($Soubor) / $FileSize * $MaxProgress); 67 if ($Hotovo >= $Pocet)67 if ($Hotovo >= $Pocet) 68 68 { 69 69 echo(str_repeat('#', $Hotovo-$Pocet)); … … 71 71 } 72 72 //echo('['.memory_get_usage().'] '.$Cesta."\n"); 73 foreach ($Files as $Radek)73 foreach ($Files as $Radek) 74 74 { 75 75 //echo($Radek.""); 76 76 $Radek = substr($Radek,0,-1); 77 77 //echo($Radek.",\n"); 78 if ($Radek[0] == 'd') $Type = 2; else $Type = 0;78 if ($Radek[0] == 'd') $Type = 2; else $Type = 0; 79 79 $Prava = substr($Radek,0,strpos($Radek,' ')); 80 80 $Radek = ltrim(substr($Radek,strlen($Prava)+1)); … … 94 94 //echo($Date.','.$Time.','.$Radek.' '); 95 95 96 if ((strpos($Nazev,'.') > 0) && ($Type != 2))96 if ((strpos($Nazev,'.') > 0) && ($Type != 2)) 97 97 { 98 98 $Ext = substr($Nazev,strrpos($Nazev,'.')+1); … … 114 114 $Citac = $Citac + 1; 115 115 // Pokud jde o sloľku, tak projdi jeji obsah a aktualizuj velikost 116 if ($Type == 2)116 if ($Type == 2) 117 117 { 118 118 //echo($Vlozit); 119 // if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky119 // if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky 120 120 // $Vlozit = ''; 121 121 $VelikostSlozky += Vetev($Cesta.$Nazev.'/',$Zanoreni+1); … … 123 123 } 124 124 //echo($Vlozit); 125 //if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky125 //if ($Vlozit!='') DB_Query($Vlozit); // Vloz vsechny polozky 126 126 127 127 // Aktualizuj velikost … … 130 130 $Database->update('NetworkShareItem', 'id='.$Parent, array('size' => $VelikostSlozky)); 131 131 //closedir($Dir); 132 return ($VelikostSlozky);132 return ($VelikostSlozky); 133 133 } 134 134 … … 152 152 $Parent = $Row[0]; 153 153 154 foreach ($Shares as $Share)154 foreach ($Shares as $Share) 155 155 { 156 156 $Pocet = 0; … … 163 163 // echo($SambaSbinDir."mount.cifs '".$ShareFull."' ".$MountDir.' -o guest,codepage=cp852,iocharset=iso8859-2'); 164 164 passthru('ls -A -R -X -l --time-style=+"%Y-%m-%d %I:%M:%S" '.$MountDir.'>'.$TempDir.$Host.'.list 2>'.$TempDir.'errors/'.$Host.'_'.$Share.'.err',$Result); 165 //if ($Result==0)165 //if ($Result==0) 166 166 //{ 167 167 echo("OK\n"); 168 168 169 if (file_exists($TempDir.$Host.'.list'))169 if (file_exists($TempDir.$Host.'.list')) 170 170 { 171 171 // Přidej poloľku sdílení do datanáze … … 215 215 $DbResult = $Database->query('SELECT id FROM hosts'); 216 216 $Vyber = ''; 217 while ($Row = $DbResult->fetch_array())217 while ($Row = $DbResult->fetch_array()) 218 218 $Vyber .= $Row['id'].','; 219 219 … … 226 226 echo("Chyby sdílení...\n"); 227 227 $Database->delete('NetworkShareError', 'host="'.$Host.'"'); 228 if (is_dir($TempDir.'errors'))228 if (is_dir($TempDir.'errors')) 229 229 { 230 230 $Dir = scandir($TempDir.'errors'); 231 foreach ($Dir as $File)231 foreach ($Dir as $File) 232 232 { 233 if (substr($File, 0, strpos($File, '_')) == $Host)233 if (substr($File, 0, strpos($File, '_')) == $Host) 234 234 { 235 235 $Share = substr($File, strpos($File, '_')+1, -4); 236 236 $ShareFull = '//'.$Host.'/'.$Share; 237 if (filesize($TempDir.'errors/'.$File) > 0)237 if (filesize($TempDir.'errors/'.$File) > 0) 238 238 { 239 239 $ErrorFile = fopen($TempDir.'errors/'.$File, 'r+'); 240 while (!feof($ErrorFile))240 while (!feof($ErrorFile)) 241 241 { 242 242 $Row = fgets($ErrorFile); 243 if ($Row != '')243 if ($Row != '') 244 244 { 245 245 $Row = substr($ShareFull.'/'.substr($Row, 39), 0, -1); -
trunk/Modules/NetworkShare/firefox.php
r790 r873 10 10 var msg="Přidání vyhledávacího modulu selhalo - "; 11 11 12 if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")){13 if (engineURL == null || engineURL == ""){12 if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")){ 13 if (engineURL == null || engineURL == ""){ 14 14 alert(msg + "nebyla zadána jeho URL."); 15 15 return false; 16 16 } 17 if (iconURL == null || iconURL == ""){17 if (iconURL == null || iconURL == ""){ 18 18 alert(msg + "nebyla zadána URL ikony."); 19 19 return false; 20 20 } 21 if (engineURL.search(/^http:\/\//i) == -1 || engineURL.search(/\.src$/i) == -1){21 if (engineURL.search(/^http:\/\//i) == -1 || engineURL.search(/\.src$/i) == -1){ 22 22 alert(msg + "nebyla zadána platná URL."); 23 23 return false; 24 24 } 25 if (iconURL.search(/^http:\/\//i) == -1 || iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1){25 if (iconURL.search(/^http:\/\//i) == -1 || iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1){ 26 26 alert(msg + " nebyla platná URL ikony."); 27 27 return false; 28 28 } 29 if (suggestedTitle == null) suggestedTitle = "";30 if (suggestedCategory == null) suggestedCategory = "";29 if (suggestedTitle == null) suggestedTitle = ""; 30 if (suggestedCategory == null) suggestedCategory = ""; 31 31 window.sidebar.addSearchEngine(engineURL, iconURL, suggestedTitle, suggestedCategory); 32 32 }else{ -
trunk/Modules/NetworkShare/online.php
r790 r873 3 3 //$Database->select_db('share'); 4 4 echo("\n====================== Kontrola online pocitacu ============================\n\n"); 5 //while (true)5 //while (true) 6 6 { 7 7 echo('Nacitam strom sdileni...'); … … 13 13 array_shift($Output); 14 14 $Online = array(); // Seznam online pocitacu 15 foreach ($Output as $Radek)15 foreach ($Output as $Radek) 16 16 { 17 if (ord($Radek[0])!=9) continue;17 if (ord($Radek[0])!=9) continue; 18 18 $Host = explode(' ',substr($Radek,3)); 19 19 $Host = $Host[0]; … … 21 21 $Section = 0; 22 22 // Zjisti IP a MAC adresu 23 if ($Host=='CENTRALA')23 if ($Host=='CENTRALA') 24 24 { 25 25 $MAC = '00:E0:4C:20:64:22'; … … 27 27 $Section = 0; 28 28 } else 29 if ($Host=='CENTRALA2')29 if ($Host=='CENTRALA2') 30 30 { 31 31 $MAC = '00:E0:4C:20:64:22'; … … 38 38 //echo('arping -c 1 '.$Host); 39 39 exec('arping -c 1 '.$Host,$Output); 40 if (count($Output)!=4)40 if (count($Output)!=4) 41 41 { 42 42 $Output = array(); 43 43 exec('arping -I wlan0 -c 1 '.$Host,$Output); 44 if (count($Output)!=4)44 if (count($Output)!=4) 45 45 { 46 46 $Output = array(); 47 47 exec('arping -I wlan1 -c 1 '.$Host,$Output); 48 if (count($Output)!=4)48 if (count($Output)!=4) 49 49 { 50 50 $Output = array(); 51 51 exec('arping -I wlan2 -c 1 '.$Host,$Output); 52 if (count($Output)!=4)52 if (count($Output)!=4) 53 53 { 54 54 $Output = array(); 55 55 exec('arping -I eth2 -c 1 '.$Host,$Output); 56 if (count($Output)!=4) continue;56 if (count($Output)!=4) continue; 57 57 else $Section = 4; 58 58 } else $Section = 3; … … 74 74 //print_r($Online); 75 75 // Aktivuj online pocitace 76 foreach ($Online as $Item)76 foreach ($Online as $Item) 77 77 { 78 78 $DbResult = $Database->query("SELECT * FROM hosts WHERE name='".$Item['host']."'"); 79 if ($DbResult->num_rows > 0)79 if ($DbResult->num_rows > 0) 80 80 { 81 81 $Database->update('hosts',"name='".$Item['host']."'",array( 'IP' => $Item['IP'], 'MAC' => $Item['MAC'], 'online' => 1, 'lastdate' => 'NOW()', 'section' => $Section)); … … 85 85 echo("\nSeznam offline pocitacu:\n"); 86 86 $DbResult = $Database->query("SELECT * FROM hosts WHERE online=0"); 87 while ($Row = $DbResult->fetch_array())87 while ($Row = $DbResult->fetch_array()) 88 88 { 89 89 echo($Row['name'].", "); -
trunk/Modules/NetworkShare/playlist.php
r790 r873 6 6 $Vyber = ''; 7 7 $Podminka = ''; 8 while ($Row = $DbResult->fetch_array())8 while ($Row = $DbResult->fetch_array()) 9 9 $Vyber .= $Row['id'].','; 10 10 $Podminka .= ' AND (host IN ('.substr($Vyber,0,-1).'))'; … … 25 25 $Cesta = ''; //$Row['name']; 26 26 $i = 0; 27 while (($Otec>1)&&($i<$MaxNesting))27 while (($Otec>1)&&($i<$MaxNesting)) 28 28 { 29 29 $DbResult = $Database->query("SELECT id,name,parent FROM items WHERE id=$Otec"); … … 33 33 $i++; 34 34 } 35 if ($i >= $MaxNesting) $Cesta = '?'.'\\'.$Cesta;36 return ('\\\\'.$Cesta);35 if ($i >= $MaxNesting) $Cesta = '?'.'\\'.$Cesta; 36 return ('\\\\'.$Cesta); 37 37 } 38 38 … … 40 40 { 41 41 //$FileInfo = new finfo(FILEINFO_MIME); 42 //return ($FileInfo->file($FileName));43 return ('');42 //return ($FileInfo->file($FileName)); 43 return (''); 44 44 } 45 45 … … 51 51 $Dir = ''; 52 52 $DbResult = $Database->select('items', '*', 'ext="mp3"'.$Podminka); //.' LIMIT 0,1000'); 53 while ($Row = $DbResult->fetch_array())53 while ($Row = $DbResult->fetch_array()) 54 54 { 55 if ($Parent != $Row['parent']) $Dir = PlnaCesta($Row); //echo('d'.PlnaCesta($Row)."\n");55 if ($Parent != $Row['parent']) $Dir = PlnaCesta($Row); //echo('d'.PlnaCesta($Row)."\n"); 56 56 $Parent = $Row['parent']; 57 57 echo($Dir.$Row['name'].'.'.$Row['ext']."\n"); -
trunk/Modules/NetworkShare/update.php
r790 r873 4 4 5 5 $Dnes = date('Y-m-d'); 6 //while (1)6 //while (1) 7 7 //{ 8 8 $Hosts = array(); 9 9 $StartTime = GetMicrotime(); 10 10 $DbResult = $Database->query("SELECT * FROM NetworkDevice WHERE Online=1 AND (Block=0 OR Name='centrala') AND (Name!='GATE') AND User>0"); 11 while ($Row = $DbResult->fetch_array())11 while ($Row = $DbResult->fetch_array()) 12 12 { 13 13 //echo('Host: '.$Host."...\n"); … … 16 16 $HostID = 100; 17 17 $StartTime2 = GetMicrotime(); 18 if ($Dnes != $Row['last_share_check'])18 if ($Dnes != $Row['last_share_check']) 19 19 { 20 20 echo("Kontroluji ".$Row['Name']."...\n"); -
trunk/Modules/NetworkTopology/NetworkTopology.php
r738 r873 10 10 function Show() 11 11 { 12 if (count($this->System->PathItems) > 1)12 if (count($this->System->PathItems) > 1) 13 13 { 14 if ($this->System->PathItems[1] == 'topologie.png') return($this->ShowImage());15 else return (PAGE_NOT_FOUND);14 if ($this->System->PathItems[1] == 'topologie.png') return ($this->ShowImage()); 15 else return (PAGE_NOT_FOUND); 16 16 17 } else return ($this->ShowOverview());17 } else return ($this->ShowOverview()); 18 18 } 19 19 … … 23 23 $this->FormatHTML = false; 24 24 25 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];25 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug']; 26 26 else $debug = 0; 27 27 … … 54 54 'FROM NetworkTopology LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkTopology.Host '. 55 55 'LEFT JOIN NetworkDeviceType ON NetworkDevice.Type = NetworkDeviceType.Id'); 56 while ($item = $DbResult->fetch_array())56 while ($item = $DbResult->fetch_array()) 57 57 { 58 58 $id = $item['Id']; … … 62 62 $vlast = $item['Last']; 63 63 $xpos = $vleft * $spacex; 64 if (($vtop > 0) or ($item['Name'] == $this->TopHostName))64 if (($vtop > 0) or ($item['Name'] == $this->TopHostName)) 65 65 { 66 if ($vtop > 0) imageline($im, $xpos + $halfx, $vtop * $spacey, $xpos + $halfx, $vtop * $spacey + 8, $black);67 if ($vfirst >= 0)66 if ($vtop > 0) imageline($im, $xpos + $halfx, $vtop * $spacey, $xpos + $halfx, $vtop * $spacey + 8, $black); 67 if ($vfirst >= 0) 68 68 { 69 69 imageline($im, $vfirst*$spacex + $halfx, $vtop * $spacey + $spacey, $vlast*$spacex + $halfx, $vtop * $spacey + $spacey, $black); … … 71 71 } 72 72 // $ip = explode('.',$item['IP']); 73 // if (!array_key_exists(3, $ip)) $ip[3] = '';74 if ($item['IconName'] == 'comp')73 // if (!array_key_exists(3, $ip)) $ip[3] = ''; 74 if ($item['IconName'] == 'comp') 75 75 { 76 if ($item['Online'] == 1) $color = $green;76 if ($item['Online'] == 1) $color = $green; 77 77 else $color = $black; 78 78 $image = $im_comp; 79 79 } else $image = $im_dev; 80 if ($item['IconName'] == 'device')80 if ($item['IconName'] == 'device') 81 81 { 82 if ($item['Online'] == 1) $color = $green;82 if ($item['Online'] == 1) $color = $green; 83 83 else $color = $red; 84 84 $image = $im_dev; 85 85 } 86 if ($item['ShowOnline'] == 0)86 if ($item['ShowOnline'] == 0) 87 87 { 88 88 $color = $gray; … … 100 100 101 101 // === Sestavení výsledného souboru ============================================ 102 if ($debug == 0)102 if ($debug == 0) 103 103 { 104 104 Header("Content-type: image/png"); … … 109 109 imagedestroy($im_dev); 110 110 } 111 return ('');111 return (''); 112 112 } 113 113 … … 126 126 zařízení, které jsou přes něj připojeny. U zařízení, kde není stav možné 127 127 zjišťovat je použita <span style="color:gray">šedá barvou</span>.</p>'; 128 return ($Output);128 return ($Output); 129 129 } 130 130 } -
trunk/Modules/NetworkTopology/topologie-gen.php
r548 r873 6 6 global $Database, $debug; 7 7 8 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];8 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug']; 9 9 else $debug = 0; 10 10 //$debug = 0; … … 110 110 $markskip = 0; 111 111 } 112 } while ($level >= 1);112 } while ($level >= 1); 113 113 } 114 114 … … 128 128 $Database->query("INSERT INTO NetworkTopology (Host, Depth, Pos, First, Last) '. 129 129 'VALUES (".$node->index.','.$node->level.','.$this->calc_pos($node).','.$first.','.$last.");"); 130 foreach ($node->children as $key => $value) {130 foreach ($node->children as $key => $value) { 131 131 $this->store_node($value); 132 132 } … … 149 149 $this->setborder($node->level, $this->border[$node->level+1]+1); 150 150 } 151 foreach ($node->children as $key => $value) {151 foreach ($node->children as $key => $value) { 152 152 if ($key == count($node->children)-1) { 153 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);153 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 154 154 } 155 155 $this->left_align($value); 156 156 if ($key == 0) { 157 if ($this->border[$node->level] <= $this->border[$node->level+1]) {157 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 158 158 $node->pos = $this->border[$node->level+1]-1; 159 159 $this->setborder($node->level, $this->border[$node->level+1]); … … 174 174 $this->setborder($node->level, $this->border[$node->level+1]+1); 175 175 } 176 for ($key=count($node->children)-1;$key>=0;$key--) {176 for ($key=count($node->children)-1;$key>=0;$key--) { 177 177 $value = $node->children[$key]; 178 178 if ((count($value->children)>0) && count($node->order)>0) { … … 180 180 } 181 181 if ($key == 0) { 182 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);182 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 183 183 } 184 184 $this->right_align($value); 185 185 if ($key == count($node->children)-1) { 186 if ($this->border[$node->level] <= $this->border[$node->level+1]) {186 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 187 187 $node->rpos = $this->border[$node->level+1]-1; 188 188 $this->setborder($node->level, $this->border[$node->level+1]); … … 196 196 /** Reset construction border **/ 197 197 function reset_border() { 198 foreach ($this->border as $key => $value) $this->border[$key] = 0;198 foreach ($this->border as $key => $value) $this->border[$key] = 0; 199 199 $this->maxborder = 0; 200 200 } … … 214 214 $target = 0; // Index cílového uzlu 215 215 $lastindex = 0; // Index poslední vydličky 216 foreach ($node->children as $key => $value) {216 foreach ($node->children as $key => $value) { 217 217 if (count($value->children)>0) { 218 218 array_push($forkmap,$value); … … 221 221 } 222 222 } 223 for ($i=0;$i<$node->forkcnt-1;$i++) {224 for ($j=0;$j<count($forkmap);$j++) {223 for ($i=0;$i<$node->forkcnt-1;$i++) { 224 for ($j=0;$j<count($forkmap);$j++) { 225 225 $this->border = $preborder; 226 226 $this->maxborder = $premax; 227 227 $k = 0; // index zpracovávané vydličky 228 foreach ($node->children as $key => $value) {228 foreach ($node->children as $key => $value) { 229 229 if (count($value->children)>0) { 230 230 if ($order[$value->index]) { … … 241 241 } 242 242 if ($key == count($node->children)-1) { 243 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);243 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 244 244 } 245 245 $this->left_align($value); 246 246 if ($key == 0) { 247 if ($this->border[$node->level] <= $this->border[$node->level+1]) {247 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 248 248 $node->pos = $this->border[$node->level+1]-1; 249 249 $this->setborder($node->level, $this->border[$node->level+1]); … … 272 272 $this->setborder($node->level, $this->border[$node->level+1]+1); 273 273 } 274 foreach ($node->children as $key => $value) {274 foreach ($node->children as $key => $value) { 275 275 if ((count($value->children)>0) && count($order)>0) { 276 276 $value = $order[$value->index]; 277 277 } 278 278 if ($key == count($node->children)-1) { 279 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);279 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 280 280 } 281 281 $this->reorder($value); 282 282 if ($key == 0) { 283 if ($this->border[$node->level] <= $this->border[$node->level+1]) {283 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 284 284 $node->pos = $this->border[$node->level+1]-1; 285 285 $this->setborder($node->level, $this->border[$node->level+1]); … … 301 301 } 302 302 $forkcnt = 0; // Fork counter 303 foreach ($node->children as $key => $value) {303 foreach ($node->children as $key => $value) { 304 304 if ($forkcnt == count($node->children)-1) { 305 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);305 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 306 306 } 307 307 if (count($value->children)>0) { 308 308 $this->left_stub($value); 309 309 if ($forkcnt == 0) { 310 if ($this->border[$node->level] <= $this->border[$node->level+1]) {310 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 311 311 $node->pos = $this->border[$node->level+1]-1; 312 312 $this->setborder($node->level, $this->border[$node->level+1]); … … 335 335 $lastindex = 0; // Index poslední vydličky 336 336 $fact = 1; // Faktoriál kombinací vydliček 337 foreach ($node->children as $key => $value) {337 foreach ($node->children as $key => $value) { 338 338 if (count($value->children)>0) { 339 339 if ($key>0) $fact = $fact * ($key+1); … … 343 343 } 344 344 } 345 for ($i=0;$i<$node->forkcnt-1;$i++) {346 for ($j=0;$j<count($forkmap);$j++) {345 for ($i=0;$i<$node->forkcnt-1;$i++) { 346 for ($j=0;$j<count($forkmap);$j++) { 347 347 $this->border = $preborder; 348 348 $this->maxborder = $premax; 349 349 $k = 0; // index zpracovávané vydličky 350 foreach ($node->children as $key => $value) {350 foreach ($node->children as $key => $value) { 351 351 if (count($value->children)>0) { 352 352 if ($order[$value->index]) { … … 363 363 } 364 364 if ($key == count($node->children)-1) { 365 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);365 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 366 366 } 367 367 $this->left_align($value); 368 368 if ($key == 0) { 369 if ($this->border[$node->level] <= $this->border[$node->level+1]) {369 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 370 370 $node->pos = $this->border[$node->level+1]-1; 371 371 $this->setborder($node->level, $this->border[$node->level+1]); … … 395 395 $this->setborder($node->level, $this->border[$node->level+1]+1); 396 396 } 397 foreach ($node->children as $key => $value) {397 foreach ($node->children as $key => $value) { 398 398 if ((count($value->children)>0) && count($order)>0) { 399 399 $value = $order[$value->index]; 400 400 } 401 401 if ($key == count($node->children)-1) { 402 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);402 if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1); 403 403 } 404 404 $this->reorder($value); 405 405 if ($key == 0) { 406 if ($this->border[$node->level] <= $this->border[$node->level+1]) {406 if ($this->border[$node->level] <= $this->border[$node->level+1]) { 407 407 $node->pos = $this->border[$node->level+1]-1; 408 408 $this->setborder($node->level, $this->border[$node->level+1]); -
trunk/Modules/NetworkTopology/topologie-img.php
r738 r873 3 3 include('../global.php'); 4 4 5 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];5 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug']; 6 6 else $debug = 0; 7 7 $TopHostName = 'nix-router'; … … 13 13 global $debug, $bbound; 14 14 15 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0;16 if ($i = $vfirst[$id])15 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0; 16 if ($i = $vfirst[$id]) 17 17 { 18 18 //if ($debug==2) echo $id.':'.@$i.','.@$vpred[$i].'-'.@$vleft[@$vpred[$i]]."\n"; … … 37 37 $vleft[$i]+=$diff; 38 38 $limit = balance($i,$level+1, $vlast,$vleft,$vpred, $vfirst,$vnext,$tbound, $width, $limit) + 2; 39 if (!array_key_exists($i, $vnext)) $vnext[$i] = 0;39 if (!array_key_exists($i, $vnext)) $vnext[$i] = 0; 40 40 $i = $vnext[$i]; 41 41 } … … 91 91 $item = $DbResult->fetch_array(); 92 92 //print_r($item); 93 if ($item)93 if ($item) 94 94 { 95 95 // --- Zpracování položky z DB ----------------------------------------------- 96 if ($position[$level] > 0)96 if ($position[$level] > 0) 97 97 { 98 98 $vnext[$curr] = $item['id']; // Neprvní položka, nastav předchozí … … 103 103 $vlast[$parent[$level]] = $curr; 104 104 $vtop[$curr] = $level; 105 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0;105 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0; 106 106 $vleft[$curr] = $tbound[$level]; 107 if (!array_key_exists($level, $tranger)) $tranger[$level] = 0;107 if (!array_key_exists($level, $tranger)) $tranger[$level] = 0; 108 108 $vpred[$curr] = $tranger[$level]; 109 109 $tranger[$level] = $curr; … … 117 117 { 118 118 // Uzelový vrchol 119 if (array_key_exists($level + 1, $tbound))120 if ($tbound[$level + 1] > $vleft[$curr]) $vleft[$curr] = $tbound[$level + 1];119 if (array_key_exists($level + 1, $tbound)) 120 if ($tbound[$level + 1] > $vleft[$curr]) $vleft[$curr] = $tbound[$level + 1]; 121 121 } 122 122 $tbound[$level] = $vleft[$curr] + 2; … … 133 133 { 134 134 // --- Zarovnávání prvků kvůli vzhledu 135 if (!array_key_exists($vfirst[$parent[$level]], $vleft)) $vleft[$vfirst[$parent[$level]]] = 0;136 if (!array_key_exists($parent[$level], $vleft)) $vleft[$parent[$level]] = 0;135 if (!array_key_exists($vfirst[$parent[$level]], $vleft)) $vleft[$vfirst[$parent[$level]]] = 0; 136 if (!array_key_exists($parent[$level], $vleft)) $vleft[$parent[$level]] = 0; 137 137 if ($vleft[$vfirst[$parent[$level]]] > $vleft[$parent[$level]]) 138 138 { … … 146 146 } 147 147 $level--; 148 if (!array_key_exists($level, $parent)) $parent[$level] = 0;149 if (!array_key_exists($parent[$level], $vlast)) $vlast[$parent[$level]] = 0;148 if (!array_key_exists($level, $parent)) $parent[$level] = 0; 149 if (!array_key_exists($parent[$level], $vlast)) $vlast[$parent[$level]] = 0; 150 150 $curr = $vlast[$parent[$level]]; 151 151 152 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0;153 if (!array_key_exists($level + 1, $tbound)) $tbound[$level + 1] = 0;154 if ($tbound[$level] > $tbound[$level + 1]) $tbound[$level + 1] = $tbound[$level];155 } 156 } while ($level >= 0);152 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0; 153 if (!array_key_exists($level + 1, $tbound)) $tbound[$level + 1] = 0; 154 if ($tbound[$level] > $tbound[$level + 1]) $tbound[$level + 1] = $tbound[$level]; 155 } 156 } while ($level >= 0); 157 157 $data = compact('tbound', 'count', 'tbound', 'vfirst', 'vlast', 'vtop', 'vleft', 'height', 'width', 'index', 'maxindex'); 158 return ($data);158 return ($data); 159 159 }; 160 160 … … 164 164 $data = gentree(1); 165 165 $datawidth = $data['width']; 166 for ($i = 0; $i <= $maxindex; $i++)167 { 168 if (!array_key_exists($i, $vleft)) $vleft[$i] = 0;169 if (!array_key_exists($i, $data['vleft'])) $data['vleft'][$i] = 0;166 for ($i = 0; $i <= $maxindex; $i++) 167 { 168 if (!array_key_exists($i, $vleft)) $vleft[$i] = 0; 169 if (!array_key_exists($i, $data['vleft'])) $data['vleft'][$i] = 0; 170 170 $vleft[$i] = .2 + ($vleft[$i] + ($datawidth - $data['vleft'][$i])) / 2; 171 171 } … … 179 179 $IconList = array(); 180 180 $DbResult = $Database->query('SELECT * FROM HostType'); 181 while ($HostType = $DbResult->fetch_assoc())181 while ($HostType = $DbResult->fetch_assoc()) 182 182 $IconList[$HostType['Id']] = imagecreatefrompng('images/'.$HostType['IconName'].'.png'); 183 183 … … 194 194 { 195 195 global $vleft, $spacex; 196 return ($vleft[$id] * $spacex);196 return ($vleft[$id] * $spacex); 197 197 } 198 198 199 199 $DbResult = $Database->query('SELECT * FROM hosts JOIN HostType ON HostType.Id = hosts.type WHERE hosts.used=1'); 200 while ($item = $DbResult->fetch_array())200 while ($item = $DbResult->fetch_array()) 201 201 { 202 202 $id = $item['id']; 203 if (!array_key_exists($id, $vtop)) $vtop[$id] = 0;204 if (($vtop[$id] > 0) || ($item['name'] == $TopHostName))203 if (!array_key_exists($id, $vtop)) $vtop[$id] = 0; 204 if (($vtop[$id] > 0) || ($item['name'] == $TopHostName)) 205 205 { 206 if ($vtop[$id] > 0) imageline($im, xpos($id) + $halfx, $vtop[$id] * $spacey, xpos($id) + $halfx, $vtop[$id] * $spacey + 8, $black);207 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0;208 if ($vfirst[$id] > 0)206 if ($vtop[$id] > 0) imageline($im, xpos($id) + $halfx, $vtop[$id] * $spacey, xpos($id) + $halfx, $vtop[$id] * $spacey + 8, $black); 207 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0; 208 if ($vfirst[$id] > 0) 209 209 { 210 210 imageline($im, xpos($vfirst[$id]) + $halfx, $vtop[$id] * $spacey + $spacey, xpos($vlast[$id]) + $halfx, $vtop[$id] * $spacey + $spacey, $black); … … 213 213 214 214 $image = $IconList[$item['type']]; 215 if ($item['IP'] == '')215 if ($item['IP'] == '') 216 216 { 217 217 $color = $gray; 218 218 } else 219 if ($item['ShowOnline'] == 1)220 { 221 if ($item['online'] == 1) $color = $green; else $color = $black;222 } else 223 { 224 if ($item['online'] == 1) $color = $green; else $color = $red;219 if ($item['ShowOnline'] == 1) 220 { 221 if ($item['online'] == 1) $color = $green; else $color = $black; 222 } else 223 { 224 if ($item['online'] == 1) $color = $green; else $color = $red; 225 225 } 226 226 // $text='IP: '.$ip[0]; … … 228 228 imagecopy($im, $image, xpos($id) + $halfx - 15, $vtop[$id] * $spacey + 12, 0, 0, 30, 30); 229 229 // imagerectangle($im,xpos($id)+$halfx-6,$vtop[$id]*$spacey+16,xpos($id)+$halfx+6,$vtop[$id]*$spacey+28,$color); 230 if ($debug)230 if ($debug) 231 231 { 232 232 imagestring($im, 2, xpos($id) + ($spacex - strlen($item['id']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), $item['id'], $color); … … 237 237 238 238 // === Sestavení výsledného souboru ============================================ 239 if (!($debug > 1))239 if (!($debug > 1)) 240 240 { 241 241 header('Content-type: image/png'); -
trunk/Modules/NetworkTopology/topologie2.php
r858 r873 29 29 $Hosts = array(); 30 30 $DbResult = $Database->select('hosts', 'id, name, ip, parent, online', 'used=1'); 31 while ($DbRow = $DbResult->fetch_array())31 while ($DbRow = $DbResult->fetch_array()) 32 32 { 33 if (!array_key_exists($DbRow['id'], $Hosts)) $Hosts[$DbRow['id']] = array('subitems' => array());33 if (!array_key_exists($DbRow['id'], $Hosts)) $Hosts[$DbRow['id']] = array('subitems' => array()); 34 34 $Hosts[$DbRow['id']] = array('id' => $DbRow['id'], 'name' => $DbRow['name'], 'parent' => $DbRow['parent'], 'online' => $DbRow['online'], 'subitems' => $Hosts[$DbRow['id']]['subitems']); 35 if (!array_key_exists($DbRow['parent'], $Hosts)) $Hosts[$DbRow['parent']] = array('subitems' => array());35 if (!array_key_exists($DbRow['parent'], $Hosts)) $Hosts[$DbRow['parent']] = array('subitems' => array()); 36 36 $Hosts[$DbRow['parent']]['subitems'][] = &$Hosts[$DbRow['id']]; 37 37 $Hosts[$DbRow['id']]['parent_node'] = &$Hosts[$DbRow['parent']]; … … 44 44 { 45 45 $Result = array('min' => $Host['displacement'], 'max' => $Host['displacement']); 46 foreach ($Host['subitems'] as $Index => $SubHost)46 foreach ($Host['subitems'] as $Index => $SubHost) 47 47 { 48 48 $SubitemResult = $this->CalculateDimension($Host['subitems'][$Index]); … … 50 50 $Result['max'] = max($SubitemResult['max'], $Result['max']); 51 51 } 52 return ($Result);52 return ($Result); 53 53 } 54 54 55 55 function CalculateDisplacement(&$Host, $Level = 0) 56 56 { 57 if (!array_key_exists('displacement', $Host)) $Host['displacement'] = 0;57 if (!array_key_exists('displacement', $Host)) $Host['displacement'] = 0; 58 58 $Host['level'] = $Level; 59 foreach ($Host['subitems'] as $Index => $SubHost)59 foreach ($Host['subitems'] as $Index => $SubHost) 60 60 { 61 61 $Host['subitems'][$Index]['rel_displacement'] = (-(count($Host['subitems']) - 1) * 0.5 + $Index) * $this->HostWidth; … … 68 68 { 69 69 $Host['displacement'] = $Host['displacement'] + $Displacement; 70 foreach ($Host['subitems'] as $Index => $SubHost)70 foreach ($Host['subitems'] as $Index => $SubHost) 71 71 { 72 72 $this->MoveNode($Host['subitems'][$Index], $Displacement); … … 76 76 function CheckColision() 77 77 { 78 foreach ($this->Levels as $Index => $Level)78 foreach ($this->Levels as $Index => $Level) 79 79 { 80 for ($I = 0; $I < count($Level) - 1; $I++)81 if ($Level[$I]['displacement'] >= $Level[$I + 1]['displacement'])80 for ($I = 0; $I < count($Level) - 1; $I++) 81 if ($Level[$I]['displacement'] >= $Level[$I + 1]['displacement']) 82 82 { 83 83 // Search for common parent 84 84 $LeftHost = $Level[$I]; 85 85 $RightHost = $Level[$I + 1]; 86 while (($LeftHost['level'] > 0) and ($LeftHost['parent'] != $RightHost['parent']))86 while (($LeftHost['level'] > 0) and ($LeftHost['parent'] != $RightHost['parent'])) 87 87 { 88 88 $LeftHost = $LeftHost['parent_node']; … … 91 91 $Host = $RightHost['parent_node']['subitems'][0]; 92 92 $II = 0; 93 while ($RightHost['parent_node']['subitems'][$II]['id'] != $RightHost['id']) $II++;94 while ($II < count($RightHost['parent_node']['subitems']))93 while ($RightHost['parent_node']['subitems'][$II]['id'] != $RightHost['id']) $II++; 94 while ($II < count($RightHost['parent_node']['subitems'])) 95 95 { 96 96 $this->MoveNode($RightHost['parent_node']['subitems'][$II], $Level[$I]['displacement'] - $Level[$I + 1]['displacement']); … … 104 104 { 105 105 $this->Levels[$Host['level']][] = &$Host; 106 foreach ($Host['subitems'] as $Index => $SubHost)106 foreach ($Host['subitems'] as $Index => $SubHost) 107 107 { 108 108 $this->BuildLevels($Host['subitems'][$Index]); … … 113 113 { 114 114 $ParentHostPos = array('x' => -$this->RelPos['min'] + $Host['displacement'], 'y' => $Host['level'] * $this->HostHeight); 115 foreach ($Host['subitems'] as $Index => $SubHost)115 foreach ($Host['subitems'] as $Index => $SubHost) 116 116 { 117 117 $HostPos = array('x' => -$this->RelPos['min'] + $SubHost['displacement'], 'y' => $SubHost['level'] * $this->HostHeight); -
trunk/Modules/News/ImportKinoVatra.php
r790 r873 16 16 $doc = new DOMDocument(); 17 17 $doc->load($SourceURL); 18 foreach ($doc->getElementsByTagName('item') as $node)18 foreach ($doc->getElementsByTagName('item') as $node) 19 19 { 20 20 $Title = $node->getElementsByTagName('title')->item(0)->nodeValue; … … 26 26 $Description = str_replace("\r", '', $Description); 27 27 $Description = str_replace("\n", '<br>', $Description); 28 //if (($CommaPos = strpos($Date, ',')) !== FALSE)28 //if (($CommaPos = strpos($Date, ',')) !== FALSE) 29 29 // $Date = substr($Date, $CommaPos + 1); 30 30 $Date = TimeToMysqlDateTime(strtotime($Date)); … … 32 32 $Query = 'SELECT Id FROM News WHERE (`Title`="'.$System->Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$System->Database->real_escape_string($Description).'") AND (`Link` = "'.$System->Database->real_escape_string($Link).'")'; 33 33 $DbResult = $System->Database->query($Query); 34 if ($DbResult->num_rows == 0)34 if ($DbResult->num_rows == 0) 35 35 { 36 36 $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); -
trunk/Modules/News/ImportObecHovezi.php
r827 r873 16 16 $doc = new DOMDocument(); 17 17 @$doc->load($SourceURL); 18 foreach ($doc->getElementsByTagName('item') as $node)18 foreach ($doc->getElementsByTagName('item') as $node) 19 19 { 20 20 $Title = $node->getElementsByTagName('title')->item(0)->nodeValue; … … 26 26 $Description = str_replace("\r", '', $Description); 27 27 $Description = str_replace("\n", '<br>', $Description); 28 //if (($CommaPos = strpos($Date, ',')) !== FALSE)28 //if (($CommaPos = strpos($Date, ',')) !== FALSE) 29 29 // $Date = substr($Date, $CommaPos + 1); 30 30 $Date = TimeToMysqlDateTime(strtotime($Date)); … … 33 33 $DbResult = $System->Database->select('News', 'Id', '(`Title`="'.$System->Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$System->Database->real_escape_string($Description).'") AND (`Link` = "'.$System->Database->real_escape_string($Link).'")'); 34 34 //echo($System->Database->LastQuery); 35 if ($DbResult->num_rows == 0)35 if ($DbResult->num_rows == 0) 36 36 { 37 37 $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); … … 44 44 //$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250')); 45 45 $Content = file_get_contents($SourceURL); 46 while (strpos($Content, $StartText) !== false)46 while (strpos($Content, $StartText) !== false) 47 47 { 48 48 $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText)); … … 74 74 $DbResult = $System->Database->select('News', 'Id', '(`Title`="'.$Title.'") AND (`Category`='.$Category.') AND (`Content` = "'.$Description.'") AND (`Link` = "'.$Link.'")'); 75 75 //echo($System->Database->LastQuery); 76 if ($DbResult->num_rows == 0)76 if ($DbResult->num_rows == 0) 77 77 { 78 78 $System->Database->insert('News', array('Title' => $Title, 'Date' => 'NOW()', 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); -
trunk/Modules/News/ImportTvBeskyd.php
r827 r873 17 17 //$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250')); 18 18 $Content = @file_get_contents($SourceURL); 19 while (strpos($Content, $StartText) !== false)19 while (strpos($Content, $StartText) !== false) 20 20 { 21 21 $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText)); … … 37 37 $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Category`='.$Category); 38 38 //echo($System->Database->LastQuery); 39 if ($DbResult->num_rows == 0)39 if ($DbResult->num_rows == 0) 40 40 { 41 41 $System->Database->insert('News', array('Title' => $Title, 'Date' => 'NOW()', 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); -
trunk/Modules/News/ImportZdechovCzNews.php
r827 r873 16 16 $Author = 'Automat'; 17 17 $Content = @file_get_contents($SourceURL); 18 while (strpos($Content, $StartText) !== false)18 while (strpos($Content, $StartText) !== false) 19 19 { 20 20 $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText)); … … 25 25 $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink)); 26 26 $Link = substr($Content, 0, strpos($Content, '"')); 27 if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;27 if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link; 28 28 $Content = substr($Content, strpos($Content, $StartTitle) + strlen($StartTitle)); 29 29 $Title = substr($Content, 0, strpos($Content, '<')); … … 40 40 $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category); 41 41 //echo($System->Database->LastQuery); 42 if ($DbResult->num_rows == 0)42 if ($DbResult->num_rows == 0) 43 43 { 44 44 $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); -
trunk/Modules/News/ImportZdechovCzRecords.php
r827 r873 16 16 $Author = 'Automat'; 17 17 $Content = @file_get_contents($SourceURL); 18 while (strpos($Content, $StartText) !== false)18 while (strpos($Content, $StartText) !== false) 19 19 { 20 20 $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText)); … … 22 22 $Date = substr($Content, 0, strpos($Content, '<')); 23 23 $DateParts = explode('.', $Date); 24 if (count($DateParts) >= 3)24 if (count($DateParts) >= 3) 25 25 $Date = $DateParts[2].'-'.$DateParts[1].'-'.$DateParts[0]; 26 26 else break; 27 27 $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink)); 28 28 $Link = substr($Content, 0, strpos($Content, '"')); 29 if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;29 if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link; 30 30 $Content = substr($Content, strpos($Content, $StartTitle) + strlen($StartTitle)); 31 31 $Title = substr($Content, 0, strpos($Content, '<')); … … 42 42 $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category); 43 43 //echo($System->Database->LastQuery); 44 if ($DbResult->num_rows == 0)44 if ($DbResult->num_rows == 0) 45 45 { 46 46 $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); -
trunk/Modules/News/News.php
r790 r873 5 5 function CategoryItemCompare($Item1, $Item2) 6 6 { 7 if ($Item1['Index'] == $Item2['Index']) return (0);7 if ($Item1['Index'] == $Item2['Index']) return (0); 8 8 return ($Item1['Index'] > $Item2['Index']) ? -1 : 1; 9 9 } … … 81 81 )); 82 82 83 if ($this->System->ModuleManager->ModulePresent('Search'))83 if ($this->System->ModuleManager->ModulePresent('Search')) 84 84 { 85 85 $this->System->ModuleManager->Modules['Search']->RegisterSearch('Novinky', 'News', array('Title', 'Content')); … … 95 95 $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption']; 96 96 $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>'; 97 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))97 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category)) 98 98 $Output .= ' <a href="aktuality/?action=add&category='.$Category.'">Přidat</a>'; 99 99 $Output .= '</div></div><div class="Content">'; … … 102 102 $Index = 0; 103 103 $FontSize = 12; 104 if ($DbResult->num_rows > 0)104 if ($DbResult->num_rows > 0) 105 105 { 106 106 $Output .= '<table class="NewsTable">'; 107 while ($Row = $DbResult->fetch_array())108 { 109 if ($Row['Name'] == '') $Author = $Row['Author'];107 while ($Row = $DbResult->fetch_array()) 108 { 109 if ($Row['Name'] == '') $Author = $Row['Author']; 110 110 else $Author = $Row['Name']; 111 111 $Output .= '<tr><td onclick="window.location=\'aktuality/?action=view&id='.$Row['Id']. … … 114 114 '<td align="right" style="font-size: '.$FontSize.'pt">'.$Author.' ('.HumanDate($Row['Date']).')</td></tr></table>'; 115 115 $Output .= '<div id="new'.$Category.$Index.'" class="NewsTableItem">'.$this->ModifyContent($Row['Content']); 116 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';117 118 if ($Row['Enclosure'] != '')116 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 117 118 if ($Row['Enclosure'] != '') 119 119 { 120 120 $Output .= '<br />Přílohy: '; 121 121 $Enclosures = explode(';', $Row['Enclosure']); 122 foreach ($Enclosures as $Enclosure)122 foreach ($Enclosures as $Enclosure) 123 123 { 124 if (file_exists($this->UploadedFilesFolder.$Enclosure))124 if (file_exists($this->UploadedFilesFolder.$Enclosure)) 125 125 $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>'; 126 126 } … … 133 133 } 134 134 $Output .= '</div></div>'; 135 return ($Output);135 return ($Output); 136 136 } 137 137 … … 142 142 $I = 1; 143 143 $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY Sequence'); 144 while ($NewsCategory = $DbResult->fetch_array())144 while ($NewsCategory = $DbResult->fetch_array()) 145 145 { 146 146 $this->NewsSetting[] = array('CategoryId' => $NewsCategory['Id'], 'Index' => $I, 'Enabled' => 1, … … 149 149 } 150 150 // Merge defaults with user setting 151 if (array_key_exists('NewsSetting', $_COOKIE))151 if (array_key_exists('NewsSetting', $_COOKIE)) 152 152 { 153 153 $NewsSettingCookie = unserialize($_COOKIE['NewsSetting']); 154 foreach ($this->NewsSetting as $Index => $this->NewSetting)155 { 156 if (array_key_exists($Index, $NewsSettingCookie))154 foreach ($this->NewsSetting as $Index => $this->NewSetting) 155 { 156 if (array_key_exists($Index, $NewsSettingCookie)) 157 157 $this->NewsSetting[$Index] = array_merge($this->NewSetting, $NewsSettingCookie[$Index]); 158 158 } … … 166 166 $this->LoadSettingsFromCookies(); 167 167 168 if (array_key_exists('Action', $_GET))168 if (array_key_exists('Action', $_GET)) 169 169 { 170 170 // Show news customize menu 171 if ($_GET['Action'] == 'CustomizeNews')171 if ($_GET['Action'] == 'CustomizeNews') 172 172 { 173 173 $Output .= $this->ShowCustomizeMenu(); … … 179 179 $ColumnCount = 2; 180 180 $Output .= '<table style="width: 100%"><tr>'; 181 for ($Column = 1; $Column <= $ColumnCount; $Column++)181 for ($Column = 1; $Column <= $ColumnCount; $Column++) 182 182 { 183 183 $Output .= '<td style="vertical-align: top; width: '.round(100 / $ColumnCount).'%;">'; 184 foreach ($this->NewsSetting as $SettingItem)185 if (($SettingItem['Enabled'] == 1) and ($SettingItem['Group'] == $Column))184 foreach ($this->NewsSetting as $SettingItem) 185 if (($SettingItem['Enabled'] == 1) and ($SettingItem['Group'] == $Column)) 186 186 $Output .= $this->ShowNews($SettingItem['CategoryId'], $SettingItem['ItemCount'], $SettingItem['DaysAgo']); 187 187 $Output .= '</td>'; … … 191 191 $Output .= '<a href="aktuality/subscription"><img class="RSSIcon" src="images/rss20.png" alt="Aktuality přes RSS" /></a> <a href="aktuality/subscription">Automatické sledování novinek</a>'; 192 192 $Output .= '</div>'; 193 return ($Output);193 return ($Output); 194 194 } 195 195 … … 200 200 $Output .= '<tr><th>Kategorie</th><th>Pozice</th><th>Zobrazit</th><th>Max. počet</th><th>Posledních dnů</th><th>Sloupec</th></tr>'; 201 201 $I = 0; 202 foreach ($this->NewsSetting as $SettingItem)202 foreach ($this->NewsSetting as $SettingItem) 203 203 { 204 204 $DbResult = $this->Database->select('NewsCategory', '*', 'Id='.$SettingItem['CategoryId']); 205 205 $NewsCategory = $DbResult->fetch_array(); 206 206 $Output .= '<tr><td>'.$NewsCategory['Caption'].'</td><td align="center"><input type="text" size="2" name="NewsCategoryIndex'.$I.'" value="'.$SettingItem['Index'].'" /></td><td align="center"><input type="checkbox" name="NewsCategoryEnabled'.$I.'"'; 207 if ($SettingItem['Enabled'] == 1) $Output .= ' checked="checked"';207 if ($SettingItem['Enabled'] == 1) $Output .= ' checked="checked"'; 208 208 $Output .= ' /></td>'. 209 209 '<td align="center"><input type="text" size="2" name="NewsCategoryCount'.$I.'" value="'.$SettingItem['ItemCount'].'" />'. … … 214 214 } 215 215 $Output .= '</table><input type="hidden" name="NewsCategoryCount" value="'.count($this->NewsSetting).'" /><input type="submit" value="Uložit" /></form></td></tr></table><br>'; 216 return ($Output);216 return ($Output); 217 217 } 218 218 … … 221 221 $Checkbox = array('' => 0, 'on' => 1); 222 222 $Setting = array(); 223 for ($I = 0; $I < $_POST['NewsCategoryCount']; $I++)224 { 225 if (($_POST['NewsCategoryDaysAgo'.$I] * 1) < 0) $_POST['NewsCategoryIndex'.$I] = 0;226 if (($_POST['NewsCategoryCount'.$I] * 1) < 0) $_POST['NewsCategoryCount'.$I] = 0;227 if (($_POST['NewsColumn'.$I] * 1) < 1) $_POST['NewsColumn'.$I] = 1;228 if (!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = '';223 for ($I = 0; $I < $_POST['NewsCategoryCount']; $I++) 224 { 225 if (($_POST['NewsCategoryDaysAgo'.$I] * 1) < 0) $_POST['NewsCategoryIndex'.$I] = 0; 226 if (($_POST['NewsCategoryCount'.$I] * 1) < 0) $_POST['NewsCategoryCount'.$I] = 0; 227 if (($_POST['NewsColumn'.$I] * 1) < 1) $_POST['NewsColumn'.$I] = 1; 228 if (!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = ''; 229 229 $Setting[] = array('CategoryId' => $_POST['NewsCategoryId'.$I], 'Enabled' => $Checkbox[$_POST['NewsCategoryEnabled'.$I]], 'ItemCount' => ($_POST['NewsCategoryCount'.$I]*1), 'DaysAgo' => ($_POST['NewsCategoryDaysAgo'.$I]*1), 'Index' => ($_POST['NewsCategoryIndex'.$I]*1), 230 230 'Group' => $_POST['NewsColumn'.$I]); … … 234 234 $Setting = array_reverse($Setting); 235 235 // Normalize indexes 236 foreach ($Setting as $Index => $Item)236 foreach ($Setting as $Index => $Item) 237 237 $Setting[$Index]['Index'] = $Index + 1; 238 238 … … 248 248 // Make HTML link from URL 249 249 $I = 0; 250 while (strpos($Content, 'http://') !== false)250 while (strpos($Content, 'http://') !== false) 251 251 { 252 252 $I = strpos($Content, 'http://'); 253 if (($I > 0) and ($Content{$I - 1} != '"'))253 if (($I > 0) and ($Content{$I - 1} != '"')) 254 254 { 255 255 $Result .= substr($Content, 0, $I); 256 256 $Content = substr($Content, $I); 257 if (strpos($Content, ' ') !== false)257 if (strpos($Content, ' ') !== false) 258 258 $URL = substr($Content, 0, strpos($Content, ' ')); 259 259 else $URL = substr($Content, 0); … … 267 267 } 268 268 $Result .= $Content; 269 return ($Result);269 return ($Result); 270 270 } 271 271 } -
trunk/Modules/News/NewsPage.php
r839 r873 11 11 { 12 12 $this->UploadedFilesFolder = $this->System->ModuleManager->Modules['News']->UploadedFilesFolder; 13 if (count($this->System->PathItems) > 1)14 { 15 if ($this->System->PathItems[1] == 'subscription') return($this->ShowSubscription());16 else if ($this->System->PathItems[1] == 'rss') return($this->ShowRSS());17 else return (PAGE_NOT_FOUND);18 } else return ($this->ShowMain());13 if (count($this->System->PathItems) > 1) 14 { 15 if ($this->System->PathItems[1] == 'subscription') return ($this->ShowSubscription()); 16 else if ($this->System->PathItems[1] == 'rss') return ($this->ShowRSS()); 17 else return (PAGE_NOT_FOUND); 18 } else return ($this->ShowMain()); 19 19 } 20 20 … … 22 22 { 23 23 $Output = ''; 24 if (!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';24 if (!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění'; 25 25 else 26 26 { 27 27 $Category = $this->GetCategory(); 28 if (array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1;28 if (array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1; 29 29 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '. 30 30 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id); 31 if ($DbResult->num_rows > 0)31 if ($DbResult->num_rows > 0) 32 32 { 33 33 $Row = $DbResult->fetch_array(); 34 if ($Row['Name'] == '') $Author = $Row['Author'];34 if ($Row['Name'] == '') $Author = $Row['Author']; 35 35 else $Author = $Row['Name']; 36 36 $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')'; 37 if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))37 if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 38 38 { 39 39 $Output .= '<div class="Action">'; … … 43 43 } 44 44 $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />'; 45 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';46 if ($Row['Enclosure'] != '')45 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 46 if ($Row['Enclosure'] != '') 47 47 { 48 48 $Output .= '<br />Přílohy: '; 49 49 $Enclosures = explode(';', $Row['Enclosure']); 50 foreach ($Enclosures as $Enclosure)50 foreach ($Enclosures as $Enclosure) 51 51 { 52 if (file_exists($this->UploadedFilesFolder.$Enclosure))52 if (file_exists($this->UploadedFilesFolder.$Enclosure)) 53 53 $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 54 54 } … … 57 57 } else $Output .= 'Položka nenalezena.'; 58 58 } 59 return ($Output);59 return ($Output); 60 60 } 61 61 … … 64 64 $Output = ''; 65 65 $Category = $this->GetCategory(); 66 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))66 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 67 67 { 68 68 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); 69 69 $Output = '<strong>Vložení nové aktuality:</strong><br />'; 70 70 // TODO: Static reference to dynamic category item 71 if ($Category['Id'] == 2) $Output .= 'U inzerátů uvádějte co nejvíce informací ať případný zájemce ví co kupuje. Uvádějte kontaktní údaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát již není platný, připište do něj např. "Prodáno" pomocí editace.';71 if ($Category['Id'] == 2) $Output .= 'U inzerátů uvádějte co nejvíce informací ať případný zájemce ví co kupuje. Uvádějte kontaktní údaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát již není platný, připište do něj např. "Prodáno" pomocí editace.'; 72 72 $Output .= '<form enctype="multipart/form-data" action="?action=add2" method="post">'. 73 73 'Kategorie: <select name="category">'; 74 74 $DbResult = $this->Database->select('NewsCategory', '*'); 75 while ($DbRow = $DbResult->fetch_array())76 { 77 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))78 { 79 if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"';75 while ($DbRow = $DbResult->fetch_array()) 76 { 77 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id'])) 78 { 79 if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"'; 80 80 else $Selected = ''; 81 81 $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>'; … … 93 93 '</form>'; 94 94 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 95 return ($Output);95 return ($Output); 96 96 } 97 97 … … 101 101 $RemoteAddr = GetRemoteAddress(); 102 102 $Category = $this->GetCategory(); 103 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))103 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 104 104 { 105 105 // Process uploaded file … … 107 107 $EnclosureFileNames = array('enclosure1', 'enclosure2', 'enclosure3'); 108 108 $Enclosures = ''; 109 foreach ($EnclosureFileNames as $EnclosureName)110 if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != ''))109 foreach ($EnclosureFileNames as $EnclosureName) 110 if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != '')) 111 111 { 112 112 $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']); 113 if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))113 if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath)) 114 114 { 115 115 $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' byl uložen na serveru.<br />'; … … 130 130 $this->System->ModuleManager->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id); 131 131 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 132 return ($Output);132 return ($Output); 133 133 } 134 134 135 135 function GetPageHeader() 136 136 { 137 return ('<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'.137 return ('<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'. 138 138 "<script>tinymce.init({ 139 139 selector: 'textarea', … … 156 156 $Output = ''; 157 157 $Category = $this->GetCategory(); 158 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))158 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 159 159 { 160 160 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']); 161 161 $Row = $DbResult->fetch_array(); 162 if (($this->System->User->User['Id'] == $Row['User']))162 if (($this->System->User->User['Id'] == $Row['User'])) 163 163 { 164 164 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); … … 174 174 } else $Output .= 'Nepovolená operace!'; 175 175 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 176 return ($Output);176 return ($Output); 177 177 } 178 178 … … 182 182 $RemoteAddr = GetRemoteAddress(); 183 183 $Category = $this->GetCategory(); 184 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))184 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 185 185 { 186 186 $_POST['id'] = $_POST['id'] * 1; 187 187 $DbResult = $this->Database->select('News', '*', '`Id`='.$_POST['id']); 188 if ($DbResult->num_rows > 0)188 if ($DbResult->num_rows > 0) 189 189 { 190 190 $Row = $DbResult->fetch_array(); 191 if ($this->System->User->User['Id'] == $Row['User'])191 if ($this->System->User->User['Id'] == $Row['User']) 192 192 { 193 193 $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], … … 198 198 } else $Output .= 'ID nenalezeno!'; 199 199 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 200 return ($Output);200 return ($Output); 201 201 } 202 202 … … 205 205 $Output = ''; 206 206 $Category = $this->GetCategory(); 207 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))207 if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 208 208 { 209 209 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']); 210 210 $Row = $DbResult->fetch_array(); 211 if ($this->System->User->User['Id'] == $Row['User'])211 if ($this->System->User->User['Id'] == $Row['User']) 212 212 { 213 213 // TODO: Make upload using general File class 214 if ($Row['Enclosure'] != '')214 if ($Row['Enclosure'] != '') 215 215 { 216 216 $Output .= '<br />Přílohy: '; 217 217 $Enclosures = explode(';', $Row['Enclosure']); 218 foreach ($Enclosures as $Enclosure)218 foreach ($Enclosures as $Enclosure) 219 219 { 220 if (file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);220 if (file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure); 221 221 } 222 222 } … … 225 225 } else $Output .= 'Nemáte oprávnění.'; 226 226 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 227 return ($Output);227 return ($Output); 228 228 } 229 229 … … 232 232 $Output = ''; 233 233 $Category = $this->GetCategory(); 234 if ($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id']))234 if ($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id'])) 235 235 { 236 236 $PerPage = 20; … … 238 238 $RowTotal = $DbResult->fetch_array(); 239 239 $PageMax = $RowTotal[0]; 240 if (array_key_exists('page', $_GET)) $Page = $_GET['page'];240 if (array_key_exists('page', $_GET)) $Page = $_GET['page']; 241 241 else $Page = 0; //round($PageMax/$PerPage); 242 242 $Output .= '<strong>Seznam aktualit kategorie '.$Category['Caption'].':</strong><div style="font-size: small;">'; … … 245 245 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '. 246 246 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category['Id'].' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage); 247 while ($Row = $DbResult->fetch_array())248 { 249 if ($Row['Name'] == '') $Author = $Row['Author'];247 while ($Row = $DbResult->fetch_array()) 248 { 249 if ($Row['Name'] == '') $Author = $Row['Author']; 250 250 else $Author = $Row['Name']; 251 251 $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')'; 252 if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))252 if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 253 253 { 254 254 $Output .= '<div class="Action">'; … … 258 258 } 259 259 $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />'; 260 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';261 if ($Row['Enclosure'] != '')260 if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 261 if ($Row['Enclosure'] != '') 262 262 { 263 263 $Output .= '<br />Přílohy: '; 264 264 $Enclosures = explode(';', $Row['Enclosure']); 265 foreach ($Enclosures as $Enclosure)265 foreach ($Enclosures as $Enclosure) 266 266 { 267 if (file_exists($this->UploadedFilesFolder.$Enclosure))267 if (file_exists($this->UploadedFilesFolder.$Enclosure)) 268 268 $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 269 269 } … … 274 274 $Output .= '</div>'; 275 275 } else $Output .= 'Nemáte oprávnění.'; 276 return ($Output);276 return ($Output); 277 277 } 278 278 … … 280 280 { 281 281 $Category = array('Id' => 1); // Default category 282 if (array_key_exists('category', $_GET)) $Category['Id'] = $_GET['category'] * 1;283 if (array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1;284 //if (is_null($Category)) throw new Exception('Kategorie neurčena');282 if (array_key_exists('category', $_GET)) $Category['Id'] = $_GET['category'] * 1; 283 if (array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1; 284 //if (is_null($Category)) throw new Exception('Kategorie neurčena'); 285 285 else 286 286 { 287 287 $DbResult = $this->Database->select('NewsCategory', '*', '`Id`='.$Category['Id'].' ORDER BY `Sequence`'); 288 if ($DbResult->num_rows > 0) $Category = $DbResult->fetch_array();288 if ($DbResult->num_rows > 0) $Category = $DbResult->fetch_array(); 289 289 else $Category = array('Id' => 0); //throw new Exception('Kategorie nenalezena'); 290 290 } 291 return ($Category);291 return ($Category); 292 292 } 293 293 … … 295 295 { 296 296 $Output = ''; 297 if (array_key_exists('action',$_GET)) $Action = $_GET['action'];297 if (array_key_exists('action',$_GET)) $Action = $_GET['action']; 298 298 else $Action = ''; 299 if ($Action == 'view') $Output .= $this->ShowView();300 else if ($Action == 'add') $Output .= $this->ShowAdd();301 else if ($Action == 'add2') $Output .= $this->ShowAdd2();302 else if ($Action == 'edit') $Output .= $this->ShowEdit();303 else if ($Action == 'update') $Output .= $this->ShowUpdate();304 else if ($Action == 'del') $Output .= $this->ShowDelete();299 if ($Action == 'view') $Output .= $this->ShowView(); 300 else if ($Action == 'add') $Output .= $this->ShowAdd(); 301 else if ($Action == 'add2') $Output .= $this->ShowAdd2(); 302 else if ($Action == 'edit') $Output .= $this->ShowEdit(); 303 else if ($Action == 'update') $Output .= $this->ShowUpdate(); 304 else if ($Action == 'del') $Output .= $this->ShowDelete(); 305 305 else $Output .= $this->ShowList(); 306 return ($Output);306 return ($Output); 307 307 } 308 308 309 309 function ShowSubscription() 310 310 { 311 if (array_key_exists('build', $_GET))311 if (array_key_exists('build', $_GET)) 312 312 { 313 313 $Select = ''; 314 foreach ($_POST as $Index => $Item)315 { 316 if (substr($Index, 0, 8) == 'category') $Select .= '-'.substr($Index, 8);314 foreach ($_POST as $Index => $Item) 315 { 316 if (substr($Index, 0, 8) == 'category') $Select .= '-'.substr($Index, 8); 317 317 } 318 318 $Select = $this->System->Config['Web']['RootFolder'].'/aktuality/rss/?select='.substr($Select, 1); … … 324 324 $Output .= '<form action="?build=1" method="post">'; 325 325 $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY `Caption`'); 326 while ($Category = $DbResult->fetch_array())326 while ($Category = $DbResult->fetch_array()) 327 327 { 328 328 $Output .= '<input type="checkbox" name="category'.$Category['Id'].'" />'.$Category['Caption'].'<br />'; … … 331 331 '</form>'; 332 332 } 333 return ($Output);333 return ($Output); 334 334 } 335 335 … … 349 349 350 350 // Prepare WHERE condition 351 if (array_key_exists('select', $_GET))351 if (array_key_exists('select', $_GET)) 352 352 { 353 353 $Where = ''; 354 354 $Parts = explode('-', $_GET['select']); 355 foreach ($Parts as $Part)355 foreach ($Parts as $Part) 356 356 { 357 357 $Where .= 'OR (`Category`='.($Part * 1).')'; … … 363 363 $Categories = array(); 364 364 $DbResult = $this->Database->select('NewsCategory', '*'); 365 while ($Category = $DbResult->fetch_array())365 while ($Category = $DbResult->fetch_array()) 366 366 { 367 367 $Categories[$Category['Id']] = $Category['Caption']; … … 375 375 $Index = 0; 376 376 //echo(DB_NumRows().','); 377 while ($Row = $DbResult->fetch_array())377 while ($Row = $DbResult->fetch_array()) 378 378 { 379 379 $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); … … 390 390 //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"'); 391 391 $DbResult2 = $Database->select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"'); 392 if ($DbResult2->num_rows == 0) //echo('.'); else echo('x');392 if ($DbResult2->num_rows == 0) //echo('.'); else echo('x'); 393 393 $Database->insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date)); 394 394 //echo($Date); … … 400 400 // Get news from database by selected categories 401 401 $DbResult = $this->Database->query('SELECT *, UNIX_TIMESTAMP(`Date`) AS `UnixTime` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE '.$Where.' ORDER BY News.Date DESC LIMIT 0,'.$NewsCount); 402 while ($Row = $DbResult->fetch_assoc())402 while ($Row = $DbResult->fetch_assoc()) 403 403 { 404 404 $EnclosuresText = ''; 405 if ($Row['Enclosure'] != '')405 if ($Row['Enclosure'] != '') 406 406 { 407 407 $EnclosuresText .= '<br />Přílohy: '; 408 408 $Enclosures = explode(';', $Row['Enclosure']); 409 foreach ($Enclosures as $Enclosure)410 { 411 if (file_exists($this->UploadedFilesFolder.$Enclosure))409 foreach ($Enclosures as $Enclosure) 410 { 411 if (file_exists($this->UploadedFilesFolder.$Enclosure)) 412 412 $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 413 413 } 414 414 } 415 if ($Row['Name'] == '') $Author = $Row['Author'];415 if ($Row['Name'] == '') $Author = $Row['Author']; 416 416 else $Author = $Row['Name']; 417 417 $Items[] = array( … … 429 429 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 430 430 $RSS->Items = $Items; 431 return ($RSS->Generate());431 return ($RSS->Generate()); 432 432 } 433 433 } -
trunk/Modules/Notify/Notify.php
r868 r873 46 46 function RegisterCheck($Name, $Callback) 47 47 { 48 if (array_key_exists($Name, $this->Checks))48 if (array_key_exists($Name, $this->Checks)) 49 49 throw new Exception('Check function "'.$Name.'" already registered.'); 50 50 $this->Checks[$Name] = array('Callback' => $Callback); … … 53 53 function UnregisterCheck($Name) 54 54 { 55 if (!array_key_exists($Name, $this->Checks))55 if (!array_key_exists($Name, $this->Checks)) 56 56 throw new Exception('Check function "'.$Name.'" not registered.'); 57 57 unset($this->Checks[$Name]); … … 88 88 'LEFT JOIN `User` ON `User`.`Id` = `NotifyUser`.`User` '. 89 89 'LEFT JOIN `Contact` ON `Contact`.`Id` = `NotifyUser`.`Contact`'); 90 while ($User = $DbResult->fetch_assoc())90 while ($User = $DbResult->fetch_assoc()) 91 91 { 92 92 $Output .= 'User '.$User['Name'].'<br/>'; … … 94 94 $this->Database->update('NotifyUser', '`Id`='.$User['Id'], array('LastTime' => TimeToMysqlDateTime($Time))); 95 95 96 if (($User['Category'] == CONTACT_CATEGORY_EMAIL) and ($Content != ''))96 if (($User['Category'] == CONTACT_CATEGORY_EMAIL) and ($Content != '')) 97 97 { 98 98 $Mail = new Mail(); … … 120 120 } 121 121 122 return ($Output);122 return ($Output); 123 123 } 124 124 … … 178 178 ' ORDER BY `Time` DESC LIMIT '.$Count; 179 179 $DbResult = $this->System->Database->query($sql); 180 while ($Line = $DbResult->fetch_assoc())180 while ($Line = $DbResult->fetch_assoc()) 181 181 { 182 182 $Items[] = array … … 195 195 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 196 196 $RSS->Items = $Items; 197 return ($RSS->Generate());197 return ($RSS->Generate()); 198 198 } 199 199 } -
trunk/Modules/OpeningHours/OpeningHours.php
r738 r873 15 15 $Hours = floor($Time / 60); 16 16 $Minutes = $Time - $Hours * 60; 17 if ($Minutes < 10) $Minutes = '0'.$Minutes;17 if ($Minutes < 10) $Minutes = '0'.$Minutes; 18 18 $Hours = $Hours % 24; 19 return ($Hours.':'.$Minutes);19 return ($Hours.':'.$Minutes); 20 20 } 21 21 … … 28 28 $Minutes = $Time; 29 29 $Output = ''; 30 if ($Days > 0) $Output .= $Days.' dnů, ';31 if ($Hours > 0) $Output .= $Hours.' hodin, ';32 if ($Minutes > 0) $Output .= $Minutes.' minut';33 return ($Output);30 if ($Days > 0) $Output .= $Days.' dnů, '; 31 if ($Hours > 0) $Output .= $Hours.' hodin, '; 32 if ($Minutes > 0) $Output .= $Minutes.' minut'; 33 return ($Output); 34 34 } 35 35 36 36 function EditSubject($Id) 37 37 { 38 if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))38 if ($this->System->User->CheckPermission('OpeningHours', 'Edit')) 39 39 { 40 40 $Output = '<div class="Centred">'; … … 46 46 $Day = array(); 47 47 $DbResult = $this->Database->query('SELECT * FROM SubjectOpenTimeDay WHERE Subject = '.$Id); 48 while ($DbRow = $DbResult->fetch_assoc())48 while ($DbRow = $DbResult->fetch_assoc()) 49 49 $Day[$DbRow['Day']] = $DbRow; 50 foreach ($this->DaysOfWeek as $Index => $Name)51 { 52 if (!array_key_exists($Index, $Day)) $Day[$Index] = array('Open1' => 0, 'Close1' => 0, 'Open2' => 0, 'Close2' => 0);50 foreach ($this->DaysOfWeek as $Index => $Name) 51 { 52 if (!array_key_exists($Index, $Day)) $Day[$Index] = array('Open1' => 0, 'Close1' => 0, 'Open2' => 0, 'Close2' => 0); 53 53 $Output .= '<tr><td>'.$Name.'</td>'. 54 54 '<td><input type="text" name="day'.$Index.'_open1_h" value="'.floor($Day[$Index]['Open1'] / 60).'" size="2" />'. … … 70 70 '</form></div>'; 71 71 } else $Output = 'Nemáte oprávnění'; 72 return ($Output);72 return ($Output); 73 73 } 74 74 … … 78 78 79 79 $Output = ''; 80 if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))80 if ($this->System->User->CheckPermission('OpeningHours', 'Edit')) 81 81 { 82 82 $this->Database->delete('SubjectOpenTimeDay', 'Subject='.$Id); 83 foreach ($this->DaysOfWeek as $Index => $Name)84 { 85 if ($_POST['day'.$Index.'_open1_h'] > 24) $_POST['day'.$Index.'_open1_h'] = 24;86 if ($_POST['day'.$Index.'_close1_h'] > 24) $_POST['day'.$Index.'_close1_h'] = 24;87 if ($_POST['day'.$Index.'_open2_h'] > 24) $_POST['day'.$Index.'_open2_h'] = 24;88 if ($_POST['day'.$Index.'_close2_h'] > 24) $_POST['day'.$Index.'_close2_h'] = 24;89 if ($_POST['day'.$Index.'_open1_m'] > 59) $_POST['day'.$Index.'_open1_m'] = 59;90 if ($_POST['day'.$Index.'_close1_m'] > 59) $_POST['day'.$Index.'_close1_m'] = 59;91 if ($_POST['day'.$Index.'_open2_m'] > 59) $_POST['day'.$Index.'_open2_m'] = 59;92 if ($_POST['day'.$Index.'_close2_m'] > 59) $_POST['day'.$Index.'_close2_m'] = 59;83 foreach ($this->DaysOfWeek as $Index => $Name) 84 { 85 if ($_POST['day'.$Index.'_open1_h'] > 24) $_POST['day'.$Index.'_open1_h'] = 24; 86 if ($_POST['day'.$Index.'_close1_h'] > 24) $_POST['day'.$Index.'_close1_h'] = 24; 87 if ($_POST['day'.$Index.'_open2_h'] > 24) $_POST['day'.$Index.'_open2_h'] = 24; 88 if ($_POST['day'.$Index.'_close2_h'] > 24) $_POST['day'.$Index.'_close2_h'] = 24; 89 if ($_POST['day'.$Index.'_open1_m'] > 59) $_POST['day'.$Index.'_open1_m'] = 59; 90 if ($_POST['day'.$Index.'_close1_m'] > 59) $_POST['day'.$Index.'_close1_m'] = 59; 91 if ($_POST['day'.$Index.'_open2_m'] > 59) $_POST['day'.$Index.'_open2_m'] = 59; 92 if ($_POST['day'.$Index.'_close2_m'] > 59) $_POST['day'.$Index.'_close2_m'] = 59; 93 93 $Day = array('Subject' => $Id, 'Day' => $Index); 94 94 $Day['Open1'] = $_POST['day'.$Index.'_open1_m'] + $_POST['day'.$Index.'_open1_h'] * 60; … … 111 111 $this->Database->update('SubjectOpenTime', 'Subject='.$Id, array('UpdateTime' => 'NOW()', 'Notice' => $_POST['notice'], 'Photo' => $FileId)); 112 112 } else $Output = 'Nemáte oprávnění'; 113 return ($Output);113 return ($Output); 114 114 } 115 115 … … 118 118 $Output = '<div class="Centred">'; 119 119 $DbResult = $this->Database->query('SELECT SubjectOpenTime.*, DATE_FORMAT(SubjectOpenTime.UpdateTime, "%e.%c.%Y") as UpdateTime, Subject.Id, Subject.Name as Name FROM SubjectOpenTime JOIN Subject ON Subject.Id = SubjectOpenTime.Subject ORDER BY Name'); 120 while ($Subject = $DbResult->fetch_assoc())120 while ($Subject = $DbResult->fetch_assoc()) 121 121 { 122 122 $Output .= '<strong>'.$Subject['Name'].':</strong><br />'; … … 125 125 $Events = array(); 126 126 $DbResult2 = $this->Database->query('SELECT * FROM `SubjectOpenTimeDay` WHERE Subject='.$Subject['Subject'].' ORDER BY Day ASC'); 127 while ($DbRow = $DbResult2->fetch_assoc())128 { 129 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1']))127 while ($DbRow = $DbResult2->fetch_assoc()) 128 { 129 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1'])) 130 130 { 131 131 $Events[] = array('Time' => $DbRow['Open1'] + $DbRow['Day'] * 24 * 60, 'Type' => 1); 132 132 $Events[] = array('Time' => $DbRow['Close1'] + $DbRow['Day'] * 24 * 60, 'Type' => 2); 133 133 } 134 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2']))134 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2'])) 135 135 { 136 136 $Events[] = array('Time' => $DbRow['Open2'] + $DbRow['Day'] * 24 * 60, 'Type' => 1); … … 141 141 142 142 // Calculate time to next event 143 if (count($Events) > 0)143 if (count($Events) > 0) 144 144 { 145 145 $CurrentTime = ((date('w') + 6) % 7) * 24 * 60 + date('G') * 60 + date('i'); 146 146 147 147 $I = 0; 148 while (($I < count($Events)) and ($Events[$I]['Time'] < $CurrentTime))148 while (($I < count($Events)) and ($Events[$I]['Time'] < $CurrentTime)) 149 149 $I++; 150 if ($I < count($Events))150 if ($I < count($Events)) 151 151 { 152 152 $NextTime = $Events[$I]['Time']; … … 160 160 $TimeDelta = $NextTime - $CurrentTime; 161 161 //$Output .= $CurrentTime.' '.$NextTime; 162 if ($NextEventType == 2) $Output .= 'Zavírá za '.$this->ToHumanTime2($TimeDelta);162 if ($NextEventType == 2) $Output .= 'Zavírá za '.$this->ToHumanTime2($TimeDelta); 163 163 else $Output .= 'Otevírá za '.$this->ToHumanTime2($TimeDelta); 164 164 } … … 166 166 // Show time inteval table 167 167 $Output .= '<table class="WideTable"><tr><th>Den</th><th>Čas</th></tr>'; 168 foreach ($this->DaysOfWeek as $DayIndex => $DayOfWeek)168 foreach ($this->DaysOfWeek as $DayIndex => $DayOfWeek) 169 169 { 170 170 $DbResult2 = $this->Database->query('SELECT * FROM SubjectOpenTimeDay WHERE Subject = '.$Subject['Subject'].' AND Day='.$DayIndex); 171 171 $Output .= '<tr><td>'.$DayOfWeek.'</td><td align="center">'; 172 if ($DbResult2->num_rows)172 if ($DbResult2->num_rows) 173 173 { 174 174 $DbRow = $DbResult2->fetch_assoc(); 175 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1']))175 if (($DbRow['Open1'] != $DbRow['Close1']) and ($DbRow['Open1'] < $DbRow['Close1'])) 176 176 { 177 177 $Output .= $this->ToHumanTime($DbRow['Open1']).' - '.$this->ToHumanTime($DbRow['Close1']).' '; 178 178 } 179 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2']))179 if (($DbRow['Open2'] != $DbRow['Close2']) and ($DbRow['Open2'] < $DbRow['Close2']) and ($DbRow['Close1'] < $DbRow['Open2'])) 180 180 { 181 181 $Output .= $this->ToHumanTime($DbRow['Open2']).' - '.$this->ToHumanTime($DbRow['Close2']).''; … … 186 186 } 187 187 $Output .= '</table>Aktualizováno: '.$Subject['UpdateTime'].'<br />'; 188 if ($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />';189 190 if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> ';191 192 if ($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))188 if ($Subject['Notice'] != '') $Output .= 'Poznámka: '.$Subject['Notice'].'<br />'; 189 190 if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> '; 191 192 if ($this->System->User->CheckPermission('SubjectOpenTime', 'Edit')) 193 193 $Output .= '<a href="edit?Subject='.$Subject['Id'].'">Editovat</a><br />'; 194 194 $Output .= '<br />'; 195 195 } 196 196 $Output .= '</div>'; 197 return ($Output);197 return ($Output); 198 198 } 199 199 200 200 function Show() 201 201 { 202 if (count($this->System->PathItems) > 1)203 { 204 if ($this->System->PathItems[1] == 'edit') $Output = $this->EditSubject($_GET['Subject']);205 else if ($this->System->PathItems[1] == 'save')202 if (count($this->System->PathItems) > 1) 203 { 204 if ($this->System->PathItems[1] == 'edit') $Output = $this->EditSubject($_GET['Subject']); 205 else if ($this->System->PathItems[1] == 'save') 206 206 { 207 207 $Output = $this->SaveSubject($_GET['Subject']); … … 209 209 } else $Output = PAGE_NOT_FOUND; 210 210 } else $Output = $this->ShowAll(); 211 return ($Output);211 return ($Output); 212 212 } 213 213 } -
trunk/Modules/Portal/Portal.php
r860 r873 60 60 $DbResult = $this->Database->query('SELECT `Id` FROM `Action` '. 61 61 'WHERE (`Action`.`Group`='.$ActionGroup['Id'].') AND (`Action`.`Enable` = 1)'); 62 while ($Action = $DbResult->fetch_assoc())62 while ($Action = $DbResult->fetch_assoc()) 63 63 { 64 64 $Output .= $this->System->ShowAction($Action['Id']).'<br/>'; 65 65 } 66 return ($this->Panel($ActionGroup['Name'], $Output));66 return ($this->Panel($ActionGroup['Name'], $Output)); 67 67 } 68 68 … … 98 98 //$Output .= 'Server běží: '.$this->GetServerUptime().' '; 99 99 100 if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))100 if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) 101 101 { 102 102 $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='.$this->System->User->User['Id'].')'); 103 if ($DbResult->num_rows > 0)103 if ($DbResult->num_rows > 0) 104 104 { 105 105 $DbRow = $DbResult->fetch_assoc(); … … 109 109 110 110 $Output = '<div class="Navigation"><span class="MenuItem">'.$Output.'</span><div class="MenuItem2"> '.$Output2.'</div></div>'; 111 return ($Output);111 return ($Output); 112 112 } 113 113 … … 115 115 { 116 116 $Output = '<a href="'.$this->System->Link('/user/?Action=UserOptions').'">Profil</a><br />'; 117 if ($this->System->User->CheckPermission('Finance', 'MemberOptions'))117 if ($this->System->User->CheckPermission('Finance', 'MemberOptions')) 118 118 $Output .= '<a href="'.$this->System->Link('/?Action=MemberOptions').'">Fakturační adresa</a><br />'; 119 if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))119 if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) 120 120 $Output .= '<a href="'.$this->System->Link('/finance/platby/').'">Finance</a><br />'; 121 if ($this->System->User->CheckPermission('Network', 'RegistredHostList'))121 if ($this->System->User->CheckPermission('Network', 'RegistredHostList')) 122 122 $Output .= '<a href="'.$this->System->Link('/network/user-hosts/').'">Počítače</a><br />'; 123 if ($this->System->User->CheckPermission('News', 'Insert'))123 if ($this->System->User->CheckPermission('News', 'Insert')) 124 124 $Output .= '<a href="'.$this->System->Link('/aktuality/?action=add').'">Vložení aktuality</a><br />'; 125 if ($this->System->User->CheckPermission('EatingPlace', 'Edit'))125 if ($this->System->User->CheckPermission('EatingPlace', 'Edit')) 126 126 $Output .= '<a href="'.$this->System->Link('/jidelna/menuedit.php').'">Úprava jídelníčků</a><br />'; 127 if ($this->System->User->CheckPermission('Finance', 'Manage'))127 if ($this->System->User->CheckPermission('Finance', 'Manage')) 128 128 $Output .= '<a href="'.$this->System->Link('/finance/sprava/').'">Správa financí</a><br />'; 129 if ($this->System->User->CheckPermission('IS', 'Manage'))129 if ($this->System->User->CheckPermission('IS', 'Manage')) 130 130 $Output .= '<a href="'.$this->System->Link('/is/').'">Správa dat</a><br />'; 131 return ($Output);131 return ($Output); 132 132 } 133 133 … … 135 135 { 136 136 $Output = $this->System->ModuleManager->Modules['WebCam']->ShowImage(); 137 return ($Output);137 return ($Output); 138 138 } 139 139 … … 141 141 { 142 142 $Output = '<a href="https://stat.zdechov.net/meteo/?Measure=28" title="Klikněte pro detailní informace a předpověď"><img src="https://www.zdechov.net/meteo/koliba.png" border="0" alt="Počasí - Meteostanice Zděchov" width="150" height="150" /></a>'; 143 return ($Output);143 return ($Output); 144 144 } 145 145 … … 150 150 'LEFT JOIN `NetworkDeviceType` ON `NetworkDeviceType`.`Id` = `NetworkDevice`.`Type` '. 151 151 'WHERE (`NetworkDeviceType`.`ShowOnline` = 1) AND (`NetworkDevice`.`Online` = 1) ORDER BY `NetworkDevice`.`Name`'); 152 while ($Device = $DbResult->fetch_array())152 while ($Device = $DbResult->fetch_array()) 153 153 { 154 154 $Output .= $Device['Name'].'<br />'; 155 155 } 156 156 $Output .= '</span>'; 157 return ($Output);157 return ($Output); 158 158 } 159 159 … … 162 162 $Output .= '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">'; 163 163 $DbResult = $Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money'); 164 while ($Row = $DbResult->fetch_array())164 while ($Row = $DbResult->fetch_array()) 165 165 { 166 166 $Output .= $Row['Name'].'<br />'; 167 167 } 168 168 $Output .= '</span>'; 169 return ($Output);169 return ($Output); 170 170 } 171 171 172 172 function Panel($Title, $Content, $Menu = array()) 173 173 { 174 if (count($Menu) > 0)175 foreach ($Menu as $Item)174 if (count($Menu) > 0) 175 foreach ($Menu as $Item) 176 176 $Title .= '<div class="Action">'.$Item.'</div>'; 177 return ('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');177 return ('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>'); 178 178 } 179 179 … … 181 181 { 182 182 $Output = ''; 183 if (array_key_exists('Action', $_GET))183 if (array_key_exists('Action', $_GET)) 184 184 { 185 185 $Action = $_GET['Action']; 186 if ($Action == 'CustomizeNewsSave')186 if ($Action == 'CustomizeNewsSave') 187 187 { 188 188 $Output .= $this->System->ModuleManager->Modules['News']->CustomizeSave(); 189 189 } else 190 if ($Action == 'MemberOptions')190 if ($Action == 'MemberOptions') 191 191 { 192 192 $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` '. 193 193 'WHERE `User`='.$this->System->User->User['Id']); 194 while ($CustomerUserRel = $DbResult->fetch_assoc())194 while ($CustomerUserRel = $DbResult->fetch_assoc()) 195 195 { 196 196 $DbResult2 = $this->Database->query('SELECT `Member`.`Id`, '. … … 202 202 $Form->SetClass('MemberOptions'); 203 203 $DbRow = $DbResult2->fetch_array(); 204 foreach ($Form->Definition['Items'] as $Index => $Item)204 foreach ($Form->Definition['Items'] as $Index => $Item) 205 205 { 206 206 $Form->Values[$Index] = $DbRow[$Index]; … … 210 210 } 211 211 } else 212 if ($Action == 'MemberOptionsSave')212 if ($Action == 'MemberOptionsSave') 213 213 { 214 214 $Form = new Form($this->System->FormManager); 215 215 $Form->SetClass('MemberOptions'); 216 216 $Form->LoadValuesFromForm(); 217 if ($Form->Values['FamilyMemberCount'] < 0)217 if ($Form->Values['FamilyMemberCount'] < 0) 218 218 $Form->Values['FamilyMemberCount'] = 0; 219 219 … … 235 235 'ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->User->User['Member']); 236 236 $DbRow = $DbResult->fetch_array(); 237 foreach ($Form->Definition['Items'] as $Index => $Item)237 foreach ($Form->Definition['Items'] as $Index => $Item) 238 238 { 239 239 $Form->Values[$Index] = $DbRow[$Index]; … … 243 243 } 244 244 } else $Output = $this->ShowMain(); 245 return ($Output);245 return ($Output); 246 246 } 247 247 … … 250 250 $Output = ''; 251 251 $DbResult = $this->Database->query('SELECT * FROM `ActionGroup`'); 252 while ($DbRow = $DbResult->fetch_assoc())252 while ($DbRow = $DbResult->fetch_assoc()) 253 253 $ActionGroups[$DbRow['Id']] = $DbRow; 254 254 255 255 // Show pannels 256 //if (IsInternetAddr()) echo('Internet'); else echo('LAN');256 //if (IsInternetAddr()) echo('Internet'); else echo('LAN'); 257 257 //$Output .= $this->InfoBar(); 258 258 $Output .= '<table id="MainTable"><tr>'; 259 259 $DbResult = $this->Database->select('PanelColumn', '*'); 260 while ($PanelColumn = $DbResult->fetch_assoc())261 { 262 if ($PanelColumn != '') $Width = ' width="'.$PanelColumn['Width'].'"';260 while ($PanelColumn = $DbResult->fetch_assoc()) 261 { 262 if ($PanelColumn != '') $Width = ' width="'.$PanelColumn['Width'].'"'; 263 263 else $Width = ''; 264 264 $Output .= '<td valign="top"'.$Width.'>'; 265 265 $DbResult2 = $this->Database->query('SELECT * FROM `Panel` WHERE `PanelColumn`='.$PanelColumn['Id'].' ORDER BY `Order`'); 266 while ($Panel = $DbResult2->fetch_assoc())267 { 268 if ($Panel['Module'] == 'ActionGroup') $Output .= $this->ShowActions($ActionGroups[$Panel['Parameters']]);269 else if ($Panel['Module'] == 'OnlineHostList') $Output .= $this->Panel('Online počítače', $this->OnlineHostList());270 else if ($Panel['Module'] == 'UserOptions')266 while ($Panel = $DbResult2->fetch_assoc()) 267 { 268 if ($Panel['Module'] == 'ActionGroup') $Output .= $this->ShowActions($ActionGroups[$Panel['Parameters']]); 269 else if ($Panel['Module'] == 'OnlineHostList') $Output .= $this->Panel('Online počítače', $this->OnlineHostList()); 270 else if ($Panel['Module'] == 'UserOptions') 271 271 { 272 //if ($this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());272 //if ($this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel()); 273 273 } else 274 if ($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel());275 if ($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel());276 else if ($Panel['Module'] == 'NewsGroupList')274 if ($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel()); 275 if ($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel()); 276 else if ($Panel['Module'] == 'NewsGroupList') 277 277 $Output .= $this->Panel('Aktuality', $this->System->ModuleManager->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>')); 278 278 } … … 280 280 } 281 281 $Output .= '</tr></table>'; 282 return ($Output);282 return ($Output); 283 283 } 284 284 } -
trunk/Modules/RSS/RSS.php
r840 r873 27 27 $this->RSSChannels[$Channel['Channel']] = $Channel; 28 28 29 if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel'];29 if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel']; 30 30 else { 31 31 array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']); … … 42 42 { 43 43 $Output = ''; 44 foreach ($this->RSSChannels as $Channel)44 foreach ($this->RSSChannels as $Channel) 45 45 { 46 //if ($this->System->User->Licence($Channel['Permission']))46 //if ($this->System->User->Licence($Channel['Permission'])) 47 47 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 48 48 $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; 49 49 } 50 return ($Output);50 return ($Output); 51 51 } 52 52 } … … 58 58 $this->ClearPage = true; 59 59 60 if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel'];60 if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel']; 61 61 else $ChannelName = ''; 62 if (array_key_exists('token', $_GET)) $Token = $_GET['token'];62 if (array_key_exists('token', $_GET)) $Token = $_GET['token']; 63 63 else $Token = ''; 64 if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels))64 if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels)) 65 65 { 66 66 $Channel = $this->System->ModuleManager->Modules['RSS']->RSSChannels[$ChannelName]; 67 if ($this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or67 if ($this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or 68 68 $this->System->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token)) 69 69 { 70 if (is_string($Channel['Callback'][0]))70 if (is_string($Channel['Callback'][0])) 71 71 { 72 72 $Class = new $Channel['Callback'][0]($this->System); … … 76 76 } else $Output = 'Nemáte oprávnění'; 77 77 } else $Output = 'Kanál nenalezen'; 78 return ($Output);78 return ($Output); 79 79 } 80 80 } -
trunk/Modules/Scheduler/Scheduler.php
r830 r873 61 61 function Run($Parameters) 62 62 { 63 while (true)63 while (true) 64 64 { 65 65 $DbResult = $this->Database->query('SELECT `Scheduler`.*, `SchedulerAction`.`Class` AS `Class` FROM `Scheduler` '. … … 68 68 '(`Scheduler`.`ScheduledTime` < "'.TimeToMysqlDateTime(time()).'") OR '. 69 69 '(`Scheduler`.`ScheduledTime` IS NULL))'); 70 while ($DbRow = $DbResult->fetch_assoc())70 while ($DbRow = $DbResult->fetch_assoc()) 71 71 { 72 72 echo('Executing '.$DbRow['Name']."\n"); 73 73 $Output = ''; 74 74 $StartTime = time(); 75 if (class_exists($DbRow['Class']))75 if (class_exists($DbRow['Class'])) 76 76 { 77 77 $Class = new $DbRow['Class']($this->System); … … 88 88 array('Log' => $Output, 'LastExecutedTime' => TimeToMysqlDateTime($StartTime), 89 89 'Duration' => $Duration)); 90 if ($DbRow['Period'] != '') {91 if ($DbRow['ScheduledTime'] == '') $NewScheduledTime = $StartTime + $DbRow['Period'];90 if ($DbRow['Period'] != '') { 91 if ($DbRow['ScheduledTime'] == '') $NewScheduledTime = $StartTime + $DbRow['Period']; 92 92 else $NewScheduledTime = MysqlDateTimeToTime($DbRow['ScheduledTime']) + $DbRow['Period']; 93 if ($NewScheduledTime < $StopTime) $NewScheduledTime = $StopTime + $DbRow['Period'];93 if ($NewScheduledTime < $StopTime) $NewScheduledTime = $StopTime + $DbRow['Period']; 94 94 $this->Database->update('Scheduler', 'Id='.$DbRow['Id'], 95 95 array('ScheduledTime' => TimeToMysqlDateTime($NewScheduledTime))); … … 115 115 { 116 116 $Output = '#'; 117 return ($Output);117 return ($Output); 118 118 } 119 119 } -
trunk/Modules/Search/Search.php
r738 r873 14 14 { 15 15 $Output = ''; 16 if (array_key_exists('t', $_GET)) $Text = $_GET['t'];16 if (array_key_exists('t', $_GET)) $Text = $_GET['t']; 17 17 else $Text = ''; 18 18 $Output .= '<form action="?" method="get">'. … … 20 20 '<input type="submit" value="Hledat"/>'. 21 21 '</form>'; 22 if ($Text != '')23 foreach ($this->System->ModuleManager->Modules['Search']->Items as $Item)22 if ($Text != '') 23 foreach ($this->System->ModuleManager->Modules['Search']->Items as $Item) 24 24 { 25 25 $Columns = ''; 26 26 $Condition = ''; 27 foreach ($Item['Columns'] as $Column)27 foreach ($Item['Columns'] as $Column) 28 28 { 29 29 $Columns .= ', `'.$Column.'`'; … … 34 34 $DbResult = $this->Database->Select($Item['Table'], $Columns, $Condition.' LIMIT '. 35 35 $this->System->ModuleManager->Modules['Search']->MaxItemCount); 36 if ($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>';37 while ($Row = $DbResult->fetch_assoc())36 if ($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>'; 37 while ($Row = $DbResult->fetch_assoc()) 38 38 { 39 39 $Output .= '<p>'; 40 foreach ($Item['Columns'] as $Column)40 foreach ($Item['Columns'] as $Column) 41 41 $Output .= $Row[$Column].'<br/>'; 42 42 $Output .= '</p>'; 43 43 } 44 44 } 45 return ($Output);45 return ($Output); 46 46 } 47 47 } -
trunk/Modules/SpeedTest/SpeedTest.php
r738 r873 39 39 function Show() 40 40 { 41 if (count($this->System->PathItems) > 1)41 if (count($this->System->PathItems) > 1) 42 42 { 43 if ($this->System->PathItems[1] == 'download.php') return($this->ShowDownload());44 //else if ($this->System->PathItems[1] == 'rss') return($this->ShowRSS());45 else return (PAGE_NOT_FOUND);46 } else return ($this->ShowMain());43 if ($this->System->PathItems[1] == 'download.php') return ($this->ShowDownload()); 44 //else if ($this->System->PathItems[1] == 'rss') return ($this->ShowRSS()); 45 else return (PAGE_NOT_FOUND); 46 } else return ($this->ShowMain()); 47 47 } 48 48 … … 62 62 63 63 ## Redirect immediately to download.php if auto_start = 1 64 if ($config->{'general'}->{'auto_start'}) {64 if ($config->{'general'}->{'auto_start'}) { 65 65 Header("Location: ".$config['general']['base_url']."/download.php"); 66 66 exit; … … 77 77 <body>'; 78 78 79 if (file_exists("header.html")) {79 if (file_exists("header.html")) { 80 80 ## Include "header.html" for a custom header, if the file exists 81 81 include("header.html"); … … 86 86 $Output .= '<div id="speedtest_content">'; 87 87 88 if (file_exists("welcome.html")) {88 if (file_exists("welcome.html")) { 89 89 ## Include "welcome.html" for a custom welcome page, if the file exists 90 90 include("welcome.html"); … … 107 107 </div>'; 108 108 109 if (file_exists("footer.html")) {109 if (file_exists("footer.html")) { 110 110 ## Include "footer.html" for a custom footer, if the file exists 111 111 include("footer.html"); … … 114 114 print "</center>\n"; 115 115 } 116 return ($Output);116 return ($Output); 117 117 } 118 118 } -
trunk/Modules/SpeedTest/common.php
r560 r873 18 18 foreach ($lines as $line_num => $line) { 19 19 $line = rtrim(preg_replace("/#.*/","",$line)); 20 if (preg_match("/\[.*\]/", $line, $parts)) {20 if (preg_match("/\[.*\]/", $line, $parts)) { 21 21 $section = $parts[0]; 22 22 $section = preg_replace("/[\[\]]/","",$section); … … 34 34 function Debug($message) { 35 35 global $config; 36 if ($config->{'general'}->{'debug'}) {36 if ($config->{'general'}->{'debug'}) { 37 37 BCLog($message); 38 38 } … … 43 43 global $config; 44 44 $logfile = $config->{'general'}->{'logfile'}; 45 if (! $logfile) {45 if (! $logfile) { 46 46 return; 47 47 } -
trunk/Modules/SpeedTest/download.php
r738 r873 19 19 $disallow = $config->{'general'}->{'disallow'}; 20 20 $allow = $config->{'general'}->{'allow'}; 21 if ( $allow && (! preg_match("/$allow/",$remote_addr)) ) {21 if ( $allow && (! preg_match("/$allow/",$remote_addr)) ) { 22 22 include("unallowed.html"); 23 23 exit; 24 } elseif ( $disallow && preg_match("/$disallow/", $remote_addr) ) {24 } elseif ( $disallow && preg_match("/$disallow/", $remote_addr) ) { 25 25 include("unallowed.html"); 26 26 exit; … … 33 33 ## on initial results 34 34 $config_auto_size = $config->{'general'}->{'auto_size'}; 35 if ($config_auto_size) {35 if ($config_auto_size) { 36 36 ## We're using the auto_size functionality 37 if ( isset($_GET['auto_size']) && $_GET['auto_size']) {37 if ( isset($_GET['auto_size']) && $_GET['auto_size']) { 38 38 ## Intial test is done. Set down/upload sizes to the same as 39 39 ## our initial measured speeds. That way the test should take … … 55 55 56 56 ## Make sure sizes are below our configured limits 57 if ($down_kbytes > $config->{'download'}->{'max_kbytes'}) {57 if ($down_kbytes > $config->{'download'}->{'max_kbytes'}) { 58 58 $down_kbytes = $config->{'download'}->{'max_kbytes'}; 59 59 } 60 if ($up_kbytes > $config->{'upload'}->{'max_kbytes'}) {60 if ($up_kbytes > $config->{'upload'}->{'max_kbytes'}) { 61 61 $up_kbytes = $config->{'upload'}->{'max_kbytes'}; 62 62 } 63 63 64 if ($config->{'upload'}->{'skip_upload'}) {64 if ($config->{'upload'}->{'skip_upload'}) { 65 65 $up_kbytes = 0; 66 66 } … … 92 92 93 93 <?php 94 if (file_exists("header.html")) {94 if (file_exists("header.html")) { 95 95 ## Include "header.html" for a custom header, if the file exists 96 96 include("header.html"); … … 103 103 104 104 <?php 105 if ( ($config_auto_size) && (! isset($_GET['auto_size'])) ) {105 if ( ($config_auto_size) && (! isset($_GET['auto_size'])) ) { 106 106 ## auto_size is performing the initial, small test 107 107 print "<div>Calculating appropriate file sizes for testing</div>\n"; … … 137 137 </div> 138 138 139 <?php if (file_exists("footer.html")) { include("footer.html"); } ?>139 <?php if (file_exists("footer.html")) { include("footer.html"); } ?> 140 140 141 141 <?php /* Begin JavaScript functions that we'll need */ ?> … … 144 144 function StartUpload() { 145 145 uploadDiv = document.getElementById('upload_message'); 146 if (uploadDiv) {146 if (uploadDiv) { 147 147 uploadDiv.style.visibility='visible'; 148 148 uploadDiv.style.display='block'; 149 <?php if ($pretty_version) { ?>149 <?php if ($pretty_version) { ?> 150 150 setInterval("IncrementUploadBar()",200); 151 151 <?php } ?> … … 158 158 function IncrementDownloadBar() { 159 159 download_barElement = document.getElementById('download_bar'); 160 if (download_barElement) {160 if (download_barElement) { 161 161 download_bar_current_width += <?php echo $download_progress_bar_increment; ?>; 162 if (download_bar_current_width <= <?php echo $progress_bar_width; ?>) {162 if (download_bar_current_width <= <?php echo $progress_bar_width; ?>) { 163 163 download_barElement.style.width = download_bar_current_width +"px"; 164 164 } … … 176 176 function IncrementUploadBar() { 177 177 upload_barElement = document.getElementById('upload_bar'); 178 if (upload_barElement) {178 if (upload_barElement) { 179 179 upload_bar_current_width += <?php echo $upload_progress_bar_increment; ?>; 180 if (upload_bar_current_width < <?php echo $progress_bar_width; ?>) {180 if (upload_bar_current_width < <?php echo $progress_bar_width; ?>) { 181 181 upload_barElement.style.width = upload_bar_current_width +"px"; 182 182 } … … 186 186 function CompleteDownloadBar() { 187 187 download_barElement = document.getElementById('download_bar'); 188 if (download_barElement) {188 if (download_barElement) { 189 189 download_barElement.style.width = "100%"; 190 190 } … … 209 209 <?php 210 210 211 if ($pretty_version) {211 if ($pretty_version) { 212 212 print " 213 213 //--> … … 225 225 $extra_down_kbytes = $down_kbytes - $up_kbytes; 226 226 $total_kbytes = 0; 227 while ($total_kbytes <= $extra_down_kbytes) {228 if ($pretty_version) {227 while ($total_kbytes <= $extra_down_kbytes) { 228 if ($pretty_version) { 229 229 print " 230 230 <script language=\"javascript\"> … … 240 240 $total_kbytes += $each_chunk; 241 241 } 242 if (!$pretty_version) {242 if (!$pretty_version) { 243 243 print "dataElement.value=\"$data\";"; 244 244 print "CompleteDownloadBar();\n"; … … 254 254 ## Now, download the remaining bytes ($up_kbytes) and save it into a 255 255 ## form variable that we will post back to test the upload speed 256 while ($total_kbytes <= $down_kbytes) {257 if ($pretty_version) {256 while ($total_kbytes <= $down_kbytes) { 257 if ($pretty_version) { 258 258 print " 259 259 <script language=\"javascript\"> … … 270 270 } 271 271 272 if (!$pretty_version) {272 if (!$pretty_version) { 273 273 #print "\";"; 274 274 } else { … … 288 288 downloadtime = (endtime - starttime)/1000; 289 289 } 290 <?php if (! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?>290 <?php if (! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?> 291 291 292 292 down_size = <?php echo $total_kbytes; ?>; … … 297 297 298 298 <?php 299 if ($config_auto_size && (! isset($_GET['auto_size'])) ) {299 if ($config_auto_size && (! isset($_GET['auto_size'])) ) { 300 300 $params_auto_size = "&auto_size=1"; 301 301 } else { 302 302 $params_auto_size = ""; 303 303 } 304 if ($config->{'upload'}->{'skip_upload'} && (! $params_auto_size)) {304 if ($config->{'upload'}->{'skip_upload'} && (! $params_auto_size)) { 305 305 $next_url = $config->{'general'}->{'base_url'}."results.php"; 306 306 } else { -
trunk/Modules/SpeedTest/results.php
r786 r873 16 16 17 17 ## Save the results of this speedtest to the database, if enabled 18 if ($config->{'database'}->{'enable'}) {18 if ($config->{'database'}->{'enable'}) { 19 19 $ip_matches = $config->{'database'}->{'ip_matches'}; 20 if ( (! $ip_matches) || ($ip_matches && preg_match("/$ip_matches/",$_SERVER['REMOTE_ADDR'])) ) {20 if ( (! $ip_matches) || ($ip_matches && preg_match("/$ip_matches/",$_SERVER['REMOTE_ADDR'])) ) { 21 21 Debug("Saving to database"); 22 22 $dbh = mysql_connect( … … 57 57 58 58 <?php 59 if (file_exists("header.html")) {59 if (file_exists("header.html")) { 60 60 ## Include "header.html" for a custom header, if the file exists 61 61 include("header.html"); … … 75 75 print "<h2>Download Speed: $clean_down</h2>\n"; 76 76 ## Find the biggest value 77 foreach ($config->{'comparisons-download'} as $key=>$value) {78 if ($value > $download_biggest) {77 foreach ($config->{'comparisons-download'} as $key=>$value) { 78 if ($value > $download_biggest) { 79 79 $download_biggest = $value; 80 80 } … … 82 82 ## Print a pretty table with a graph of the results 83 83 print "<center><table>\n"; 84 foreach ($config->{'comparisons-download'} as $key=>$value) {84 foreach ($config->{'comparisons-download'} as $key=>$value) { 85 85 $this_bar_width = $bar_width / $download_biggest * $value; 86 86 print "<tr><td>$key</td><td>".CleanSpeed($value)."</td><td width=\"400\">\n"; … … 97 97 98 98 ## Don't display the upload stuff if we didn't get a speed to compare with 99 if (isset($_GET['upspeed'])) {99 if (isset($_GET['upspeed'])) { 100 100 $clean_up = CleanSpeed($_GET['upspeed']); 101 101 $upload_biggest = $_GET['upspeed']; 102 102 print "<h2>Upload Speed: $clean_up</h2>\n"; 103 foreach ($config->{'comparisons-upload'} as $key=>$value) {104 if ($value > $upload_biggest) {103 foreach ($config->{'comparisons-upload'} as $key=>$value) { 104 if ($value > $upload_biggest) { 105 105 $upload_biggest = $value; 106 106 } 107 107 } 108 108 print "<table>\n"; 109 foreach ($config->{'comparisons-upload'} as $key=>$value) {109 foreach ($config->{'comparisons-upload'} as $key=>$value) { 110 110 $this_bar_width = $bar_width / $upload_biggest * $value; 111 111 print "<tr><td>$key</td><td>".CleanSpeed($value)."</td>\n"; … … 128 128 </div> 129 129 130 <?php if (file_exists("footer.html")) { include("footer.html"); } ?>130 <?php if (file_exists("footer.html")) { include("footer.html"); } ?> 131 131 132 132 </body> … … 136 136 ## Convert the raw speed value to a nicer value 137 137 function CleanSpeed($kbps) { 138 if ($kbps > 1024) {138 if ($kbps > 1024) { 139 139 $cleanspeed = round($kbps / 1024,2) . " Mbps"; 140 140 } else { -
trunk/Modules/Stock/Stock.php
r807 r873 248 248 function BeforeInsertStockMove($Form) 249 249 { 250 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);250 if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']); 251 251 else $Year = date("Y", $Form->Values['ValidFrom']); 252 252 $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup'); 253 253 $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year); 254 return ($Form->Values);254 return ($Form->Values); 255 255 } 256 256 } -
trunk/Modules/Subject/Subject.php
r761 r873 184 184 $DbRow = $DbResult->fetch_row(); 185 185 $Output = 'Subjektů: '.$DbRow['0'].'<br/>'; 186 return ($Output);186 return ($Output); 187 187 } 188 188 } -
trunk/Modules/System/System.php
r825 r873 39 39 40 40 $DbResult = $this->Database->query($Query); 41 while ($Module = $DbResult->fetch_assoc())42 { 43 if ($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies'];41 while ($Module = $DbResult->fetch_assoc()) 42 { 43 if ($Module['Dependencies'] != '') $Dependencies = $Module['Dependencies']; 44 44 else $Dependencies = ' '; 45 if ($Module['Installed'] == 1) $Installed = 'Ano';45 if ($Module['Installed'] == 1) $Installed = 'Ano'; 46 46 else $Installed = 'Ne'; 47 if ($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&Id='.$Module['Id'].'">Odinstalovat</a>';47 if ($Module['Installed'] == 1) $Actions = '<a href="?A=Uninstall&Id='.$Module['Id'].'">Odinstalovat</a>'; 48 48 else $Actions = '<a href="?A=Install&Id='.$Module['Id'].'">Instalovat</a>'; 49 49 $Output .= '<tr><td>'.$Module['Name'].'</td>'. … … 59 59 $Output .= $PageList['Output']; 60 60 $Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>'; 61 return ($Output);61 return ($Output); 62 62 } 63 63 … … 65 65 { 66 66 $Output = ''; 67 if (array_key_exists('A', $_GET))68 { 69 if ($_GET['A'] == 'SaveToDb')67 if (array_key_exists('A', $_GET)) 68 { 69 if ($_GET['A'] == 'SaveToDb') 70 70 { 71 71 $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase(); 72 72 $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován'); 73 73 } else 74 if ($_GET['A'] == 'Install')74 if ($_GET['A'] == 'Install') 75 75 { 76 76 $this->System->ModuleManager->LoadModules(false); 77 77 $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']); 78 if ($ModuleName != '')78 if ($ModuleName != '') 79 79 { 80 80 $this->System->Modules[$ModuleName]->Install(); … … 83 83 84 84 } else 85 if ($_GET['A'] == 'Uninstall')85 if ($_GET['A'] == 'Uninstall') 86 86 { 87 87 $ModuleName = $this->System->ModuleManager->SearchModuleById($_GET['Id']); 88 if ($ModuleName != '')88 if ($ModuleName != '') 89 89 { 90 90 $this->System->ModuleManager->Modules[$ModuleName]->UnInstall(); … … 94 94 } 95 95 $Output .= $this->ShowList(); 96 return ($Output);96 return ($Output); 97 97 } 98 98 } … … 408 408 function IsInstalled() 409 409 { 410 if ($this->InstalledChecked == false)410 if ($this->InstalledChecked == false) 411 411 { 412 412 $DbResult = $this->Database->query('SELECT table_name FROM information_schema.tables 413 413 WHERE table_schema = "'.$this->Database->Database.'" AND table_name = "SystemVersion";'); 414 if ($DbResult->num_rows > 0) $this->Installed = true;414 if ($DbResult->num_rows > 0) $this->Installed = true; 415 415 else $this->Installed = false; 416 416 $this->InstalledChecked = true; 417 417 } 418 return ($this->Installed);418 return ($this->Installed); 419 419 } 420 420 421 421 function ModuleChange($Module) 422 422 { 423 //if ($this->IsInstalled())424 { 425 426 if ($Module->IsInstalled()) $Installed = 1;423 //if ($this->IsInstalled()) 424 { 425 426 if ($Module->IsInstalled()) $Installed = 1; 427 427 else $Installed = 0; 428 428 $this->Database->query('UPDATE `Module` SET `Installed`=1 WHERE `Name`="'.$Module->Name.'"'); … … 436 436 $Query = 'SELECT `Id`, `Name`,`Installed` FROM `Module`'; 437 437 $DbResult = $this->Database->query($Query); 438 while ($Module = $DbResult->fetch_array())438 while ($Module = $DbResult->fetch_array()) 439 439 { 440 440 //echo($Module['Name'].','); … … 453 453 $Modules = array(); 454 454 $DbResult = $this->Database->query('SELECT * FROM `Module`'); 455 while ($DbRow = $DbResult->fetch_assoc())455 while ($DbRow = $DbResult->fetch_assoc()) 456 456 { 457 457 $Modules[$DbRow['Name']] = $DbRow; 458 if ($this->System->ModuleManager->ModulePresent($DbRow['Name']))458 if ($this->System->ModuleManager->ModulePresent($DbRow['Name'])) 459 459 $this->System->ModuleManager->Modules[$DbRow['Name']]->Id = $DbRow['Id']; 460 460 } 461 461 462 462 // Add missing 463 foreach ($this->System->ModuleManager->Modules as $Module)464 { 465 if (!array_key_exists($Module->Name, $Modules))463 foreach ($this->System->ModuleManager->Modules as $Module) 464 { 465 if (!array_key_exists($Module->Name, $Modules)) 466 466 { 467 467 $this->Database->insert('Module', array('Name' => $Module->Name, … … 480 480 481 481 // Remove exceeding 482 foreach ($Modules as $Module)483 if (!$this->System->ModuleManager->ModulePresent($Module['Name']))482 foreach ($Modules as $Module) 483 if (!$this->System->ModuleManager->ModulePresent($Module['Name'])) 484 484 { 485 485 $Output .= 'Removing module '.$Module['Name'].' from list</br/>'; … … 487 487 $this->Database->query('DELETE FROM `ModuleLink` WHERE `LinkedModule` = '.$Module['Id']); 488 488 $DbResult = $this->Database->query('SELECT Id FROM `PermissionOperation` WHERE `Module` = '.$Module['Id']); 489 while ($DbRow = $DbResult->fetch_assoc())489 while ($DbRow = $DbResult->fetch_assoc()) 490 490 { 491 491 $this->Database->query('DELETE FROM `PermissionGroupAssignment` WHERE `AssignedOperation` = '.$DbRow['Id']); … … 495 495 $this->Database->query('DELETE FROM `Model` WHERE `Module` = '.$Module['Id']); 496 496 $DbResult = $this->Database->query('SELECT Id FROM `Model` WHERE `Module` = '.$Module['Id']); 497 while ($DbRow = $DbResult->fetch_assoc())497 while ($DbRow = $DbResult->fetch_assoc()) 498 498 $this->Database->query('DELETE FROM `ModelField` WHERE `Model` = '.$DbRow['Id']); 499 499 $this->Database->query('DELETE FROM `Module` WHERE `Id` = '.$Module['Id']); … … 503 503 $DbDependency = array(); 504 504 $DbResult = $this->Database->query('SELECT * FROM `ModuleLink`'); 505 while ($DbRow = $DbResult->fetch_assoc())505 while ($DbRow = $DbResult->fetch_assoc()) 506 506 $DbDependency[$DbRow['Module']][] = $DbRow['LinkedModule']; 507 507 508 foreach ($this->System->ModuleManager->Modules as $Module)508 foreach ($this->System->ModuleManager->Modules as $Module) 509 509 { 510 510 // Add missing 511 foreach ($Module->Dependencies as $Dependency)512 { 513 if (!array_key_exists($Module->Id, $DbDependency) or511 foreach ($Module->Dependencies as $Dependency) 512 { 513 if (!array_key_exists($Module->Id, $DbDependency) or 514 514 !in_array($this->System->ModuleManager->Modules[$Dependency]->Id, $DbDependency[$Module->Id])) 515 515 { 516 if (array_key_exists($Dependency, $this->System->ModuleManager->Modules))516 if (array_key_exists($Dependency, $this->System->ModuleManager->Modules)) 517 517 $DependencyId = $this->System->ModuleManager->Modules[$Dependency]->Id; 518 518 else throw new Exception('Dependent module '.$Dependency.' not found'); … … 523 523 524 524 // Remove exceeding 525 if (array_key_exists($Module->Id, $DbDependency))526 foreach ($DbDependency[$Module->Id] as $Dep)525 if (array_key_exists($Module->Id, $DbDependency)) 526 foreach ($DbDependency[$Module->Id] as $Dep) 527 527 { 528 528 $DepModName = $this->System->ModuleManager->SearchModuleById($Dep); 529 if (!in_array($DepModName, $Module->Dependencies))529 if (!in_array($DepModName, $Module->Dependencies)) 530 530 $this->Database->query('DELETE FROM `ModuleLink` WHERE `Module` = '. 531 531 $Module->Id.' AND LinkedModule='.$Dep); 532 532 } 533 533 } 534 return ($Output);534 return ($Output); 535 535 } 536 536 } -
trunk/Modules/TV/TV.php
r825 r873 11 11 function Show() 12 12 { 13 if (count($this->System->PathItems) > 1)13 if (count($this->System->PathItems) > 1) 14 14 { 15 if ($this->System->PathItems[1] == 'playlist.m3u') return($this->ShowPlayList());16 else return (PAGE_NOT_FOUND);17 } else return ($this->ShowChannelList());15 if ($this->System->PathItems[1] == 'playlist.m3u') return ($this->ShowPlayList()); 16 else return (PAGE_NOT_FOUND); 17 } else return ($this->ShowChannelList()); 18 18 } 19 19 … … 51 51 52 52 $DbResult = $this->Database->query($Query); 53 while ($Line = $DbResult->fetch_assoc())53 while ($Line = $DbResult->fetch_assoc()) 54 54 { 55 if ($Line['Stream'] <> '') $Line['Show'] = '<a href="playlist.m3u?id='.$Line['ShortName'].'">Naladit</a>';55 if ($Line['Stream'] <> '') $Line['Show'] = '<a href="playlist.m3u?id='.$Line['ShortName'].'">Naladit</a>'; 56 56 else 57 if ($Line['StreamWeb'] <> '') $Line['Show'] = '<a href="'.$Line['StreamWeb'].'">Naladit</a>';57 if ($Line['StreamWeb'] <> '') $Line['Show'] = '<a href="'.$Line['StreamWeb'].'">Naladit</a>'; 58 58 else $Line['Show'] = ' '; 59 59 … … 72 72 $Output .= 'Další online TV na webu: <a href="http://www.tvinfo.cz/live/televize/evropa/cz">TV info</a><br/>'; 73 73 74 return ($Output);74 return ($Output); 75 75 } 76 76 … … 83 83 84 84 echo('#EXTM3U'."\n"); 85 if (array_key_exists('id', $_GET))85 if (array_key_exists('id', $_GET)) 86 86 { 87 87 $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") AND (`ShortName`="'.addslashes($_GET['id']).'") '); 88 if ($DbResult->num_rows > 0)88 if ($DbResult->num_rows > 0) 89 89 { 90 90 $Channel = $DbResult->fetch_array(); … … 95 95 { 96 96 $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") ORDER BY `Name` '); 97 while ($Channel = $DbResult->fetch_array())97 while ($Channel = $DbResult->fetch_array()) 98 98 { 99 99 echo('#EXTINF:0,'.$Channel['Name']."\n"); -
trunk/Modules/TV/tkr.php
r738 r873 12 12 '<tr><th>Číslo</th<th>Jméno stanice</th><th>Frekvence [MHz]</th><th>Jazyk</th></tr>'; 13 13 $DbResult = $this->Database->select('TV', '*', ' 1 ORDER BY Id'); 14 while ($Row = $DbResult->fetch_array())14 while ($Row = $DbResult->fetch_array()) 15 15 { 16 16 $Output .= '<tr><td>'.$Row['Id'].'</td><td><a href="'.$Row['Homepage'].'">'.$Row['Name'].'</a></td><td align="right">'.($Row['Frequency'] / 1000).'</td><td>'.$Row['Language'].'</td></tr>'; 17 17 } 18 18 $Output .= '</table>Aktualizováno dne 17.12.2007<br></div>'; 19 return ($Output);19 return ($Output); 20 20 } 21 21 } -
trunk/Modules/TimeMeasure/Graph.php
r738 r873 20 20 { 21 21 $this->ClearPage = true; 22 return ($this->Render());22 return ($this->Render()); 23 23 } 24 24 … … 27 27 $PrefixMultiplier = new PrefixMultiplier(); 28 28 29 if (array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];29 if (array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug']; 30 30 else $Debug = 0; 31 31 32 if (!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku');32 if (!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku'); 33 33 $StartTime = addslashes($_GET['From']); 34 if (!array_key_exists('To', $_GET)) die('Musíte zadat čas konce');34 if (!array_key_exists('To', $_GET)) die('Musíte zadat čas konce'); 35 35 $EndTime = addslashes($_GET['To']); 36 if ($EndTime < $StartTime) $EndTime = $StartTime + 60;36 if ($EndTime < $StartTime) $EndTime = $StartTime + 60; 37 37 $TimeDifference = $EndTime - $StartTime; 38 if (!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');38 if (!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu'); 39 39 $MeasureId = addslashes($_GET['Measure']); 40 if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;40 if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth; 41 41 else $Width = addslashes($_GET['Width']); 42 if (!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;42 if (!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight; 43 43 else $Height = addslashes($_GET['Height']); 44 if (!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential'];44 if (!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential']; 45 45 else $Differential = addslashes($_GET['Differential']); 46 46 $VerticalLinesCount = round($Height / ($this->FontSize + 4)); … … 63 63 64 64 $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1; 65 if ($Level < 0) $Level = 0;66 if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;65 if ($Level < 0) $Level = 0; 66 if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel; 67 67 //$Level = 0; 68 68 69 69 $Points = $Measure->GetValues($StartTime, $EndTime, $Level); 70 70 71 if ($Debug) echo('Points count: '.count($Points).'<br/>');72 //if ($Debug) foreach($Points as $Index => $Item)71 if ($Debug) echo('Points count: '.count($Points).'<br/>'); 72 //if ($Debug) foreach ($Points as $Index => $Item) 73 73 // echo($Index.': '.$Item['min'].'<br>'); 74 74 … … 77 77 $AvgValue = 0; 78 78 $MinValue = 1000000000000000000; 79 foreach ($Points as $Index => $Item)79 foreach ($Points as $Index => $Item) 80 80 { 81 81 //$Points[$Index]['min'] = $Points[$Index]['min'] / $Measure['Divider']; 82 82 //$Points[$Index]['avg'] = $Points[$Index]['avg'] / $Measure['Divider']; 83 83 //$Points[$Index]['max'] = $Points[$Index]['max'] / $Measure['Divider']; 84 if ($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg'];85 if ($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg'];86 if ($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max'];87 if ($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min'];84 if ($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg']; 85 if ($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg']; 86 if ($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max']; 87 if ($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min']; 88 88 $AvgValue = $AvgValue + $Points[$Index]['Avg']; 89 89 } … … 96 96 $PointsAvg = array(0, $Height - 1); 97 97 $PointsMax = array(0, $Height - 1); 98 if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;98 if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1; 99 99 { 100 foreach ($Points as $Index => $Item)100 foreach ($Points as $Index => $Item) 101 101 { 102 102 $PointsMin[] = $Index * $Width / $Measure->DivisionCount; … … 128 128 129 129 // Generate image 130 if (!$Debug)130 if (!$Debug) 131 131 { 132 132 Header('Content-type: image/png'); … … 153 153 $TimeRange = $EndTime - $StartTime; 154 154 $TimeMarksIndex = 0; 155 while (($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) $TimeMarksIndex += 1;156 if ($TimeMarksIndex < 2) $TimeMarksIndex = 2;155 while (($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) $TimeMarksIndex += 1; 156 if ($TimeMarksIndex < 2) $TimeMarksIndex = 2; 157 157 $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1]; 158 158 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; … … 163 163 // Zobraz měřítko Y 164 164 $VerticalLinesDistance = $Height / $VerticalLinesCount; 165 for ($I = 1; $I <= $VerticalLinesCount; $I++)165 for ($I = 1; $I <= $VerticalLinesCount; $I++) 166 166 { 167 167 $Y = $Height - 1 - ($VerticalLinesDistance * $I); 168 for ($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);168 for ($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray); 169 169 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 170 170 } … … 174 174 // Zobraz měřítko X 175 175 $LastTextEnd = 0; 176 for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)176 for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks) 177 177 { 178 178 $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 179 179 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 180 if (($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift);180 if (($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift); 181 181 else $Text = date('j.n.Y G:i', $Time + $TimeShift); 182 182 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 183 if ($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))183 if ($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2)) 184 184 { 185 for ($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);185 for ($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray); 186 186 imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2, $Height - 2, $Black, $FontFile, $Text); 187 187 $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2; 188 188 } 189 else for ($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);189 else for ($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray); 190 190 } 191 191 192 192 // Popisky osy Y 193 for ($I = 1; $I <= $VerticalLinesCount; $I++)193 for ($I = 1; $I <= $VerticalLinesCount; $I++) 194 194 { 195 195 $Y = $Height - 1 - ($VerticalLinesDistance * $I); … … 199 199 $this->ValueToImageHeigthCoefficient * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3); 200 200 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 201 if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)201 if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) 202 202 imagettftext($Image, $FontSize, 0, 2, $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text); 203 203 } -
trunk/Modules/TimeMeasure/Main.php
r825 r873 62 62 // Day selection 63 63 $Output .= '<select name="Day">'; 64 for ($I = 1; $I < 32; $I++)65 { 66 if ($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = '';64 for ($I = 1; $I < 32; $I++) 65 { 66 if ($I == $TimeParts['mday']) $Selected = ' selected="1"'; else $Selected = ''; 67 67 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 68 68 } … … 71 71 // Month selection 72 72 $Output .= '<select name="Month">'; 73 foreach ($MonthNames as $Index => $Month)74 { 75 if ($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';76 if ($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>';73 foreach ($MonthNames as $Index => $Month) 74 { 75 if ($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = ''; 76 if ($Index > 0) $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$Month.'</option>'; 77 77 } 78 78 $Output .= '</select>. '; … … 80 80 // Day selection 81 81 $Output .= '<select name="Year">'; 82 for ($I = 2000; $I < 2010; $I++)83 { 84 if ($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = '';82 for ($I = 2000; $I < 2010; $I++) 83 { 84 if ($I == $TimeParts['year']) $Selected = ' selected="1"'; else $Selected = ''; 85 85 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 86 86 } … … 89 89 // Hour selection 90 90 $Output .= '<select name="Hour">'; 91 for ($I = 0; $I < 24; $I++)92 { 93 if ($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = '';91 for ($I = 0; $I < 24; $I++) 92 { 93 if ($I == $TimeParts['hours']) $Selected = ' selected="1"'; else $Selected = ''; 94 94 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 95 95 } … … 98 98 // Minute selection 99 99 $Output .= '<select name="Minute">'; 100 for ($I = 0; $I < 60; $I++)101 { 102 if ($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = '';100 for ($I = 0; $I < 60; $I++) 101 { 102 if ($I == $TimeParts['minutes']) $Selected = ' selected="1"'; else $Selected = ''; 103 103 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>'; 104 104 } … … 111 111 $Output .= '</form>'; 112 112 113 return ($Output);113 return ($Output); 114 114 } 115 115 … … 118 118 $Debug = 0; 119 119 120 foreach ($this->DefaultVariables as $Index => $Variable)121 { 122 if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;123 if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index];124 if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index];120 foreach ($this->DefaultVariables as $Index => $Variable) 121 { 122 if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable; 123 if (array_key_exists($Index, $_GET)) $_SESSION[$Index] = $_GET[$Index]; 124 if (array_key_exists($Index, $_POST)) $_SESSION[$Index] = $_POST[$Index]; 125 125 //$$Index = $_SESSION[$Index]; 126 126 } 127 127 128 if ($_SESSION['TimeSpecify'] == 0)128 if ($_SESSION['TimeSpecify'] == 0) 129 129 { 130 130 $_SESSION['TimeEnd'] = time() - 60; … … 134 134 $Output = '<div style="text-align: center;">'; 135 135 136 if (!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';137 switch ($_GET['Operation'])136 if (!array_key_exists('Operation', $_GET)) $_GET['Operation'] = ''; 137 switch ($_GET['Operation']) 138 138 { 139 139 case 'SetTime': 140 if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and140 if (array_key_exists('Time', $_GET) and array_key_exists('Month', $_POST) and array_key_exists('Day', $_POST) and 141 141 array_key_exists('Year', $_POST) and array_key_exists('Hour', $_POST) and array_key_exists('Minute', $_POST)) 142 142 { 143 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))143 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) 144 144 { 145 145 $_SESSION[$_GET['Time']] = mktime($_POST['Hour'], $_POST['Minute'], 0, $_POST['Month'], … … 150 150 break; 151 151 case 'SetTimeNow': 152 if (array_key_exists('Time', $_GET))152 if (array_key_exists('Time', $_GET)) 153 153 { 154 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd'))154 if (($_GET['Time'] == 'TimeStart') or ($_GET['Time'] == 'TimeEnd')) 155 155 { 156 156 $_SESSION[$_GET['Time']] = time(); … … 162 162 $Output .= '<strong>Časový úsek:</strong><br>'; 163 163 // Show graf time range menu 164 if ($_SESSION['TimeSpecify'] == 0)164 if ($_SESSION['TimeSpecify'] == 0) 165 165 { 166 166 $Output .= 'Délka úseku: '; 167 foreach ($this->GraphTimeRanges as $Index => $Item)167 foreach ($this->GraphTimeRanges as $Index => $Item) 168 168 $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a> '; 169 169 $Output .= '<br/>'; … … 179 179 180 180 $Output .= '<br/>'.$this->MeasureTable(); 181 return ($Output);181 return ($Output); 182 182 } 183 183 … … 191 191 $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&TimeStart='. 192 192 $_SESSION['TimeStart'].'&TimeEnd='.$_SESSION['TimeEnd'].'&TimeSpecify=1&Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>'; 193 return ($Output);193 return ($Output); 194 194 } 195 195 … … 212 212 array('Name' => 'Description', 'Title' => 'Popis'), 213 213 ); 214 if (array_key_exists('Debug', $_GET))214 if (array_key_exists('Debug', $_GET)) 215 215 { 216 216 $TableColumns[] = array('Name' => 'ItemCount', 'Title' => 'Počet položek'); … … 221 221 222 222 $Result = $this->Database->select('Measure', '*', '`Enabled`=1 '.$Order['SQL'].$PageList['SQLLimit']); 223 while ($Measure = $Result->fetch_array())223 while ($Measure = $Result->fetch_array()) 224 224 { 225 225 $DbResult2 = $this->Database->select('MeasureMethod', '*', '`Id`='.$Measure['Method']); 226 226 $MeasureMethod = $DbResult2->fetch_assoc(); 227 227 $StopWatchStart = GetMicrotime(); 228 if (array_key_exists('Debug', $_GET))228 if (array_key_exists('Debug', $_GET)) 229 229 { 230 230 $DbResult = $this->Database->select($Measure['DataTable'], 'COUNT(*)', 'Measure='.$Measure['Id']); … … 233 233 } 234 234 $Result2 = $this->Database->select($Measure['DataTable'], 'Time, Avg', 'Measure='.$Measure['Id'].' AND Level=0 ORDER BY Time DESC LIMIT 1'); 235 if ($Result2->num_rows > 0)235 if ($Result2->num_rows > 0) 236 236 { 237 237 $Row = $Result2->fetch_array(); … … 243 243 $LastMeasureValue = ' '; 244 244 } 245 if ($Measure['Continuity'] == 1) $Interpolate = 'Ano';245 if ($Measure['Continuity'] == 1) $Interpolate = 'Ano'; 246 246 else $Interpolate = 'Ne'; 247 //if ($Measure['Description'] == '') $Measure['Description'] = ' ';247 //if ($Measure['Description'] == '') $Measure['Description'] = ' '; 248 248 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 249 249 $Output .= '<tr><td><a href="?Measure='.$Measure['Id'].'&Differential=0">'.$Measure['Name'].'</a></td><td align="center">'.$LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.$Interpolate.'</td><td>'.$Measure['Description'].'</td>'; 250 if (array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';250 if (array_key_exists('Debug', $_GET)) $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>'; 251 251 $Output .= '</tr>'; 252 252 } … … 260 260 //echo($PrefixMultiplier->Add('-0.000000071112345', 'B')); 261 261 $Output .= '</div>'; 262 return ($Output);262 return ($Output); 263 263 } 264 264 } … … 271 271 272 272 $Output = ''; 273 if (!array_key_exists('MeasureId', $_GET)) return('Nebylo zadáno Id měření.');274 if (!array_key_exists('Value', $_GET)) return('Nebyla zadána hodnota.');273 if (!array_key_exists('MeasureId', $_GET)) return ('Nebylo zadáno Id měření.'); 274 if (!array_key_exists('Value', $_GET)) return ('Nebyla zadána hodnota.'); 275 275 $Measure = new Measure($this->System); 276 276 $Measure->Load($_GET['MeasureId']); 277 if (!isset($Measure->Data['Id'])) return('Měření s Id '.$_GET['MeasureId'].' nenalezeno.');277 if (!isset($Measure->Data['Id'])) return ('Měření s Id '.$_GET['MeasureId'].' nenalezeno.'); 278 278 $Measure->AddValue(array('Min' => $_GET['Value'], 'Avg' => $_GET['Value'], 'Max' => $_GET['Value'])); 279 return ($Output);279 return ($Output); 280 280 } 281 281 } -
trunk/Modules/TimeMeasure/Measure.php
r790 r873 15 15 { 16 16 $Result = $this->Database->select('Measure', '*', 'Id='.$Id); 17 if ($Result->num_rows > 0)17 if ($Result->num_rows > 0) 18 18 { 19 19 $this->Data = $Result->fetch_assoc(); 20 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous20 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous 21 21 else $this->Data['ContinuityEnabled'] = 2; // continuous graph 22 22 } else throw new Exception('Measure not found'); … … 25 25 function TimeSegment($Base, $Level) 26 26 { 27 return (pow($this->LevelReducing, $Level) * $Base);27 return (pow($this->LevelReducing, $Level) * $Base); 28 28 } 29 29 30 30 function StatTableName($Level) 31 31 { 32 if ($Level == 0) return('Data');33 else return ('DataCache');32 if ($Level == 0) return ('Data'); 33 else return ('DataCache'); 34 34 } 35 35 36 36 function AlignTime($Time, $TimeSegment) 37 37 { 38 return (round(($Time - $this->ReferenceTime) / $TimeSegment) * $TimeSegment + $this->ReferenceTime);38 return (round(($Time - $this->ReferenceTime) / $TimeSegment) * $TimeSegment + $this->ReferenceTime); 39 39 } 40 40 41 41 function AddValue($Value = array('Min' => 0, 'Avg' => 0, 'Max' => 0), $Level = 0, $Time = 0) 42 42 { 43 if ($Time == 0) $Time = time();43 if ($Time == 0) $Time = time(); 44 44 45 45 $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='. 46 46 $this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2'); 47 if ($Result->num_rows == 0)47 if ($Result->num_rows == 0) 48 48 { 49 49 $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 50 50 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 51 51 'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time), 'Continuity' => 0)); 52 } else if ($Result->num_rows == 1)52 } else if ($Result->num_rows == 1) 53 53 { 54 54 $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], … … 59 59 $LastValue = $Result->fetch_assoc(); 60 60 $NextToLastValue = $Result->fetch_assoc(); 61 if ((($Time - MysqlDateTimeToTime($LastValue['Time'])) < 0.75 * $this->Data['Period']) and ($Level == 0))61 if ((($Time - MysqlDateTimeToTime($LastValue['Time'])) < 0.75 * $this->Data['Period']) and ($Level == 0)) 62 62 { 63 63 echo('Too short period. Minimal period is '.(0.75 * $this->Data['Period'])." seconds\n"); 64 64 } else 65 65 { 66 if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1;66 if (($Time - MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1; 67 67 else $Continuity = 0; 68 if (($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] ==68 if (($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == 69 69 $Value['Min']) and ($LastValue['Avg'] == $NextToLastValue['Avg']) and 70 70 ($LastValue['Avg'] == $Value['Avg']) and ($LastValue['Max'] == $NextToLastValue['Max']) … … 82 82 83 83 // Update next level 84 if ($Level < $this->MaxLevel)84 if ($Level < $this->MaxLevel) 85 85 { 86 86 $Level = $Level + 1; 87 87 $TimeSegment = $this->TimeSegment($this->Data['Period'], 1); 88 88 $EndTime = $this->AlignTime($Time, $TimeSegment); 89 //if ($EndTime < $Time) $EndTime = $EndTime + $TimeSegment;89 //if ($EndTime < $Time) $EndTime = $EndTime + $TimeSegment; 90 90 $StartTime = $EndTime - $TimeSegment; 91 91 … … 96 96 TimeToMysqlDateTime($StartTime).'") AND (Time < "'.TimeToMysqlDateTime($EndTime). 97 97 '") AND (Measure='.$this->Data['Id'].') AND (Level='.($Level - 1).') ORDER BY Time'); 98 while ($Row = $Result->fetch_assoc())98 while ($Row = $Result->fetch_assoc()) 99 99 { 100 100 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 101 101 $Values[] = $Row; 102 102 } 103 //if (count($Values) > 2)103 //if (count($Values) > 2) 104 104 { 105 105 //array_pop($Values); … … 124 124 { 125 125 $Y = ($Y2 - $Y1) / ($X2 - $X1) * ($X - $X1) + $Y1; 126 return ($Y);126 return ($Y); 127 127 } 128 128 … … 132 132 133 133 // Trim outside parts 134 foreach ($this->ValueTypes as $ValueType)134 foreach ($this->ValueTypes as $ValueType) 135 135 { 136 136 $Values[0][$ValueType] = $this->Interpolation($Values[0]['Time'], $Values[0][$ValueType], $Values[1]['Time'], $Values[1][$ValueType], $LeftTime); 137 137 } 138 138 $Values[0]['Time'] = $LeftTime; 139 foreach ($this->ValueTypes as $ValueType)139 foreach ($this->ValueTypes as $ValueType) 140 140 { 141 141 $Values[count($Values) - 1][$ValueType] = $this->Interpolation($Values[count($Values) - 2]['Time'], $Values[count($Values) - 2][$ValueType], … … 145 145 146 146 // Perform computation 147 foreach ($this->ValueTypes as $ValueType)147 foreach ($this->ValueTypes as $ValueType) 148 148 { 149 149 // Compute new value 150 for ($I = 0; $I < (count($Values) - 1); $I++)151 { 152 if ($ValueType == 'Avg')153 { 154 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']);155 else if ($this->Differential == 0)150 for ($I = 0; $I < (count($Values) - 1); $I++) 151 { 152 if ($ValueType == 'Avg') 153 { 154 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']); 155 else if ($this->Differential == 0) 156 156 { 157 157 $NewValue[$ValueType] = $NewValue[$ValueType] + ($Values[$I + 1]['Time'] - $Values[$I]['Time']) * … … 163 163 } 164 164 } 165 else if ($ValueType == 'Max')166 { 167 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])168 { 169 if (0 > $NewValue[$ValueType]) $NewValue[$ValueType] = 0;165 else if ($ValueType == 'Max') 166 { 167 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']) 168 { 169 if (0 > $NewValue[$ValueType]) $NewValue[$ValueType] = 0; 170 170 } else 171 171 { 172 if ($this->Differential == 0)172 if ($this->Differential == 0) 173 173 { 174 if ($Values[$I + 1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];174 if ($Values[$I + 1][$ValueType] > $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType]; 175 175 } else { 176 176 $Difference = $Values[$I + 1][$ValueType] - $Values[$I][$ValueType]; 177 if ($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;177 if ($Difference > $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference; 178 178 } 179 179 } 180 180 } 181 else if ($ValueType == 'Min')182 { 183 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])184 { 185 if (0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0;181 else if ($ValueType == 'Min') 182 { 183 if ($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled']) 184 { 185 if (0 < $NewValue[$ValueType]) $NewValue[$ValueType] = 0; 186 186 } else 187 187 { 188 if ($this->Differential == 0)188 if ($this->Differential == 0) 189 189 { 190 if ($Values[$I + 1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType];190 if ($Values[$I + 1][$ValueType] < $NewValue[$ValueType]) $NewValue[$ValueType] = $Values[$I + 1][$ValueType]; 191 191 } else { 192 192 $Difference = $Values[$I + 1][$ValueType] - $Values[$I][$ValueType]; 193 if ($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference;193 if ($Difference < $NewValue[$ValueType]) $NewValue[$ValueType] = $Difference; 194 194 } 195 195 } … … 198 198 $NewValue[$ValueType] = $NewValue[$ValueType]; 199 199 } 200 //if (($RightTime - $LeftTime) > 0)201 if ($this->Data['Cumulative'] == 0)200 //if (($RightTime - $LeftTime) > 0) 201 if ($this->Data['Cumulative'] == 0) 202 202 { 203 203 $NewValue['Avg'] = $NewValue['Avg'] / ($RightTime - $LeftTime); 204 204 } 205 return ($NewValue);205 return ($NewValue); 206 206 } 207 207 … … 210 210 // Get first and last time 211 211 $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time LIMIT 1'); 212 if ($Result->num_rows > 0)212 if ($Result->num_rows > 0) 213 213 { 214 214 $Row = $Result->fetch_assoc(); … … 217 217 218 218 $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1'); 219 if ($Result->num_rows > 0)219 if ($Result->num_rows > 0) 220 220 { 221 221 $Row = $Result->fetch_assoc(); … … 223 223 } else $AbsoluteRightTime = 0; 224 224 225 if ($this->Debug)225 if ($this->Debug) 226 226 { 227 227 echo('AbsoluteLeftTime: '.$AbsoluteLeftTime.'('.TimeToMysqlDateTime($AbsoluteLeftTime).')<br>'); 228 228 echo('AbsoluteRightTime: '.$AbsoluteRightTime.'('.TimeToMysqlDateTime($AbsoluteRightTime).')<br>'); 229 229 } 230 return (array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime));230 return (array('Left' => $AbsoluteLeftTime, 'Right' => $AbsoluteRightTime)); 231 231 } 232 232 … … 235 235 $Result = array(); 236 236 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1'); 237 if ($DbResult->num_rows > 0)237 if ($DbResult->num_rows > 0) 238 238 { 239 239 $Row = $DbResult->fetch_assoc(); 240 240 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 241 return (array($Row));241 return (array($Row)); 242 242 } else 243 243 { … … 247 247 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time < "'. 248 248 TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1'); 249 if ($DbResult->num_rows > 0)249 if ($DbResult->num_rows > 0) 250 250 { 251 251 $Row = $DbResult->fetch_assoc(); 252 252 array_unshift($Result, array('Time' => (MysqlDateTimeToTime($Row['Time']) + 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 253 253 } 254 // if ($Debug) print_r($Result);255 return ($Result);254 // if ($Debug) print_r($Result); 255 return ($Result); 256 256 } 257 257 } … … 262 262 $DbResult = $this->Database->select($this->Data['DataTable'], '*', '(Time < "'. 263 263 TimeToMysqlDateTime($Time).'") AND (Measure='.$this->Data['Id'].') AND (Level='.$Level.') ORDER BY Time DESC LIMIT 1'); 264 if ($DbResult->num_rows > 0)264 if ($DbResult->num_rows > 0) 265 265 { 266 266 $Row = $DbResult->fetch_assoc(); 267 267 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); 268 return (array($Row));268 return (array($Row)); 269 269 } else 270 270 { 271 271 //$Time = $Values[0]['Time'] - 60; 272 272 //array_unshift($Values, array('Time' => $Time, 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 273 if ($this->Debug) echo($this->TimeSegment($this->Data['Period'], $Level));273 if ($this->Debug) echo($this->TimeSegment($this->Data['Period'], $Level)); 274 274 $Result[] = array('Time' => ($Time - $this->TimeSegment($this->Data['Period'], $Level)), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0); 275 275 276 276 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time ASC LIMIT 1'); 277 if ($DbResult->num_rows > 0)277 if ($DbResult->num_rows > 0) 278 278 { 279 279 $Row = $DbResult->fetch_assoc(); 280 280 array_push($Result, array('Time' => (MysqlDateTimeToTime($Row['Time']) - 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0)); 281 281 } 282 return ($Result);282 return ($Result); 283 283 } 284 284 } … … 286 286 function GetValues($TimeFrom, $TimeTo, $Level) 287 287 { 288 if ($this->Debug) echo('TimeFrom: '.$TimeFrom.'('.TimeToMysqlDateTime($TimeFrom).')<br>');289 if ($this->Debug) echo('TimeTo: '.$TimeTo.'('.TimeToMysqlDateTime($TimeTo).')<br>');288 if ($this->Debug) echo('TimeFrom: '.$TimeFrom.'('.TimeToMysqlDateTime($TimeFrom).')<br>'); 289 if ($this->Debug) echo('TimeTo: '.$TimeTo.'('.TimeToMysqlDateTime($TimeTo).')<br>'); 290 290 291 291 //$AbsoluteTime = GetTimeRange($MeasureId); 292 292 293 // if (($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and293 // if (($TimeFrom > $AbsoluteLeftTime) and ($TimeStart < $AbsoluteRightTime) and 294 294 // ($TimeTo > $AbsoluteLeftTime) and ($TimeTo < $AbsoluteRightTime)) 295 295 // { … … 304 304 // echo(DB_NumRows()); 305 305 // $III = 0; 306 while ($Row = $Result->fetch_assoc())306 while ($Row = $Result->fetch_assoc()) 307 307 { 308 308 // echo($III.' '.$Row['Time'].' '.memory_get_usage().','); … … 314 314 // echo('abc'); 315 315 // die(); 316 if ($this->Debug) echo('Item count: '.count($Values));316 if ($this->Debug) echo('Item count: '.count($Values)); 317 317 318 318 $Points = array(); 319 if (count($Values) > 0)319 if (count($Values) > 0) 320 320 { 321 321 $Values = array_merge($this->LoadLeftSideValue($Level, $TimeFrom), $Values, $this->LoadRightSideValue($Level, $TimeTo)); 322 322 $StartIndex = 0; 323 323 $Points = array(); 324 if ($this->Debug) print_r($Values);325 for ($I = 0; $I < $this->DivisionCount; $I++)324 if ($this->Debug) print_r($Values); 325 for ($I = 0; $I < $this->DivisionCount; $I++) 326 326 { 327 327 $TimeStart = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * $I; 328 328 $TimeEnd = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * ($I + 1); 329 if ($this->Debug) echo('TimeEnd '.$I.': '.$TimeEnd.'('.TimeToMysqlDateTime($TimeEnd).')<br>');329 if ($this->Debug) echo('TimeEnd '.$I.': '.$TimeEnd.'('.TimeToMysqlDateTime($TimeEnd).')<br>'); 330 330 331 331 $EndIndex = $StartIndex; 332 while (($Values[$EndIndex]['Time'] < $TimeEnd) and ($EndIndex < count($Values))) $EndIndex = $EndIndex + 1;333 //while (($Values[$EndIndex]['Time'] < $TimeEnd)) $EndIndex = $EndIndex + 1;332 while (($Values[$EndIndex]['Time'] < $TimeEnd) and ($EndIndex < count($Values))) $EndIndex = $EndIndex + 1; 333 //while (($Values[$EndIndex]['Time'] < $TimeEnd)) $EndIndex = $EndIndex + 1; 334 334 $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1); 335 335 $Points[] = $this->ComputeOneValue($TimeStart, $TimeEnd, $SubValues, $Level); 336 336 $StartIndex = $EndIndex - 1; 337 337 } 338 if ($this->Debug) print_r($Points);338 if ($this->Debug) print_r($Points); 339 339 } else $Points[] = array('Min' => 0, 'Avg' => 0, 'Max' => 0); 340 return ($Points);340 return ($Points); 341 341 } 342 342 … … 344 344 { 345 345 echo('Veličina '.$this->Data['Name']."<br>\n"); 346 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous346 if ($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0; // non continuous 347 347 else $this->Data['ContinuityEnabled'] = 2; // continuous graph 348 348 … … 354 354 echo("<br>\n"); 355 355 356 for ($Level = 1; $Level <= $this->MaxLevel; $Level++)356 for ($Level = 1; $Level <= $this->MaxLevel; $Level++) 357 357 { 358 358 echo('Uroven '.$Level."<br>\n"); … … 363 363 $BurstCount = 500; 364 364 echo('For 0 to '.round(($EndTime - $StartTime) / $TimeSegment / $BurstCount)."<br>\n"); 365 for ($I = 0; $I <= round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); $I++)365 for ($I = 0; $I <= round(($EndTime - $StartTime) / $TimeSegment / $BurstCount); $I++) 366 366 { 367 367 echo($I.' '); … … 371 371 $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'. 372 372 TimeToMysqlDateTime($StartTime2).'" AND Time < "'.TimeToMysqlDateTime($EndTime2).'" AND Measure='.$this->Data['Id'].' AND Level='.($Level - 1).' ORDER BY Time'); 373 while ($Row = $DbResult->fetch_assoc())373 while ($Row = $DbResult->fetch_assoc()) 374 374 { 375 375 $Row['Time'] = MysqlDateTimeToTime($Row['Time']); … … 377 377 } 378 378 379 if (count($Values) > 0)379 if (count($Values) > 0) 380 380 { 381 381 $Values = array_merge($this->LoadLeftSideValue($Level - 1, $StartTime2), … … 383 383 384 384 $StartIndex = 0; 385 for ($B = 0; $B < $BurstCount; $B++)385 for ($B = 0; $B < $BurstCount; $B++) 386 386 { 387 387 echo('.'); … … 390 390 391 391 $EndIndex = $StartIndex; 392 while ($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1;392 while ($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1; 393 393 $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1); 394 if (count($SubValues) > 2)394 if (count($SubValues) > 2) 395 395 { 396 396 $Point = $this->ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Level); … … 420 420 $Measures = array(); 421 421 $Result = $Database->select('Measure', '*'); 422 while ($Row = $Result->fetch_assoc())422 while ($Row = $Result->fetch_assoc()) 423 423 { 424 424 $Measures = new Measure(); … … 426 426 } 427 427 428 foreach ($Measures as $Measure)428 foreach ($Measures as $Measure) 429 429 { 430 430 $Measure->RebuildMeasureCache(); -
trunk/Modules/TimeMeasure/Measurement/MeasureClient.php
r738 r873 8 8 { 9 9 $DbResult = $this->Database->select('MeasureClient', '*'); 10 while ($MeasureClient = $DbResult->fetch_assoc())10 while ($MeasureClient = $DbResult->fetch_assoc()) 11 11 { 12 12 $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$MeasureClient['Method']); … … 15 15 include_once(dirname(__FILE__).'/'.$MeasureMethod['MeasureClass'].'.php'); 16 16 $MeasureMethod['MeasureClass'] .= 'Measurement'; 17 if (class_exists($MeasureMethod['MeasureClass']))17 if (class_exists($MeasureMethod['MeasureClass'])) 18 18 { 19 19 $MeasureClass = new $MeasureMethod['MeasureClass']($this->System); 20 if (method_exists($MeasureClass, $MeasureMethod['Method']))20 if (method_exists($MeasureClass, $MeasureMethod['Method'])) 21 21 { 22 if ($MeasureClient['Parameter'] != '') $Value = $Measure->$MeasureMethod['Method']($MeasureClient['Parameter']);22 if ($MeasureClient['Parameter'] != '') $Value = $Measure->$MeasureMethod['Method']($MeasureClient['Parameter']); 23 23 else $Value = $MeasureClass->$MeasureMethod['Method'](); 24 24 echo(file_get_contents('http://'.$MeasureClient['Host'].$MeasureClient['Path'].'/?M=Add&MeasureId='.$MeasureClient['MeasureId'].'&Value='.addslashes($Value))); -
trunk/Modules/TimeMeasure/Measurement/System.php
r660 r873 11 11 set_error_handler('ErrorHandler'); 12 12 //error_reporting(0); 13 if ($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout))13 if ($Fp1 = fsockopen($Ip, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout)) 14 14 { 15 15 fclose($Fp1); 16 return (TRUE);16 return (TRUE); 17 17 } else 18 18 { 19 19 //echo($ERROR_NO.','.$ERROR_STR); 20 return (FALSE);20 return (FALSE); 21 21 } 22 22 restore_error_handler(); … … 30 30 // c - ping count 31 31 $Parts = explode(' ', $Row[0]); 32 if (count($Parts) > 6)32 if (count($Parts) > 6) 33 33 { 34 34 $Time = $Parts[7]; 35 35 $TimeParts = explode('=', $Time); 36 return ($TimeParts[1]);37 } else return (0);36 return ($TimeParts[1]); 37 } else return (0); 38 38 } 39 39 … … 43 43 exec('free -b', $Output); 44 44 $Row = $Output[2]; 45 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row);45 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); 46 46 $RowParts = explode(' ', $Row); 47 47 $Row = $Output[3]; 48 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row);48 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); 49 49 $RowParts2 = explode(' ', $Row); 50 return ($RowParts[2] + $RowParts2[2]);50 return ($RowParts[2] + $RowParts2[2]); 51 51 } 52 52 … … 81 81 } 82 82 file_put_contents($CpuStateFileName, serialize($CpuUsage)); 83 return (100 - round($CpuUsagePercent['Idle'], 2));83 return (100 - round($CpuUsagePercent['Idle'], 2)); 84 84 } 85 85 … … 93 93 array_shift($Output); // Skip header 94 94 array_shift($Output); // Skip header 95 foreach ($Output as $Item)95 foreach ($Output as $Item) 96 96 { 97 while (strpos($Item, ' ') !== false) $Item = str_replace(' ', ' ', $Item); // Rrmove multiple spaces97 while (strpos($Item, ' ') !== false) $Item = str_replace(' ', ' ', $Item); // Rrmove multiple spaces 98 98 $Item = explode(':', $Item); 99 99 $Interface = trim($Item[0]); 100 100 $Item = explode(' ', trim($Item[1])); 101 101 $NetworkState[$Interface] = array('Down' => $Item[0], 'Up' => $Item[8]); 102 if (array_key_exists($Interface, $LastNetworkState))102 if (array_key_exists($Interface, $LastNetworkState)) 103 103 { 104 104 $Period = time() - $LastNetworkState['Time']; … … 110 110 $NetworkState[$Interface]['UpAverage'] = 0; 111 111 } 112 if ($NetworkState[$Interface]['DownAverage'] < 0) $NetworkState[$Interface]['DownAverage'] = 0;113 if ($NetworkState[$Interface]['UpAverage'] < 0) $NetworkState[$Interface]['UpAverage'] = 0;112 if ($NetworkState[$Interface]['DownAverage'] < 0) $NetworkState[$Interface]['DownAverage'] = 0; 113 if ($NetworkState[$Interface]['UpAverage'] < 0) $NetworkState[$Interface]['UpAverage'] = 0; 114 114 } 115 115 file_put_contents($NetworkStateFile, serialize($NetworkState)); 116 return ($NetworkState);116 return ($NetworkState); 117 117 } 118 118 … … 120 120 { 121 121 $NetworkState = $this->GetNetworkState(); 122 return ($NetworkState['Interface']['DownAverage']);122 return ($NetworkState['Interface']['DownAverage']); 123 123 } 124 124 … … 126 126 { 127 127 $NetworkState = $this->GetNetworkState(); 128 return ($NetworkState['Interface']['UpAverage']);128 return ($NetworkState['Interface']['UpAverage']); 129 129 } 130 130 … … 134 134 $Output = array(); 135 135 exec('cat /proc/net/nf_conntrack|grep "dst='.$HostIP.' "|grep "dport='.$Port.' "|grep "ASSURED"', $Output); 136 return (count($Output));136 return (count($Output)); 137 137 } 138 138 … … 142 142 exec('iostat -d '.$Device.' -x -m 2 2', $Output); // 2 second measure delay 143 143 $Row = $Output[6]; 144 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row);144 while (strpos($Row, ' ') !== false) $Row = str_replace(' ', ' ', $Row); 145 145 $Parts = explode(' ', $Row); 146 146 $Value = str_replace(',', '.', $Parts[11]); 147 return ($Value);147 return ($Value); 148 148 } 149 149 150 150 function DiskFree($Path) 151 151 { 152 return (disk_free_space($Path));152 return (disk_free_space($Path)); 153 153 } 154 154 … … 157 157 $Output = array(); 158 158 exec('/usr/bin/sensors', $Output); 159 foreach ($Output as $Line)159 foreach ($Output as $Line) 160 160 { 161 if (substr($Line, 0, strlen($Sensor)) == $Sensor)161 if (substr($Line, 0, strlen($Sensor)) == $Sensor) 162 162 { 163 163 $Line = substr($Line, strpos($Line, '+') + 1); 164 164 $Line = substr($Line, 0, strpos($Line, '°')); 165 return ($Line);165 return ($Line); 166 166 } 167 167 } 168 return (0);168 return (0); 169 169 } 170 170 … … 175 175 fclose($File); 176 176 $UptimeParts = explode(' ', $Uptime); 177 return ($UptimeParts[0]);177 return ($UptimeParts[0]); 178 178 } 179 179 } -
trunk/Modules/TimeMeasure/Measurement/WoW.php
r738 r873 12 12 $DbResult = $Database->query('SELECT COUNT(*) FROM account WHERE online=1'); 13 13 $Row = $DbResult->fetch_array(); 14 return ($Row[0]);14 return ($Row[0]); 15 15 } 16 16 … … 20 20 $DbResult = $Database->query('SELECT COUNT(*) FROM account WHERE online=1 AND gmlevel > 0'); 21 21 $Row = $DbResult->fetch_array(); 22 return ($Row[0]);22 return ($Row[0]); 23 23 } 24 24 … … 28 28 $DbResult = $Database->query('SELECT COUNT(*) FROM account'); 29 29 $Row = $DbResult->fetch_array(); 30 return ($Row[0]);30 return ($Row[0]); 31 31 } 32 32 … … 36 36 $DbResult = $Database->query('SELECT COUNT(*) FROM guild'); 37 37 $Row = $DbResult->fetch_array(); 38 return ($Row[0]);38 return ($Row[0]); 39 39 } 40 40 … … 44 44 $DbResult = $Database->query('SELECT COUNT(*) FROM `characters`'); 45 45 $Row = $DbResult->fetch_array(); 46 return ($Row[0]);46 return ($Row[0]); 47 47 } 48 48 … … 52 52 $DbResult = $Database->query('SELECT COUNT(*) FROM uptime'); 53 53 $Row = $DbResult->fetch_array(); 54 return ($Row[0]);54 return ($Row[0]); 55 55 } 56 56 57 57 function WoWEmulatorAvailability() 58 58 { 59 if (CheckPortStatus('localhost', 8085)) return(100); else return(0);59 if (CheckPortStatus('localhost', 8085)) return (100); else return (0); 60 60 } 61 61 … … 69 69 $Row = $DbResult->fetch_array(); 70 70 $Value = $Row[0]; 71 return ($Value);71 return ($Value); 72 72 } 73 73 } -
trunk/Modules/User/User.php
r858 r873 122 122 /* 123 123 124 if ($this->InstalledVersion == '1.0') {124 if ($this->InstalledVersion == '1.0') { 125 125 $this->System->Database->Query('SELECT * FROM User WHERE Id=1'); 126 126 $this->InstalledVersion = '1.1'; … … 132 132 { 133 133 $this->System->User = new User($this->System); 134 if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check();134 if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check(); 135 135 $this->System->RegisterPage('userlist', 'PageUserList'); 136 136 $this->System->RegisterPage('user', 'PageUser'); … … 290 290 function TopBarCallback() 291 291 { 292 if ($this->System->User->User['Id'] == null)292 if ($this->System->User->User['Id'] == null) 293 293 { 294 294 $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '. … … 301 301 // <a href="'.$this->System->Link('/?Action=UserOptions').'">Nastavení</a>'; 302 302 } 303 return ($Output);303 return ($Output); 304 304 } 305 305 } -
trunk/Modules/User/UserList.php
r833 r873 9 9 function Show() 10 10 { 11 if (!$this->System->User->CheckPermission('User', 'ShowList'))12 return ('Nemáte oprávnění');11 if (!$this->System->User->CheckPermission('User', 'ShowList')) 12 return ('Nemáte oprávnění'); 13 13 14 14 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `User`'); … … 30 30 31 31 $DbResult = $this->Database->query($Query); 32 while ($User = $DbResult->fetch_assoc())32 while ($User = $DbResult->fetch_assoc()) 33 33 { 34 34 $Devices = array(); 35 35 $DbResult2 = $this->Database->query('SELECT `Id` FROM `Member` WHERE `Member`.`ResponsibleUser` = '.$User['Id']); 36 while ($Member = $DbResult2->fetch_assoc())36 while ($Member = $DbResult2->fetch_assoc()) 37 37 { 38 38 $DbResult3 = $this->Database->query('SELECT `Name`, `Id` FROM `NetworkDevice` '. 39 39 'WHERE `Member` = '.$Member['Id'].' AND `Used`=1 ORDER BY `Name`'); 40 while ($Device = $DbResult3->fetch_assoc())40 while ($Device = $DbResult3->fetch_assoc()) 41 41 { 42 42 $Devices[] = $Device['Name']; … … 52 52 $Output .= $PageList['Output']; 53 53 54 return ($Output);54 return ($Output); 55 55 } 56 56 } -
trunk/Modules/User/UserModel.php
r828 r873 30 30 function Hash($Password, $Salt) 31 31 { 32 return (sha1(sha1($Password).$Salt));32 return (sha1(sha1($Password).$Salt)); 33 33 } 34 34 35 35 function Verify($Password, $Salt, $StoredHash) 36 36 { 37 return ($this->Hash($Password, $Salt) == $StoredHash);37 return ($this->Hash($Password, $Salt) == $StoredHash); 38 38 } 39 39 … … 71 71 // Lookup user record 72 72 $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"'); 73 if ($Query->num_rows > 0)73 if ($Query->num_rows > 0) 74 74 { 75 75 // Refresh time of last access … … 81 81 82 82 // Logged permanently? 83 if (array_key_exists('LoginHash', $_COOKIE))83 if (array_key_exists('LoginHash', $_COOKIE)) 84 84 { 85 85 $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId']. 86 86 ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"'); 87 if ($DbResult->num_rows > 0)87 if ($DbResult->num_rows > 0) 88 88 { 89 89 $DbRow = $DbResult->fetch_assoc(); 90 if (sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash'])90 if (sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash']) 91 91 { 92 92 $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"'); … … 99 99 $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"'); 100 100 $Row = $Query->fetch_assoc(); 101 if ($Row['User'] != '')101 if ($Row['User'] != '') 102 102 { 103 103 $Query = $this->Database->query('SELECT `User`.*, `UserCustomerRel`.`Customer` AS `Member` FROM `User` '. … … 114 114 // Remove nonactive users 115 115 $DbResult = $this->Database->select('UserOnline', '`Id`, `User`', '(`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.$this->OnlineStateTimeout.' SECOND)) AND (`StayLogged` = 0)'); 116 while ($DbRow = $DbResult->fetch_array())116 while ($DbRow = $DbResult->fetch_array()) 117 117 { 118 118 $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']); 119 if ($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');119 if ($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout'); 120 120 } 121 121 //$this->LoadPermission($this->User['Role']); … … 127 127 function Register($Login, $Password, $Password2, $Email, $Name) 128 128 { 129 if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '') || ($Name == '')) $Result = DATA_MISSING;130 else if ($Password != $Password2) $Result = PASSWORDS_UNMATCHED;129 if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '') || ($Name == '')) $Result = DATA_MISSING; 130 else if ($Password != $Password2) $Result = PASSWORDS_UNMATCHED; 131 131 else 132 132 { 133 133 // Is user registred yet? 134 134 $Query = $this->Database->select('User', '*', 'Login = "'.$Login.'"'); 135 if ($Query->num_rows > 0) $Result = LOGIN_USED;135 if ($Query->num_rows > 0) $Result = LOGIN_USED; 136 136 else 137 137 { 138 138 $Query = $this->Database->select('User', '*', 'Name = "'.$Name.'"'); 139 if ($Query->num_rows > 0) $Result = NAME_USED;139 if ($Query->num_rows > 0) $Result = NAME_USED; 140 140 else 141 141 { 142 142 $Query = $this->Database->select('User', '*', 'Email = "'.$Email.'"'); 143 if ($Query->num_rows > 0) $Result = EMAIL_USED;143 if ($Query->num_rows > 0) $Result = EMAIL_USED; 144 144 else 145 145 { … … 177 177 } 178 178 } 179 return ($Result);179 return ($Result); 180 180 } 181 181 … … 183 183 { 184 184 $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id); 185 if ($DbResult->num_rows > 0)185 if ($DbResult->num_rows > 0) 186 186 { 187 187 $Row = $DbResult->fetch_array(); 188 188 $NewPassword = substr(sha1(strtoupper($Row['Login'])), 0, 7); 189 if ($Hash == $NewPassword)189 if ($Hash == $NewPassword) 190 190 { 191 191 $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0)); … … 195 195 } else $Output = PASSWORDS_UNMATCHED; 196 196 } else $Output = USER_NOT_FOUND; 197 return ($Output);197 return ($Output); 198 198 } 199 199 200 200 function Login($Login, $Password, $StayLogged = false) 201 201 { 202 if ($StayLogged) $StayLogged = 1; else $StayLogged = 0;202 if ($StayLogged) $StayLogged = 1; else $StayLogged = 0; 203 203 $SID = session_id(); 204 204 $Query = $this->Database->select('User', '*', 'Login="'.$Login.'"'); 205 if ($Query->num_rows > 0)205 if ($Query->num_rows > 0) 206 206 { 207 207 $Row = $Query->fetch_assoc(); 208 208 $PasswordHash = new PasswordHash(); 209 if (!$PasswordHash->Verify($Password, $Row['Salt'], $Row['Password'])) $Result = BAD_PASSWORD;210 else if ($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED;209 if (!$PasswordHash->Verify($Password, $Row['Salt'], $Row['Password'])) $Result = BAD_PASSWORD; 210 else if ($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED; 211 211 else 212 212 { … … 217 217 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array( 218 218 'User' => $Row['Id'], 'StayLogged' => $StayLogged, 'StayLoggedHash' => $StayLoggedSalt)); 219 if ($StayLogged)219 if ($StayLogged) 220 220 { 221 221 setcookie('LoginUserId', $Row['Id'], time()+365*24*60*60, $this->System->Link('/')); … … 231 231 } 232 232 } else $Result = USER_NOT_REGISTRED; 233 return ($Result);233 return ($Result); 234 234 } 235 235 … … 240 240 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']); 241 241 $this->Check(); 242 return (USER_LOGGED_OUT);242 return (USER_LOGGED_OUT); 243 243 } 244 244 … … 247 247 $this->Roles = array(); 248 248 $DbResult = $this->Database->select('UserRole', '*'); 249 while ($DbRow = $DbResult->fetch_array())249 while ($DbRow = $DbResult->fetch_array()) 250 250 $this->Roles[] = $DbRow; 251 251 } … … 255 255 $this->User['Permission'] = array(); 256 256 $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description` FROM `UserRolePermission` JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` WHERE `UserRolePermission`.`Role` = '.$Role); 257 if ($DbResult->num_rows > 0)258 while ($DbRow = $DbResult->fetch_array())257 if ($DbResult->num_rows > 0) 258 while ($DbRow = $DbResult->fetch_array()) 259 259 $this->User['Permission'][$DbRow['Operation']] = $DbRow; 260 260 } … … 264 264 $Result = array(); 265 265 $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description`, `UserRole`.`Title` FROM `UserRolePermission` LEFT JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` LEFT JOIN `UserRole` ON `UserRole`.`Id` = `UserRolePermission`.`Role`'); 266 while ($DbRow = $DbResult->fetch_array())266 while ($DbRow = $DbResult->fetch_array()) 267 267 { 268 268 $Value = ''; 269 if ($DbRow['Read']) $Value .= 'R';270 if ($DbRow['Write']) $Value .= 'W';269 if ($DbRow['Read']) $Value .= 'R'; 270 if ($DbRow['Write']) $Value .= 'W'; 271 271 $Result[$DbRow['Description']][$DbRow['Title']] = $Value; 272 272 } 273 return ($Result);273 return ($Result); 274 274 } 275 275 … … 278 278 $PermissionExists = false; 279 279 // First try to check cache group-group relation 280 if (array_key_exists($GroupId, $this->PermissionGroupCache))280 if (array_key_exists($GroupId, $this->PermissionGroupCache)) 281 281 { 282 282 $PermissionExists = true; … … 287 287 '") AND (`AssignedGroup` IS NOT NULL)'); 288 288 $DbRow = array(); 289 while ($DbRow[] = $DbResult->fetch_array());289 while ($DbRow[] = $DbResult->fetch_array()); 290 290 $this->PermissionGroupCache[$GroupId] = $DbRow; 291 291 $PermissionExists = true; 292 292 } 293 if ($PermissionExists)294 { 295 foreach ($this->PermissionGroupCache[$GroupId] as $DbRow)296 { 297 if ($DbRow['AssignedGroup'] != '')298 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);293 if ($PermissionExists) 294 { 295 foreach ($this->PermissionGroupCache[$GroupId] as $DbRow) 296 { 297 if ($DbRow['AssignedGroup'] != '') 298 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return (true); 299 299 } 300 300 } 301 301 302 302 // Check group-operation relation 303 if (array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp))303 if (array_key_exists($GroupId.','.$OperationId, $this->PermissionGroupCacheOp)) 304 304 { 305 305 $PermissionExists = true; … … 308 308 // If no permission combination exists in cache, do new check of database items 309 309 $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `AssignedOperation`="'.$OperationId.'"'); 310 if ($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true;310 if ($DbResult->num_rows > 0) $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = true; 311 311 else $this->PermissionGroupCacheOp[$GroupId.','.$OperationId] = false; 312 312 $PermissionExists = true; 313 313 } 314 if ($PermissionExists)315 { 316 return ($this->PermissionGroupCacheOp[$GroupId.','.$OperationId]);317 } 318 return (false);314 if ($PermissionExists) 315 { 316 return ($this->PermissionGroupCacheOp[$GroupId.','.$OperationId]); 317 } 318 return (false); 319 319 } 320 320 … … 323 323 // Get module id 324 324 $DbResult = $this->Database->select('Module', 'Id', '`Name`="'.$Module.'"'); 325 if ($DbResult->num_rows > 0)325 if ($DbResult->num_rows > 0) 326 326 { 327 327 $DbRow = $DbResult->fetch_assoc(); 328 328 $ModuleId = $DbRow['Id']; 329 } else return (false);329 } else return (false); 330 330 331 331 // First try to check cache 332 if (in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache))332 if (in_array(array($Module, $Operation, $ItemType, $ItemType), $this->PermissionCache)) 333 333 { 334 334 $OperationId = array_search(array($Module, $Operation, $ItemType, $ItemIndex), $this->PermissionCache); … … 339 339 $DbResult = $this->Database->select('PermissionOperation', 'Id', '(`Module`="'.$ModuleId. 340 340 '") AND (`Item`="'.$ItemType.'") AND (`ItemId`='.$ItemIndex.') AND (`Operation`="'.$Operation.'")'); 341 if ($DbResult->num_rows > 0)341 if ($DbResult->num_rows > 0) 342 342 { 343 343 $DbRow = $DbResult->fetch_array(); … … 352 352 } 353 353 354 if ($PermissionExists)355 { 356 if ($this->User['Id'] == null) $UserCondition = '(`User` IS NULL)';354 if ($PermissionExists) 355 { 356 if ($this->User['Id'] == null) $UserCondition = '(`User` IS NULL)'; 357 357 else $UserCondition = '(`User`="'.$this->User['Id'].'")'; 358 358 // Check user-operation relation 359 359 $DbResult = $this->Database->select('PermissionUserAssignment', '*', $UserCondition.' AND (`AssignedOperation`="'.$OperationId.'")'); 360 if ($DbResult->num_rows > 0) return(true);360 if ($DbResult->num_rows > 0) return (true); 361 361 362 362 // Check user-group relation 363 363 $DbResult = $this->Database->select('PermissionUserAssignment', 'AssignedGroup', $UserCondition); 364 while ($DbRow = $DbResult->fetch_array())365 { 366 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return(true);367 } 368 return (false);369 } else return (false);364 while ($DbRow = $DbResult->fetch_array()) 365 { 366 if ($this->CheckGroupPermission($DbRow['AssignedGroup'], $OperationId) == true) return (true); 367 } 368 return (false); 369 } else return (false); 370 370 } 371 371 … … 373 373 { 374 374 $DbResult = $this->Database->select('User', 'Login, Name, Id, Email, Password', '`Login`="'.$Login.'" AND `Email`="'.$Email.'"'); 375 if ($DbResult->num_rows > 0)375 if ($DbResult->num_rows > 0) 376 376 { 377 377 $Row = $DbResult->fetch_array(); … … 394 394 $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email); 395 395 } else $Output = USER_PASSWORD_RECOVERY_FAIL; 396 return ($Output);396 return ($Output); 397 397 } 398 398 … … 400 400 { 401 401 $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id); 402 if ($DbResult->num_rows > 0)402 if ($DbResult->num_rows > 0) 403 403 { 404 404 $Row = $DbResult->fetch_array(); 405 405 $NewPassword2 = substr(sha1(strtoupper($Row['Login'])), 0, 7); 406 if (($NewPassword == $NewPassword2) and ($Hash == $Row['Password']))406 if (($NewPassword == $NewPassword2) and ($Hash == $Row['Password'])) 407 407 { 408 408 $PasswordHash = new PasswordHash(); … … 414 414 } else $Output = PASSWORDS_UNMATCHED; 415 415 } else $Output = USER_NOT_FOUND; 416 return ($Output);416 return ($Output); 417 417 } 418 418 … … 420 420 { 421 421 $DbResult = $this->Database->select('APIToken', 'User', '`Token`="'.$Token.'"'); 422 if ($DbResult->num_rows > 0)422 if ($DbResult->num_rows > 0) 423 423 { 424 424 $DbRow = $DbResult->fetch_assoc(); 425 425 $User = new User($this->System); 426 426 $User->User = array('Id' => $DbRow['User']); 427 return ($User->CheckPermission($Module, $Operation));428 } else return (false);427 return ($User->CheckPermission($Module, $Operation)); 428 } else return (false); 429 429 } 430 430 } -
trunk/Modules/User/UserPage.php
r828 r873 9 9 function Panel($Title, $Content, $Menu = array()) 10 10 { 11 if (count($Menu) > 0)12 foreach ($Menu as $Item)11 if (count($Menu) > 0) 12 foreach ($Menu as $Item) 13 13 $Title .= '<div class="Action">'.$Item.'</div>'; 14 return ('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>');14 return ('<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>'); 15 15 } 16 16 … … 39 39 40 40 $DbResult = $this->Database->query($Query); 41 while ($Contact = $DbResult->fetch_assoc())41 while ($Contact = $DbResult->fetch_assoc()) 42 42 { 43 43 $Output .= '<tr>'. … … 50 50 $Output .= $PageList['Output']; 51 51 52 return ($Output);52 return ($Output); 53 53 } 54 54 … … 56 56 { 57 57 $Output = ''; 58 if ($this->System->User->User['Id'] != null)58 if ($this->System->User->User['Id'] != null) 59 59 { 60 60 $Actions = ''; 61 foreach ($this->System->ModuleManager->Modules['User']->UserPanel as $Action)62 { 63 if (is_string($Action[0]))61 foreach ($this->System->ModuleManager->Modules['User']->UserPanel as $Action) 62 { 63 if (is_string($Action[0])) 64 64 { 65 65 $Class = new $Action[0]($this->System); … … 71 71 $Output .= $this->Panel('Nabídka uživatele', $Actions); 72 72 $Output .= '</td><td style="vertical-align:top;">'; 73 if ($this->System->User->User['Id'] != null)73 if ($this->System->User->User['Id'] != null) 74 74 { 75 75 $Form = new Form($this->System->FormManager); … … 85 85 $Output .= '</td></tr></table></div>'; 86 86 } else $Output .= $this->SystemMessage('Oprávnění', 'Nejste přihlášen'); 87 return ($Output);87 return ($Output); 88 88 } 89 89 … … 91 91 { 92 92 $Output = ''; 93 if (array_key_exists('Action', $_GET))93 if (array_key_exists('Action', $_GET)) 94 94 { 95 95 $Action = $_GET['Action']; 96 if ($Action == 'LoginForm')96 if ($Action == 'LoginForm') 97 97 { 98 98 $Form = new Form($this->System->FormManager); … … 103 103 '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>'; 104 104 } else 105 if ($Action == 'Login')106 { 107 if (array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST))105 if ($Action == 'Login') 106 { 107 if (array_key_exists('Username', $_POST) and array_key_exists('Password', $_POST)) 108 108 { 109 109 $Form = new Form($this->System->FormManager); 110 110 $Form->SetClass('UserLogin'); 111 111 $Form->OnSubmit = '?Action=Login'; 112 if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true;112 if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true; 113 113 else $StayLogged = false; 114 114 $Result = $this->System->User->Login($_POST['Username'], $_POST['Password'], $StayLogged); 115 115 $Output .= $this->SystemMessage('Přihlášení', $Result); 116 if ($Result <> USER_LOGGED_IN)116 if ($Result <> USER_LOGGED_IN) 117 117 { 118 118 $Form->LoadValuesFromForm(); … … 128 128 } else $Output .= $this->SystemMessage('Přihlášení', 'Nezadány přihlašovací údaje'); 129 129 } else 130 if ($Action == 'Logout')131 { 132 if ($this->System->User->User['Id'] != null)130 if ($Action == 'Logout') 131 { 132 if ($this->System->User->User['Id'] != null) 133 133 { 134 134 $Output .= $this->SystemMessage('Odhlášení', $this->System->User->Logout()); 135 135 } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen'); 136 136 } else 137 if ($Action == 'UserOptions')138 { 139 if ($this->System->User->User['Id'] != null)137 if ($Action == 'UserOptions') 138 { 139 if ($this->System->User->User['Id'] != null) 140 140 { 141 141 $Form = new Form($this->System->FormManager); … … 146 146 } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen'); 147 147 } else 148 if ($Action == 'UserOptionsSave')148 if ($Action == 'UserOptionsSave') 149 149 { 150 150 $Form = new Form($this->System->FormManager); … … 158 158 $Output .= $Form->ShowEditForm(); 159 159 } else 160 if ($Action == 'UserRegister')160 if ($Action == 'UserRegister') 161 161 { 162 162 $Form = new Form($this->System->FormManager); … … 166 166 $Output .= $Form->ShowEditForm(); 167 167 } else 168 if ($Action == 'UserRegisterConfirm')168 if ($Action == 'UserRegisterConfirm') 169 169 { 170 170 $Output .= $this->SystemMessage('Potvrzení registrace', 171 171 $this->System->User->RegisterConfirm($_GET['User'], $_GET['H'])); 172 172 } else 173 if ($Action == 'PasswordRecovery')173 if ($Action == 'PasswordRecovery') 174 174 { 175 175 $Form = new Form($this->System->FormManager); … … 178 178 $Output .= $Form->ShowEditForm(); 179 179 } else 180 if ($Action == 'PasswordRecovery2')180 if ($Action == 'PasswordRecovery2') 181 181 { 182 182 $Form = new Form($this->System->FormManager); … … 185 185 $Result = $this->System->User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']); 186 186 $Output .= $this->SystemMessage('Obnova hesla', $Result); 187 if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS)187 if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS) 188 188 { 189 189 $Output .= $Form->ShowEditForm(); 190 190 } 191 191 } else 192 if ($Action == 'PasswordRecoveryConfirm')192 if ($Action == 'PasswordRecoveryConfirm') 193 193 { 194 194 $Output .= $this->SystemMessage('Obnova hesla', $this->System->User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P'])); 195 195 } else 196 if ($Action == 'UserRegisterSave')196 if ($Action == 'UserRegisterSave') 197 197 { 198 198 $Form = new Form($this->System->FormManager); … … 202 202 $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']); 203 203 $Output .= $this->SystemMessage('Registrace nového účtu', $Result); 204 if ($Result <> USER_REGISTRATED)204 if ($Result <> USER_REGISTRATED) 205 205 { 206 206 $Form->OnSubmit = '?Action=UserRegisterSave'; … … 208 208 } 209 209 } else 210 if ($Action == 'UserMenu')210 if ($Action == 'UserMenu') 211 211 { 212 212 $Output = $this->ShowUserPanel(); 213 213 } else $Output = $this->ShowMain(); 214 214 } else $Output = $this->ShowMain(); 215 return ($Output);215 return ($Output); 216 216 } 217 217 … … 219 219 { 220 220 $Output = 'Nebyla vybrána akce'; 221 return ($Output);221 return ($Output); 222 222 } 223 223 } -
trunk/Modules/WebCam/WebCam.php
r860 r873 9 9 function Show() 10 10 { 11 if (file_exists($this->System->ModuleManager->Modules['WebCam']->ImageFileName))11 if (file_exists($this->System->ModuleManager->Modules['WebCam']->ImageFileName)) 12 12 { 13 13 $Output = '<script language="JavaScript"> … … 38 38 '<a href="http://www.mestovsetin.cz/vismo/dokumenty2.asp?id_org=18676&id=480245">Webové kamery ve Vsetíně</a><br />'; 39 39 40 return ($Output);40 return ($Output); 41 41 } 42 42 } … … 72 72 $Output .= '<a href="//www.zdechov.net/kamery/?Id=3"><img alt="Skiareál, motokrosová grapa" width="140" height="79" src="//www.zdechov.net/images/webcam/webcam3.jpg" /></a>'; 73 73 $Output .= '<a href="//www.zdechov.net/kamery/?Id=4"><img alt="Fotbalové hřiště" width="140" height="79" src="//www.zdechov.net/images/webcam/webcam4.jpg" /></a>'; 74 return ($Output);74 return ($Output); 75 75 } 76 76 } -
trunk/Modules/WebCam/webcam_refresh.php
r738 r873 3 3 4 4 $Config['Web']['ShowPHPError'] = true; 5 while (1)5 while (1) 6 6 { 7 7 $ModifyTime = filemtime('webcam.jpg'); 8 if ((time() - $Config['Web']['WebcamRefresh']) >= $ModifyTime)8 if ((time() - $Config['Web']['WebcamRefresh']) >= $ModifyTime) 9 9 { 10 10 // $Output = shell_exec('wget "http://kamera-stred/Webcam.jpg?MobilePass='.$Config['Web']['WebcamPassword'].'&V=2&Q=2&B=2&U=0" -O webcam_cache.jpg -T '.($Config['Web']['WebcamRefresh']).' --limit-rate=200k'); 11 11 $Output = shell_exec('wget "http://kamera-knihovna/cgi-bin/viewer/video.jpg" -O webcam_cache.jpg -T '.($Config['Web']['WebcamRefresh']).' --limit-rate=200k'); 12 12 13 if ((strpos($Output, 'failed') === false) and (strpos($Output, 'error') === false))13 if ((strpos($Output, 'failed') === false) and (strpos($Output, 'error') === false)) 14 14 shell_exec('mv -f webcam_cache.jpg webcam.jpg'); 15 15 } -
trunk/Modules/Wiki/Wiki.php
r825 r873 60 60 { 61 61 $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1'); 62 while ($DbRow = $DbResult->fetch_assoc())62 while ($DbRow = $DbResult->fetch_assoc()) 63 63 { 64 64 $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki'); … … 82 82 function Show() 83 83 { 84 if (array_key_exists('Action', $_GET))85 { 86 if ($_GET['Action'] == 'Edit') $Output = $this->EditContent();87 else if ($_GET['Action'] == 'EditSave') $Output = $this->SaveContent();88 else if ($_GET['Action'] == 'History') $Output = $this->ShowHistory();84 if (array_key_exists('Action', $_GET)) 85 { 86 if ($_GET['Action'] == 'Edit') $Output = $this->EditContent(); 87 else if ($_GET['Action'] == 'EditSave') $Output = $this->SaveContent(); 88 else if ($_GET['Action'] == 'History') $Output = $this->ShowHistory(); 89 89 else $Output = $this->ShowContent(); 90 90 } else $Output = $this->ShowContent(); 91 return ($Output);91 return ($Output); 92 92 } 93 93 … … 96 96 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 97 97 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 98 if ($DbResult->num_rows > 0)98 if ($DbResult->num_rows > 0) 99 99 { 100 100 $DbRow = $DbResult->fetch_assoc(); 101 if (array_key_exists('ver', $_GET))101 if (array_key_exists('ver', $_GET)) 102 102 { 103 103 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' AND Id='.$_GET['ver']*1); 104 if ($DbResult2->num_rows > 0)104 if ($DbResult2->num_rows > 0) 105 105 { 106 106 $DbRow2 = $DbResult2->fetch_assoc(); 107 107 $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>'; 108 108 $Output .= $DbRow2['Content']; 109 if ($this->System->User->Licence(LICENCE_MODERATOR))109 if ($this->System->User->Licence(LICENCE_MODERATOR)) 110 110 $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>'; 111 111 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); … … 113 113 { 114 114 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 115 if ($DbResult2->num_rows > 0)115 if ($DbResult2->num_rows > 0) 116 116 { 117 117 $DbRow2 = $DbResult2->fetch_assoc(); 118 118 $Output = '<h3>'.$DbRow['Name'].'</h3>'; 119 119 $Output .= $DbRow2['Content']; 120 if ($this->System->User->Licence(LICENCE_MODERATOR))120 if ($this->System->User->Licence(LICENCE_MODERATOR)) 121 121 $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>'; 122 122 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 123 123 } 124 124 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 125 return ($Output);125 return ($Output); 126 126 } 127 127 128 128 function EditContent() 129 129 { 130 if ($this->System->User->Licence(LICENCE_MODERATOR))130 if ($this->System->User->Licence(LICENCE_MODERATOR)) 131 131 { 132 132 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 133 133 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 134 if ($DbResult->num_rows > 0)134 if ($DbResult->num_rows > 0) 135 135 { 136 136 $DbRow = $DbResult->fetch_assoc(); 137 137 $Output = '<h3>Úprava '.$DbRow['Name'].'</h3>'; 138 138 $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1'); 139 if ($DbResult2->num_rows > 0)139 if ($DbResult2->num_rows > 0) 140 140 { 141 141 $DbRow2 = $DbResult2->fetch_assoc(); … … 148 148 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 149 149 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 150 return ($Output);150 return ($Output); 151 151 } 152 152 153 153 function SaveContent() 154 154 { 155 if ($this->System->User->Licence(LICENCE_MODERATOR))155 if ($this->System->User->Licence(LICENCE_MODERATOR)) 156 156 { 157 157 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 158 158 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 159 if ($DbResult->num_rows > 0)159 if ($DbResult->num_rows > 0) 160 160 { 161 161 $DbRow = $DbResult->fetch_assoc(); 162 if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST))162 if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST)) 163 163 { 164 164 $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']), … … 169 169 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 170 170 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 171 return ($Output);171 return ($Output); 172 172 } 173 173 174 174 function ShowHistory() 175 175 { 176 if ($this->System->User->Licence(LICENCE_MODERATOR))176 if ($this->System->User->Licence(LICENCE_MODERATOR)) 177 177 { 178 178 $PageName = $this->System->PathItems[count($this->System->PathItems) - 1]; 179 179 $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"'); 180 if ($DbResult->num_rows > 0)180 if ($DbResult->num_rows > 0) 181 181 { 182 182 $DbRow = $DbResult->fetch_assoc(); … … 202 202 ' FROM `WikiPageContent` WHERE Page='. 203 203 $DbRow['Id'].' '.$Order['SQL'].$PageList['SQLLimit']); 204 while ($PageContent = $DbResult2->fetch_assoc())204 while ($PageContent = $DbResult2->fetch_assoc()) 205 205 { 206 206 $Output .= '<tr>'. … … 215 215 } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL); 216 216 } else $Output = ShowMessage('Nemáte oprávnění', MESSAGE_CRITICAL); 217 return ($Output);217 return ($Output); 218 218 } 219 219 … … 242 242 $text = str_replace("\r\n", '<br/>', $text); 243 243 $text = '<p>'.$text.'</p>'; 244 return ($text);244 return ($text); 245 245 } 246 246 } -
trunk/Packages/Common/AppModule.php
r858 r873 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
r817 r873 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
r870 r873 65 65 66 66 $Result = ''; 67 if (array_key_exists('all', $QueryItems))67 if (array_key_exists('all', $QueryItems)) 68 68 { 69 69 $PageCount = 1; … … 76 76 } 77 77 78 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;79 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;80 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;81 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;78 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 79 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 80 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 81 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 82 82 $CurrentPage = $_SESSION['Page']; 83 83 … … 85 85 86 86 $Result = ''; 87 if ($PageCount > 1)87 if ($PageCount > 1) 88 88 { 89 if ($CurrentPage > 0)89 if ($CurrentPage > 0) 90 90 { 91 91 $QueryItems['page'] = 0; … … 96 96 $PagesMax = $PageCount - 1; 97 97 $PagesMin = 0; 98 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;99 if ($PagesMin < ($CurrentPage - $Around))98 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 99 if ($PagesMin < ($CurrentPage - $Around)) 100 100 { 101 101 $Result.= ' ... '; 102 102 $PagesMin = $CurrentPage - $Around; 103 103 } 104 for ($i = $PagesMin; $i <= $PagesMax; $i++)104 for ($i = $PagesMin; $i <= $PagesMax; $i++) 105 105 { 106 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';106 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 107 107 else { 108 108 $QueryItems['page'] = $i; … … 110 110 } 111 111 } 112 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';113 if ($CurrentPage < ($PageCount - 1))112 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 113 if ($CurrentPage < ($PageCount - 1)) 114 114 { 115 115 $QueryItems['page'] = ($CurrentPage + 1); … … 120 120 } 121 121 $QueryItems['all'] = '1'; 122 if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';122 if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 123 123 124 124 $Result = '<div style="text-align: center">'.$Result.'</div>'; 125 125 $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage; 126 126 $this->Page = $CurrentPage; 127 return ($Result);127 return ($Result); 128 128 } 129 129 } -
trunk/Packages/Common/Config.php
r782 r873 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
r861 r873 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 { 99 99 $Time = round(microtime_float() - $QueryStartTime, 4); 100 100 $Duration = ' ; '.$Time. ' s'; 101 101 } 102 if (($this->LogSQLQuery == true) and ($Time != 0))102 if (($this->LogSQLQuery == true) and ($Time != 0)) 103 103 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND); 104 if ($this->ShowSQLQuery == true)104 if ($this->ShowSQLQuery == true) 105 105 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '. 106 106 'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n"); 107 107 $Result = new DatabaseResult(); 108 108 $Result->PDOStatement = $this->PDO->query($Query); 109 if ($Result->PDOStatement)109 if ($Result->PDOStatement) 110 110 { 111 111 $Result->num_rows = $Result->PDOStatement->rowCount(); … … 115 115 $this->Error = $this->PDO->errorInfo(); 116 116 $this->Error = $this->Error[2]; 117 if (($this->Error != '') and ($this->ShowSQLError == true))117 if (($this->Error != '') and ($this->ShowSQLError == true)) 118 118 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); 119 119 throw new Exception('SQL Error: '.$this->Error.', Query: '.$Query); 120 120 } 121 return ($Result);121 return ($Result); 122 122 } 123 123 124 124 function select($Table, $What = '*', $Condition = 1) 125 125 { 126 return ($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition));126 return ($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition)); 127 127 } 128 128 … … 142 142 $Name = ''; 143 143 $Values = ''; 144 foreach ($Data as $Key => $Value)144 foreach ($Data as $Key => $Value) 145 145 { 146 146 $Name .= ',`'.$Key.'`'; 147 if (!in_array($Value, $this->Functions))147 if (!in_array($Value, $this->Functions)) 148 148 { 149 if (is_null($Value)) $Value = 'NULL';149 if (is_null($Value)) $Value = 'NULL'; 150 150 else $Value = $this->PDO->quote($Value); 151 151 } … … 154 154 $Name = substr($Name, 1); 155 155 $Values = substr($Values, 1); 156 return ('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');156 return ('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 157 157 } 158 158 … … 165 165 { 166 166 $Values = ''; 167 foreach ($Data as $Key => $Value)168 { 169 if (!in_array($Value, $this->Functions))167 foreach ($Data as $Key => $Value) 168 { 169 if (!in_array($Value, $this->Functions)) 170 170 { 171 if (is_null($Value)) $Value = 'NULL';171 if (is_null($Value)) $Value = 'NULL'; 172 172 else $Value = $this->PDO->quote($Value); 173 173 } … … 175 175 } 176 176 $Values = substr($Values, 2); 177 return ('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');177 return ('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'); 178 178 } 179 179 … … 182 182 $Name = ''; 183 183 $Values = ''; 184 foreach ($Data as $Key => $Value)185 { 186 if (!in_array($Value, $this->Functions))184 foreach ($Data as $Key => $Value) 185 { 186 if (!in_array($Value, $this->Functions)) 187 187 { 188 if (is_null($Value)) $Value = 'NULL';188 if (is_null($Value)) $Value = 'NULL'; 189 189 else $Value = $this->PDO->quote($Value); 190 190 } … … 206 206 function real_escape_string($Text) 207 207 { 208 return (addslashes($Text));208 return (addslashes($Text)); 209 209 } 210 210 211 211 function quote($Text) 212 212 { 213 return ($this->PDO->quote($Text));213 return ($this->PDO->quote($Text)); 214 214 } 215 215 … … 239 239 function TimeToMysqlDateTime($Time) 240 240 { 241 if ($Time == NULL) return(NULL);242 else return (date('Y-m-d H:i:s', $Time));241 if ($Time == NULL) return (NULL); 242 else return (date('Y-m-d H:i:s', $Time)); 243 243 } 244 244 245 245 function TimeToMysqlDate($Time) 246 246 { 247 if ($Time == NULL) return(NULL);248 else return (date('Y-m-d', $Time));247 if ($Time == NULL) return (NULL); 248 else return (date('Y-m-d', $Time)); 249 249 } 250 250 251 251 function TimeToMysqlTime($Time) 252 252 { 253 if ($Time == NULL) return(NULL);254 else return (date('H:i:s', $Time));253 if ($Time == NULL) return (NULL); 254 else return (date('H:i:s', $Time)); 255 255 } 256 256 257 257 function MysqlDateTimeToTime($DateTime) 258 258 { 259 if ($DateTime == '') return(NULL);259 if ($DateTime == '') return (NULL); 260 260 $Parts = explode(' ', $DateTime); 261 261 $DateParts = explode('-', $Parts[0]); 262 262 $TimeParts = explode(':', $Parts[1]); 263 263 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 264 return ($Result);264 return ($Result); 265 265 } 266 266 267 267 function MysqlDateToTime($Date) 268 268 { 269 if ($Date == '') return(NULL);270 return (MysqlDateTimeToTime($Date.' 0:0:0'));269 if ($Date == '') return (NULL); 270 return (MysqlDateTimeToTime($Date.' 0:0:0')); 271 271 } 272 272 273 273 function MysqlTimeToTime($Time) 274 274 { 275 if ($Time == '') return(NULL);276 return (MysqlDateTimeToTime('0000-00-00 '.$Time));277 } 275 if ($Time == '') return (NULL); 276 return (MysqlDateTimeToTime('0000-00-00 '.$Time)); 277 } -
trunk/Packages/Common/Error.php
r864 r873 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>'; … … 92 92 $Date = date('Y-m-d H:i:s'); 93 93 $Error = '# '.$Date."\n"; 94 foreach ($Backtrace as $Item)94 foreach ($Backtrace as $Item) 95 95 { 96 if (!array_key_exists('line', $Item)) $Item['line'] = '';97 if (!array_key_exists('file', $Item)) $Item['file'] = '';96 if (!array_key_exists('line', $Item)) $Item['line'] = ''; 97 if (!array_key_exists('file', $Item)) $Item['file'] = ''; 98 98 99 99 $Error .= ' '.$Item['file'].'('.$Item['line'].")\t".$Item['function']; 100 100 $Arguments = ''; 101 if (array_key_exists('args', $Item) and is_array($Item['args']))102 foreach ($Item['args'] as $Item)101 if (array_key_exists('args', $Item) and is_array($Item['args'])) 102 foreach ($Item['args'] as $Item) 103 103 { 104 if (is_object($Item)) ;105 else if (is_array($Item)) $Arguments .= "'".serialize($Item)."',";104 if (is_object($Item)) ; 105 else if (is_array($Item)) $Arguments .= "'".serialize($Item)."',"; 106 106 else $Arguments .= "'".$Item."',"; 107 107 } 108 if (strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')';108 if (strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')'; 109 109 $Error .= "\n"; 110 110 } 111 111 $Error .= "\n"; 112 112 113 foreach ($this->OnError as $OnError)113 foreach ($this->OnError as $OnError) 114 114 call_user_func($OnError, $Error); 115 115 } -
trunk/Packages/Common/Image.php
r746 r873 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 $this->Image = imagecreatefromgif ($FileName);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
r791 r873 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
r791 r873 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
r870 r873 16 16 function GetNetMask() 17 17 { 18 return (((1 << IPV4_BIT_WIDTH) - 1) ^ ((1 << (IPV4_BIT_WIDTH - $this->Prefix)) - 1));18 return (((1 << IPV4_BIT_WIDTH) - 1) ^ ((1 << (IPV4_BIT_WIDTH - $this->Prefix)) - 1)); 19 19 } 20 20 21 21 function AddressToString() 22 22 { 23 return (implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255))));23 return (implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255)))); 24 24 } 25 25 … … 39 39 $To->Address = $From->Address + $HostMask; 40 40 $To->Prefix = IPV4_BIT_WIDTH; 41 return (array('From' => $From, 'To' => $To));41 return (array('From' => $From, 'To' => $To)); 42 42 } 43 43 … … 45 45 { 46 46 $this->Prefix = $NewPrefix; 47 if ($this->Prefix > IPV4_BIT_WIDTH) $this->Prefix = IPV4_BIT_WIDTH;48 if ($this->Prefix < 0) $this->Prefix = 0;47 if ($this->Prefix > IPV4_BIT_WIDTH) $this->Prefix = IPV4_BIT_WIDTH; 48 if ($this->Prefix < 0) $this->Prefix = 0; 49 49 $this->Address = $this->Address & $this->GetNetMask(); 50 50 } … … 53 53 { 54 54 $UpperNetmask = $this->GetNetMask(); 55 if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;55 if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true; 56 56 else $Result = false; 57 return ($Result);57 return ($Result); 58 58 } 59 59 } … … 74 74 function GetNetMask() 75 75 { 76 return (Int128Xor(Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH)), IntToInt128(1)),76 return (Int128Xor(Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH)), IntToInt128(1)), 77 77 Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH - $this->Prefix)), IntToInt128(1)))); 78 78 } … … 80 80 function AddressToString() 81 81 { 82 return (inet_ntop($this->Address));82 return (inet_ntop($this->Address)); 83 83 } 84 84 … … 91 91 { 92 92 $this->Prefix = $NewPrefix; 93 if ($this->Prefix > IPV6_BIT_WIDTH) $this->Prefix = IPV6_BIT_WIDTH;94 if ($this->Prefix < 0) $this->Prefix = 0;93 if ($this->Prefix > IPV6_BIT_WIDTH) $this->Prefix = IPV6_BIT_WIDTH; 94 if ($this->Prefix < 0) $this->Prefix = 0; 95 95 $this->Address = Int128And($this->Address, $this->GetNetMask()); 96 96 } … … 100 100 $Result = array(); 101 101 $Data = array_reverse(unpack('C*', $this->Address)); 102 foreach ($Data as $Item)102 foreach ($Data as $Item) 103 103 { 104 104 … … 106 106 $Result[] = dechex(($Item >> 4) & 15); 107 107 } 108 return ($Result);108 return ($Result); 109 109 } 110 110 … … 127 127 { 128 128 $UpperNetmask = $this->GetNetMask(); 129 if (($this->Prefix < $Address->Prefix) and ((Int128Equal(Int128And($Address->Address, $UpperNetmask), Int128And($this->Address, $UpperNetmask))))) $Result = true;129 if (($this->Prefix < $Address->Prefix) and ((Int128Equal(Int128And($Address->Address, $UpperNetmask), Int128And($this->Address, $UpperNetmask))))) $Result = true; 130 130 else $Result = false; 131 return ($Result);131 return ($Result); 132 132 } 133 133 } -
trunk/Packages/Common/Page.php
r796 r873 20 20 function Show() 21 21 { 22 return ('');22 return (''); 23 23 } 24 24 … … 26 26 { 27 27 $Output = $this->Show(); 28 return ($Output);28 return ($Output); 29 29 } 30 30 31 31 function SystemMessage($Title, $Text) 32 32 { 33 return (call_user_func_array($this->OnSystemMessage, array($Title, $Text)));33 return (call_user_func_array($this->OnSystemMessage, array($Title, $Text))); 34 34 } 35 35 } -
trunk/Packages/Common/PrefixMultiplier.php
r746 r873 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/Process.php
r816 r873 20 20 function Start() 21 21 { 22 if (!$this->IsRunning())22 if (!$this->IsRunning()) 23 23 { 24 24 $DescriptorSpec = array( … … 38 38 function Stop() 39 39 { 40 if ($this->IsRunning())40 if ($this->IsRunning()) 41 41 { 42 42 proc_close($this->Handle); … … 47 47 function IsRunning() 48 48 { 49 return (is_resource($this->Handle));49 return (is_resource($this->Handle)); 50 50 } 51 51 } -
trunk/Packages/Common/RSS.php
r746 r873 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
r841 r873 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() and404 return ($this->Database->Connected() and $this->UpdateManager->IsInstalled() and 405 405 $this->UpdateManager->IsUpToDate()); 406 406 } … … 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
r791 r873 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
r746 r873 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
r838 r873 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
r746 r873 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/block/index.php
r659 r873 22 22 23 23 $DbResult = $this->Database->query('SELECT * FROM NetworkInterface WHERE LocalIP="'.GetRemoteAddress().'"'); 24 if ($DbResult->num_rows > 0)24 if ($DbResult->num_rows > 0) 25 25 { 26 26 $Interface = $DbResult->fetch_array(); … … 30 30 $Member = $DbResult->fetch_array(); 31 31 32 if ($Member['Blocked'] == 1)32 if ($Member['Blocked'] == 1) 33 33 { 34 34 $Output .= $this->Reasons[1]; … … 38 38 $Output .= '<br/><br/>V případě problémů kontaktujte technickou podporu na telefonu 737785792<br/><br/>'; 39 39 $Output .= '</body></html>'; 40 return ($Output);40 return ($Output); 41 41 } 42 42 } -
trunk/cmd.php
r790 r873 3 3 include_once('Application/System.php'); 4 4 5 if (isset($_SERVER['REMOTE_ADDR'])) die();5 if (isset($_SERVER['REMOTE_ADDR'])) die(); 6 6 7 7 $System = new Core();
Note:
See TracChangeset
for help on using the changeset viewer.