Changeset 292
- Timestamp:
- Dec 27, 2009, 8:19:32 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/export/export.php
r291 r292 60 60 } 61 61 62 if( $_SESSION['UserID'] != '')62 if(isset($_SESSION) and ($_SESSION['UserID'] != '')) 63 63 { 64 64 $DbResult = $this->Database->query('SELECT user FROM `user` WHERE ID='.$_SESSION['UserID']); … … 234 234 $this->LoadFilters(); 235 235 236 $TempDir = $this->Config['Web']['TempFolder'].$_SESSION['User'].'/dbc/'; 237 if(!file_exists($TempDir)) mkdir($TempDir, 0777, true); 238 239 240 foreach($TranslationTree as $Group) 241 if(in_array($Group['Id'], $Setting['groups']) and ($Group['DBCFileName'] != '')) 242 { 236 $DbResult = $this->Database->query('SELECT `group`.* FROM `ExportGroup` JOIN `group` ON `group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `group`.`DBCFileName` != ""'); 237 while($Group = $DbResult->fetch_assoc()) 238 { 243 239 echo($Group['Name'].'... '); 244 240 $DBCFile = new DBCFile(); 245 $DBCFile->OpenFile('../source/'.$ Setting['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc', GetDBCColumns($Setting['Version'],$Group['DBCFileName']));241 $DBCFile->OpenFile('../source/'.$this->ClientVersion['Version'].'/dbc/'.$Group['DBCFileName'].'.dbc', GetDBCColumns($Setting['Version'], $Group['DBCFileName'])); 246 242 $DBCFile2 = new DBCFile(); 247 $DBCFile2->CreateFile($ TempDir.$Group['DBCFileName'].'.dbc', GetDBCColumns($Setting['Version'],$Group['DBCFileName']));243 $DBCFile2->CreateFile($this->TempDir.$Group['DBCFileName'].'.dbc', GetDBCColumns($this->ClientVersion['Version'], $Group['DBCFileName'])); 248 244 $Count = $DBCFile->GetRecordCount(); 249 245 //if($Group['DBCFileName'] == 'Spell') $Count = 1000; … … 253 249 { 254 250 $Line = $DBCFile->GetLine($I); 255 $Query = 'SELECT * FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND '.$ WhereLang.' AND '.$WhereUsers.' AND (entry='.$Line[0].') AND VersionStart <= '.GetBuildNumber($Setting['Version']).' AND VersionEnd >= '.GetBuildNumber($Setting['Version']).' ORDER BY FIELD(User, '.$SelectedUsers.')) AS T GROUP BY T.entry';256 $DbResult = $this->Database->query($Query);257 if($DbResult ->num_rows > 0)258 { 259 $DbRow = $DbResult ->fetch_assoc();251 $Query = 'SELECT * FROM (SELECT * FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND '.$this->WhereLang.' AND '.$this->WhereUsers.' AND (entry='.$Line[0].') AND VersionStart <= '.$this->ClientVersion['BuildNumber'].' AND VersionEnd >= '.$this->ClientVersion['BuildNumber'].' ORDER BY FIELD(User, '.$this->SelectedUsers.')) AS T GROUP BY T.entry'; 252 $DbResult2 = $this->Database->query($Query); 253 if($DbResult2->num_rows > 0) 254 { 255 $DbRow = $DbResult2->fetch_assoc(); 260 256 // if($Setting['Diacritics'] != 1) $Buffer = utf2ascii($Buffer); 261 257 262 foreach($ Group['Items'] as $GroupItem)263 if(GetDBCColumnIndex($ Setting['Version'], $Group['DBCFileName'], $GroupItem['Column']) != '')264 $Line[GetDBCColumnIndex($this-> Export['ClientVersion'], $Group['DBCFileName'],$GroupItem['Column'])] = $DbRow[$GroupItem['Column']];258 foreach($TranslationTree[$Group['Id']]['Items'] as $GroupItem) 259 if(GetDBCColumnIndex($this->ClientVersion['Version'], $Group['DBCFileName'], $GroupItem['Column']) != '') 260 $Line[GetDBCColumnIndex($this->ClientVersion['Version'], $Group['DBCFileName'],$GroupItem['Column'])] = $DbRow[$GroupItem['Column']]; 265 261 //print_r($Line); 266 262 } … … 279 275 $this->LoadFilters(); 280 276 281 $TempDir = $this->Config['Web']['TempFolder'].$_SESSION['User'].'/lua/';282 if(!file_exists($TempDir)) mkdir($TempDir, 0777, true);283 284 277 $DbResult = $this->Database->query('SELECT `group`.* FROM `ExportGroup` JOIN `group` ON `group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `group`.`LuaFileName` != ""'); 285 278 while($Group = $DbResult->fetch_assoc()) … … 289 282 $File->OpenFile('../source/'.$this->ClientVersion['Version'].'/lua/'.$Group['LuaFileName'].'.lua'); 290 283 $File2 = new FileStream(); 291 $File2->CreateFile($ TempDir.''.$Group['LuaFileName'].'.lua');284 $File2->CreateFile($this->TempDir.''.$Group['LuaFileName'].'.lua'); 292 285 293 286 while(!$File->EOF()) -
trunk/export/export_output.php
r291 r292 195 195 if($ExportTask['TimeFinish'] > $ExportTask['TimeStart']) 196 196 { 197 echo('<strong>Soubor ke stažení: <a href=" ">CzWoW.zip</a></strong><br/>');197 echo('<strong>Soubor ke stažení: <a href="../tmp/Export/'.$ExportTask['Export'].'/CzWoW_DBC.zip">CzWoW_DBC.zip</a></strong><br/>'); 198 198 } else echo('<strong>Soubor čeká na zpracování ve frontě.</strong><br/>'); 199 199 } -
trunk/img_level.php
r142 r292 2 2 3 3 require_once('includes/global.php'); 4 if (array_key_exists('nothide',$_GET)) 5 $nothide = true; 6 else 7 $nothide = false; 8 if ($nothide) ShowPage(); 4 5 if (array_key_exists('nothide', $_GET)) $nothide = true; 6 else $nothide = false; 7 if($nothide) ShowPage(); 9 8 10 9 $FontFile = 'images/FRIZQT__.ttf'; 11 $TranslationTree = GetTranslationTree();12 10 13 // nastavení11 // Nastavení 14 12 $xp_from_word = 1; 15 13 $index_level = 100; 16 14 $from_diakrit = 3; //zvýšené xp za slovo s diakritikou 17 15 18 function CheckDiakrit($word) { 19 $result = false; 20 $Diakrit = Array("á","č","ď","é","ě","í","ľ","ň","ó","ř","š","ť","ú", 21 "ů","ý","ž","Á","Č","Ď","É","Ě","Í","Ľ","Ň","Ó","Ř","Š","Ť","Ú","Ů","Ý","Ž"); 22 for ($i=0;$i<count($Diakrit);$i=$i+1) { 23 if (strpos($word,$Diakrit[$i]) <> false) { 24 $result = true; 25 } 26 } 27 return $result; 16 function CheckDiakrit($word) 17 { 18 $result = false; 19 $Diakrit = Array("á","č","ď","é","ě","í","ľ","ň","ó","ř","š","ť","ú", 20 "ů","ý","ž","Á","Č","Ď","É","Ě","Í","Ľ","Ň","Ó","Ř","Š","Ť","Ú","Ů","Ý","Ž"); 21 for($i = 0; $i < count($Diakrit); $i = $i + 1) 22 { 23 if(strpos($word, $Diakrit[$i]) <> false) 24 { 25 $result = true; 26 } 28 27 } 28 return $result; 29 } 29 30 30 function CreateImg($user,$xp) { 31 global $index_level,$FontFile; 32 33 if ($xp > 0) { 34 $level = sqrt ($xp / $index_level); 35 $level = substr($level,0,strpos($level,'.')); 36 } else { 37 $level = 0; 38 } 39 $xp_min = ($level) * ($level) * ($index_level); 40 $xp_max = ($level+1)*($level+1)* ($index_level); 41 $xp_max = $xp_max-$xp_min; 42 $xp = $xp-$xp_min; 43 44 if($xp_max > 0) $Percent = ( $xp / $xp_max) * 100; else $Percent = 0; 45 $Percent = substr($Percent, 0, 5); 31 function CreateImg($prefix, $user, $xp) 32 { 33 global $index_level, $FontFile; 34 35 if($xp > 0) 36 { 37 $level = sqrt ($xp / $index_level); 38 $level = substr($level, 0, strpos($level, '.')); 39 } else $level = 0; 40 $xp_min = $level * $level * $index_level; 41 $xp_max = ($level + 1) * ($level + 1) * $index_level; 42 $xp_max = $xp_max - $xp_min; 43 $xp = $xp - $xp_min; 44 45 if($xp_max > 0) $Percent = ( $xp / $xp_max) * 100; 46 else $Percent = 0; 47 $Percent = substr($Percent, 0, 5); 46 48 47 $PercentBar = $Percent * 2.5; 48 $Image = ImageCreateTrueColor(250, 15); 49 $Color1 = imagecolorallocate($Image, 214, 214, 214); 50 $Color2 = imagecolorallocate($Image, 239, 131, 166); 51 $Color3 = imagecolorallocate($Image, 225, 0, 0); 52 imagefilledrectangle($Image, 0, 0, 250, 15, $Color1); 53 imagefilledrectangle($Image, 0, 0, $PercentBar, 59, $Color2); 54 ImageTTFText($Image, 11, 0, 10, 12, $Color3, $FontFile, $level.' Level'); 55 ImageTTFText($Image, 8, 0, 80, 12, $Color3, $FontFile, $xp.'/'.$xp_max.' xp '.$user); 56 57 if (file_exists('tmp/teams/') == false) mkdir ('tmp/teams/'); 58 if (file_exists('tmp/'.$user.'/') == false) mkdir ('tmp/'.$user.'/'); 59 ImagePNG($Image,'tmp/'.$user.'/level.png'); 49 $PercentBar = $Percent * 2.5; 50 $Image = ImageCreateTrueColor(250, 15); 51 $Color1 = imagecolorallocate($Image, 214, 214, 214); 52 $Color2 = imagecolorallocate($Image, 239, 131, 166); 53 $Color3 = imagecolorallocate($Image, 225, 0, 0); 54 imagefilledrectangle($Image, 0, 0, 250, 15, $Color1); 55 imagefilledrectangle($Image, 0, 0, $PercentBar, 59, $Color2); 56 ImageTTFText($Image, 11, 0, 10, 12, $Color3, $FontFile, $level.' Level'); 57 ImageTTFText($Image, 8, 0, 80, 12, $Color3, $FontFile, $xp.'/'.$xp_max.' xp '.$user); 58 59 if(!file_exists('tmp/'.$prefix.'/')) mkdir('tmp/'.$prefix.'/'); 60 if(!file_exists('tmp/'.$prefix.'/'.$user.'/')) mkdir('tmp/'.$prefix.'/'.$user.'/'); 61 ImagePNG($Image, 'tmp/'.$prefix.'/'.$user.'/level.png'); 62 } 63 64 function GetXPFromTranslation($user_ID) 65 { 66 global $Database, $TranslationTree, $xp_from_word, $from_diakrit; 67 $xp = 0; 68 69 foreach($TranslationTree as $Group) 70 { //překladové skupiny 71 if($Group['TablePrefix'] != '') 72 { 73 $groupby = 'GROUP BY'; 74 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) 75 { 76 if($groupby == 'GROUP BY') $groupby .= ' '.$TextItem['Column']; 77 else $groupby .= ', '.$TextItem['Column']; 78 } 79 $IDtran = $Database->SQLCommand('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE User = '.$user_ID.' AND Complete = 1 '.$groupby); 80 while($Line = mysql_fetch_array($IDtran)) 81 { //jednotlivé překlady 82 $LineComparison = mysql_fetch_assoc($Database->SQLCommand('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE ID = '.$Line['Take'])); 83 $xp_translation = 0; //mazání posledního 84 $translated = true; 85 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) 86 { //jednotlivé položky překladu 87 if(($Line[$TextItem['Column']] <> $LineComparison[$TextItem['Column']]) and (strlen($Line[$TextItem['Column']]) > (strlen($LineComparison[$TextItem['Column']]) * 0.5))) 88 { //zda není stejný, zda je aspoň dlouhý jako polovina 89 $TextArr = explode(' ',$Line[$TextItem['Column']]); 90 for ($i = 0; $i < count($TextArr); $i = $i + 1) 91 { //pro každé slovo 92 if(CheckDiakrit($TextArr[$i])) $indikator = $from_diakrit; 93 else $indikator = 1; 94 $xp_translation = $xp_translation + ($indikator * $xp_from_word); 95 } 96 } else 97 { 98 if (($Line[$TextItem['Column']] == $LineComparison[$TextItem['Column']]) and ('0' == $LineComparison['Language']) and ($LineComparison[$TextItem['Column']] <> '') and ($TextItem['Column'] <> 'ShortCut')) $translated = false; 99 } 100 } 101 if($translated) $xp = $xp + $xp_translation; //přičítání XP za celý překlad, pokud je celý přeložený 102 } 103 } 60 104 } 105 return $xp; 106 } 61 107 62 function GetXPFromTranslation($user_ID) { 63 global $Database,$TranslationTree,$xp_from_word,$from_diakrit; 64 $xp = 0; 108 // Hlavní kod pro uživatele 109 if($nothide) $ID = $Database->SQLCommand('SELECT ID,user FROM user'); 110 else $ID = $Database->SQLCommand('SELECT ID,user FROM user WHERE NeedUpdate = 1'); 111 while($LineUser = mysql_fetch_array($ID)) 112 { 113 $xp = GetXPFromTranslation($LineUser['ID']); // Načítání XP 114 $Database->SQLCommand('UPDATE user SET XP = '.$xp.' WHERE ID = '.$LineUser['ID']); // Ukládání XP pro řazení 115 CreateImg('user', $LineUser['user'], $xp); // Vytváření obrázku 116 if($nothide) echo('<img src="tmp/user/'.$LineUser['user'].'/level.png" /><br />'); 117 } 65 118 66 foreach($TranslationTree as $Group) { //překladové skupiny 67 if($Group['TablePrefix'] != '') { 68 $groupby = 'GROUP BY'; 69 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) { 70 if ($groupby == 'GROUP BY') $groupby .= ' '.$TextItem['Column']; 71 else $groupby .= ', '.$TextItem['Column']; 72 } 73 $IDtran = $Database->SQLCommand('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE User = '.$user_ID.' AND Complete = 1 '.$groupby); 74 while ($Line = mysql_fetch_array($IDtran)) { //jednotlivé překlady 75 $LineComparison = mysql_fetch_assoc($Database->SQLCommand('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE ID = '.$Line['Take'])); 76 $xp_translation = 0; //mazání posledního 77 $translated = true; 78 foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem) { //jednotlivé položky překladu 79 if (($Line[$TextItem['Column']] <> $LineComparison[$TextItem['Column']]) and (strlen($Line[$TextItem['Column']]) > (strlen($LineComparison[$TextItem['Column']])*0.5))) { //zda není stejný, zda je aspoň dlouhý jako polovina 80 $TextArr = explode(' ',$Line[$TextItem['Column']]); 81 for ($i=0;$i<count($TextArr);$i=$i+1) { //pro každé slovo 82 if (CheckDiakrit($TextArr[$i])) // zjišťování diakritiky 83 $indikator = $from_diakrit; 84 else 85 $indikator = 1; 86 $xp_translation = $xp_translation + ($indikator * $xp_from_word); 87 } 88 } else { 89 if (($Line[$TextItem['Column']] == $LineComparison[$TextItem['Column']]) and 90 ('0' == $LineComparison['Language']) and 91 ($LineComparison[$TextItem['Column']] <> '') and 92 ($TextItem['Column'] <> 'ShortCut')) 93 $translated = false; 94 } 95 } 96 if ($translated) $xp = $xp+$xp_translation; //přičítání XP za celý překlad, pokud je celý přeložený 97 } 98 } 99 } 100 return $xp; 101 } 119 // Hlavní kod pro překladatelské týmy 120 if($nothide) $ID = $Database->SQLCommand('SELECT ID,name,(SELECT avg(XP) FROM user WHERE team = team.ID) as average FROM team'); 121 else $ID = $Database->SQLCommand('SELECT ID,name,(SELECT avg(XP) FROM user WHERE team = team.ID) as average FROM team WHERE ID IN (SELECT Team FROM user WHERE NeedUpdate = 1)'); 122 while($LineTeam = mysql_fetch_array($ID)) 123 { 124 CreateImg('team', $LineTeam['name'], substr($LineTeam['average'], 0, strpos($LineTeam['average'],'.'))); //vytváření obrázku 125 if($nothide) echo('<img src="tmp/team/'.$LineTeam['name'].'/level.png" /><br />'); 126 } 127 $Database->SQLCommand('UPDATE user SET NeedUpdate = 0'); 102 128 103 //hlavní kod pro uživatele 104 if ($nothide) $ID = $Database->SQLCommand('SELECT ID,user FROM user'); 105 else $ID = $Database->SQLCommand('SELECT ID,user FROM user WHERE NeedUpdate = 1'); 106 while ($LineUser = mysql_fetch_array($ID)) { 107 $xp = GetXPFromTranslation($LineUser['ID']); //načítání XP 108 $Database->SQLCommand('UPDATE user SET XP = '.$xp.' WHERE ID = '.$LineUser['ID']); //ukládání XP pro řazení 109 CreateImg($LineUser['user'],$xp); //vytváření obrázku 110 if ($nothide) echo ('<img src="tmp/'.$LineUser['user'].'/level.png" /><br />'); 111 } 112 //hlavní kod pro překladatelské týmy 113 if ($nothide) $ID = $Database->SQLCommand('SELECT ID,name,(SELECT avg(XP) FROM user WHERE team = team.ID) as average FROM team'); 114 else $ID = $Database->SQLCommand('SELECT ID,name,(SELECT avg(XP) FROM user WHERE team = team.ID) as average FROM team WHERE ID IN (SELECT Team FROM user WHERE NeedUpdate = 1)'); 115 while ($LineTeam = mysql_fetch_array($ID)) { 116 CreateImg('teams/'.$LineTeam['name'],substr($LineTeam['average'], 0, strpos($LineTeam['average'],'.'))); //vytváření obrázku 117 if ($nothide) echo ('<img src="tmp/'.$LineTeam['name'].'/level.png" /><br />'); 118 } 119 $Database->SQLCommand('UPDATE user SET NeedUpdate = 0'); 120 121 if ($nothide) ShowFooter(); 129 if($nothide) ShowFooter(); 122 130 123 131 ?> -
trunk/img_statistic.php
r289 r292 18 18 } else $language = ''; 19 19 20 if(array_key_exists('user', $_GET))21 {22 $DbResult = $Database->SQLCommand('SELECT `user`,`ExportSetting` FROM `user` WHERE ID='.($_GET['user'] * 1));23 if(mysql_num_rows($DbResult) > 0)24 {25 $User = mysql_fetch_assoc($DbResult);26 $ExportSetting = unserialize($User['ExportSetting']);27 $SelectedUsers = '';28 foreach($ExportSetting['users-selection'] as $Item)29 $SelectedUsers .= ','.$Item;30 $SelectedUsers = substr($SelectedUsers, 1);31 $user_sql = ' AND `User` IN ('.$SelectedUsers.')';32 } else $user_sql = '';33 } else $user_sql = '';34 35 20 36 21 $ID = mysql_fetch_row($Database->SQLCommand('SELECT MAX(`VersionEnd`) FROM '.$Group['TablePrefix'])); 37 22 $BuildNumber_max = $ID[0]; 38 23 39 $where = 'VersionEnd = '.$BuildNumber_max.' AND (`Language` <> 0) AND (`Complete` = 1) '.$team.$language .$user_sql;24 $where = 'VersionEnd = '.$BuildNumber_max.' AND (`Language` <> 0) AND (`Complete` = 1) '.$team.$language; 40 25 $ID = mysql_fetch_row($Database->SQLCommand('SELECT count(distinct(`entry`)) FROM '.$Group['TablePrefix'].' WHERE '.$where)); 41 26 $NumberTranslate = $ID[0]; … … 68 53 ImageTTFText($Image, $FontSize, 0, 5, 29, $Color3, $FontFile, getmonthyears($TimeToTranslate)); 69 54 } 70 if($user_sql <> '')71 {72 ImageTTFText($Image, $FontSize, 0, 5, 13, $Color3, $FontFile, 'Statistika výběru');73 ImageTTFText($Image, $FontSize, 0, 5, 29, $Color3, $FontFile, 'uživatele: '.$User['user'] );74 }75 55 ImageTTFText($Image, $FontSize, 0, 140, 13, $Color3, $FontFile, $NumberTranslate.'/'.$NumberAJ); 76 56 ImageTTFText($Image, $FontSize, 0, 240, 13, $Color3, $FontFile, $Group['Name']); -
trunk/includes/config.sample.php
r284 r292 25 25 'VisiblePagingItems' => 20, 26 26 ), 27 'ExportTashProcessPeriod' => 10, 27 28 ); 28 29 -
trunk/includes/global.php
r290 r292 3 3 $ScriptStartTime = GetMicrotime(); 4 4 5 if( !isset($_SESSION)) session_start();5 if(isset($_SERVER['REMOTE_ADDR'])) session_start(); 6 6 7 7 // SQL injection hack protection -
trunk/readme.txt
r147 r292 47 47 Číslo id ve sloupci entry je však přiděleno dynamicky a pro různé verze mangosu by byly čísla generovány jinak. Proto je nutno při aktualizacích čísla přebrat synchronizovat vůči starým verzím. 48 48 49 8) Při startu systému je potřeba spustit skript export/process_task.php pro zpracování delé trvajících úloh exportů. 50 51 -
trunk/team.php
r291 r292 135 135 'Počet členů týmu: <a href="userlist.php?team='.$Line['ID'].'" title="Zobrazit členy týmu">'.$Line['numberuser'].'</a><br />'. 136 136 'Počet přeložených textů týmu: <strong>'.$Line['NumberTranslate'].'</strong><br />'. 137 'Průměrná úroveň překladatelů v týmu: <img src="tmp/team s/'.$Line['name'].'/level.png" /><br /><br />'.137 'Průměrná úroveň překladatelů v týmu: <img src="tmp/team/'.$Line['name'].'/level.png" /><br /><br />'. 138 138 '<strong>Stav dokončení pro tým:</strong><br />'); 139 139 foreach($TranslationTree as $Group) -
trunk/userlist.php
r291 r292 63 63 echo('<tr><td>'.$Name.'</td> 64 64 <td style="text-align: center;"><a href="TranslationList.php?user='.$Line['ID'].'&action=userall" title="Zobrazit Všechny jeho přeložené texty">'.$Line['NumberTranslate'].'</a></td> 65 <td><img src="tmp/ '.$Line['user'].'/level.png" alt="Úroveň uživatele" /></td>65 <td><img src="tmp/user/'.$Line['user'].'/level.png" alt="Úroveň uživatele" /></td> 66 66 <td>'.$Moderators[$Line['GM']].'</td> 67 67 <td>'.HumanDate($Line['LastLogin']).'</td></tr>');
Note:
See TracChangeset
for help on using the changeset viewer.