- Timestamp:
- Oct 2, 2024, 10:31:47 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/ClientVersion/ClientVersion.php
r888 r901 39 39 } 40 40 41 function ShowItem() 41 function ShowItem(): string 42 42 { 43 if (array_key_exists('id', $_GET)) 43 $Id = 0; 44 if (TryGetUrlParameterInt('id', $Id)) 44 45 { 45 46 $YesNo = array('Ne', 'Ano'); 46 $DbResult = $this->System->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='. ($_GET['id']*1));47 $DbResult = $this->System->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$Id); 47 48 if ($DbResult->num_rows > 0) 48 49 { 49 50 $Version = $DbResult->fetch_assoc(); 50 51 51 $Output = '<h3>'.T('Client version').'</h3>';52 $Output .= '<table class="BaseTable">'.53 '<tr><td>'.T('Version').'</td><td>'.$Version['Version'].'</td></tr>'.54 '<tr><td>'.T('More information').'</td><td><a href="http://www.wowwiki.com/Patch_'.$Version['Version'].'">wowwiki.com'.55 '</a></td></tr>'.56 '<tr><td>'.T('Build number').'</td><td>'.$Version['BuildNumber'].'</td></tr>'.57 '<tr><td>'.T('Release date').'</td><td>'.HumanDate($Version['ReleaseDate']).'</td></tr>'.58 '<tr><td>'.T('Title').'</td><td>'.$Version['Title'].'</td></tr>'.59 '<tr><td>'.T('Imported').'</td><td>'.$YesNo[$Version['Imported']].'</td></tr>'.60 '</table>';52 $Output = '<h3>'.T('Client version').'</h3>'; 53 $Output .= '<table class="BaseTable">'. 54 '<tr><td>'.T('Version').'</td><td>'.$Version['Version'].'</td></tr>'. 55 '<tr><td>'.T('More information').'</td><td><a href="http://www.wowwiki.com/Patch_'.$Version['Version'].'">wowwiki.com'. 56 '</a></td></tr>'. 57 '<tr><td>'.T('Build number').'</td><td>'.$Version['BuildNumber'].'</td></tr>'. 58 '<tr><td>'.T('Release date').'</td><td>'.HumanDate($Version['ReleaseDate']).'</td></tr>'. 59 '<tr><td>'.T('Title').'</td><td>'.$Version['Title'].'</td></tr>'. 60 '<tr><td>'.T('Imported').'</td><td>'.$YesNo[$Version['Imported']].'</td></tr>'. 61 '</table>'; 61 62 $Output .= '<div><a href="?">'.T('All versions list').'</a></div>'; 62 63 if ($Version['Imported']) 64 { 63 65 $Output .= '<div><a href="'.$this->System->Link('/progress/?Version='. 64 66 $Version['Version']).'">'.T('Progress').'</a></div>'; 67 } 65 68 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 66 } else $Output = ShowMessage(T('I tem not found'), MESSAGE_CRITICAL);69 } else $Output = ShowMessage(T('Id not valid'), MESSAGE_CRITICAL); 67 70 return $Output; 68 71 } 69 72 70 function ShowList() 73 function ShowList(): string 71 74 { 72 75 $this->Title = T('Game version'); -
trunk/Modules/News/News.php
r893 r901 97 97 $Output .= '<div class="shoutbox">'; 98 98 $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, `News`.`Id`, '. 99 99 '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` ORDER BY `News`.`Time` DESC '.$PageList['SQLLimit']); 100 100 while ($Line = $DbResult->fetch_assoc()) 101 101 { … … 108 108 function ShowItem() 109 109 { 110 if (array_key_exists('i', $_GET)) 110 $Id = 0; 111 if (TryGetUrlParameterInt('i', $Id)) 111 112 { 112 113 $Output = '<h3>'.T('News').'</h3>'; 113 114 $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, `News`.`Id`, '. 114 '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id` = '. ($_GET['i'] * 1));115 '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id` = '.$Id); 115 116 if ($DbResult->num_rows == 1) 116 117 { … … 118 119 $Output .= '<h4>'.$Line['Title'].' ('.HumanDate($Line['Time']).')</h4><div>'.$Line['Text'].' ('.$Line['User'].')</div>'; 119 120 } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL); 120 } else $Output = ShowMessage(T('I tem not found'), MESSAGE_CRITICAL);121 } else $Output = ShowMessage(T('Id not valid'), MESSAGE_CRITICAL); 121 122 $Output .= '<br/><a href="'.$this->System->Link('/news/').'">'.T('All news').'</a>'; 122 123 return $Output; -
trunk/Modules/Translation/Form.php
r900 r901 30 30 else $Action = ''; 31 31 32 if (array_key_exists('ID', $_GET)) 32 $TextID = 0; 33 if (TryGetUrlParameterInt('ID', $TextID)) 33 34 { 34 $TextID = $_GET['ID'] * 1;35 35 $this->ID = $TextID; 36 36 -
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.