Changeset 880 for trunk/Application
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- Location:
- trunk/Application
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Core.php
r878 r880 34 34 35 35 $this->Config = $Config; 36 if (isset($this->Config['Web']['Timezone']))36 if (isset($this->Config['Web']['Timezone'])) 37 37 date_default_timezone_set($this->Config['Web']['Timezone']); 38 38 mb_internal_encoding("UTF-8"); 39 39 40 if (isset($this->Config['Database']))41 { 42 $this->Database->Connect($this->Config['Database']['Host'],43 $this->Config['Database']['User'], $this->Config['Database']['Password'],44 $this->Config['Database']['Database']);45 $this->Database->charset($this->Config['Database']['Charset']);46 $this->Database->ShowSQLQuery = $this->Config['Web']['ShowSQLQuery'];47 $this->Database->ShowSQLError = $this->Config['Web']['ShowSQLError'];48 $this->Database->LogSQLQuery = $this->Config['Web']['LogSQLQuery'];40 if (isset($this->Config['Database'])) 41 { 42 $this->Database->Connect($this->Config['Database']['Host'], 43 $this->Config['Database']['User'], $this->Config['Database']['Password'], 44 $this->Config['Database']['Database']); 45 $this->Database->charset($this->Config['Database']['Charset']); 46 $this->Database->ShowSQLQuery = $this->Config['Web']['ShowSQLQuery']; 47 $this->Database->ShowSQLError = $this->Config['Web']['ShowSQLError']; 48 $this->Database->LogSQLQuery = $this->Config['Web']['LogSQLQuery']; 49 49 } 50 50 … … 60 60 ); 61 61 62 if (GetRemoteAddress() != '')62 if (GetRemoteAddress() != '') 63 63 { 64 64 $this->BaseURL = $_SERVER["CONTEXT_PREFIX"]; … … 68 68 69 69 // Detect interface locale 70 if (isset($this->Config['Web']['Locale']))70 if (isset($this->Config['Web']['Locale'])) 71 71 $this->LocaleManager->DefaultLangCode = $this->Config['Web']['Locale']; 72 72 $this->LocaleManager->LangCode = $this->LocaleManager->DefaultLangCode; 73 if (count($this->PathItems) > 0)73 if (count($this->PathItems) > 0) 74 74 { 75 75 $NewLangCode = $this->PathItems[0]; 76 if (array_key_exists($NewLangCode, $this->LocaleManager->Available)) {76 if (array_key_exists($NewLangCode, $this->LocaleManager->Available)) { 77 77 array_shift($this->PathItems); 78 78 $this->LocaleManager->LangCode = $NewLangCode; 79 79 } 80 80 } 81 if (array_key_exists($this->LocaleManager->LangCode, $this->LocaleManager->Available))81 if (array_key_exists($this->LocaleManager->LangCode, $this->LocaleManager->Available)) 82 82 $this->LocaleManager->LoadLocale($this->LocaleManager->LangCode); 83 83 … … 109 109 110 110 $ScriptStartTime = GetMicrotime(); 111 //if (GetRemoteAddress() != '')111 //if (GetRemoteAddress() != '') 112 112 session_start(); 113 113 114 114 // SQL injection hack protection 115 foreach ($_POST as $Index => $Item)116 { 117 if (is_array($_POST[$Index]))118 foreach ($_POST[$Index] as $Index2 => $Item2) $_POST[$Index][$Index2] = addslashes($Item2);115 foreach ($_POST as $Index => $Item) 116 { 117 if (is_array($_POST[$Index])) 118 foreach ($_POST[$Index] as $Index2 => $Item2) $_POST[$Index][$Index2] = addslashes($Item2); 119 119 else $_POST[$Index] = addslashes($_POST[$Index]); 120 120 } 121 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]);121 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]); 122 122 123 123 $this->RegisterPageBar('Top'); … … 130 130 $this->Setup->Start(); 131 131 $this->Setup->UpdateManager->VersionTable = 'DbVersion'; 132 if ($this->Setup->CheckState())132 if ($this->Setup->CheckState()) 133 133 { 134 134 $this->ModuleManager->Start(); … … 136 136 137 137 $this->BaseView = new BaseView($this); 138 if ($this->DoNotShowPage == false)138 if ($this->DoNotShowPage == false) 139 139 { 140 140 $this->ShowPage(); … … 145 145 { 146 146 list($Usec, $Sec) = explode(' ', microtime()); 147 return ( (float)$Usec + (float)$Sec);147 return (float)$Usec + (float)$Sec; 148 148 } 149 149 … … 152 152 $Remaining = substr($Target, strlen($this->BaseURL)); 153 153 $TargetParts = explode('/', $Remaining); 154 if (count($TargetParts) > 0)155 { 156 if (in_array($TargetParts[0], $this->LinkLocaleExceptions))154 if (count($TargetParts) > 0) 155 { 156 if (in_array($TargetParts[0], $this->LinkLocaleExceptions)) 157 157 { 158 return ($this->BaseURL.$Target);159 } 160 } 161 return ($this->LinkLocale($Target));158 return $this->BaseURL.$Target; 159 } 160 } 161 return $this->LinkLocale($Target); 162 162 } 163 163 … … 168 168 $RemainingParts = explode('?', $Remaining); 169 169 $Directory = $RemainingParts[0]; 170 if (count($RemainingParts) > 1)170 if (count($RemainingParts) > 1) 171 171 { 172 172 $Params = $RemainingParts[1]; … … 180 180 181 181 $DirectoryParts = explode('/', $Directory); 182 foreach ($DirectoryParts as $Index => $Item)182 foreach ($DirectoryParts as $Index => $Item) 183 183 { 184 184 $NewText = $TargetLocaleManager->CurrentLocale->Texts->Translate($Item, 'URL'); … … 187 187 $Directory = implode('/', $DirectoryParts); 188 188 $Remaining = $Directory; 189 if ($Params != '') $Remaining .= '?'.$Params;190 191 return ($Remaining);189 if ($Params != '') $Remaining .= '?'.$Params; 190 191 return $Remaining; 192 192 } 193 193 … … 198 198 $RemainingParts = explode('?', $Remaining); 199 199 $Directory = $RemainingParts[0]; 200 if (count($RemainingParts) > 1)200 if (count($RemainingParts) > 1) 201 201 { 202 202 $Params = $RemainingParts[1]; … … 210 210 211 211 $DirectoryParts = explode('/', $Directory); 212 foreach ($DirectoryParts as $Index => $Item)212 foreach ($DirectoryParts as $Index => $Item) 213 213 { 214 214 $NewText = $TargetLocaleManager->CurrentLocale->Texts->TranslateReverse($Item, 'URL'); … … 217 217 $Directory = implode('/', $DirectoryParts); 218 218 $Remaining = $Directory; 219 if ($Params != '') $Remaining .= '?'.$Params;220 221 return ($Remaining);219 if ($Params != '') $Remaining .= '?'.$Params; 220 221 return $Remaining; 222 222 } 223 223 224 224 function LinkLocale($Target, $Locale = '') 225 225 { 226 if ($Locale == '') $Locale = $this->LocaleManager->LangCode;226 if ($Locale == '') $Locale = $this->LocaleManager->LangCode; 227 227 228 228 $Target = $this->TranslateURL($Target, $Locale); 229 229 230 if ($Locale == $this->LocaleManager->DefaultLangCode)231 return ($this->BaseURL.$Target);232 return ($this->BaseURL.'/'.$Locale.$Target);230 if ($Locale == $this->LocaleManager->DefaultLangCode) 231 return $this->BaseURL.$Target; 232 return $this->BaseURL.'/'.$Locale.$Target; 233 233 } 234 234 235 235 function RegisterPage($Path, $Handler) 236 236 { 237 if (is_array($Path))237 if (is_array($Path)) 238 238 { 239 239 $Page = &$this->Pages; 240 240 $LastKey = array_pop($Path); 241 foreach ($Path as $PathItem)241 foreach ($Path as $PathItem) 242 242 { 243 243 $Page = &$Page[$PathItem]; 244 244 } 245 if (!is_array($Page)) $Page = array('' => $Page);245 if (!is_array($Page)) $Page = array('' => $Page); 246 246 $Page[$LastKey] = $Handler; 247 247 } else $this->Pages[$Path] = $Handler; … … 250 250 function RegisterMenuItem($MenuItem, $Pos = NULL) 251 251 { 252 if (is_null($Pos)) $this->Menu[] = $MenuItem;252 if (is_null($Pos)) $this->Menu[] = $MenuItem; 253 253 else { 254 254 array_splice($this->Menu, $Pos, 0, array($MenuItem)); … … 258 258 function SearchPage($PathItems, $Pages) 259 259 { 260 if (count($PathItems) == 0) $PathItems = array('');260 if (count($PathItems) == 0) $PathItems = array(''); 261 261 $PathItem = $PathItems[0]; 262 262 $PathItem = $this->LocaleManager->CurrentLocale->Texts->TranslateReverse($PathItem, 'URL'); 263 263 264 if (array_key_exists($PathItem, $Pages))265 { 266 if (is_array($Pages[$PathItem]))264 if (array_key_exists($PathItem, $Pages)) 265 { 266 if (is_array($Pages[$PathItem])) 267 267 { 268 268 array_shift($PathItems); 269 return ($this->SearchPage($PathItems, $Pages[$PathItem]));269 return $this->SearchPage($PathItems, $Pages[$PathItem]); 270 270 } else 271 271 { 272 if (count($PathItems) == 1) return($Pages[$PathItem]);273 else return (''); // Unexpected subpages274 } 275 } else return ('');272 if (count($PathItems) == 1) return $Pages[$PathItem]; 273 else return ''; // Unexpected subpages 274 } 275 } else return ''; 276 276 } 277 277 … … 279 279 { 280 280 // Send correct HTTP status code to signal unknown page 281 if (array_key_exists('SERVER_PROTOCOL', $_SERVER))281 if (array_key_exists('SERVER_PROTOCOL', $_SERVER)) 282 282 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 283 if (array_key_exists('HTTP_REFERER', $_SERVER)) $Referer = ' Referer: '.$_SERVER['HTTP_REFERER'];283 if (array_key_exists('HTTP_REFERER', $_SERVER)) $Referer = ' Referer: '.$_SERVER['HTTP_REFERER']; 284 284 else $Referer = ''; 285 if (isset($this->ModuleManager->Modules['Log']))285 if (isset($this->ModuleManager->Modules['Log'])) 286 286 $this->ModuleManager->Modules['Log']->WriteLog('Stránka "'. 287 287 implode('/', $this->PathItems).'" nenalezena'.$Referer, LOG_TYPE_PAGE_NOT_FOUND); 288 return (ShowMessage(sprintf(T('Page "%s" not found'), implode('/', $this->PathItems)), MESSAGE_CRITICAL));288 return ShowMessage(sprintf(T('Page "%s" not found'), implode('/', $this->PathItems)), MESSAGE_CRITICAL); 289 289 } 290 290 … … 295 295 /* @var $Page Page */ 296 296 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 297 if (($ClassName != '') and (class_exists($ClassName)))297 if (($ClassName != '') and (class_exists($ClassName))) 298 298 { 299 299 $Page = new $ClassName($this); 300 300 $Output = $Page->GetOutput(); 301 301 $this->BaseView->Title = $Page->Title; 302 if ($Page->RawPage == false) $Output = $this->BaseView->ShowPage($Output);302 if ($Page->RawPage == false) $Output = $this->BaseView->ShowPage($Output); 303 303 } else { 304 304 $Output2 = ''; 305 if ((count($this->OnPageNotFound) == 2)305 if ((count($this->OnPageNotFound) == 2) 306 306 and method_exists($this->OnPageNotFound[0], $this->OnPageNotFound[1])) 307 307 $Output2 = call_user_func_array($this->OnPageNotFound, array()); 308 if ($Output2 != '') $Output .= $this->BaseView->ShowPage($Output2);308 if ($Output2 != '') $Output .= $this->BaseView->ShowPage($Output2); 309 309 else { 310 310 $Output = $this->PageNotFound(); … … 338 338 function HumanDate($Time) 339 339 { 340 return (date('j.n.Y', $Time));340 return date('j.n.Y', $Time); 341 341 } 342 342 } -
trunk/Application/DefaultConfig.php
r861 r880 6 6 { 7 7 $IsDeveloper = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1')); 8 return (array(8 return array( 9 9 array('Name' => 'SystemPassword', 'Type' => 'PasswordEncoded', 'Default' => '', 'Title' => 'System password'), 10 10 array('Name' => 'Database/Host', 'Type' => 'String', 'Default' => 'localhost', 'Title' => 'Server'), … … 46 46 array('Name' => 'OriginalLanguage', 'Type' => 'Integer', 'Default' => 1, 'Title' => 'Original language'), 47 47 array('Name' => 'EnableGoogleTranslate', 'Type' => 'Boolean', 'Default' => false, 'Title' => 'Enable Google translate'), 48 ) );48 ); 49 49 } 50 50 } -
trunk/Application/UpdateTrace.php
r879 r880 2483 2483 2484 2484 $DbResult = $System->Database->query('SELECT `TablePrefix` FROM `Group`'); 2485 while ($Group = $DbResult->fetch_assoc())2485 while ($Group = $DbResult->fetch_assoc()) 2486 2486 { 2487 2487 $Manager->Execute('ALTER TABLE `'.$Group['TablePrefix'].'` ADD FOREIGN KEY ( `Language` ) REFERENCES `Language` ('. … … 2532 2532 // Set all string collation to utf8 general 2533 2533 $DbResult = $Manager->Execute("SHOW TABLES"); 2534 while ($DbRow = $DbResult->fetch_row())2534 while ($DbRow = $DbResult->fetch_row()) 2535 2535 { 2536 2536 $Manager->Execute("ALTER TABLE `".$DbRow[0]."` CONVERT TO CHARACTER SET utf8"); … … 2946 2946 2947 2947 function UpdateTo872($Manager) 2948 { 2948 { 2949 2949 // Allow to store IPv6 addresses 2950 2950 $Manager->Execute('ALTER TABLE `UserOnline` CHANGE `IpAddress` `IpAddress` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT "";'); … … 2957 2957 2958 2958 function UpdateTo873($Manager) 2959 { 2959 { 2960 2960 $Manager->Execute('ALTER TABLE `User` CHANGE `XP` `XP` INT(11) NOT NULL DEFAULT "0";'); 2961 2961 $Manager->Execute('ALTER TABLE `User` CHANGE `TranslatedCount` `TranslatedCount` INT(11) NOT NULL DEFAULT "0";'); … … 2971 2971 function Get() 2972 2972 { 2973 return (array(2973 return array( 2974 2974 498 => array('Revision' => 506, 'Function' => 'UpdateTo506'), 2975 2975 506 => array('Revision' => 510, 'Function' => 'UpdateTo510'), … … 3006 3006 867 => array('Revision' => 872, 'Function' => 'UpdateTo872'), 3007 3007 872 => array('Revision' => 873, 'Function' => 'UpdateTo873'), 3008 ) );3008 ); 3009 3009 } 3010 3010 } -
trunk/Application/View.php
r864 r880 9 9 //$Output .= ' <form action="?setlocale" method="get">'; 10 10 $Output = ' <select onchange="window.location=this.value">'; 11 foreach ($this->System->LocaleManager->Available as $Locale)11 foreach ($this->System->LocaleManager->Available as $Locale) 12 12 { 13 13 $Remaining = substr($_SERVER["REQUEST_URI"], strlen($this->System->BaseURL)); 14 if (substr($Remaining, 1, strlen($Locale['Code'].'/')) == $this->System->LocaleManager->LangCode.'/')14 if (substr($Remaining, 1, strlen($Locale['Code'].'/')) == $this->System->LocaleManager->LangCode.'/') 15 15 $Remaining = substr($Remaining, strlen('/'.$Locale['Code'])); 16 if ($Locale['Code'] == $this->System->LocaleManager->CurrentLocale->Texts->Code) $Selected = ' selected="selected"';16 if ($Locale['Code'] == $this->System->LocaleManager->CurrentLocale->Texts->Code) $Selected = ' selected="selected"'; 17 17 else $Selected = ''; 18 18 $Remaining = $this->System->TranslateReverseURL($Remaining, $this->System->LocaleManager->LangCode); … … 23 23 $Output .= '</select><noscript><span><input type="submit" value="Submit"/></span></noscript>'; 24 24 25 return ($Output);25 return $Output; 26 26 } 27 27 … … 29 29 { 30 30 $Output = '<div class="Menu">'; 31 if (isset($this->System->User))31 if (isset($this->System->User)) 32 32 { 33 if (!$this->System->User->Licence(LICENCE_USER))33 if (!$this->System->User->Licence(LICENCE_USER)) 34 34 $Output .= '<div class="advert">'.$this->System->Config['Web']['Advertisement'].'</div>'; 35 35 } … … 38 38 // Show bars items 39 39 $Bar = ''; 40 foreach ($this->System->Bars['Top'] as $BarItem)40 foreach ($this->System->Bars['Top'] as $BarItem) 41 41 $Bar .= call_user_func($BarItem); 42 if (trim($Bar) != '') $Output .= $Bar;42 if (trim($Bar) != '') $Output .= $Bar; 43 43 else $Output .= ' '; 44 44 … … 46 46 //$Output .= '</form>'; 47 47 $Output .= '</span></div>'; 48 return ($Output);48 return $Output; 49 49 } 50 50 … … 53 53 $Output = '<strong>'.T('Menu').':</strong>'. 54 54 '<div class="verticalmenu"><ul>'; 55 foreach ($this->System->Menu as $MenuItem)56 if (!isset($this->System->User) or $this->System->User->Licence($MenuItem['Permission']))55 foreach ($this->System->Menu as $MenuItem) 56 if (!isset($this->System->User) or $this->System->User->Licence($MenuItem['Permission'])) 57 57 { 58 if (isset($MenuItem['Click'])) $OnClick = ' onclick="'.$MenuItem['Click'].'"';58 if (isset($MenuItem['Click'])) $OnClick = ' onclick="'.$MenuItem['Click'].'"'; 59 59 else $OnClick = ''; 60 if ($MenuItem['Icon'] != '') $Icon = '<img src="'.$this->System->Link('/images/menu/'.$MenuItem['Icon']).'"/>';60 if ($MenuItem['Icon'] != '') $Icon = '<img src="'.$this->System->Link('/images/menu/'.$MenuItem['Icon']).'"/>'; 61 61 else $Icon = ''; 62 62 $Output .= '<li>'.$Icon.'<a class="verticalmenua" title="'.$MenuItem['Hint'].'" href="'. … … 64 64 } 65 65 $Output .= '</ul></div>'; 66 return ($Output);66 return $Output; 67 67 } 68 68 … … 83 83 // Show page headers 84 84 $Bar = ''; 85 foreach ($this->System->PageHeaders as $Item)85 foreach ($this->System->PageHeaders as $Item) 86 86 $Output .= call_user_func($Item); 87 87 88 88 $Title = $this->System->Config['Web']['Title']; 89 if ($this->Title != '') $Title = $this->Title.' - '.$Title;89 if ($this->Title != '') $Title = $this->Title.' - '.$Title; 90 90 $Output .= '<title>'.$Title.'</title>'. 91 91 '<script src="'.$this->System->Link('/style/respond.js').'"></script>'. … … 98 98 // Show bars items 99 99 $Bar = ''; 100 foreach ($this->System->Bars['Left'] as $BarItem)100 foreach ($this->System->Bars['Left'] as $BarItem) 101 101 $Bar .= call_user_func($BarItem); 102 if (trim($Bar) != '') $Output .= $Bar;102 if (trim($Bar) != '') $Output .= $Bar; 103 103 else $Output .= ' '; 104 104 105 105 $Output .= '</td><td id="border-left"></td><td class="content">'; 106 return ($Output);106 return $Output; 107 107 } 108 108 … … 117 117 // Show bars items 118 118 $Bar = ''; 119 foreach ($this->System->Bars['Right'] as $BarItem)119 foreach ($this->System->Bars['Right'] as $BarItem) 120 120 $Bar .= call_user_func($BarItem); 121 if (trim($Bar) != '') $Output .= $Bar;121 if (trim($Bar) != '') $Output .= $Bar; 122 122 else $Output .= ' '; 123 123 $Output .= '</td>'; … … 129 129 130 130 $Output .= '</td></tr>'; 131 if ($this->System->Config['Web']['ShowRuntimeInfo'] == true)131 if ($this->System->Config['Web']['ShowRuntimeInfo'] == true) 132 132 $Output .= '<tr><td colspan="3" style="text-align: center;">'.T('Generating duration').': '. 133 133 $ScriptGenerateDuration.' s / '.ini_get('max_execution_time').' s '.T('Used memory').': '. … … 137 137 '</body>'. 138 138 '</html>'; 139 return ($Output);139 return $Output; 140 140 } 141 141 … … 143 143 { 144 144 $Output = $this->ShowHeader().$Content.$this->ShowFooter(); 145 if ($this->System->Config['Web']['FormatOutput'])145 if ($this->System->Config['Web']['FormatOutput']) 146 146 $Output = $this->FormatOutput($Output); 147 return ($Output);147 return $Output; 148 148 } 149 149 … … 153 153 $nn = 0; 154 154 $n = 0; 155 while ($s != '')155 while ($s != '') 156 156 { 157 157 $start = strpos($s, '<'); 158 158 $end = strpos($s, '>'); 159 if ($start != 0)159 if ($start != 0) 160 160 { 161 161 $end = $start - 1; … … 163 163 } 164 164 $line = trim(substr($s, $start, $end + 1)); 165 if (strlen($line) > 0)166 if ($line[0] == '<')165 if (strlen($line) > 0) 166 if ($line[0] == '<') 167 167 { 168 if ($s[$start + 1] == '/')168 if ($s[$start + 1] == '/') 169 169 { 170 170 $n = $n - 2; … … 172 172 } else 173 173 { 174 if (strpos($line, ' ')) $cmd = substr($line, 1, strpos($line, ' ') - 1);174 if (strpos($line, ' ')) $cmd = substr($line, 1, strpos($line, ' ') - 1); 175 175 else $cmd = substr($line, 1, strlen($line) - 2); 176 176 //echo('['.$cmd.']'); 177 if (strpos($s, '</'.$cmd.'>')) $n = $n + 2;177 if (strpos($s, '</'.$cmd.'>')) $n = $n + 2; 178 178 } 179 179 }// else $line = '['.$line.']'; 180 //if ($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));181 if ($nn < 0) $nn = 0;182 if ($line != '') $out .= (str_repeat(' ', $nn).$line."\n");180 //if ($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n")); 181 if ($nn < 0) $nn = 0; 182 if ($line != '') $out .= (str_repeat(' ', $nn).$line."\n"); 183 183 $s = substr($s, $end + 1, strlen($s)); 184 184 $nn = $n; 185 185 } 186 return ($out);186 return $out; 187 187 } 188 188 }
Note:
See TracChangeset
for help on using the changeset viewer.