Changeset 797 for trunk/includes/global.php
- Timestamp:
- Feb 12, 2014, 9:11:46 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/global.php
r787 r797 6 6 include_once(dirname(__FILE__).'/Update.php'); 7 7 include_once(dirname(__FILE__).'/Page.php'); 8 if(file_exists(dirname(__FILE__).'/config.php')) 8 if(file_exists(dirname(__FILE__).'/config.php')) 9 9 include_once(dirname(__FILE__).'/config.php'); 10 10 include_once(dirname(__FILE__).'/Version.php'); … … 83 83 84 84 $UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB'); 85 85 86 86 function HumanSize($Value) 87 87 { … … 120 120 $Parts[] = $Index.'='.$Item; 121 121 } 122 return(implode('& ', $Parts));122 return(implode('&', $Parts)); 123 123 } 124 124 … … 135 135 } 136 136 137 function getmonthyears($Days) 137 function getmonthyears($Days) 138 138 { 139 139 $month = floor($Days / 30); 140 140 $year = floor($month / 12); 141 141 $Days = floor($Days - $month * 30); 142 $month = $month - $year * 12; 142 $month = $month - $year * 12; 143 143 return($year.'r '.$month.'m '.$Days.'d'); 144 144 } … … 149 149 // $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.'; 150 150 // $text = htmlspecialchars($text); 151 151 152 152 $text = str_replace('$B','$B ',$text); 153 153 $text = urlencode($text); … … 163 163 error_reporting(E_ALL ^ E_WARNING); 164 164 if (($handle = @fopen($url, "r")) === FALSE) return false; 165 165 166 166 $data = stream_get_contents($handle); 167 167 $data = substr($data, strpos($data,'result_box')); … … 178 178 $data = $partbefore.' '.$partafter; 179 179 } 180 180 181 181 $data = utf8_encode($data); 182 182 … … 184 184 $data = str_replace('$b $b','$b$b',$data); 185 185 $data = str_replace('| ','|',$data); 186 187 return $data; 186 187 return $data; 188 188 } 189 189 … … 191 191 { 192 192 global $System; 193 193 194 194 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 195 195 196 196 $ItemPerPage = $System->Config['Web']['ItemsPerPage']; 197 197 $Around = round($System->Config['Web']['VisiblePagingItems'] / 2); 198 198 $Result = ''; 199 199 $PageCount = floor($TotalCount / $ItemPerPage) + 1; 200 200 201 201 if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 202 202 if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; … … 204 204 if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 205 205 $CurrentPage = $_SESSION['Page']; 206 207 206 207 208 208 $Result .= 'Počet položek: <strong>'.$TotalCount.'</strong> Stránky: '; 209 209 … … 211 211 if($PageCount > 1) 212 212 { 213 if($CurrentPage > 0) 213 if($CurrentPage > 0) 214 214 { 215 $QueryItems['page'] = 0; 215 $QueryItems['page'] = 0; 216 216 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> '; 217 217 $QueryItems['page'] = ($CurrentPage - 1); … … 233 233 $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> '; 234 234 } 235 } 235 } 236 236 if($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 237 if($CurrentPage < ($PageCount - 1)) 237 if($CurrentPage < ($PageCount - 1)) 238 238 { 239 239 $QueryItems['page'] = ($CurrentPage + 1); … … 244 244 } 245 245 $Result = '<div style="text-align: center">'.$Result.'</div>'; 246 return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 246 return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 247 247 'Page' => $CurrentPage, 248 248 'Output' => $Result, … … 256 256 { 257 257 global $OrderDirSQL, $OrderArrowImage, $Config, $System; 258 258 259 259 if(array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 260 if(array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage))) 260 if(array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage))) 261 261 $_SESSION['OrderDir'] = $_GET['OrderDir']; 262 262 if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn; 263 if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder; 264 263 if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder; 264 265 265 // Check OrderCol 266 266 $Found = false; … … 269 269 if($Column['Name'] == $_SESSION['OrderCol']) 270 270 { 271 $Found = true; 271 $Found = true; 272 272 break; 273 273 } … … 280 280 // Check OrderDir 281 281 if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0; 282 282 283 283 $Result = ''; 284 284 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); … … 304 304 { 305 305 global $System; 306 306 307 307 $Output = '<select name="ClientVersion">'; 308 308 $DbResult = $System->Database->select('ClientVersion', '`Id`, `Version`', '`Imported` = 1'); 309 $Output .= '<option value=""'; 310 if($Selected == '') 309 $Output .= '<option value=""'; 310 if($Selected == '') 311 311 $Output .= ' selected="selected"'; 312 312 $Output .= '>Žádná</option>'; 313 313 while($ClientVersion = $DbResult->fetch_assoc()) 314 314 { 315 $Output .= '<option value="'.$ClientVersion['Id'].'"'; 316 if($Selected == $ClientVersion['Id']) 315 $Output .= '<option value="'.$ClientVersion['Id'].'"'; 316 if($Selected == $ClientVersion['Id']) 317 317 $Output .= ' selected="selected"'; 318 318 $Output .= '>'.$ClientVersion['Version'].'</option>'; 319 } 319 } 320 320 $Output .= '</select>'; 321 return($Output); 321 return($Output); 322 322 } 323 323 324 324 function GetLanguageList() 325 { 325 { 326 326 global $System; 327 327 328 328 $Result = array(); 329 329 $DbResult = $System->Database->query('SELECT * FROM `Language` WHERE `Enabled` = 1'); … … 334 334 335 335 function GetTranslationTree() 336 { 336 { 337 337 global $System; 338 338 339 339 $Result = array(); 340 340 $DbResult = $System->Database->query('SELECT *, UNIX_TIMESTAMP(`LastImport`) AS `LastImportTime` FROM `Group` ORDER BY `Name`'); … … 381 381 } 382 382 383 function FollowingTran($TextID, $Table, $GroupId, $Prev = false) 384 { 383 function FollowingTran($TextID, $Table, $GroupId, $Prev = false) 384 { 385 385 global $System, $Config; 386 386 387 387 if($Prev) 388 388 $sql = 'SELECT `ID` FROM `'.$Table.'` AS `item` WHERE '. … … 394 394 'FROM `'.$Table.'` AS `sub` WHERE (`sub`.`Language` <> '.$Config['OriginalLanguage'].') '. 395 395 'AND (`sub`.`entry` = `item`.`entry`)) AND `ID` > '.$TextID.' ORDER BY `ID` LIMIT 1'; 396 396 397 397 $DbResult = $System->Database->query($sql); 398 398 $Next = $DbResult->fetch_assoc(); 399 if($Next) 399 if($Next) 400 400 { 401 401 if($Prev) $Output = '<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> '; … … 408 408 { 409 409 global $System, $BuildNumbers; 410 411 if(isset($BuildNumbers[$Version]) == false) 410 411 if(isset($BuildNumbers[$Version]) == false) 412 412 { 413 413 $sql = 'SELECT `BuildNumber` FROM `ClientVersion` WHERE `Version` = "'.$Version.'"'; … … 419 419 } 420 420 421 // TODO: Client version build number should not be used in internal references 421 // TODO: Client version build number should not be used in internal references 422 422 function GetVersionWOW($BuildNumber) 423 423 { 424 424 global $System, $VersionsWOW; 425 426 if(isset($VersionsWOW[$BuildNumber]) == false) 425 426 if(isset($VersionsWOW[$BuildNumber]) == false) 427 427 { 428 428 $sql = 'SELECT `Version` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"'; … … 434 434 } 435 435 436 // TODO: Client version build number should not be used in internal references 436 // TODO: Client version build number should not be used in internal references 437 437 function GetVersionWOWId($BuildNumber) 438 438 { 439 439 global $System, $VersionsWOWId; 440 441 if(isset($VersionsWOWId[$BuildNumber]) == false) 440 441 if(isset($VersionsWOWId[$BuildNumber]) == false) 442 442 { 443 443 $sql = 'SELECT `Id` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"'; … … 452 452 { 453 453 global $TranslationTree; 454 455 if(array_key_exists('group', $_GET)) $GroupId = $_GET['group'] * 1; 454 455 if(array_key_exists('group', $_GET)) $GroupId = $_GET['group'] * 1; 456 456 else $GroupId = 1; 457 457 458 458 if(isset($TranslationTree[$GroupId]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.'); 459 459 return($GroupId); … … 473 473 $_GET[$Index] = $Parameter; 474 474 } 475 } 475 } 476 476 } 477 477 } … … 480 480 { 481 481 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 482 482 483 483 if(array_key_exists('Tab', $_GET)) $_SESSION['Tab'] = $_GET['Tab']; 484 484 if(!array_key_exists('Tab', $_SESSION)) $_SESSION['Tab'] = 0; … … 489 489 { 490 490 $QueryItems['Tab'] = $Index; 491 if($Index == $_SESSION['Tab']) $Selected = ' id="selected"'; 491 if($Index == $_SESSION['Tab']) $Selected = ' id="selected"'; 492 492 else $Selected = ''; 493 493 $Output .= '<li'.$Selected.'><a href="?'.SetQueryStringArray($QueryItems).'">'.$Tab.'</a></li>'; … … 520 520 } 521 521 522 function DeleteDirectory($dirname) 522 function DeleteDirectory($dirname) 523 523 { 524 524 if(is_dir($dirname)) … … 526 526 $dir_handle = opendir($dirname); 527 527 if(!$dir_handle) return(false); 528 while($file = readdir($dir_handle)) 528 while($file = readdir($dir_handle)) 529 529 { 530 530 if(($file != '.') and ($file != '..')) 531 531 { 532 532 if(!is_dir($dirname.'/'.$file)) unlink($dirname.'/'.$file); 533 else DeleteDirectory($dirname.'/'.$file); 533 else DeleteDirectory($dirname.'/'.$file); 534 534 } 535 535 } … … 546 546 } 547 547 548 function GetIDbyName($Table) 548 function GetIDbyName($Table) 549 549 { 550 550 global $TranslationTree; 551 552 foreach($TranslationTree as $TableID => $Value) 551 552 foreach($TranslationTree as $TableID => $Value) 553 553 { 554 554 if($Value['TablePrefix'] == $Table) return $TableID; 555 555 } 556 556 } 557 function GetTranslatNamesArray() { 557 function GetTranslatNamesArray() { 558 558 559 559 $TablesColumn = array … … 576 576 return($TablesColumn); 577 577 } 578 function GetTranslatNames($Text,$mode,$TablesColumn, $FirstBig = True) 578 function GetTranslatNames($Text,$mode,$TablesColumn, $FirstBig = True) 579 579 { 580 580 global $System, $Config; 581 581 582 582 /* $TablesID = array('gameobject' => 5, 583 583 'creature' => 6, … … 609 609 $Text = str_replace('>',' ',$Text); 610 610 $ArrStr = explode(' ', $Text); 611 $sqlall = ''; 612 foreach($TablesColumn as $Table => $Column) 613 { 611 $sqlall = ''; 612 foreach($TablesColumn as $Table => $Column) 613 { 614 614 $orderinby = ' ORDER BY ID DESC '; 615 615 $sql = 'SELECT `ID`, (SELECT CONCAT( \''.GetIDbyName($Table).'\' )) AS `GoupId`,`'.$Column.'` AS Orig, (SELECT `'.$Column.'` FROM `'.$Table.'` AS `T` WHERE '. … … 620 620 if ($mode == 1) $where .= ' AND EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE (`Sub`.`Language` <> '.$Config['OriginalLanguage'].') AND (`Sub`.`Entry` = `O`.`Entry`))'; 621 621 if ($mode == 2) $where .= ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE (`Sub`.`Language` <> '.$Config['OriginalLanguage'].') AND (`Sub`.`Entry` = `O`.`Entry`))'; 622 $where .= ' AND ('; 622 $where .= ' AND ('; 623 623 if (array_search('the' , $ArrStr)) $where .= '(`O`.`'.$Column.'` LIKE "The %") OR '; 624 624 625 625 $SqlOK = false; 626 626 if (count($ArrStr) > 0) { … … 639 639 $where .= ')'; 640 640 } 641 if ($SqlOK) { 641 if ($SqlOK) { 642 642 //$sql.$where.$groupby.$orderby 643 643 // $buff[] = array($Line['ID'], GetIDbyName($Table), $Line['Orig'], $Line['Tran']); … … 646 646 } 647 647 648 } 648 } 649 649 if ($SqlOK) { 650 650 $orderby = ' ORDER BY LENGTH(Orig) DESC '; … … 652 652 $DbResult = $System->Database->query($sqlall.$orderby); 653 653 // echo ($sql.'|'.$where.'|'.$groupby); 654 while($Line = $DbResult->fetch_assoc()) 654 while($Line = $DbResult->fetch_assoc()) 655 655 { 656 656 $buff[] = array($Line['ID'], $Line['GoupId'], $Line['Orig'], $Line['Tran']); … … 665 665 if($Pixels > $Width) $Pixels = $Width; 666 666 if($Text == '') $Text = $Percent; 667 667 668 668 return('<div class="progressbar" style="width: '.$Width.'px">'. 669 '<div class="bar" style="width: '.$Pixels.'px;"></div>'. 670 '<div class="text" style="width: '.$Width.'px">'.$Text.'</div>'. 669 '<div class="bar" style="width: '.$Pixels.'px;"></div>'. 670 '<div class="text" style="width: '.$Width.'px">'.$Text.'</div>'. 671 671 '</div>'); 672 672 } … … 675 675 { 676 676 $IndexLevel = 100; 677 677 678 678 if($XP > 0) $Level = floor(sqrt($XP / $IndexLevel)); 679 679 else $Level = 0; … … 701 701 $Content = str_replace("\n", ' <br/>', $Content); 702 702 $Content = str_replace("\r", '', $Content); 703 704 $Result = ''; 703 704 $Result = ''; 705 705 $I = 0; 706 706 while((strpos($Content, 'http://') !== false) or (strpos($Content, 'https://') !== false)) … … 713 713 if($SpacePos !== false) $URL = substr($Content, 0, strpos($Content, ' ')); 714 714 else $URL = substr($Content, 0); 715 715 716 716 $Result .= '<a href="'.$URL.'">'.$URL.'</a>'; 717 717 $Content = substr($Content, strlen($URL)); … … 728 728 { 729 729 global $System; 730 730 731 731 $IconName = array( 732 MESSAGE_INFORMATION => 'information', 733 MESSAGE_WARNING => 'warning', 732 MESSAGE_INFORMATION => 'information', 733 MESSAGE_WARNING => 'warning', 734 734 MESSAGE_CRITICAL => 'critical' 735 735 ); 736 736 $BackgroundColor = array( 737 MESSAGE_INFORMATION => '#e0e0ff', 738 MESSAGE_WARNING => '#ffffe0', 737 MESSAGE_INFORMATION => '#e0e0ff', 738 MESSAGE_WARNING => '#ffffe0', 739 739 MESSAGE_CRITICAL => '#ffe0e0' 740 740 ); 741 741 742 742 return('<div class="message" style="background-color: '.$BackgroundColor[$Type]. 743 743 ';"><table><tr><td class="icon"><img src="'.
Note:
See TracChangeset
for help on using the changeset viewer.