Changeset 657 for trunk/Application/System.php
- Timestamp:
- May 25, 2014, 8:29:03 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/System.php
r634 r657 13 13 /** @var Database */ 14 14 var $Database; 15 var $Modules; 15 var $Modules; 16 16 /** @var Type */ 17 17 var $Type; … … 38 38 if(substr($this->RootURLFolder, -10, 10) == '/index.php') 39 39 $this->RootURLFolder = substr($this->RootURLFolder, 0, -10); 40 } 41 40 } 41 42 42 function RegisterPage($Path, $Handler) 43 43 { … … 48 48 foreach($Path as $PathItem) 49 49 { 50 $Page = &$Page[$PathItem]; 50 $Page = &$Page[$PathItem]; 51 51 } 52 52 if(!is_array($Page)) $Page = array('' => $Page); … … 54 54 } else $this->Pages[$Path] = $Handler; 55 55 } 56 56 57 57 function UnregisterPage($Path) 58 58 { 59 unset($this->Pages[$Path]); 60 } 61 59 unset($this->Pages[$Path]); 60 } 61 62 62 function SearchPage($PathItems, $Pages) 63 63 { … … 66 66 if(array_key_exists($PathItem, $Pages)) 67 67 { 68 if(is_array($Pages[$PathItem])) 68 if(is_array($Pages[$PathItem])) 69 69 { 70 70 array_shift($PathItems); … … 73 73 } else return(''); 74 74 } 75 75 76 76 function PageNotFound() 77 77 { 78 78 return('Page '.implode('/', $this->PathItems).' not found.'); 79 79 } 80 80 81 81 function ShowPage() 82 82 { 83 83 /* @var $Page Page */ 84 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 85 if($ClassName != '') 84 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 85 if($ClassName != '') 86 86 { 87 87 $Page = new $ClassName($this); … … 92 92 } 93 93 } 94 94 95 95 function ModulePresent($Name) 96 96 { … … 103 103 $this->Modules[get_class($Module)] = $Module; 104 104 } 105 105 106 106 function HumanDate($Time) 107 107 { 108 108 return(date('j.n.Y', $Time)); 109 109 } 110 110 111 111 function Link($Target) 112 112 { 113 113 return($this->RootURLFolder.$Target); 114 114 } 115 115 116 116 function ShowAction($Id) 117 117 { … … 136 136 global $Database, $ScriptTimeStart, $ConfigFileName, $Mail, $Type, 137 137 $DatabaseRevision, $Config; 138 138 139 139 date_default_timezone_set('Europe/Prague'); 140 140 mb_internal_encoding("UTF-8"); 141 141 $ScriptTimeStart = GetMicrotime(); 142 142 143 143 // SQL injection hack protection 144 144 foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item); … … 147 147 if(isset($_SERVER['REMOTE_ADDR'])) session_start(); 148 148 149 $ConfigFileName = dirname(__FILE__).'/../config.php'; 150 if(file_exists($ConfigFileName)) 149 $ConfigFileName = dirname(__FILE__).'/../config.php'; 150 if(file_exists($ConfigFileName)) 151 151 $this->ConfigManager->LoadFromFile($ConfigFileName); 152 152 //$this->Config = $this->ConfigManager->GetAsArray(); 153 153 $this->Config = &$Config; 154 155 try { 156 $this->Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'], 154 155 try { 156 $this->Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'], 157 157 $this->Config['Database']['Password'], $this->Config['Database']['Database']); 158 158 $this->Database->Prefix = $this->Config['Database']['Prefix']; … … 166 166 $this->RootURLFolder = $this->Config['Web']['RootFolder']; 167 167 $this->FormManager->Root = $this->RootURLFolder; 168 168 169 169 $this->RegisterPageBar('Top'); 170 171 $Database = $this->Database; 172 RegisterFormClasses($this->FormManager); 173 170 171 $Database = $this->Database; 172 RegisterFormClasses($this->FormManager); 173 174 174 // Register and start existing modules 175 175 $this->Setup = new Setup($this); … … 183 183 $this->PathItems = ProcessURL(); 184 184 $this->ShowPage(); 185 } 186 } 187 185 } 186 } 187 188 188 function RegisterPageBar($Name) 189 189 { … … 206 206 var $FullTitle = 'Stránka nenalezena'; 207 207 var $ShortTitle = 'Stránka nenalezena'; 208 208 209 209 function __construct($System) 210 210 { … … 215 215 function Show() 216 216 { 217 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 217 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 218 218 return('<h3 align="center">Požadovaná stránka neexistuje.</h3>'); 219 219 }
Note:
See TracChangeset
for help on using the changeset viewer.