Ignore:
Timestamp:
Feb 12, 2014, 9:11:46 PM (11 years ago)
Author:
chronos
Message:
  • Fixed: HTML syntax in user profile.
  • Fixed: Use correct HTML entity symbol "&" in query handling function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/global.php

    r787 r797  
    66include_once(dirname(__FILE__).'/Update.php');
    77include_once(dirname(__FILE__).'/Page.php');
    8 if(file_exists(dirname(__FILE__).'/config.php')) 
     8if(file_exists(dirname(__FILE__).'/config.php'))
    99  include_once(dirname(__FILE__).'/config.php');
    1010include_once(dirname(__FILE__).'/Version.php');
     
    8383
    8484$UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB');
    85  
     85
    8686function HumanSize($Value)
    8787{
     
    120120    $Parts[] = $Index.'='.$Item;
    121121  }
    122   return(implode('&', $Parts));
     122  return(implode('&', $Parts));
    123123}
    124124
     
    135135}
    136136
    137 function getmonthyears($Days) 
     137function getmonthyears($Days)
    138138{
    139139  $month = floor($Days / 30);
    140140  $year = floor($month / 12);
    141141  $Days = floor($Days - $month * 30);
    142   $month = $month - $year * 12; 
     142  $month = $month - $year * 12;
    143143  return($year.'r '.$month.'m '.$Days.'d');
    144144}
     
    149149//  $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.';
    150150 // $text = htmlspecialchars($text);
    151  
     151
    152152  $text = str_replace('$B','$B ',$text);
    153153  $text = urlencode($text);
     
    163163  error_reporting(E_ALL ^ E_WARNING);
    164164  if (($handle = @fopen($url, "r")) === FALSE) return false;
    165    
     165
    166166  $data = stream_get_contents($handle);
    167167  $data = substr($data, strpos($data,'result_box'));
     
    178178    $data = $partbefore.' '.$partafter;
    179179  }
    180  
     180
    181181  $data = utf8_encode($data);
    182182
     
    184184  $data = str_replace('$b $b','$b$b',$data);
    185185  $data = str_replace('| ','|',$data);
    186  
    187   return $data; 
     186
     187  return $data;
    188188}
    189189
     
    191191{
    192192  global $System;
    193    
     193
    194194  $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    195  
     195
    196196  $ItemPerPage = $System->Config['Web']['ItemsPerPage'];
    197197  $Around = round($System->Config['Web']['VisiblePagingItems'] / 2);
    198198  $Result = '';
    199199  $PageCount = floor($TotalCount / $ItemPerPage) + 1;
    200  
     200
    201201  if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
    202202  if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
     
    204204  if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
    205205  $CurrentPage = $_SESSION['Page'];
    206  
    207        
     206
     207
    208208  $Result .= 'Počet položek: <strong>'.$TotalCount.'</strong> &nbsp; Stránky: ';
    209209
     
    211211  if($PageCount > 1)
    212212  {
    213     if($CurrentPage > 0) 
     213    if($CurrentPage > 0)
    214214    {
    215       $QueryItems['page'] = 0;     
     215      $QueryItems['page'] = 0;
    216216      $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;&lt;</a> ';
    217217      $QueryItems['page'] = ($CurrentPage - 1);
     
    233233       $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> ';
    234234      }
    235     } 
     235    }
    236236    if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
    237     if($CurrentPage < ($PageCount - 1)) 
     237    if($CurrentPage < ($PageCount - 1))
    238238    {
    239239      $QueryItems['page'] = ($CurrentPage + 1);
     
    244244  }
    245245  $Result = '<div style="text-align: center">'.$Result.'</div>';
    246   return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage, 
     246  return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,
    247247    'Page' => $CurrentPage,
    248248    'Output' => $Result,
     
    256256{
    257257  global $OrderDirSQL, $OrderArrowImage, $Config, $System;
    258  
     258
    259259  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)))
    261261        $_SESSION['OrderDir'] = $_GET['OrderDir'];
    262262  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
    265265  // Check OrderCol
    266266  $Found = false;
     
    269269    if($Column['Name'] == $_SESSION['OrderCol'])
    270270    {
    271       $Found = true;   
     271      $Found = true;
    272272      break;
    273273    }
     
    280280  // Check OrderDir
    281281  if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;
    282  
     282
    283283  $Result = '';
    284284  $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
     
    304304{
    305305  global $System;
    306  
     306
    307307  $Output = '<select name="ClientVersion">';
    308308  $DbResult = $System->Database->select('ClientVersion', '`Id`, `Version`', '`Imported` = 1');
    309   $Output .= '<option value=""'; 
    310   if($Selected == '') 
     309  $Output .= '<option value=""';
     310  if($Selected == '')
    311311    $Output .= ' selected="selected"';
    312312  $Output .= '>Žádná</option>';
    313313  while($ClientVersion = $DbResult->fetch_assoc())
    314314  {
    315     $Output .= '<option value="'.$ClientVersion['Id'].'"'; 
    316     if($Selected == $ClientVersion['Id']) 
     315    $Output .= '<option value="'.$ClientVersion['Id'].'"';
     316    if($Selected == $ClientVersion['Id'])
    317317      $Output .= ' selected="selected"';
    318318    $Output .= '>'.$ClientVersion['Version'].'</option>';
    319   }   
     319  }
    320320  $Output .= '</select>';
    321   return($Output);   
     321  return($Output);
    322322}
    323323
    324324function GetLanguageList()
    325 { 
     325{
    326326  global $System;
    327  
     327
    328328  $Result = array();
    329329  $DbResult = $System->Database->query('SELECT * FROM `Language` WHERE `Enabled` = 1');
     
    334334
    335335function GetTranslationTree()
    336 { 
     336{
    337337  global $System;
    338  
     338
    339339  $Result = array();
    340340  $DbResult = $System->Database->query('SELECT *, UNIX_TIMESTAMP(`LastImport`) AS `LastImportTime` FROM `Group` ORDER BY `Name`');
     
    381381}
    382382
    383 function FollowingTran($TextID, $Table, $GroupId, $Prev = false) 
    384 { 
     383function FollowingTran($TextID, $Table, $GroupId, $Prev = false)
     384{
    385385  global $System, $Config;
    386  
     386
    387387  if($Prev)
    388388    $sql = 'SELECT `ID` FROM `'.$Table.'` AS `item` WHERE '.
     
    394394      'FROM `'.$Table.'` AS `sub` WHERE (`sub`.`Language` <> '.$Config['OriginalLanguage'].') '.
    395395      'AND (`sub`.`entry` = `item`.`entry`)) AND `ID` > '.$TextID.' ORDER BY `ID` LIMIT 1';
    396  
     396
    397397  $DbResult = $System->Database->query($sql);
    398398  $Next = $DbResult->fetch_assoc();
    399   if($Next) 
     399  if($Next)
    400400  {
    401401    if($Prev) $Output = '<a href="form.php?group='.$GroupId.'&amp;ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> ';
     
    408408{
    409409  global $System, $BuildNumbers;
    410  
    411   if(isset($BuildNumbers[$Version]) == false) 
     410
     411  if(isset($BuildNumbers[$Version]) == false)
    412412  {
    413413    $sql = 'SELECT `BuildNumber` FROM `ClientVersion` WHERE `Version` = "'.$Version.'"';
     
    419419}
    420420
    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
    422422function GetVersionWOW($BuildNumber)
    423423{
    424424  global $System, $VersionsWOW;
    425  
    426   if(isset($VersionsWOW[$BuildNumber]) == false) 
     425
     426  if(isset($VersionsWOW[$BuildNumber]) == false)
    427427  {
    428428    $sql = 'SELECT `Version` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"';
     
    434434}
    435435
    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
    437437function GetVersionWOWId($BuildNumber)
    438438{
    439439  global $System, $VersionsWOWId;
    440  
    441   if(isset($VersionsWOWId[$BuildNumber]) == false) 
     440
     441  if(isset($VersionsWOWId[$BuildNumber]) == false)
    442442  {
    443443    $sql = 'SELECT `Id` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"';
     
    452452{
    453453  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;
    456456    else $GroupId = 1;
    457  
     457
    458458  if(isset($TranslationTree[$GroupId]) == false) ErrorMessage('Překladová skupina dle zadaného Id neexistuje.');
    459459  return($GroupId);
     
    473473        $_GET[$Index] = $Parameter;
    474474      }
    475     } 
     475    }
    476476  }
    477477}
     
    480480{
    481481  $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    482  
     482
    483483  if(array_key_exists('Tab', $_GET)) $_SESSION['Tab'] = $_GET['Tab'];
    484484  if(!array_key_exists('Tab', $_SESSION)) $_SESSION['Tab'] = 0;
     
    489489  {
    490490    $QueryItems['Tab'] = $Index;
    491     if($Index == $_SESSION['Tab']) $Selected = ' id="selected"'; 
     491    if($Index == $_SESSION['Tab']) $Selected = ' id="selected"';
    492492      else $Selected = '';
    493493    $Output .= '<li'.$Selected.'><a href="?'.SetQueryStringArray($QueryItems).'">'.$Tab.'</a></li>';
     
    520520}
    521521
    522 function DeleteDirectory($dirname) 
     522function DeleteDirectory($dirname)
    523523{
    524524  if(is_dir($dirname))
     
    526526    $dir_handle = opendir($dirname);
    527527    if(!$dir_handle) return(false);
    528     while($file = readdir($dir_handle)) 
     528    while($file = readdir($dir_handle))
    529529    {
    530530      if(($file != '.') and ($file != '..'))
    531531      {
    532532        if(!is_dir($dirname.'/'.$file)) unlink($dirname.'/'.$file);
    533           else DeleteDirectory($dirname.'/'.$file);   
     533          else DeleteDirectory($dirname.'/'.$file);
    534534      }
    535535    }
     
    546546}
    547547
    548 function GetIDbyName($Table) 
     548function GetIDbyName($Table)
    549549{
    550550  global $TranslationTree;
    551  
    552   foreach($TranslationTree as $TableID => $Value) 
     551
     552  foreach($TranslationTree as $TableID => $Value)
    553553  {
    554554    if($Value['TablePrefix'] == $Table) return $TableID;
    555555  }
    556556}
    557 function GetTranslatNamesArray() { 
     557function GetTranslatNamesArray() {
    558558
    559559$TablesColumn = array
     
    576576  return($TablesColumn);
    577577}
    578 function GetTranslatNames($Text,$mode,$TablesColumn, $FirstBig = True) 
     578function GetTranslatNames($Text,$mode,$TablesColumn, $FirstBig = True)
    579579{
    580580  global $System, $Config;
    581  
     581
    582582 /* $TablesID = array('gameobject' => 5,
    583583  'creature' => 6,
     
    609609    $Text = str_replace('>',' ',$Text);
    610610    $ArrStr = explode(' ', $Text);
    611     $sqlall = ''; 
    612   foreach($TablesColumn as $Table => $Column) 
    613   { 
     611    $sqlall = '';
     612  foreach($TablesColumn as $Table => $Column)
     613  {
    614614    $orderinby = ' ORDER BY ID DESC ';
    615615    $sql = 'SELECT `ID`, (SELECT CONCAT(  \''.GetIDbyName($Table).'\' )) AS  `GoupId`,`'.$Column.'` AS Orig, (SELECT `'.$Column.'` FROM `'.$Table.'` AS `T` WHERE '.
     
    620620    if ($mode == 1) $where .= ' AND EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE (`Sub`.`Language` <> '.$Config['OriginalLanguage'].') AND (`Sub`.`Entry` = `O`.`Entry`))';
    621621    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 (';
    623623    if (array_search('the' , $ArrStr)) $where .= '(`O`.`'.$Column.'` LIKE "The %") OR ';
    624    
     624
    625625    $SqlOK = false;
    626626    if (count($ArrStr) > 0) {
     
    639639      $where .= ')';
    640640    }
    641       if ($SqlOK) {                                                       
     641      if ($SqlOK) {
    642642        //$sql.$where.$groupby.$orderby
    643643//          $buff[] = array($Line['ID'], GetIDbyName($Table), $Line['Orig'], $Line['Tran']);
     
    646646      }
    647647
    648   }   
     648  }
    649649    if ($SqlOK) {
    650650        $orderby = ' ORDER BY LENGTH(Orig) DESC ';
     
    652652        $DbResult = $System->Database->query($sqlall.$orderby);
    653653    //  echo ($sql.'|'.$where.'|'.$groupby);
    654         while($Line = $DbResult->fetch_assoc()) 
     654        while($Line = $DbResult->fetch_assoc())
    655655        {
    656656          $buff[] = array($Line['ID'], $Line['GoupId'], $Line['Orig'], $Line['Tran']);
     
    665665  if($Pixels > $Width) $Pixels = $Width;
    666666  if($Text == '') $Text = $Percent;
    667  
     667
    668668  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>'.
    671671    '</div>');
    672672}
     
    675675{
    676676  $IndexLevel = 100;
    677  
     677
    678678  if($XP > 0) $Level = floor(sqrt($XP / $IndexLevel));
    679679    else $Level = 0;
     
    701701  $Content = str_replace("\n", ' <br/>', $Content);
    702702  $Content = str_replace("\r", '', $Content);
    703  
    704   $Result = ''; 
     703
     704  $Result = '';
    705705  $I = 0;
    706706  while((strpos($Content, 'http://') !== false) or (strpos($Content, 'https://') !== false))
     
    713713    if($SpacePos !== false) $URL = substr($Content, 0, strpos($Content, ' '));
    714714      else $URL = substr($Content, 0);
    715    
     715
    716716    $Result .= '<a href="'.$URL.'">'.$URL.'</a>';
    717717    $Content = substr($Content, strlen($URL));
     
    728728{
    729729  global $System;
    730  
     730
    731731  $IconName = array(
    732           MESSAGE_INFORMATION => 'information', 
    733     MESSAGE_WARNING => 'warning', 
     732          MESSAGE_INFORMATION => 'information',
     733    MESSAGE_WARNING => 'warning',
    734734    MESSAGE_CRITICAL => 'critical'
    735735  );
    736736  $BackgroundColor = array(
    737         MESSAGE_INFORMATION => '#e0e0ff', 
    738     MESSAGE_WARNING => '#ffffe0', 
     737        MESSAGE_INFORMATION => '#e0e0ff',
     738    MESSAGE_WARNING => '#ffffe0',
    739739        MESSAGE_CRITICAL => '#ffe0e0'
    740740  );
    741  
     741
    742742  return('<div class="message" style="background-color: '.$BackgroundColor[$Type].
    743743        ';"><table><tr><td class="icon"><img src="'.
Note: See TracChangeset for help on using the changeset viewer.