Changeset 507
- Timestamp:
- Feb 15, 2013, 10:12:08 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/action.php
r505 r507 269 269 270 270 $Output = '<h3>Novinky</h3>'.$PageList['Output']; 271 if($User->Licence(LICENCE_ USER)) $Output .= ' <a href="admin.php?action=addnew">Vložit</a>';271 if($User->Licence(LICENCE_ADMIN)) $Output .= ' <a href="admin/?action=addnew">Vložit</a>'; 272 272 $Output .= '<div class="shoutbox">'; 273 273 $DbResult = $System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` ORDER BY `News`.`Time` DESC '.$PageList['SQLLimit']); … … 278 278 } 279 279 280 $GroupId = LoadGroupIdParameter(); 281 $Table = $TranslationTree[$GroupId]['TablePrefix']; 280 if(array_key_exists('group', $_GET)) $GroupId = LoadGroupIdParameter(); 281 else $GroupId = 1; 282 //$Table = $TranslationTree[$GroupId]['TablePrefix']; 282 283 $Action = ''; 283 284 if(array_key_exists('action', $_GET)) $Action = $_GET['action']; -
trunk/dictionary.php
r506 r507 53 53 { 54 54 $_SESSION['language'] = $User->Language; 55 } else $_SESSION['language'] = 1;55 } else $_SESSION['language'] = 2; 56 56 } 57 57 if(array_key_exists('language', $_GET)) $_SESSION['language'] = LoadLanguageIdParameter(); … … 81 81 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 82 82 $Text .= ' '.$Line[$TextItem['Column']]; 83 $Output .= WriteTranslatNames($Text, $mode);83 $Output .= WriteTranslatNames($Text, $mode); 84 84 } 85 85 } -
trunk/img_level.php
r504 r507 111 111 // Build TranslatedCount query 112 112 $TranslatedCount = '('; 113 foreach($TranslationTree as $Group) 113 if(count($TranslationTree) > 0) 114 { 115 foreach($TranslationTree as $Group) 114 116 if($Group['TablePrefix'] != '') 115 117 { … … 117 119 $TranslatedCount .= 'COALESCE('.$Count.', 0) + '; 118 120 } 119 $TranslatedCount = substr($TranslatedCount, 0, -3).')'; 121 $TranslatedCount = substr($TranslatedCount, 0, -3).')'; 122 } else $TranslatedCount = 0; 120 123 121 124 $xp = GetXPFromTranslation($LineUser['ID']); -
trunk/includes/Database.php
r457 r507 2 2 3 3 // Extended database class 4 // Date: 201 0-01-294 // Date: 2011-11-25 5 5 6 class Database extends mysqli 6 7 class DatabaseResult 7 8 { 8 var $HostName = 'localhost'; 9 var $UserName; 10 var $Password; 11 var $Schema; 12 var $Charset = 'utf8'; 13 var $Prefix = ''; 14 var $ShowSQLQuery = false; 15 var $ShowSQLError = false; 16 17 function open() 9 var $PDOStatement; 10 var $num_rows = 0; 11 12 function fetch_assoc() 18 13 { 19 parent::connect($this->HostName, $this->UserName, $this->Password, $this->Schema); 20 $this->charset($this->Charset); 14 return($this->PDOStatement->fetch(PDO::FETCH_ASSOC)); 15 } 16 17 function fetch_array() 18 { 19 return($this->PDOStatement->fetch(PDO::FETCH_BOTH)); 21 20 } 22 21 22 function fetch_row() 23 { 24 return($this->PDOStatement->fetch(PDO::FETCH_NUM)); 25 } 26 } 27 28 class Database 29 { 30 var $Prefix = ''; 31 var $Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()'); 32 var $Type = 'mysql'; // mysql, pgsql 33 var $PDO; 34 var $Error = ''; 35 var $insert_id; 36 var $LastQuery = ''; 37 var $ShowSQLError = false; 38 var $ShowSQLQuery = false; 39 40 function __construct($Host, $User, $Password, $Database) 41 { 42 if($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database; 43 else if($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host; 44 else $ConnectionString = ''; 45 $this->PDO = new PDO($ConnectionString, $User, $Password); 46 } 47 48 function select_db($Database) 49 { 50 $this->query('USE `'.$Database.'`'); 51 } 52 23 53 function query($Query) 24 54 { 25 26 if($this->ShowSQLQuery) 55 $this->LastQuery = $Query; 56 if($this->ShowSQLQuery == true) 57 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>'."\n"); 58 $Result = new DatabaseResult(); 59 $Result->PDOStatement = $this->PDO->query($Query); 60 if($Result->PDOStatement) 27 61 { 28 if(isset($_SERVER['REMOTE_ADDR'])) echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>'); 29 else echo($Query."\n"); 62 $Result->num_rows = $Result->PDOStatement->rowCount(); 63 } else 64 { 65 $this->Error = $this->PDO->errorInfo(); 66 $this->Error = $this->Error[2]; 67 if(($this->Error != '') and ($this->ShowSQLError == true)) 68 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); 30 69 } 31 $Result = parent::query($Query); 32 if(($this->error != '') and ($this->ShowSQLError)) 33 { 34 if(isset($_SERVER['REMOTE_ADDR'])) echo('<div><strong>SQL Error: </strong>'.$this->error.'<br />'.$Query.'</div>'); 35 echo('SQL Error: '.$this->error.' '.$Query."\n"); 36 } 37 70 $this->insert_id = $this->PDO->lastInsertId(); 38 71 return($Result); 39 72 } 40 73 41 74 function select($Table, $What = '*', $Condition = 1) 42 { 75 { 43 76 return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition)); 44 77 } … … 56 89 { 57 90 $Name .= ',`'.$Key.'`'; 91 if(!in_array($Value, $this->Functions)) 92 { 93 if(is_null($Value)) $Value = 'NULL'; 94 else $Value = $this->PDO->quote($Value); 95 } 58 96 $Values .= ','.$Value; 59 97 } … … 61 99 $Values = substr($Values, 1); 62 100 $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 101 $this->insert_id = $this->PDO->lastInsertId(); 63 102 } 64 103 … … 68 107 foreach($Data as $Key => $Value) 69 108 { 109 if(!in_array($Value, $this->Functions)) 110 { 111 if(is_null($Value)) $Value = 'NULL'; 112 else $Value = $this->PDO->quote($Value); 113 } 70 114 $Values .= ', `'.$Key.'`='.$Value; 71 115 } … … 80 124 foreach($Data as $Key => $Value) 81 125 { 126 if(!in_array($Value, $this->Functions)) 127 { 128 if(is_null($Value)) $Value = 'NULL'; 129 else $Value = $this->PDO->quote($Value); 130 } 82 131 $Name .= ',`'.$Key.'`'; 83 132 $Values .= ','.$Value; … … 94 143 $this->query('SET NAMES "'.$Charset.'"'); 95 144 } 145 146 function real_escape_string($Text) 147 { 148 return(addslashes($Text)); 149 } 150 151 } 96 152 97 function TimeToMysqlDateTime($Time) 98 { 99 return(date('Y-m-d H:i:s', $Time)); 100 } 153 function TimeToMysqlDateTime($Time) 154 { 155 if($Time == NULL) return(NULL); 156 else return(date('Y-m-d H:i:s', $Time)); 157 } 101 158 102 function MysqlDateTimeToTime($Time) 103 { 104 $Parts = explode(' ', $Time); 105 $DateParts = explode('-', $Parts[0]); 106 $TimeParts = explode(':', $Parts[1]); 107 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 108 return($Result); 109 } 159 function TimeToMysqlDate($Time) 160 { 161 if($Time == NULL) return(NULL); 162 else return(date('Y-m-d', $Time)); 163 } 110 164 111 function MysqlDateToTime($Time) 112 { 113 return($this->MysqlDateTimeToTime($Time.' 0:0:0')); 114 } 165 function TimeToMysqlTime($Time) 166 { 167 if($Time == NULL) return(NULL); 168 else return(date('H:i:s', $Time)); 169 } 170 171 function MysqlDateTimeToTime($DateTime) 172 { 173 if($DateTime == '') return(0); 174 $Parts = explode(' ', $DateTime); 175 $DateParts = explode('-', $Parts[0]); 176 $TimeParts = explode(':', $Parts[1]); 177 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 178 return($Result); 179 } 180 181 function MysqlDateToTime($Date) 182 { 183 if($Date == '') return(0); 184 return(MysqlDateTimeToTime($Date.' 0:0:0')); 185 } 186 187 function MysqlTimeToTime($Time) 188 { 189 if($Time == '') return(0); 190 return(MysqlDateTimeToTime('0000-00-00 '.$Time)); 115 191 } 116 192 -
trunk/includes/Page.php
r506 r507 189 189 if(isset($RSSChannels)) 190 190 foreach($RSSChannels as $Channel) 191 { 191 192 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 192 193 $System->Link('/rss.php?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; 194 } 193 195 $Output .= '<title>'.$System->Config['Web']['Title'].'</title> 194 196 </head> -
trunk/includes/error.php
r443 r507 1 1 <?php 2 3 include_once('global_function.php');4 2 5 3 function EmptyErrorHandler($Number, $Message, $Filename, $LineNumber, $Variables) … … 84 82 } 85 83 86 set_error_handler('CustomErrorHandler');84 //set_error_handler('CustomErrorHandler'); 87 85 88 86 ?> -
trunk/includes/global.php
r506 r507 1 1 <?php 2 2 3 $ScriptStartTime = GetMicrotime();4 5 if(isset($_SERVER['REMOTE_ADDR'])) session_start();6 7 // SQL injection hack protection8 foreach($_POST as $Index => $Item)9 {10 if(is_array($_POST[$Index]))11 foreach($_POST[$Index] as $Index2 => $Item2) $_POST[$Index][$Index2] = addslashes($Item2);12 else $_POST[$Index] = addslashes($_POST[$Index]);13 }14 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]);15 16 if(file_exists(dirname(__FILE__).'/config.php')) include_once(dirname(__FILE__).'/config.php');17 else die('Nenalezen konfigurační soubor config.php ve složce includes. '.18 'Vytvořte jej zkopírováním vzoru config.sample.php.');19 date_default_timezone_set($Config['Web']['Timezone']);20 3 include_once(dirname(__FILE__).'/Database.php'); 4 include_once(dirname(__FILE__).'/system.php'); 5 include_once(dirname(__FILE__).'/Update.php'); 21 6 include_once(dirname(__FILE__).'/rss.php'); 22 include_once(dirname(__FILE__).'/system.php');23 7 include_once(dirname(__FILE__).'/user.php'); 24 8 include_once(dirname(__FILE__).'/Page.php'); 25 26 $System = new System();27 $System->Init();28 $User = new User($System);29 30 9 include_once(dirname(__FILE__).'/error.php'); 31 10 32 $TranslationTree = GetTranslationTree(); 33 34 LogReferrer(); 11 GlobalInit(); 12 13 function GlobalInit() 14 { 15 global $System, $ScriptStartTime, $TranslationTree, $User, $StopAfterUpdateManager, 16 $UpdateManager, $Config; 17 18 $ScriptStartTime = GetMicrotime(); 19 20 if(isset($_SERVER['REMOTE_ADDR'])) session_start(); 21 22 if(file_exists(dirname(__FILE__).'/config.php')) include_once(dirname(__FILE__).'/config.php'); 23 else die('Nenalezen konfigurační soubor config.php ve složce includes. '. 24 'Vytvořte jej zkopírováním vzoru config.sample.php.'); 25 date_default_timezone_set($Config['Web']['Timezone']); 26 27 $Revision = 506; // Subversion revision 28 $ReleaseTime = '2013-02-15'; 29 30 $System = new System(); 31 $System->Init(); 32 33 // Check database persistence structure 34 $UpdateManager = new UpdateManager(); 35 $UpdateManager->Database = $System->Database; 36 $UpdateManager->Revision = $Revision; 37 if(isset($StopAfterUpdateManager)) return; 38 if(!$UpdateManager->IsInstalled()) die('Systém vyžaduje instalaci databáze.'); 39 if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze.'); 40 41 // SQL injection hack protection 42 foreach($_POST as $Index => $Item) 43 { 44 if(is_array($_POST[$Index])) 45 foreach($_POST[$Index] as $Index2 => $Item2) $_POST[$Index][$Index2] = addslashes($Item2); 46 else $_POST[$Index] = addslashes($_POST[$Index]); 47 } 48 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]); 49 50 $User = new User($System); 51 52 set_error_handler('CustomErrorHandler'); 53 54 // TODO: Global initialized variable should be removed 55 $TranslationTree = GetTranslationTree(); 56 57 LogReferrer(); 58 } 35 59 36 60 $RSSChannels = array( … … 298 322 } 299 323 300 function MysqlDateTimeToTime($Time)301 {302 $Parts = explode(' ', $Time);303 $DateParts = explode('-', $Parts[0]);304 $TimeParts = explode(':', $Parts[1]);305 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);306 return($Result);307 }308 309 324 function GetLanguageList() 310 325 { … … 429 444 430 445 if(array_key_exists('language', $_GET)) $LanguageId = $_GET['language'] * 1; 431 else $LanguageId = 1;446 else $LanguageId = 2; 432 447 433 448 if(isset($LanguageList[$LanguageId]) == false) -
trunk/includes/system.php
r506 r507 24 24 function __construct() 25 25 { 26 $this->Database = new Database();27 26 $this->Config = array(); 28 27 } … … 30 29 function Init() 31 30 { 32 global $Config; 31 global $Config; 32 33 33 $this->Config = $Config; 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']; 34 $this->Database = new Database($this->Config['Database']['Host'], 35 $this->Config['Database']['User'], $this->Config['Database']['Password'], 36 $this->Config['Database']['Database']); 37 $this->Database->charset($this->Config['Database']['Charset']); 39 38 $this->Database->ShowSQLQuery = $this->Config['Web']['ShowSQLQuery']; 40 39 $this->Database->ShowSQLError = $this->Config['Web']['ShowSQLError']; 41 $this->Database->open();42 40 } 43 41 -
trunk/index.php
r505 r507 28 28 $UnionItems = array(); 29 29 $DbResult = $System->Database->query($GroupListQuery); 30 if($DbResult->num_rows > 0) 31 { 30 32 while($DbRow = $DbResult->fetch_assoc()) 31 33 { … … 51 53 } 52 54 $Output .= '</table>'; 55 } 53 56 return($Output); 54 57 } -
trunk/log.php
r504 r507 27 27 $Output .= GenerateRSS(array 28 28 ( 29 'Title' => 'WoWpřeklad',29 'Title' => $Config['Web']['Title'], 30 30 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 31 31 'Description' => $Config['Web']['Title'], … … 44 44 else $WhereType = '1=1'; 45 45 46 $RSSChannels = array(array('Title' => 'Záznamy změn', 'URL' => 'log.php?rss&type='.$_SESSION['type'])); 46 $RSSChannels = array( 47 array('Title' => 'Záznamy změn', 'Channel' => 'log&type='.$_SESSION['type']) 48 ); 47 49 48 50 if($User->Licence(LICENCE_MODERATOR)) … … 88 90 while($Line = $DbResult->fetch_assoc()) 89 91 { 90 $Output .= '<tr><td>'.$Line['Date'].'</td><td><span style="color: '.$Line['LogColor'].'">'.$Line['Text'].'</span></td><td>'.$Line['UserName'].'</td><td>'.$Line['IP'].'</td></tr>';92 //$Output .= '<tr><td>'.$Line['Date'].'</td><td><span style="color: '.$Line['LogColor'].'">'.$Line['Text'].'</span></td><td>'.$Line['UserName'].'</td><td>'.$Line['IP'].'</td></tr>'; 91 93 } 92 94 $Output .= '</table>'. -
trunk/serverlist.php
r504 r507 21 21 22 22 23 $Query = 'SELECT *FROM `ServerList` '.$Order['SQL'].$PageList['SQLLimit'];23 $Query = 'SELECT `URL`, `Name` FROM `ServerList` '.$Order['SQL'].$PageList['SQLLimit']; 24 24 25 25 $DbResult = $System->Database->query($Query); -
trunk/statistic.php
r506 r507 12 12 global $System; 13 13 14 $LanguageId = LoadLanguageIdParameter(); 14 $Output = ''; 15 if(!isset($_SESSION['language'])) 16 { 17 if($User->Licence(LICENCE_USER)) 18 { 19 $_SESSION['language'] = $User->Language; 20 } else $_SESSION['language'] = 2; 21 } 22 if(array_key_exists('language', $_GET)) $_SESSION['language'] = LoadLanguageIdParameter(); 23 15 24 $BuildNumber = GetBuildNumber($_SESSION['StatVersion']); 16 25 … … 18 27 $Query = ''; 19 28 $DbResult = $System->Database->query($GroupListQuery); 29 if($DbResult->num_rows > 0) 30 { 20 31 while($DbRow = $DbResult->fetch_assoc()) 21 32 { 22 33 $Query .= 'SELECT (SELECT COUNT(DISTINCT(`Entry`)) FROM ('. 23 34 ' SELECT `T`.`Id`, `T`.`Entry` FROM `'.$DbRow['TablePrefix'].'` AS `T`'. 24 ' WHERE (`Complete` = 1) AND (`Language`='.$ LanguageId.') AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'.35 ' WHERE (`Complete` = 1) AND (`Language`='.$_SESSION['language'].') AND (`VersionStart` <= '.$BuildNumber.') AND (`VersionEnd` >= '.$BuildNumber.')'. 25 36 ') AS `C1`) AS `Translated`, '. 26 37 '(SELECT COUNT(DISTINCT(`Entry`)) FROM ('. … … 34 45 $DbRow = $DbResult->fetch_row(); 35 46 $PageList = GetPageList($DbRow[0]); 36 $Output = $PageList['Output'];47 $Output .= $PageList['Output']; 37 48 38 49 $Output .= '<table class="BaseTable">'; … … 60 71 $Output .= '<tr><td><strong>Celkem</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, $TotalCount).'</strong></td></tr>'. 61 72 '</table>'; 73 } 62 74 return($Output); 63 75 } -
trunk/team.php
r504 r507 97 97 if(($Count == 0) and ($_POST['Name'] != '')) 98 98 { 99 $System->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`,`Leader`) VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'.$_POST['URL'].'", NOW(), '.$User->Id.')'); 99 $System->Database->query('INSERT INTO `Team` (`Name` ,`Description`, `URL`, `TimeCreate`, `Leader`)'. 100 ' VALUES ("'.trim($_POST['Name']).'", "'.trim($_POST['Description']).'", "'. 101 $_POST['URL'].'", NOW(), '.$User->Id.')'); 100 102 $System->Database->query('UPDATE `User` SET `Team` = '.$System->Database->insert_id.' WHERE `ID` = '.$User->Id); 101 103 $Output .= ShowMessage('Překladatelský tým vytvořen.'); … … 220 222 $Query = ''; 221 223 $DbResult = $System->Database->query($GroupListQuery); 224 if($DbResult->num_rows > 0) 225 { 222 226 while($DbRow = $DbResult->fetch_assoc()) 223 227 { … … 247 251 248 252 $Order = GetOrderTableHeader($TableColumns, 'Name', 0); 249 $Output .= $Order['Output'];253 $Output .= $Order['Output']; 250 254 251 255 $Translated = 0; … … 260 264 $Output .='<tr><td><strong>Celkem</strong></td><td><strong>'.$Translated.'</strong></td><td><strong>'.$Total.'</strong></td><td><strong>'.ProgressBar(150, round($Translated / $Total * 100, 2)).'</strong></td></tr>'; 261 265 $Output .='</table>'; 262 266 } 263 267 $Output .='</fieldset>'; 264 268 } else $Output .=ShowMessage('Tým nenalezen', MESSAGE_CRITICAL);
Note:
See TracChangeset
for help on using the changeset viewer.