Changeset 880 for trunk/includes/Global.php
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/Global.php
r879 r880 2 2 3 3 include_once(dirname(__FILE__).'/../Packages/Common/Common.php'); 4 if (file_exists(dirname(__FILE__).'/../Config/Config.php'))4 if (file_exists(dirname(__FILE__).'/../Config/Config.php')) 5 5 include_once(dirname(__FILE__).'/../Config/Config.php'); 6 6 include_once(dirname(__FILE__).'/../Application/Core.php'); … … 13 13 14 14 // Back compatibility, will be removed 15 if (isset($InitSystem) and $InitSystem)15 if (isset($InitSystem) and $InitSystem) 16 16 { 17 17 $System = new Core(); … … 25 25 { 26 26 global $TempPageContent; 27 return ($TempPageContent);27 return $TempPageContent; 28 28 } 29 29 } … … 54 54 { 55 55 list($Usec, $Sec) = explode(' ', microtime()); 56 return ( (float)$Usec + (float)$Sec);56 return (float)$Usec + (float)$Sec; 57 57 } 58 58 … … 64 64 65 65 $UnitIndex = 0; 66 while ($Value > 1024)66 while ($Value > 1024) 67 67 { 68 68 $Value = round($Value / 1024, 3); 69 69 $UnitIndex++; 70 70 } 71 return ($Value.' '.$UnitNames[$UnitIndex]);71 return $Value.' '.$UnitNames[$UnitIndex]; 72 72 } 73 73 … … 76 76 $Result = array(); 77 77 $Parts = explode('&', $QueryString); 78 foreach ($Parts as $Part)79 { 80 if ($Part != '')81 { 82 if (!strpos($Part, '=')) $Part .= '=';78 foreach ($Parts as $Part) 79 { 80 if ($Part != '') 81 { 82 if (!strpos($Part, '=')) $Part .= '='; 83 83 $Item = explode('=', $Part); 84 84 $Result[$Item[0]] = $Item[1]; 85 85 } 86 86 } 87 return ($Result);87 return $Result; 88 88 } 89 89 … … 91 91 { 92 92 $Parts = array(); 93 foreach ($QueryStringArray as $Index => $Item)93 foreach ($QueryStringArray as $Index => $Item) 94 94 { 95 95 $Parts[] = $Index.'='.$Item; 96 96 } 97 return (implode('&', $Parts));97 return implode('&', $Parts); 98 98 } 99 99 … … 107 107 //$return = Str_Replace(Array("(",")",".","!",",","\"","'"), "", $return); //odstraní ().!,"' 108 108 //$return = StrToLower($return); // velká písmena nahradí malými. 109 return ($return);109 return $return; 110 110 } 111 111 … … 116 116 $Days = floor($Days - $month * 30); 117 117 $month = $month - $year * 12; 118 return ($year.'r '.$month.'m '.$Days.'d');118 return $year.'r '.$month.'m '.$Days.'d'; 119 119 } 120 120 … … 137 137 138 138 error_reporting(E_ALL ^ E_WARNING); 139 if (($handle = @fopen($url, "r")) === FALSE) return (false);139 if (($handle = @fopen($url, "r")) === FALSE) return false; 140 140 141 141 $data = stream_get_contents($handle); … … 164 164 $data = strip_tags($data); 165 165 166 return ($data);166 return $data; 167 167 } 168 168 … … 178 178 $PageCount = floor($TotalCount / $ItemPerPage) + 1; 179 179 180 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;181 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;182 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;183 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;180 if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 181 if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 182 if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 183 if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 184 184 $CurrentPage = $_SESSION['Page']; 185 185 … … 188 188 189 189 $Result = ''; 190 if ($PageCount > 1)191 { 192 if ($CurrentPage > 0)190 if ($PageCount > 1) 191 { 192 if ($CurrentPage > 0) 193 193 { 194 194 $QueryItems['page'] = 0; … … 199 199 $PagesMax = $PageCount - 1; 200 200 $PagesMin = 0; 201 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;202 if ($PagesMin < ($CurrentPage - $Around))201 if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 202 if ($PagesMin < ($CurrentPage - $Around)) 203 203 { 204 204 $Result.= ' ... '; 205 205 $PagesMin = $CurrentPage - $Around; 206 206 } 207 for ($i = $PagesMin; $i <= $PagesMax; $i++)208 { 209 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';207 for ($i = $PagesMin; $i <= $PagesMax; $i++) 208 { 209 if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 210 210 else { 211 211 $QueryItems['page'] = $i; … … 213 213 } 214 214 } 215 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';216 if ($CurrentPage < ($PageCount - 1))215 if ($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 216 if ($CurrentPage < ($PageCount - 1)) 217 217 { 218 218 $QueryItems['page'] = ($CurrentPage + 1); … … 223 223 } 224 224 $Result = '<div style="text-align: center">'.$Result.'</div>'; 225 return (array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,225 return array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 226 226 'Page' => $CurrentPage, 227 227 'Output' => $Result, 228 ) );228 ); 229 229 } 230 230 … … 236 236 global $OrderDirSQL, $OrderArrowImage, $Config, $System; 237 237 238 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];239 if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage)))238 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 239 if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage))) 240 240 $_SESSION['OrderDir'] = $_GET['OrderDir']; 241 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;242 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;241 if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn; 242 if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder; 243 243 244 244 // Check OrderCol 245 245 $Found = false; 246 foreach ($Columns as $Column)247 { 248 if ($Column['Name'] == $_SESSION['OrderCol'])246 foreach ($Columns as $Column) 247 { 248 if ($Column['Name'] == $_SESSION['OrderCol']) 249 249 { 250 250 $Found = true; … … 252 252 } 253 253 } 254 if ($Found == false)254 if ($Found == false) 255 255 { 256 256 $_SESSION['OrderCol'] = $DefaultColumn; … … 258 258 } 259 259 // Check OrderDir 260 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;260 if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0; 261 261 262 262 $Result = ''; 263 263 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 264 foreach ($Columns as $Index => $Column)264 foreach ($Columns as $Index => $Column) 265 265 { 266 266 $QueryItems['OrderCol'] = $Column['Name']; 267 267 $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir']; 268 if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.268 if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'. 269 269 $System->Link('/images/'.$OrderArrowImage[$_SESSION['OrderDir']]).'" alt="order arrow"/>'; 270 270 else $ArrowImage = ''; 271 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';271 if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>'; 272 272 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>'; 273 273 } 274 return (array(274 return array( 275 275 'SQL' => ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$OrderDirSQL[$_SESSION['OrderDir']], 276 276 'Output' => '<tr>'.$Result.'</tr>', 277 277 'Column' => $_SESSION['OrderCol'], 278 278 'Direction' => $_SESSION['OrderDir'], 279 ) );279 ); 280 280 } 281 281 … … 287 287 $DbResult = $System->Database->select('ClientVersion', '`Id`, `Version`', '`Imported` = 1'); 288 288 $Output .= '<option value=""'; 289 if ($Selected == '')289 if ($Selected == '') 290 290 $Output .= ' selected="selected"'; 291 291 $Output .= '>'.T('None').'</option>'; 292 while ($ClientVersion = $DbResult->fetch_assoc())292 while ($ClientVersion = $DbResult->fetch_assoc()) 293 293 { 294 294 $Output .= '<option value="'.$ClientVersion['Id'].'"'; 295 if ($Selected == $ClientVersion['Id'])295 if ($Selected == $ClientVersion['Id']) 296 296 $Output .= ' selected="selected"'; 297 297 $Output .= '>'.$ClientVersion['Version'].'</option>'; 298 298 } 299 299 $Output .= '</select>'; 300 return ($Output);300 return $Output; 301 301 } 302 302 … … 307 307 $Result = array(); 308 308 $DbResult = $System->Database->query('SELECT * FROM `Language` WHERE `Enabled` = 1'); 309 while ($DbRow = $DbResult->fetch_assoc())309 while ($DbRow = $DbResult->fetch_assoc()) 310 310 $Result[$DbRow['Id']] = $DbRow; 311 return ($Result);311 return $Result; 312 312 } 313 313 … … 316 316 function HumanDate($SQLDateTime) 317 317 { 318 if ($SQLDateTime == '') return(' ');318 if ($SQLDateTime == '') return ' '; 319 319 $DateTimeParts = explode(' ', $SQLDateTime); 320 if ($DateTimeParts[0] != '0000-00-00')320 if ($DateTimeParts[0] != '0000-00-00') 321 321 { 322 322 $DateParts = explode('-', $DateTimeParts[0]); 323 return (($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.($DateParts[0] * 1));324 } else return (' ');323 return ($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.($DateParts[0] * 1); 324 } else return ' '; 325 325 } 326 326 327 327 function HumanDateTime($SQLDateTime) 328 328 { 329 if ($SQLDateTime == '') return(' ');329 if ($SQLDateTime == '') return ' '; 330 330 $DateTimeParts = explode(' ', $SQLDateTime); 331 if ($DateTimeParts[0] != '0000-00-00' and $SQLDateTime <> '')331 if ($DateTimeParts[0] != '0000-00-00' and $SQLDateTime <> '') 332 332 { 333 333 $DateParts = explode('-', $DateTimeParts[0]); 334 334 $Output = ($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.($DateParts[0] * 1); 335 335 } else $Output = ' '; 336 if (count($DateTimeParts) > 1)337 if ($DateTimeParts[1] != '00:00:00')336 if (count($DateTimeParts) > 1) 337 if ($DateTimeParts[1] != '00:00:00') 338 338 { 339 339 $TimeParts = explode(':', $DateTimeParts[1]); 340 340 $Output .= ' '.($TimeParts[0] * 1).':'.($TimeParts[1] * 1).':'.($TimeParts[2] * 1); 341 341 }; 342 return ($Output);342 return $Output; 343 343 } 344 344 … … 347 347 global $System, $Config; 348 348 349 if ($Prev)349 if ($Prev) 350 350 $sql = 'SELECT `ID` FROM `'.$Table.'` AS `item` WHERE '. 351 351 '(`Language` = '.$Config['OriginalLanguage'].') AND NOT EXISTS(SELECT `entry` '. … … 359 359 $DbResult = $System->Database->query($sql); 360 360 $Next = $DbResult->fetch_assoc(); 361 if ($Next)362 { 363 if ($Prev) $Output = '<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> ';361 if ($Next) 362 { 363 if ($Prev) $Output = '<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> '; 364 364 else $Output = '<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Následující '.$Next['ID'].'</a> '; 365 return ('form.php?group='.$GroupId.'&ID='.$Next['ID']);365 return 'form.php?group='.$GroupId.'&ID='.$Next['ID']; 366 366 } 367 367 } … … 371 371 global $System, $BuildNumbers; 372 372 373 if (isset($BuildNumbers[$Version]) == false)373 if (isset($BuildNumbers[$Version]) == false) 374 374 { 375 375 $sql = 'SELECT `BuildNumber` FROM `ClientVersion` WHERE `Version` = "'.$Version.'"'; … … 378 378 $BuildNumbers[$Version] = $DbRow['BuildNumber']; 379 379 } 380 return ($BuildNumbers[$Version]);380 return $BuildNumbers[$Version]; 381 381 } 382 382 … … 386 386 global $System, $VersionsWOW; 387 387 388 if (isset($VersionsWOW[$BuildNumber]) == false)388 if (isset($VersionsWOW[$BuildNumber]) == false) 389 389 { 390 390 $sql = 'SELECT `Version` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"'; … … 393 393 $VersionsWOW[$BuildNumber] = $Version['Version']; 394 394 } 395 return ($VersionsWOW[$BuildNumber]);395 return $VersionsWOW[$BuildNumber]; 396 396 } 397 397 … … 401 401 global $System, $VersionsWOWId; 402 402 403 if (isset($VersionsWOWId[$BuildNumber]) == false)403 if (isset($VersionsWOWId[$BuildNumber]) == false) 404 404 { 405 405 $sql = 'SELECT `Id` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"'; … … 408 408 $VersionsWOWId[$BuildNumber] = $Version['Id']; 409 409 } 410 return ($VersionsWOWId[$BuildNumber]);410 return $VersionsWOWId[$BuildNumber]; 411 411 } 412 412 … … 416 416 $TranslationTree = $System->ModuleManager->Modules['Translation']->GetTranslationTree(); 417 417 418 if (array_key_exists('group', $_GET)) $GroupId = $_GET['group'] * 1;418 if (array_key_exists('group', $_GET)) $GroupId = $_GET['group'] * 1; 419 419 else $GroupId = 1; 420 420 421 if (isset($TranslationTree[$GroupId]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.');422 return ($GroupId);421 if (isset($TranslationTree[$GroupId]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 422 return $GroupId; 423 423 } 424 424 425 425 function LoadCommandLineParameters() 426 426 { 427 if (!array_key_exists('REMOTE_ADDR', $_SERVER))428 { 429 foreach ($_SERVER['argv'] as $Parameter)430 { 431 if (strpos($Parameter, '=') !== false)427 if (!array_key_exists('REMOTE_ADDR', $_SERVER)) 428 { 429 foreach ($_SERVER['argv'] as $Parameter) 430 { 431 if (strpos($Parameter, '=') !== false) 432 432 { 433 433 $Index = substr($Parameter, 0, strpos($Parameter, '=')); … … 444 444 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 445 445 446 if (array_key_exists('Tab', $_GET)) $_SESSION['Tab'] = $_GET['Tab'];447 if (!array_key_exists('Tab', $_SESSION)) $_SESSION['Tab'] = 0;448 if (($_SESSION['Tab'] < 0) or ($_SESSION['Tab'] > (count($Tabs) - 1))) $_SESSION['Tab'] = 0;446 if (array_key_exists('Tab', $_GET)) $_SESSION['Tab'] = $_GET['Tab']; 447 if (!array_key_exists('Tab', $_SESSION)) $_SESSION['Tab'] = 0; 448 if (($_SESSION['Tab'] < 0) or ($_SESSION['Tab'] > (count($Tabs) - 1))) $_SESSION['Tab'] = 0; 449 449 $Output = '<div id="header">'. 450 450 '<ul>'; 451 foreach ($Tabs as $Index => $Tab)451 foreach ($Tabs as $Index => $Tab) 452 452 { 453 453 $QueryItems['Tab'] = $Index; 454 if ($Index == $_SESSION['Tab']) $Selected = ' id="selected"';454 if ($Index == $_SESSION['Tab']) $Selected = ' id="selected"'; 455 455 else $Selected = ''; 456 456 $Output .= '<li'.$Selected.'><a href="?'.SetQueryStringArray($QueryItems).'">'.$Tab.'</a></li>'; 457 457 } 458 458 $Output .= '</ul></div>'; 459 return ($Output);459 return $Output; 460 460 } 461 461 462 462 function CheckBox($Name, $Checked = false, $Id = '', $Class = '', $Disabled = false) 463 463 { 464 if ($Id) $Id = ' id="'.$Id.'"'; else $Id = '';465 if ($Class) $Class = ' class="'.$Class.'"'; else $Class = '';466 if ($Checked) $Checked = ' checked="checked"'; else $Checked = '';467 if ($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = '';468 return ('<input type="checkbox" value="checked" name="'.$Name.'"'.$Checked.$Disabled.$Id.$Class.' />');464 if ($Id) $Id = ' id="'.$Id.'"'; else $Id = ''; 465 if ($Class) $Class = ' class="'.$Class.'"'; else $Class = ''; 466 if ($Checked) $Checked = ' checked="checked"'; else $Checked = ''; 467 if ($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = ''; 468 return '<input type="checkbox" value="checked" name="'.$Name.'"'.$Checked.$Disabled.$Id.$Class.' />'; 469 469 } 470 470 471 471 function RadioButton($Name, $Value, $Checked = false, $OnClick = '', $Disabled = false) 472 472 { 473 if ($Checked) $Checked = ' checked="checked"'; else $Checked = '';474 if ($OnClick != '') $OnClick = ' onclick="'.$OnClick.'"'; else $OnClick = '';475 if ($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = '';476 return ('<input type="radio" name="'.$Name.'" value="'.$Value.'"'.$Checked.$Disabled.$OnClick.'/>');473 if ($Checked) $Checked = ' checked="checked"'; else $Checked = ''; 474 if ($OnClick != '') $OnClick = ' onclick="'.$OnClick.'"'; else $OnClick = ''; 475 if ($Disabled) $Disabled = ' disabled="disabled"'; else $Disabled = ''; 476 return '<input type="radio" name="'.$Name.'" value="'.$Value.'"'.$Checked.$Disabled.$OnClick.'/>'; 477 477 } 478 478 479 479 function SelectOption($Name, $Text, $Selected = false) 480 480 { 481 if ($Selected) $Selected = ' selected="selected"'; else $Selected = '';482 return ('<option value="'.$Name.'"'.$Selected.'>'.$Text.'</option>');481 if ($Selected) $Selected = ' selected="selected"'; else $Selected = ''; 482 return '<option value="'.$Name.'"'.$Selected.'>'.$Text.'</option>'; 483 483 } 484 484 485 485 function DeleteDirectory($dirname) 486 486 { 487 if (is_dir($dirname))487 if (is_dir($dirname)) 488 488 { 489 489 $dir_handle = opendir($dirname); 490 if (!$dir_handle) return(false);491 while ($file = readdir($dir_handle))492 { 493 if (($file != '.') and ($file != '..'))490 if (!$dir_handle) return false; 491 while ($file = readdir($dir_handle)) 492 { 493 if (($file != '.') and ($file != '..')) 494 494 { 495 if (!is_dir($dirname.'/'.$file)) unlink($dirname.'/'.$file);495 if (!is_dir($dirname.'/'.$file)) unlink($dirname.'/'.$file); 496 496 else DeleteDirectory($dirname.'/'.$file); 497 497 } … … 500 500 rmdir($dirname); 501 501 } 502 return (true);502 return true; 503 503 } 504 504 … … 515 515 $TranslationTree = $System->ModuleManager->Modules['Translation']->GetTranslationTree(); 516 516 517 foreach ($TranslationTree as $TableID => $Value)518 { 519 if ($Value['TablePrefix'] == $Table) return $TableID;517 foreach ($TranslationTree as $TableID => $Value) 518 { 519 if ($Value['TablePrefix'] == $Table) return $TableID; 520 520 } 521 521 } … … 540 540 'Dictionary' => 'Text', 541 541 ); 542 return ($TablesColumn);542 return $TablesColumn; 543 543 } 544 544 … … 578 578 $sqlall = ''; 579 579 580 foreach ($TablesColumn as $Table => $Column)580 foreach ($TablesColumn as $Table => $Column) 581 581 { 582 582 $orderinby = ' ORDER BY ID DESC '; … … 588 588 589 589 $where = '(`Language` = '.$Config['OriginalLanguage'].') '; 590 if ($mode == 1) 590 if ($mode == 1) 591 591 { 592 592 $where .= ' AND EXISTS(SELECT 1 FROM `'.$Table. … … 594 594 ') AND (`Sub`.`Entry` = `O`.`Entry`))'; 595 595 } 596 if ($mode == 2) 596 if ($mode == 2) 597 597 { 598 598 $where .= ' AND NOT EXISTS(SELECT 1 FROM `'.$Table. … … 601 601 } 602 602 $where .= ' AND ('; 603 if (array_search('the', $ArrStr)) 603 if (array_search('the', $ArrStr)) 604 604 { 605 605 $where .= '(`O`.`'.$Column.'` LIKE "The %") OR '; … … 607 607 608 608 $SqlOK = false; 609 if (count($ArrStr) > 0) 609 if (count($ArrStr) > 0) 610 610 { 611 611 for ($i = 0; $i < count($ArrStr); $i++) … … 614 614 if ((strlen($ArrStr[$i]) > 3) or ( ((count($ArrStr) < 6) or ($i == 0)) and (strlen($ArrStr[$i]) > 0) ) ) //length 615 615 if ((!$FirstBig) or (ctype_upper(substr($ArrStr[$i], 0, 1))) or (count($ArrStr) < 6) ) //first big 616 if (array_search($ArrStr[$i], $ArrStr) == $i) 616 if (array_search($ArrStr[$i], $ArrStr) == $i) 617 617 { // first in array 618 618 $where .= '(`O`.`'.$Column.'` LIKE "'.addslashes($ArrStr[$i]).'%") OR '; … … 623 623 $where .= ')'; 624 624 } 625 if ($SqlOK) 625 if ($SqlOK) 626 626 { 627 627 //$sql.$where.$groupby.$orderby 628 628 // $buff[] = array($Line['ID'], GetIDbyName($Table), $Line['Orig'], $Line['Tran']); 629 if ($sqlall <> '') 630 { 631 $sqlall .= ' UNION ALL ( '.$sql.$where.$groupby.' )'; 629 if ($sqlall <> '') 630 { 631 $sqlall .= ' UNION ALL ( '.$sql.$where.$groupby.' )'; 632 632 } else { 633 $sqlall .= ' ( '.$sql.$where.$groupby.' )'; 633 $sqlall .= ' ( '.$sql.$where.$groupby.' )'; 634 634 } 635 635 } 636 636 } 637 if ($SqlOK) 637 if ($SqlOK) 638 638 { 639 639 $orderby = ' ORDER BY LENGTH(Orig) DESC '; … … 641 641 $DbResult = $System->Database->query($sqlall.$orderby); 642 642 // echo ($sql.'|'.$where.'|'.$groupby); 643 while ($Line = $DbResult->fetch_assoc())643 while ($Line = $DbResult->fetch_assoc()) 644 644 { 645 645 $buff[] = array($Line['ID'], $Line['GroupId'], $Line['Orig'], $Line['Tran']); … … 652 652 { 653 653 $Pixels = $Width * ($Percent / 100); 654 if ($Pixels > $Width) $Pixels = $Width;655 if ($Text == '') $Text = $Percent;656 657 return ('<div class="progressbar" style="width: '.$Width.'px">'.654 if ($Pixels > $Width) $Pixels = $Width; 655 if ($Text == '') $Text = $Percent; 656 657 return '<div class="progressbar" style="width: '.$Width.'px">'. 658 658 '<div class="bar" style="width: '.$Pixels.'px;"></div>'. 659 659 '<div class="text" style="width: '.$Width.'px">'.$Text.'</div>'. 660 '</div>' );660 '</div>'; 661 661 } 662 662 … … 665 665 $IndexLevel = 100; 666 666 667 if ($XP > 0) $Level = floor(sqrt($XP / $IndexLevel));667 if ($XP > 0) $Level = floor(sqrt($XP / $IndexLevel)); 668 668 else $Level = 0; 669 669 $MinXP = $Level * $Level * $IndexLevel; … … 671 671 $MaxXP = $MaxXP - $MinXP; 672 672 $XP = $XP - $MinXP; 673 return (array('Level' => $Level, 'XP' => $XP, 'MaxXP' => $MaxXP));673 return array('Level' => $Level, 'XP' => $XP, 'MaxXP' => $MaxXP); 674 674 } 675 675 … … 677 677 { 678 678 $Result = $Default; 679 if (array_key_exists($Name, $_GET)) $Result = $_GET[$Name];680 else if (array_key_exists($Name, $_POST)) $Result = $_POST[$Name];681 else if ($Session and array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name];682 if ($Numeric and !is_numeric($Result)) $Result = $Default;683 if ($Session) $_SESSION[$Name] = $Result;684 return ($Result);679 if (array_key_exists($Name, $_GET)) $Result = $_GET[$Name]; 680 else if (array_key_exists($Name, $_POST)) $Result = $_POST[$Name]; 681 else if ($Session and array_key_exists($Name, $_SESSION)) $Result = $_SESSION[$Name]; 682 if ($Numeric and !is_numeric($Result)) $Result = $Default; 683 if ($Session) $_SESSION[$Name] = $Result; 684 return $Result; 685 685 } 686 686 … … 693 693 $Result = ''; 694 694 $I = 0; 695 while ((strpos($Content, 'http://') !== false) or (strpos($Content, 'https://') !== false))696 { 697 if (strpos($Content, 'http://') !== false) $I = strpos($Content, 'http://');698 if (strpos($Content, 'https://') !== false) $I = strpos($Content, 'https://');695 while ((strpos($Content, 'http://') !== false) or (strpos($Content, 'https://') !== false)) 696 { 697 if (strpos($Content, 'http://') !== false) $I = strpos($Content, 'http://'); 698 if (strpos($Content, 'https://') !== false) $I = strpos($Content, 'https://'); 699 699 $Result .= substr($Content, 0, $I); 700 700 $Content = substr($Content, $I); 701 701 $SpacePos = strpos($Content, ' '); 702 if ($SpacePos !== false) $URL = substr($Content, 0, strpos($Content, ' '));702 if ($SpacePos !== false) $URL = substr($Content, 0, strpos($Content, ' ')); 703 703 else $URL = substr($Content, 0); 704 704 … … 707 707 } 708 708 $Result .= $Content; 709 return ($Result);709 return $Result; 710 710 } 711 711 … … 729 729 ); 730 730 731 return ('<div class="message" style="background-color: '.$BackgroundColor[$Type].731 return '<div class="message" style="background-color: '.$BackgroundColor[$Type]. 732 732 ';"><table><tr><td class="icon"><img src="'. 733 733 $System->Link('/images/message/'.$IconName[$Type].'.png').'" alt="'. 734 $IconName[$Type].'"><td>'.$Text.'</td></tr></table></div>' );734 $IconName[$Type].'"><td>'.$Text.'</td></tr></table></div>'; 735 735 } 736 736 737 737 function ProcessURL() 738 738 { 739 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))739 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) 740 740 $PathString = $_SERVER['REDIRECT_QUERY_STRING']; 741 741 else $PathString = ''; 742 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);742 if (substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1); 743 743 $PathItems = explode('/', $PathString); 744 if (strpos(GetRequestURI(), '?') !== false)744 if (strpos(GetRequestURI(), '?') !== false) 745 745 $_SERVER['QUERY_STRING'] = substr(GetRequestURI(), strpos(GetRequestURI(), '?') + 1); 746 746 else $_SERVER['QUERY_STRING'] = ''; 747 747 parse_str($_SERVER['QUERY_STRING'], $_GET); 748 748 // SQL injection hack protection 749 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]);750 return ($PathItems);749 foreach ($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]); 750 return $PathItems; 751 751 } 752 752 … … 757 757 $Output = '<select name="Language">'; 758 758 $DbResult = $System->Database->select('Language', '`Id`, `Name`', '`Enabled` = 1'); 759 while ($Language = $DbResult->fetch_assoc())759 while ($Language = $DbResult->fetch_assoc()) 760 760 { 761 761 $Output .= '<option value="'.$Language['Id'].'"'; 762 if ($Selected == $Language['Id'])762 if ($Selected == $Language['Id']) 763 763 $Output .= ' selected="selected"'; 764 764 $Output .= '>'.T($Language['Name']).'</option>'; 765 765 } 766 766 $Output .= '</select>'; 767 return ($Output);767 return $Output; 768 768 } 769 769 770 770 function GetClientProxyAddresses() 771 771 { 772 if (array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'];772 if (array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR']; 773 773 else $IP = array(); 774 774 } … … 776 776 function GetRemoteAddress() 777 777 { 778 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];778 if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR']; 779 779 else $IP = ''; 780 return ($IP);780 return $IP; 781 781 } 782 782 783 783 function GetRequestURI() 784 784 { 785 if (array_key_exists('REQUEST_URI', $_SERVER)) return($_SERVER['REQUEST_URI']);786 else return ($_SERVER['PHP_SELF']);787 } 785 if (array_key_exists('REQUEST_URI', $_SERVER)) return $_SERVER['REQUEST_URI']; 786 else return $_SERVER['PHP_SELF']; 787 }
Note:
See TracChangeset
for help on using the changeset viewer.