- Timestamp:
- Jan 24, 2009, 5:55:02 PM (16 years ago)
- Location:
- branches/2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2/database.php
r8 r40 12 12 { 13 13 $this->LastQuery = $Query; 14 //if(($this->error != '')) 15 { 16 //echo('<strong>Database error:</strong> '); 17 echo($this->error.'<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;"><strong>Query:</strong> '.$Query.'</div>'); 18 //echo('<pre style="font-size: 9px">'); print_r(debug_backtrace()); echo('</pre>'); 19 } 14 20 return(parent::query($Query)); 15 21 } -
branches/2/frontend.php
r9 r40 46 46 } 47 47 48 function ShowText($TranslationGroupId, $Edit) 49 { 50 if($Edit) 51 { 52 // Edit new text 53 $Output = '<strong>Překlad textů:</strong><table class="TranslationTable">'; 54 foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem) 55 { 56 $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td><div><textarea name="GroupItem'.$GroupItem['Id'].'">'.$GroupItem['Text'].'</textarea></div></td></tr>'; 57 } 58 $Output .= '</table>'; 59 } 48 function NewText($TranslationGroupId) 49 { 50 $Output = '<form action="?Action=AddText&GroupId='.$TranslationGroupId.'&Index='.$Index.'" method="post"><strong>Překlad textů:</strong><table class="TranslationTable">'; 51 foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem) 52 { 53 $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td><div><textarea name="GroupItem'.$GroupItem['Id'].'">'.$GroupItem['Text'].'</textarea></div></td></tr>'; 54 } 55 $Output .= '</table><input type="submit" value="Přidat"></from>'; 56 return($Output); 57 } 58 59 function EditText($TranslationGroupId) 60 { 61 $Output = '<form action="?Action=SaveText&GroupId='.$TranslationGroupId.'" method="post"><strong>Překlad textů:</strong><table class="TranslationTable">'; 62 foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem) 63 { 64 $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td><div><textarea name="GroupItem'.$GroupItem['Id'].'">'.$GroupItem['Text'].'</textarea></div></td></tr>'; 65 } 66 $Output .= '</table><input type="submit" value="Uložit"></from>'; 67 return($Output); 68 } 69 70 function ShowText($TranslationGroupId) 71 { 72 $Output = '<strong>Zobrazení textu:</strong><table class="TranslationTable">'; 73 foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem) 74 { 75 $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td>'.$GroupItem['Text'].'</td></tr>'; 76 } 77 $Output .= '</table>'; 78 $Output .= '<a href="?Action=NewText">Překládat</a>'; 79 return($Output); 80 } 81 82 function AddText($TranslationGroupId, $Index) 83 { 84 $Values = array(); 85 foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem) 86 { 87 $Values[] = array($GroupItem['Id'] => $_POST['GroupItem'.$GroupItem['Id']]); 88 } 89 $this->System->Modules['Translation']->AddTranslation($TranslationGroupId, $Index, $Values); 90 } 91 92 function ShowMultipleText($TranslationGroupId, $Index) 93 { 94 $TextList = $this->System->Modules['Translation']->GetMultipleText($TranslationGroupId, $Index); 95 $EnglishText = array_shift($TextList); 96 if(count($TextList) == 0) $Output = 'Tento text zatím nebyl přeložen! <a href="?Action=NewText&GroupId='.$TranslationGroupId.'&Index='.$_GET['Index'].'">Překládat</a>'; 97 else if(count($TextList) == 1) $Output = $this->ShowText($EnglishText['Id']); 60 98 else 61 99 { 62 // Show only one63 $Output = '<strong>Zobrazení textu:</strong><table class="TranslationTable">';64 foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem)65 {66 $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td>'.$GroupItem['Text'].'</td></tr>';67 }68 $Output .= '</table>';69 }70 return($Output);71 }72 73 function ShowMultipleText($TranslationGroupId)74 {75 $TextList = $this->System->Modules['Translation']->GetMultipleText($TranslationGroupId, $_GET['Index']);76 $EnglishText = array_shift($TextList);77 if(count($TextList) == 0) $Output = $this->ShowText($EnglishText['Id'], 1);78 else if(count($TextList) == 1) $Output = $this->ShowText($EnglishText['Id'], 0);79 else {80 100 // Show multiple possibilites 81 101 $Output = '<strong>Více překladů jednoho textu:</strong><table>'. … … 176 196 } 177 197 178 function UserTextList( $GroupId)198 function UserTextList() 179 199 { 180 200 $ItemPerPage = 30; 181 201 if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0; 182 202 $Output = '<strong>Seznam vašich textů:</strong><br/>'; 183 foreach($this->System->Modules['Translation']->GetTextGroupList($GroupId, $this->System->Modules['User']->User['Id'], 1, $Page, $ItemPerPage) as $Translation) 184 { 203 foreach($this->System->Modules['Translation']->GetTextGroupList(0, $this->System->Modules['User']->User['Id'], 1, $Page, $ItemPerPage) as $Translation) 204 { 205 echo('.'); 185 206 if(strlen($Translation['Text']) > 30) $Translation['Text'] = substr($Translation['Text'], 0, 30).'...'; 186 207 $Output .= $Translation['Index'].'. <a href="?Action=TranslationGroupEdit&GroupId='.$Translation['Id'].'">'.$Translation['Text'].'</a><br />'; 187 208 } 188 $Output .= $this->System->PagesList('?Action=TextGroupList&GroupId='.$GroupId.'&Page=', $Page, $this->System->Modules['Translation']->GetTextGroupListCount( $GroupId, 1, 1), $ItemPerPage);209 $Output .= $this->System->PagesList('?Action=TextGroupList&GroupId='.$GroupId.'&Page=', $Page, $this->System->Modules['Translation']->GetTextGroupListCount(0, $this->System->Modules['User']->User['Id'], 1), $ItemPerPage); 189 210 return($Output); 190 211 } … … 215 236 break; 216 237 case 'ShowMultipleText': 217 $Output = $this->ShowMultipleText($_GET['GroupId']); 238 $Output = $this->ShowMultipleText($_GET['GroupId'], $_GET['Index']); 239 break; 240 case 'NewText': 241 $Output = $this->NewText($_GET['GroupId'], $_GET['Index']); 242 break; 243 case 'AddText': 244 $Output = $this->AddText($_GET['GroupId'], $_GET['Index']); 245 break; 246 case 'SaveText': 247 $Output = $this->SaveText($_GET['GroupId'], $_GET['Edit']); 218 248 break; 219 249 case 'TextGroupList': -
branches/2/mangos_import.php
r9 r40 29 29 while($DbRow = $DbResult->fetch_array()) 30 30 { 31 $this->Database-> replace('TextGroup', array('Language' => 1, 'User' => 1, 'Revision' => 1, 'Time' => 'NOW()', 'Group' => $Group['Id'], 'Index' => $DbRow[$Group['MangosTableIndex']]));31 $this->Database->query('REPLACE INTO `TextGroup` (`Language`, `User`, `Revision`, `Time`, `Group`, `Index`) VALUES (1, 2, 1, "NOW()", '.$Group['Id'].', '.$DbRow[$Group['MangosTableIndex']].')'); 32 32 $TranslationGroupId = $this->Database->insert_id; 33 33 foreach($GroupItemList as $GroupItem) … … 51 51 // Import users 52 52 $this->Database->query('TRUNCATE TABLE `User`'); 53 $this->Database->insert('User', array('Name' => 'Anonym', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1)); 54 $AnonymousId = $this->Database->insert_id; 55 $this->Database->insert('User', array('Name' => 'MaNGOS', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1)); 56 $MangosId = $this->Database->insert_id; 57 $this->Database->insert('User', array('Name' => 'WoWEmu', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1)); 58 $WowemuId = $this->Database->insert_id; 59 $this->Database->insert('User', array('Name' => 'Neznámý', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1)); 60 $UnknownUserId = $this->Database->insert_id; 61 $UserIdIncrement = 4; 62 63 // Load old users 53 64 $DbResult = $this->Database->query('SELECT * FROM `quests`.`user`'); 54 65 while($User = $DbResult->fetch_array()) … … 59 70 if($User['gm'] == 1) $Role = 3; 60 71 if($User['gm'] == 2) $Role = 4; 61 $this->Database->insert('User', array('Name' => $User['user'], 'Password' => $User['pass'], 'Email' => $User['Email'], 'TranslationLanguage' => $Language, 'LastLoginTime' => $User['LastLogin'], 'LastIpAddress' => $User['LastIP'], 'Role' => $Role, 'Id' => $User['ID']));72 $this->Database->insert('User', array('Name' => $User['user'], 'Password' => $User['pass'], 'Email' => $User['Email'], 'TranslationLanguage' => $Language, 'LastLoginTime' => $User['LastLogin'], 'LastIpAddress' => $User['LastIP'], 'Role' => $Role, 'Id' => ($User['ID'] + $UserIdIncrement))); 62 73 } 63 $this->Database->insert('User', array('Name' => 'Anonym', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1));64 $this->Database->insert('User', array('Name' => 'MaNGOS', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1));65 $this->Database->insert('User', array('Name' => 'WoWEmu', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1));66 $UnknownUserId = $this->Database->insert_id;67 74 $Output .= 'Uživatelé převedeni<br>'; 68 75 69 76 // Import texts 70 $this->Database->query('CREATE TABLE Transition (OldIndex INT, NewIndex INT, INDEX OldIndex) ENGINE=MEMORY');77 $this->Database->query('CREATE TABLE Transition (OldIndex INT, NewIndex INT, INDEX (OldIndex) ) ENGINE=MEMORY'); 71 78 //$this->Database->query('TRUNCATE TABLE `User`'); 72 79 $DbResult = $this->Database->query('SELECT * FROM `quests`.`quests`'); … … 75 82 if($Quest['Language'] > 0) 76 83 { 77 if($Quest['User'] == 0) $Quest['User'] = $UnknownUserId; 84 if($Quest['User'] == 0) $Quest['User'] = $UnknownUserId; else $Quest['User'] = $Quest['User'] + $UserIdIncrement; 78 85 if($Quest['Take'] > 0) 79 86 { -
branches/2/sql/full.sql
r37 r40 1 1 -- phpMyAdmin SQL Dump 2 -- version 2. 9.1.12 -- version 2.10.2 3 3 -- http://www.phpmyadmin.net 4 4 -- 5 -- Host: localhost 6 -- Generation Time: Oct 13, 2008 at 07:51 PM 7 -- Server version: 5.0.67 8 -- PHP Version: 5.2.0 5 -- Počítač: localhost 6 -- Vygenerováno: Čtvrtek 08. května 2008, 19:59 7 -- Verze MySQL: 5.0.45 8 -- Verze PHP: 5.2.4 9 10 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; 11 9 12 -- 10 -- Datab ase: `wowpreklad`13 -- Databáze: `wowpreklad` 11 14 -- 12 15 … … 14 17 15 18 -- 16 -- Table structure for table `language`19 -- Struktura tabulky `Language` 17 20 -- 18 21 19 CREATE TABLE ` language` (22 CREATE TABLE `Language` ( 20 23 `Id` int(11) NOT NULL auto_increment, 21 24 `Name` varchar(64) collate utf8_czech_ci NOT NULL, … … 26 29 27 30 -- 28 -- Table structure for table `permission`31 -- Struktura tabulky `Permission` 29 32 -- 30 33 31 CREATE TABLE ` permission` (34 CREATE TABLE `Permission` ( 32 35 `Id` int(11) NOT NULL auto_increment, 33 36 `Title` varchar(64) collate utf8_czech_ci NOT NULL, … … 38 41 39 42 -- 40 -- Table structure for table `text`43 -- Struktura tabulky `Text` 41 44 -- 42 45 43 CREATE TABLE ` text` (46 CREATE TABLE `Text` ( 44 47 `Id` int(11) NOT NULL auto_increment, 45 48 `TranslationGroup` int(11) NOT NULL, … … 53 56 54 57 -- 55 -- Table structure for table `textgroup`58 -- Struktura tabulky `TextGroup` 56 59 -- 57 60 58 CREATE TABLE ` textgroup` (61 CREATE TABLE `TextGroup` ( 59 62 `Id` int(11) NOT NULL auto_increment, 60 63 `Group` int(11) NOT NULL, … … 71 74 72 75 -- 73 -- Table structure for table `translation`76 -- Struktura tabulky `Translation` 74 77 -- 75 78 76 CREATE TABLE ` translation` (79 CREATE TABLE `Translation` ( 77 80 `Id` int(11) NOT NULL auto_increment, 78 81 `Group` int(11) NOT NULL, … … 85 88 86 89 -- 87 -- Table structure for table `translationgroup`90 -- Struktura tabulky `TranslationGroup` 88 91 -- 89 92 90 CREATE TABLE ` translationgroup` (93 CREATE TABLE `TranslationGroup` ( 91 94 `Id` int(11) NOT NULL auto_increment, 92 95 `Name` varchar(64) collate utf8_czech_ci NOT NULL, … … 99 102 100 103 -- 101 -- Table structure for table `user`104 -- Struktura tabulky `User` 102 105 -- 103 106 104 CREATE TABLE ` user` (107 CREATE TABLE `User` ( 105 108 `Id` int(11) NOT NULL auto_increment, 106 109 `Name` varchar(64) collate utf8_czech_ci NOT NULL, … … 108 111 `Email` varchar(128) collate utf8_czech_ci NOT NULL, 109 112 `Permission` int(11) NOT NULL, 110 `LastIpAddress` varchar( 255) collate utf8_czech_ci NOT NULL,113 `LastIpAddress` varchar(16) collate utf8_czech_ci NOT NULL, 111 114 `LastLoginTime` datetime NOT NULL, 112 115 `TranslationLanguage` int(11) NOT NULL, 113 116 `FullName` varchar(128) collate utf8_czech_ci NOT NULL, 114 117 PRIMARY KEY (`Id`) 115 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT= 4;118 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=2 ; 116 119 117 120 -- -------------------------------------------------------- 118 121 119 122 -- 120 -- Table structure for table `useronline`123 -- Struktura tabulky `UserOnline` 121 124 -- 122 125 123 CREATE TABLE ` useronline` (126 CREATE TABLE `UserOnline` ( 124 127 `User` int(11) NOT NULL, 125 128 `Time` datetime NOT NULL, 126 129 `SessionId` varchar(255) collate utf8_czech_ci NOT NULL, 127 `IpAddress` varchar( 255) collate utf8_czech_ci NOT NULL,128 UNIQUE KEY `SessionId` (`SessionId`)130 `IpAddress` varchar(16) collate utf8_czech_ci NOT NULL, 131 PRIMARY KEY (`User`) 129 132 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci; 130 133 … … 132 135 133 136 -- 134 -- Table structure for table `vote`137 -- Struktura tabulky `Vote` 135 138 -- 136 139 137 CREATE TABLE ` vote` (140 CREATE TABLE `Vote` ( 138 141 `TranslationGroup` int(11) NOT NULL, 139 142 `User` int(11) NOT NULL, -
branches/2/sql/init_data.sql
r37 r40 1 1 -- phpMyAdmin SQL Dump 2 -- version 2.10.2 2 -- version 2.10.2 3 3 -- http://www.phpmyadmin.net 4 4 -- -
branches/2/translation.php
r9 r40 44 44 { 45 45 $Result = array(); 46 $DbResult = $this->Database->query('SELECT `TextGroup`.*, (SELECT `Text` FROM `Text` WHERE `Text`.`TranslationGroup` = `TextGroup`.`Id` LIMIT 1) as `Text`, (SELECT COUNT(`TextGroup2`.`User`) FROM `TextGroup` AS `TextGroup2` WHERE `TextGroup2`.`Index` = `TextGroup`.`Index` AND `TextGroup2`.`Group` = `TextGroup`.`Group`) as `TextCount` FROM `TextGroup` WHERE `TextGroup`.`Group`='.$GroupId.' AND `TextGroup`.`User`='.$UserId.' AND `TextGroup`.`Language`='.$Language.' LIMIT '.($Page * $ItemPerPage).','.$ItemPerPage); 46 if($GroupId != 0) $GroupCondition = '`TextGroup`.`Group`='.$GroupId.' AND '; else $GroupCondition = ''; 47 $DbResult = $this->Database->query('SELECT `TextGroup`.*, (SELECT `Text` FROM `Text` WHERE `Text`.`TranslationGroup` = `TextGroup`.`Id` LIMIT 1) as `Text`, (SELECT COUNT(`TextGroup2`.`User`) FROM `TextGroup` AS `TextGroup2` WHERE `TextGroup2`.`Index` = `TextGroup`.`Index` AND `TextGroup2`.`Group` = `TextGroup`.`Group`) as `TextCount` FROM `TextGroup` WHERE '.$GroupCondition.'`TextGroup`.`User`='.$UserId.' AND `TextGroup`.`Language`='.$Language.' LIMIT '.($Page * $ItemPerPage).','.$ItemPerPage); 47 48 //echo($this->Database->LastQuery); 48 49 if($DbResult->num_rows > 0) … … 50 51 { 51 52 $Result[] = $DbRow; 53 echo('.'); 52 54 } 53 55 return($Result); … … 57 59 { 58 60 $Result = array(); 59 $DbResult = $this->Database->select('TextGroup', 'COUNT(*)', '`Group`='.$GroupId.' AND `User`='.$UserId.' AND `Language`='.$Language); 61 if($GroupId != 0) $GroupCondition = '`Group`='.$GroupId.' AND '; else $GroupCondition = ''; 62 $DbResult = $this->Database->select('TextGroup', 'COUNT(*)', $GroupCondition.'`User`='.$UserId.' AND `Language`='.$Language); 60 63 //echo($this->Database->LastQuery); 61 64 $DbRow = $DbResult->fetch_array(); … … 75 78 return($Result); 76 79 } 80 81 function AddTranslation($Group, $Index, $TextList) 82 { 83 $this->Database->insert('TextGroup', array('Group' => $Group, 'Index' => $Index, 'Language' => $this->System->Modules['User']->User['Language'], 'User' => $this->System->Modules['User']->User['Id'], 'Time' => 'NOW()', 'Revision' => 1, 'OriginalText' => 0)); 84 $GroupId = $this->Database->insert_id; 85 foreach($TextList as $Index => $Text) 86 { 87 $this->Database->insert('Text', array('TranslationGroup' => $GroupId, 'Text' => $Text, 'GroupItem' => $Index)); 88 } 89 } 77 90 } 78 91 -
branches/2/user.php
r9 r40 20 20 var $DefaultRole = 2; 21 21 var $AnonymousUserId = 1; 22 22 23 23 function Check() 24 24 { … … 31 31 // Refresh time of last access 32 32 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('Time' => 'NOW()')); 33 } else $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $ AnonymousUserId, 'Time' => 'NOW()', 'IpAddress' => (gethostbyaddr(GetRemoteAddress()).' '.GetRemoteAddress())));33 } else $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'Time' => 'NOW()', 'HostAddress' => (gethostbyaddr(GetRemoteAddress()).' '.GetRemoteAddress()))); 34 34 35 35 // Odeber neaktivní uživatele … … 37 37 38 38 // Zkontroluj přihlášení 39 $ Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');40 $Row = $ Query->fetch_array();39 $DbResult = $this->Database->select('UserOnline', 'User', 'SessionId="'.$SID.'"'); 40 $Row = $DbResult->fetch_assoc(); 41 41 if($Row['User'] != $this->AnonymousUserId) 42 42 {
Note:
See TracChangeset
for help on using the changeset viewer.