Ignore:
Timestamp:
Apr 13, 2010, 10:03:12 AM (14 years ago)
Author:
george
Message:
  • Upraveno: Přístup k databázi převeden na objektový pomocí rozšířené PHP třídy mysqli. Při práci s databází použít globální objekt $System a jeho prvek $Database ($System->Database->query("SELECT ...");.
  • Upraveno: Při vkládání nové zprávy do Kecátka neprovádět přesměrování, ale rovnou zobrazit výpis. U některých překladatelů toto způsobovalo opakované vložení zprávy.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/global.php

    r454 r455  
    1515
    1616include_once(dirname(__FILE__).'/config.php');
    17 include_once(dirname(__FILE__).'/error.php');
    18 include_once(dirname(__FILE__).'/databaseconection.php');
     17include_once(dirname(__FILE__).'/Database.php');
    1918include_once(dirname(__FILE__).'/global_function.php');
    2019include_once(dirname(__FILE__).'/rss.php');
     
    2221include_once(dirname(__FILE__).'/user.php');
    2322
    24 $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password']);
    25 $Database->SQLCommand('SET NAMES '.$Config['Database']['Charset']);
    26 $Database->SelectDatabase($Config['Database']['Database']);   
    27 
    28 $TranslationTree = GetTranslationTree();
    29 $LanguageList = GetLanguageList();
    30 
    3123$System = new System();
    3224$System->Init();
    3325$User = new User($System);
    3426
     27include_once(dirname(__FILE__).'/error.php');
     28
     29$TranslationTree = GetTranslationTree();
     30$LanguageList = GetLanguageList();
     31
    3532function GetMicrotime()
    3633{
     
    4138function ShowShoutbox()
    4239{
    43   global $Database, $Config, $User, $System;
     40  global $System, $Config, $User, $System;
    4441 
    4542  echo('<strong><a href="'.$System->Link('/action.php?action=ShoutBoxView').'">Kecátko:</a></strong>');
     
    4744    echo(' <a href="'.$System->Link('/action.php?action=shoutbox').'">Vložit</a>');
    4845  echo('<div class="box"><table>');
    49   $ID = $Database->SQLCommand('SELECT * FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 30');
    50   while($Line = mysql_fetch_assoc($ID))
     46  $DbResult = $System->Database->query('SELECT * FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 30');
     47  while($Line = $DbResult->fetch_assoc())
    5148    echo('<tr><td><strong>'.$Line['User'].'</strong>: '.htmlspecialchars($Line['Text']).'</td></tr>');
    5249  echo('</table></div>');
     
    5552function ShowTopBar()
    5653{
    57   global $Config, $Database, $User, $System;
     54  global $Config, $System, $User, $System;
    5855 
    5956  echo('<div class="Menu">');
     
    6158  if($User->Licence(LICENCE_USER))
    6259  {
    63     $DbResult = $Database->SQLCommand('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$User->Team);
    64     $Team = mysql_fetch_assoc($DbResult);
     60    $DbResult = $System->Database->query('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$User->Team);
     61    $Team = $DbResult->fetch_assoc();
    6562
    6663    //echo('<span class="MenuItem">Moje překlady: <a href="">Dokončené</a> <a href="">Rozpracované</a> <a href="">Exporty</a> Tým: <a href="">'.$Team['name'].'</a></span>');
     
    159156function ShowTranslatedMenu()
    160157{
    161   global $TranslationTree, $Config, $Database, $User, $System;
     158  global $TranslationTree, $User, $System;
    162159
    163160  echo('<strong>Překladové skupiny:</strong><br /><div id="TranslationMenu">');
     
    182179function ShowOnlineUserList()
    183180{
    184   global $Database, $Moderators, $User;
     181  global $System, $Moderators, $User;
    185182 
    186183  echo('Online překladatelé:<br />');
    187   $ID = $Database->SQLCommand('SELECT `Name`, `GM`, `ID` FROM `User` WHERE `LastLogin` >= NOW() - 300 AND ((`LastLogout` < `LastLogin`) OR (ISNULL(`LastLogout`)))');
    188   while($DbUser = mysql_fetch_assoc($ID))
     184  $DbResult = $System->Database->query('SELECT `Name`, `GM`, `ID` FROM `User` WHERE `LastLogin` >= NOW() - 300 AND ((`LastLogout` < `LastLogin`) OR (ISNULL(`LastLogout`)))');
     185  while($DbUser = $DbResult->fetch_assoc())
    189186  {
    190187    if($User->Licence(LICENCE_MODERATOR)) $Name = '<a href="user.php?user='.$DbUser['ID'].'">'.$DbUser['Name'].'</a>';
     
    197194function ShowPage()
    198195{
    199   global $User, $Config, $Database, $RSSChannels, $PageFooterRequested, $System; 
    200  
    201   echo('<?xml version="1.0" encoding="'.$Config['Web']['Charset'].'"?>
     196  global $User, $RSSChannels, $PageFooterRequested, $System; 
     197 
     198  echo('<?xml version="1.0" encoding="'.$System->Config['Web']['Charset'].'"?>
    202199  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    203200<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cz">'.
    204201'<head>'.
    205 '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$Config['Web']['Charset'].'" />'.
     202'<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$System->Config['Web']['Charset'].'" />'.
    206203'<meta name="keywords" content="wow, quest, questy, questů, preklad, mangos, překlad, překládání, přeložený, přeložení, čeština, world of warcraft, open source, free, addon" />'.
    207 '<meta name="description" content="'.$Config['Web']['Title'].'" />'.
     204'<meta name="description" content="'.$System->Config['Web']['Title'].'" />'.
    208205'<meta name="robots" content="all" />'.
    209206'<link rel="stylesheet" href="'.$System->Link('/style/style.css').'" type="text/css" media="all" />'.
     
    213210  foreach($RSSChannels as $Channel)
    214211    echo(' <link rel="alternate" title="'.$Channel['Title'].'" href="'.$Channel['URL'].'" type="application/rss+xml" />');
    215   echo('<title>'.$Config['Web']['Title'].'</title>
     212  echo('<title>'.$System->Config['Web']['Title'].'</title>
    216213</head>
    217214<body>');
     
    268265function ShowFooter()
    269266{
    270   global $Database, $Config, $ScriptStartTime, $PageFooterRequested, $User;
     267  global $System, $ScriptStartTime, $PageFooterRequested, $User;
    271268
    272269  if(isset($PageFooterRequested))
     
    291288
    292289    echo('</td></tr>');
    293     if($Config['Web']['ShowRuntimeInfo'] == true) echo('<tr><td colspan="3" style="text-align: center;">Doba generování: '.$ScriptGenerateDuration.' s / '.ini_get('max_execution_time').' s &nbsp;&nbsp; Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B &nbsp;&nbsp; <a href="http://validator.w3.org/check?uri='.htmlentities('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'?'.$_SERVER['QUERY_STRING']).'">HTML validator</a></td></tr>');
     290    if($System->Config['Web']['ShowRuntimeInfo'] == true) echo('<tr><td colspan="3" style="text-align: center;">Doba generování: '.$ScriptGenerateDuration.' s / '.ini_get('max_execution_time').' s &nbsp;&nbsp; Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B &nbsp;&nbsp; <a href="http://validator.w3.org/check?uri='.htmlentities('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'?'.$_SERVER['QUERY_STRING']).'">HTML validator</a></td></tr>');
    294291    echo('</table>'.
    295292      '</body>'.
    296293      '</html>');
    297     $Database->Disconnect();
    298294    $User->Store();
    299295  }
Note: See TracChangeset for help on using the changeset viewer.