Changeset 873 for trunk/Application/System.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.