Changeset 7 for trunk/Application/Core.php
- Timestamp:
- Apr 14, 2020, 11:13:32 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Core.php
r3 r7 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__).'/../Packages/Common/Common.php'); … … 31 31 $this->BaseURL = $_SERVER['SCRIPT_NAME']; 32 32 $BaseScriptName = '/index.php'; 33 if (substr($this->BaseURL, -strlen($BaseScriptName), strlen($BaseScriptName)) == $BaseScriptName)33 if (substr($this->BaseURL, -strlen($BaseScriptName), strlen($BaseScriptName)) == $BaseScriptName) 34 34 $this->BaseURL = substr($this->BaseURL, 0, -strlen($BaseScriptName)); 35 35 $this->FormManager = new FormManager($this->Database); … … 48 48 $this->Config = &$Config; 49 49 50 if (isset($this->Config['Database']))50 if (isset($this->Config['Database'])) 51 51 { 52 52 $this->Database->Connect($Config['Database']['Host'], $Config['Database']['User'], … … 59 59 60 60 // SQL injection hack protection 61 foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);62 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);61 foreach ($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item); 62 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); 63 63 64 64 $this->RegisterPageBar('Top'); … … 68 68 $this->Setup = new Setup($this); 69 69 $this->Setup->Start(); 70 if ($this->Setup->CheckState())70 if ($this->Setup->CheckState()) 71 71 { 72 72 $this->ModuleManager->Start(); … … 77 77 { 78 78 $this->RunCommon(); 79 if ($this->ShowPage)79 if ($this->ShowPage) 80 80 { 81 81 $this->PathItems = ProcessURL(); … … 90 90 /* @var $Page Page */ 91 91 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 92 if ($ClassName != '')92 if ($ClassName != '') 93 93 { 94 94 $Page = new $ClassName($this); … … 101 101 function RegisterPage($Path, $Handler) 102 102 { 103 if (is_array($Path))103 if (is_array($Path)) 104 104 { 105 105 $Page = &$this->Pages; 106 106 $LastKey = array_pop($Path); 107 foreach ($Path as $PathItem)107 foreach ($Path as $PathItem) 108 108 { 109 109 $Page = &$Page[$PathItem]; 110 110 } 111 if (!is_array($Page)) $Page = array('' => $Page);111 if (!is_array($Page)) $Page = array('' => $Page); 112 112 $Page[$LastKey] = $Handler; 113 113 } else $this->Pages[$Path] = $Handler; … … 136 136 function SearchPage($PathItems, $Pages) 137 137 { 138 if (count($PathItems) > 0) $PathItem = $PathItems[0];138 if (count($PathItems) > 0) $PathItem = $PathItems[0]; 139 139 else $PathItem = ''; 140 if (array_key_exists($PathItem, $Pages))140 if (array_key_exists($PathItem, $Pages)) 141 141 { 142 if (is_array($Pages[$PathItem]))142 if (is_array($Pages[$PathItem])) 143 143 { 144 144 array_shift($PathItems); 145 return ($this->SearchPage($PathItems, $Pages[$PathItem]));146 } else return ($Pages[$PathItem]);147 } else return ('');145 return $this->SearchPage($PathItems, $Pages[$PathItem]); 146 } else return $Pages[$PathItem]; 147 } else return ''; 148 148 } 149 149 150 150 function Link($Target) 151 151 { 152 return ($this->BaseURL.$Target);152 return $this->BaseURL.$Target; 153 153 } 154 154 } … … 166 166 { 167 167 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 168 return ('<h3 align="center">'.T('Required page not found').'</h3>');168 return '<h3 align="center">'.T('Required page not found').'</h3>'; 169 169 } 170 170 }
Note:
See TracChangeset
for help on using the changeset viewer.