Changeset 901 for trunk/includes
- Timestamp:
- Oct 2, 2024, 10:31:47 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/Global.php
r894 r901 30 30 function ShowPageClass($Page) 31 31 { 32 global $ TempPageContent, $System;32 global $System; 33 33 34 34 $System->Pages['temporary-page'] = get_class($Page); … … 38 38 } 39 39 40 function ShowPage( $Content)40 function ShowPage(string $Content): void 41 41 { 42 42 global $TempPageContent, $System; … … 50 50 } 51 51 52 function GetMicrotime() 52 function GetMicrotime(): float 53 53 { 54 54 list($Usec, $Sec) = explode(' ', microtime()); … … 58 58 $UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB'); 59 59 60 function HumanSize( $Value)60 function HumanSize(float $Value): string 61 61 { 62 62 global $UnitNames; … … 71 71 } 72 72 73 function GetQueryStringArray( $QueryString)73 function GetQueryStringArray(string $QueryString): array 74 74 { 75 75 $Result = array(); … … 87 87 } 88 88 89 function SetQueryStringArray( $QueryStringArray)89 function SetQueryStringArray(array $QueryStringArray): string 90 90 { 91 91 $Parts = array(); … … 97 97 } 98 98 99 function utf2ascii( $text)99 function utf2ascii(string $text): string 100 100 { 101 101 $return = Str_Replace( … … 109 109 } 110 110 111 function getmonthyears($Days)112 { 113 $ month = floor($Days / 30);114 $ year = floor($month / 12);115 $Days = floor($Days - $ month * 30);116 $ month = $month - $year * 12;117 return $ year.'r '.$month.'m '.$Days.'d';118 } 119 120 function GetTranslateGoogle($System, $text,$withouttitle = false)111 function GetMonthYears(int $Days): string 112 { 113 $Month = floor($Days / 30); 114 $Year = floor($Month / 12); 115 $Days = floor($Days - $Month * 30); 116 $Month = $Month - $Year * 12; 117 return $Year.'r '.$Month.'m '.$Days.'d'; 118 } 119 120 function GetTranslateGoogle($System, string $text, bool $withouttitle = false) 121 121 { 122 122 // $text = 'Balthule\'s letter is dire. This Cult of the Dark Strand is a thorn in my side that must be removed. I have been dealing with some of the Dark Strand scum northeast of here at Ordil\'Aran. One of their number possesses a soul gem that I believe holds the secret to the cult\'s power.$b$bBring it to me, and I will be able to decipher the secrets held within.'; … … 165 165 } 166 166 167 function GetPageList( $TotalCount)167 function GetPageList(int $TotalCount): array 168 168 { 169 169 global $System; … … 182 182 $CurrentPage = $_SESSION['Page']; 183 183 184 185 184 $Result .= 'Počet položek: <strong>'.$TotalCount.'</strong> Stránky: '; 186 185 … … 230 229 $OrderArrowImage = array('sort_asc.png', 'sort_desc.png'); 231 230 232 function GetOrderTableHeader( $Columns, $DefaultColumn, $DefaultOrder = 0)233 { 234 global $OrderDirSQL, $OrderArrowImage, $ Config, $System;231 function GetOrderTableHeader(array $Columns, string $DefaultColumn, int $DefaultOrder = 0): array 232 { 233 global $OrderDirSQL, $OrderArrowImage, $System; 235 234 236 235 if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; … … 278 277 } 279 278 280 function ClientVersionSelection( $Selected)279 function ClientVersionSelection(string $Selected): string 281 280 { 282 281 global $System; … … 299 298 } 300 299 301 function GetLanguageList() 300 function GetLanguageList(): array 302 301 { 303 302 global $System; … … 312 311 $Moderators = array('Překladatel', 'Moderátor', 'Administrátor'); 313 312 314 function HumanDate( $SQLDateTime)313 function HumanDate(string $SQLDateTime): string 315 314 { 316 315 if ($SQLDateTime == '') return ' '; … … 323 322 } 324 323 325 function HumanDateTime( $SQLDateTime)324 function HumanDateTime(string $SQLDateTime): string 326 325 { 327 326 if ($SQLDateTime == '') return ' '; … … 365 364 } 366 365 367 function GetBuildNumber( $Version)366 function GetBuildNumber(string $Version): int 368 367 { 369 368 global $System, $BuildNumbers; 370 369 371 if (isset($BuildNumbers[$Version]) == false) 372 { 373 $sql = 'SELECT `BuildNumber` FROM `ClientVersion` WHERE `Version` = "'.$Version.'"'; 374 $DbResult = $System->Database->query($sql); 375 $DbRow = $DbResult->fetch_assoc(); 376 $BuildNumbers[$Version] = $DbRow['BuildNumber']; 370 if (!isset($BuildNumbers)) $BuildNumbers = array(); 371 if (!array_key_exists($Version, $BuildNumbers)) 372 { 373 $DbResult = $System->Database->select('ClientVersion', 'BuildNumber', '`Version` = "'.$Version.'"'); 374 if ($DbResult->num_rows == 1) 375 { 376 $DbRow = $DbResult->fetch_assoc(); 377 $BuildNumbers[$Version] = $DbRow['BuildNumber']; 378 } else return 0; 377 379 } 378 380 return $BuildNumbers[$Version]; … … 380 382 381 383 // TODO: Client version build number should not be used in internal references 382 function GetVersionWOW( $BuildNumber)384 function GetVersionWOW(int $BuildNumber): string 383 385 { 384 386 global $System, $VersionsWOW; 385 387 386 if (isset($VersionsWOW[$BuildNumber]) == false) 387 { 388 $sql = 'SELECT `Version` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"'; 389 $DbResult = $System->Database->query($sql); 390 $Version = $DbResult->fetch_assoc(); 391 $VersionsWOW[$BuildNumber] = $Version['Version']; 388 if (!isset($VersionsWOW)) $VersionsWOW = array(); 389 if (!array_key_exists($BuildNumber, $VersionsWOW)) 390 { 391 $DbResult = $System->Database->select('ClientVersion', 'Version', '`BuildNumber` = "'.$BuildNumber.'"'); 392 if ($DbResult->num_rows == 1) 393 { 394 $Version = $DbResult->fetch_assoc(); 395 $VersionsWOW[$BuildNumber] = $Version['Version']; 396 } else return ''; 392 397 } 393 398 return $VersionsWOW[$BuildNumber]; … … 414 419 $TranslationTree = ModuleTranslation::Cast($System->ModuleManager->GetModule('Translation'))->GetTranslationTree(); 415 420 416 if (array_key_exists('group', $_GET)) $GroupId = $_GET['group'] * 1; 417 else $GroupId = 1; 418 419 if (isset($TranslationTree[$GroupId]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 420 return $GroupId; 421 } 422 423 function LoadCommandLineParameters() 421 $GroupId = 0; 422 if (TryGetUrlParameterInt('group', $GroupId)) 423 { 424 if (isset($TranslationTree[$GroupId]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 425 return $GroupId; 426 } 427 ErrorMessage('Group not valid.'); 428 } 429 430 function LoadCommandLineParameters(): void 424 431 { 425 432 if (!array_key_exists('REMOTE_ADDR', $_SERVER)) … … 438 445 } 439 446 440 function ShowTabs( $Tabs)447 function ShowTabs(array $Tabs): string 441 448 { 442 449 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); … … 481 488 } 482 489 483 function DeleteDirectory( $dirname)490 function DeleteDirectory(string $dirname): bool 484 491 { 485 492 if (is_dir($dirname)) … … 501 508 } 502 509 503 function ErrorMessage( $Text)510 function ErrorMessage(string $Text): void 504 511 { 505 512 ShowPage($Text); … … 507 514 } 508 515 509 function GetIDbyName( $Table)516 function GetIDbyName(string $Table) 510 517 { 511 518 global $System; … … 519 526 } 520 527 521 function GetTranslatNamesArray() 528 function GetTranslatNamesArray(): array 522 529 { 523 530 $TablesColumn = array … … 659 666 } 660 667 661 function GetLevelMinMax( $XP)668 function GetLevelMinMax(int $XP): array 662 669 { 663 670 $IndexLevel = 100; … … 672 679 } 673 680 674 function GetParameter( $Name, $Default = '', $Numeric = false, $Session = false)681 function GetParameter(string $Name, string $Default = '', bool $Numeric = false, bool $Session = false): string 675 682 { 676 683 $Result = $Default; … … 683 690 } 684 691 685 function MakeActiveLinks( $Content)692 function MakeActiveLinks(string $Content): string 686 693 { 687 694 $Content = htmlspecialchars($Content); … … 712 719 define('MESSAGE_INFORMATION', 2); 713 720 714 function ShowMessage( $Text,$Type = MESSAGE_INFORMATION)721 function ShowMessage(string $Text, int $Type = MESSAGE_INFORMATION) 715 722 { 716 723 global $System; … … 733 740 } 734 741 735 function ProcessURL() 742 function ProcessURL(): array 736 743 { 737 744 if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER)) … … 840 847 return implode('/', $Result); 841 848 } 849 850 function TryGetUrlParameterInt(string $Name, int &$Value): bool 851 { 852 if (array_key_exists($Name, $_GET)) 853 { 854 if (is_numeric($_GET[$Name])) 855 { 856 $Value = $_GET[$Name] * 1; 857 return true; 858 } 859 return false; 860 } 861 return false; 862 }
Note:
See TracChangeset
for help on using the changeset viewer.