Changeset 455 for trunk/includes
- Timestamp:
- Apr 13, 2010, 10:03:12 AM (15 years ago)
- Location:
- trunk/includes
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/Database.php
r420 r455 17 17 function open() 18 18 { 19 parent:: __construct($this->HostName, $this->UserName, $this->Password, $this->Schema);19 parent::real_connect($this->HostName, $this->UserName, $this->Password, $this->Schema); 20 20 $this->charset($this->Charset); 21 21 } -
trunk/includes/global.php
r454 r455 15 15 16 16 include_once(dirname(__FILE__).'/config.php'); 17 include_once(dirname(__FILE__).'/error.php'); 18 include_once(dirname(__FILE__).'/databaseconection.php'); 17 include_once(dirname(__FILE__).'/Database.php'); 19 18 include_once(dirname(__FILE__).'/global_function.php'); 20 19 include_once(dirname(__FILE__).'/rss.php'); … … 22 21 include_once(dirname(__FILE__).'/user.php'); 23 22 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 31 23 $System = new System(); 32 24 $System->Init(); 33 25 $User = new User($System); 34 26 27 include_once(dirname(__FILE__).'/error.php'); 28 29 $TranslationTree = GetTranslationTree(); 30 $LanguageList = GetLanguageList(); 31 35 32 function GetMicrotime() 36 33 { … … 41 38 function ShowShoutbox() 42 39 { 43 global $ Database, $Config, $User, $System;40 global $System, $Config, $User, $System; 44 41 45 42 echo('<strong><a href="'.$System->Link('/action.php?action=ShoutBoxView').'">Kecátko:</a></strong>'); … … 47 44 echo(' <a href="'.$System->Link('/action.php?action=shoutbox').'">Vložit</a>'); 48 45 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()) 51 48 echo('<tr><td><strong>'.$Line['User'].'</strong>: '.htmlspecialchars($Line['Text']).'</td></tr>'); 52 49 echo('</table></div>'); … … 55 52 function ShowTopBar() 56 53 { 57 global $Config, $ Database, $User, $System;54 global $Config, $System, $User, $System; 58 55 59 56 echo('<div class="Menu">'); … … 61 58 if($User->Licence(LICENCE_USER)) 62 59 { 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(); 65 62 66 63 //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>'); … … 159 156 function ShowTranslatedMenu() 160 157 { 161 global $TranslationTree, $ Config, $Database, $User, $System;158 global $TranslationTree, $User, $System; 162 159 163 160 echo('<strong>Překladové skupiny:</strong><br /><div id="TranslationMenu">'); … … 182 179 function ShowOnlineUserList() 183 180 { 184 global $ Database, $Moderators, $User;181 global $System, $Moderators, $User; 185 182 186 183 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()) 189 186 { 190 187 if($User->Licence(LICENCE_MODERATOR)) $Name = '<a href="user.php?user='.$DbUser['ID'].'">'.$DbUser['Name'].'</a>'; … … 197 194 function ShowPage() 198 195 { 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'].'"?> 202 199 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 203 200 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cz">'. 204 201 '<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'].'" />'. 206 203 '<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'].'" />'. 208 205 '<meta name="robots" content="all" />'. 209 206 '<link rel="stylesheet" href="'.$System->Link('/style/style.css').'" type="text/css" media="all" />'. … … 213 210 foreach($RSSChannels as $Channel) 214 211 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> 216 213 </head> 217 214 <body>'); … … 268 265 function ShowFooter() 269 266 { 270 global $ Database, $Config, $ScriptStartTime, $PageFooterRequested, $User;267 global $System, $ScriptStartTime, $PageFooterRequested, $User; 271 268 272 269 if(isset($PageFooterRequested)) … … 291 288 292 289 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 Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B <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 Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B <a href="http://validator.w3.org/check?uri='.htmlentities('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'?'.$_SERVER['QUERY_STRING']).'">HTML validator</a></td></tr>'); 294 291 echo('</table>'. 295 292 '</body>'. 296 293 '</html>'); 297 $Database->Disconnect();298 294 $User->Store(); 299 295 } -
trunk/includes/global_function.php
r443 r455 36 36 function GetPageList($TotalCount) 37 37 { 38 global $ Database, $Config;38 global $System; 39 39 40 40 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 41 41 42 $ItemPerPage = $ Config['Web']['ItemsPerPage'];43 $Around = round($ Config['Web']['VisiblePagingItems'] / 2);42 $ItemPerPage = $System->Config['Web']['ItemsPerPage']; 43 $Around = round($System->Config['Web']['VisiblePagingItems'] / 2); 44 44 $Result = ''; 45 45 $PageCount = floor($TotalCount / $ItemPerPage) + 1; … … 218 218 function GetLanguageList() 219 219 { 220 global $ Database;220 global $System; 221 221 222 222 $Result = array(); 223 $DbResult = $ Database->SQLCommand('SELECT * FROM `Language` WHERE `Enabled` = 1');224 while($DbRow = mysql_fetch_assoc($DbResult))223 $DbResult = $System->Database->query('SELECT * FROM `Language` WHERE `Enabled` = 1'); 224 while($DbRow = $DbResult->fetch_assoc()) 225 225 $Result[$DbRow['Id']] = $DbRow; 226 226 return($Result); … … 229 229 function GetTranslationTree() 230 230 { 231 global $ Database;231 global $System; 232 232 233 233 $Result = array(); 234 $DbResult = $ Database->SQLCommand('SELECT *, UNIX_TIMESTAMP(`LastImport`) AS `LastImportTime` FROM `Group` ORDER BY `Name`');235 while($DbRow = mysql_fetch_assoc($DbResult))234 $DbResult = $System->Database->query('SELECT *, UNIX_TIMESTAMP(`LastImport`) AS `LastImportTime` FROM `Group` ORDER BY `Name`'); 235 while($DbRow = $DbResult->fetch_assoc()) 236 236 { 237 237 $DbRow['Items'] = array(); 238 238 $Result[$DbRow['Id']] = $DbRow; 239 239 } 240 $DbResult = $ Database->SQLCommand('SELECT * FROM `GroupItem` ORDER BY `Group`, `Sequence`');241 while($DbRow = mysql_fetch_assoc($DbResult))240 $DbResult = $System->Database->query('SELECT * FROM `GroupItem` ORDER BY `Group`, `Sequence`'); 241 while($DbRow = $DbResult->fetch_assoc()) 242 242 { 243 243 $Result[$DbRow['Group']]['Items'][] = $DbRow; … … 250 250 function WriteLog($Text, $Type) 251 251 { 252 global $ Database, $Config, $User;252 global $System, $User; 253 253 254 254 if(!isset($_SERVER['REMOTE_ADDR'])) $IP = 'Konzole'; 255 255 else $IP = addslashes($_SERVER['REMOTE_ADDR']); 256 256 257 $Database->SelectDatabase($Config['Database']['Database']); 257 if(isset($User->Id)) $UserId = $User->Id; 258 else $UserId = 0; 258 259 $Query = 'INSERT INTO `Log` ( `User` , `Type` , `Text` , `Date` , `IP` ) 259 VALUES ('.$User ->Id.', '.$Type.', "'.addslashes($Text).'", NOW(), "'.$IP.'")';260 $ Database->SQLCommand($Query);260 VALUES ('.$UserId.', '.$Type.', "'.addslashes($Text).'", NOW(), "'.$IP.'")'; 261 $System->Database->query($Query); 261 262 } 262 263 … … 273 274 function FollowingTran($TextID, $Table, $GroupId, $Prev = false) 274 275 { 275 global $ Database;276 global $System; 276 277 277 278 if($Prev) … … 283 284 } 284 285 285 $Next = mysql_fetch_assoc($Database->SQLCommand($sql)); 286 $DbResult = $System->Database->query($sql); 287 $Next = $DbResult->fetch_assoc(); 286 288 if($Next) 287 289 { 288 290 if($Prev) echo('<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Předcházející '.$Next['ID'].'</a> '); 289 291 else echo('<a href="form.php?group='.$GroupId.'&ID='.$Next['ID'].'">Následující '.$Next['ID'].'</a> '); 290 return 'form.php?group='.$GroupId.'&ID='.$Next['ID'];292 return('form.php?group='.$GroupId.'&ID='.$Next['ID']); 291 293 } 292 294 } … … 294 296 function GetBuildNumber($Version) 295 297 { 296 global $ Database, $BuildNumbers;298 global $System, $BuildNumbers; 297 299 298 300 if(isset($BuildNumbers[$Version]) == false) 299 301 { 300 302 $sql = 'SELECT `BuildNumber` FROM `ClientVersion` WHERE `Version` = "'.$Version.'"'; 301 $DbRow = mysql_fetch_assoc($Database->SQLCommand($sql)); 303 $DbResult = $System->Database->query($sql); 304 $DbRow = $DbResult->fetch_assoc(); 302 305 $BuildNumbers[$Version] = $DbRow['BuildNumber']; 303 306 } … … 307 310 function GetVersionWOW($BuildNumber) 308 311 { 309 global $ Database, $VersionsWOW;312 global $System, $VersionsWOW; 310 313 311 314 if(isset($VersionsWOW[$BuildNumber]) == false) 312 315 { 313 316 $sql = 'SELECT `Version` FROM `ClientVersion` WHERE `BuildNumber` = "'.$BuildNumber.'"'; 314 $Version = mysql_fetch_assoc($Database->SQLCommand($sql)); 317 $DbResult = $System->Database->query($sql); 318 $Version = $DbResult->fetch_assoc(); 315 319 $VersionsWOW[$BuildNumber] = $Version['Version']; 316 320 } … … 442 446 } 443 447 444 445 448 function GetTranslatNames($Text,$mode,$TablesColumn) 446 449 { 447 global $ Database;450 global $System; 448 451 449 452 /* $TablesID = array('gameobject' => 5, … … 482 485 } 483 486 } 484 $where = substr($where, 0,strlen($where)-4);487 $where = substr($where, 0, strlen($where) - 4); 485 488 $where .= ')'; 486 489 if ($SqlOK) { 487 $ ID = $Database->SQLCommand($sql.$where.$groupby);490 $DbResult = $System->Database->query($sql.$where.$groupby); 488 491 // echo ($sql.'|'.$where.'|'.$groupby); 489 while($Line = mysql_fetch_assoc($ID)) { 490 $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']); 492 while($Line = $DbResult->fetch_assoc()) 493 { 494 $buff[] = array($Line['ID'], GetIDbyName($Table), $Line[$Column], $Line['Tran']); 491 495 } 492 496 } -
trunk/includes/system.php
r426 r455 1 1 <?php 2 2 3 //include_once('database.php');3 include_once('Database.php'); 4 4 5 5 class Module … … 22 22 var $Config; 23 23 24 function __construct() 25 { 26 $this->Database = new Database(); 27 $this->Config = array(); 28 } 29 24 30 function Init() 25 31 { 26 32 include('config.php'); 27 33 $this->Config = $Config; 28 $this->Database = new mysqli($this->Config['Database']['Host'], $this->Config['Database']['User'], $this->Config['Database']['Password'], $this->Config['Database']['Database']); 29 $this->Database->query('SET NAMES '.$this->Config['Database']['Charset']); 34 $this->Database->HostName = $this->Config['Database']['Host']; 35 $this->Database->UserName = $this->Config['Database']['User']; 36 $this->Database->Password = $this->Config['Database']['Password']; 37 $this->Database->Schema = $this->Config['Database']['Database']; 38 $this->Database->Charset = $this->Config['Database']['Charset']; 39 $this->Database->ShowSQLQuery = $this->Config['Web']['ShowSQLQuery']; 40 $this->Database->ShowSQLError = $this->Config['Web']['ShowSQLError']; 41 $this->Database->open(); 30 42 } 31 43
Note:
See TracChangeset
for help on using the changeset viewer.