Changeset 350
- Timestamp:
- Mar 3, 2010, 12:50:21 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin.php
r349 r350 21 21 echo('<a href="'.$Config['Web']['BaseURL'].'admin.php?action=img_level">Generování obrázků úrovní překladatelů</a><br/>'. 22 22 '<small>Ihned provede přegenerování všech obrázků úrovní překladatelů</small><br/><br/>'); 23 echo('<a href="'.$Config['Web']['BaseURL'].'admin.php?action=delerrlog">Vymázání chybových záznamů</a><br/>'. 24 '<small>Provede vymazání všech chybových záznamů v logu</small><br/><br/>'); 25 echo('<a href="'.$Config['Web']['BaseURL'].'admin.php?action=delolduser">Vymázání prázdných účtů</a><br/>'. 26 '<small>Vymaže všechny účty překladatelů bez překladů starší třech měsíců</small><br/><br/>'); 27 } 28 29 function DeleteOldUsers() 30 { 31 global $Database; 32 33 $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `user`'); 34 $DbRow2 = mysql_fetch_row($DbResult); 35 36 $Condition = ' WHERE (`TranslatedCount`= 0)'. // Without translated texts 37 ' AND (`ID` != 128)'. // Skip user Neznámý 38 ' AND (`LastLogin` < DATE_SUB(NOW(), INTERVAL 3 MONTH))'. // Time limit 39 ' AND (NOT EXISTS (SELECT `ID` FROM `dictionary` WHERE `user`.`ID` = `dictionary`.`user`))'. // dictionary 40 ' AND (NOT EXISTS (SELECT `Id` FROM `news` WHERE `user`.`ID` = `news`.`user`))'. // news 41 ' AND (NOT EXISTS (SELECT `ID` FROM `shoutbox` WHERE `user`.`user` = `shoutbox`.`user`))'. // shoutbox 42 ''; 43 $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `user`'.$Condition); 44 $DbRow = mysql_fetch_row($DbResult); 45 $Database->SQLCommand('DELETE FROM `user`'.$Condition); 46 echo('Smazáno '.$DbRow[0].' účtů ze všech '.$DbRow2[0].'<br/>'); 47 48 // Delete logs without user 49 $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `log`'); 50 $DbRow2 = mysql_fetch_row($DbResult); 51 $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `log` WHERE (NOT EXISTS (SELECT `ID` FROM `user` WHERE `user`.`ID` = `log`.`user`)) AND (user != 0)'); 52 $DbRow = mysql_fetch_row($DbResult); 53 $Database->SQLCommand('DELETE FROM `log` WHERE (NOT EXISTS (SELECT `ID` FROM `user` WHERE `user`.`ID` = `log`.`user`)) AND (user != 0)'); 54 echo('Smazáno '.$DbRow[0].' položek logu ze všech '.$DbRow2[0].'<br/>'); 55 56 // Delete all teams without users 57 $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Team`'); 58 $DbRow2 = mysql_fetch_row($DbResult); 59 $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Team` WHERE (SELECT COUNT(*) FROM `user` WHERE `user`.`Team` = `Team`.`Id`) = 0'); 60 $DbRow = mysql_fetch_row($DbResult); 61 $Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `user` WHERE `user`.`team` = `Team`.`Id`) = 0'); 62 echo('Smazáno '.$DbRow[0].' týmů ze všech '.$DbRow2[0].'<br/>'); 63 64 // Set new leader for teams where old leader went to other team 65 $Database->SQLCommand('UPDATE Team SET Leader=(SELECT Id FROM `user` WHERE user.Team=Team.Id ORDER BY user.RegistrationTime LIMIT 1) WHERE Leader NOT IN (SELECT ID FROM user WHERE user.Team=Team.Id);'); 23 66 } 24 67 … … 30 73 { 31 74 ImgLevelShow(); 32 } else ShowMenu(); 75 } else 76 if($_GET['action'] == 'delerrlog') 77 { 78 $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `log` WHERE `type`=10'); 79 $DbRow = mysql_fetch_row($DbResult); 80 $Database->SQLCommand('DELETE FROM `log` WHERE `type`=10'); 81 echo('Smazáno všech '.$DbRow[0].' chybových záznamů.<br/>'); 82 } else 83 if($_GET['action'] == 'delolduser') DeleteOldUsers(); 84 else ShowMenu(); 33 85 } else ShowMenu(); 34 86 } else echo('Nemáte oprávnění'); -
trunk/img_level.php
r349 r350 103 103 function ImgLevelUpdate() 104 104 { 105 global $Database ;105 global $Database, $TranslationTree; 106 106 107 107 // Hlavní kod pro uživatele 108 $ID = $Database->SQLCommand('SELECT ID,user FROM user WHERE NeedUpdate= 1');108 $ID = $Database->SQLCommand('SELECT `ID`, `user` FROM `user` WHERE `NeedUpdate` = 1'); 109 109 while($LineUser = mysql_fetch_array($ID)) 110 110 { 111 $xp = GetXPFromTranslation($LineUser['ID']); // Načítání XP 112 $Database->SQLCommand('UPDATE user SET XP = '.$xp.' WHERE ID = '.$LineUser['ID']); // Ukládání XP pro řazení 113 CreateImg('user', $LineUser['user'], $xp); // Vytváření obrázku 111 // Build TranslatedCount query 112 $TranslatedCount = '('; 113 foreach($TranslationTree as $Group) 114 if($Group['TablePrefix'] != '') 115 { 116 $Count = '(SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` WHERE (`Complete` = 1) AND (`Language` <> 0) AND (`User`='.$LineUser['ID'].'))'; 117 $TranslatedCount .= 'COALESCE('.$Count.', 0) + '; 118 } 119 $TranslatedCount = substr($TranslatedCount, 0, -3).')'; 120 121 $xp = GetXPFromTranslation($LineUser['ID']); 122 $Database->SQLCommand('UPDATE `user` SET `XP` = '.$xp.', `TranslatedCount` = '.$TranslatedCount.' WHERE `user`.`ID` = '.$LineUser['ID']); 123 CreateImg('user', $LineUser['user'], $xp); 114 124 } 115 125 116 126 // Hlavní kod pro překladatelské týmy 117 $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)');127 $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)'); 118 128 while($LineTeam = mysql_fetch_array($ID)) 119 129 { 120 130 CreateImg('team', $LineTeam['name'], substr($LineTeam['average'], 0, strpos($LineTeam['average'],'.'))); //vytváření obrázku 121 131 } 122 $Database->SQLCommand('UPDATE user SET NeedUpdate= 0');132 $Database->SQLCommand('UPDATE `user` SET `NeedUpdate` = 0'); 123 133 } 124 134 … … 127 137 global $Database; 128 138 129 // Hlavní kod pro uživatele 130 $ID = $Database->SQLCommand('SELECT ID,user FROM user'); 139 // Do update for all users 140 $Database->SQLCommand('UPDATE `user` SET `NeedUpdate` = 1'); 141 ImgLevelUpdate(); 142 143 echo('<strong>Uživatelé</strong><br/>'); 144 $ID = $Database->SQLCommand('SELECT `ID`, `user` FROM `user`'); 131 145 while($LineUser = mysql_fetch_array($ID)) 132 146 { 133 $xp = GetXPFromTranslation($LineUser['ID']); // Načítání XP 134 $Database->SQLCommand('UPDATE user SET XP = '.$xp.' WHERE ID = '.$LineUser['ID']); // Ukládání XP pro řazení 135 CreateImg('user', $LineUser['user'], $xp); // Vytváření obrázku 136 echo('<img src="tmp/user/'.$LineUser['user'].'/level.png" /><br />'); 147 echo('<img src="tmp/user/'.$LineUser['user'].'/level.png" /> '.$LineUser['user'].'<br />'); 137 148 } 138 149 139 // Hlavní kod pro překladatelské týmy140 $ID = $Database->SQLCommand('SELECT ID, name,(SELECT avg(XP) FROM user WHERE team = Team.Id) as average FROM Team');150 echo('<br/><strong>Týmy</strong><br/>'); 151 $ID = $Database->SQLCommand('SELECT ID, Name FROM Team'); 141 152 while($LineTeam = mysql_fetch_array($ID)) 142 153 { 143 CreateImg('team', $LineTeam['name'], substr($LineTeam['average'], 0, strpos($LineTeam['average'],'.'))); // Vytváření obrázku 144 echo('<img src="tmp/team/'.$LineTeam['name'].'/level.png" /><br />'); 154 echo('<img src="tmp/team/'.$LineTeam['Name'].'/level.png" /> '.$LineTeam['Name'].'<br />'); 145 155 } 146 $Database->SQLCommand('UPDATE user SET NeedUpdate = 0');147 156 } 148 157 -
trunk/team.php
r349 r350 194 194 { 195 195 ImgLevelUpdate(); 196 $Columns = '';197 $Joins = '';198 foreach($TranslationTree as $Group)199 if($Group['TablePrefix'] != '')200 {201 $Columns .= 'COALESCE(T'.$Group['Id'].'.Count, 0) + ';202 $Joins .= ' LEFT JOIN (SELECT User, COUNT(User) as Count FROM `'.$Group['TablePrefix'].'` WHERE (Complete = 1) AND (Language <> 0) GROUP BY User) as T'.$Group['Id'].' ON user.ID=T'.$Group['Id'].'.User';203 }204 196 205 $Team = mysql_fetch_assoc($Database->SQLCommand('SELECT *, (SELECT count(*) FROM `user` WHERE `team` = `Team`.`Id`) as `NumberUser`, (SELECT SUM('.substr($Columns, 0, -3).') FROM user '.$Joins.' WHERE `team` = `Team`.`Id`) as`NumberTranslate` FROM `Team` WHERE `Id`='.$_GET['id']));197 $Team = mysql_fetch_assoc($Database->SQLCommand('SELECT *, (SELECT count(*) FROM `user` WHERE `team` = `Team`.`Id`) AS `NumberUser`, (SELECT SUM(`TranslatedCount`) FROM `user` WHERE `team` = `Team`.`Id`) AS `NumberTranslate` FROM `Team` WHERE `Id`='.$_GET['id'])); 206 198 $DbResult = $Database->SQLCommand('SELECT user FROM user WHERE ID='.$Team['Leader']); 207 199 if(mysql_num_rows($DbResult) > 0) -
trunk/user.php
r290 r350 26 26 if(array_key_exists('user', $_GET) and Licence(LICENCE_MODERATOR)) 27 27 { 28 $Query = 'SELECT *, ('; 29 foreach($TranslationTree as $Group) 30 if($Group['TablePrefix'] != '') 31 $Query .= '(SELECT count(*) FROM `'.$Group['TablePrefix'].'` WHERE User = '.$_GET['user'].' AND User <> 0 AND Complete = 1) + '; 32 $Query .= '0) as NumberTranslate FROM `user` WHERE ID = '.$_GET['user']; 28 $Query = 'SELECT * FROM `user` WHERE ID = '.$_GET['user']; 33 29 $LineUser = mysql_fetch_array($Database->SQLCommand($Query)); 34 30 … … 38 34 echo('Poslední připojení: <strong>'.$LineUser['LastLogin'].'</strong><br />'); 39 35 echo('Poslední IP: <strong>'.$LineUser['LastIP'].'</strong><br />'); 40 echo('Počet přeložených: <a href="TranslationList.php?user='.$_GET['user'].'&action=userall" title="Zobrazit Všechny jeho přeložené texty"><strong>'.$LineUser[' NumberTranslate'].'</strong></a><br />');36 echo('Počet přeložených: <a href="TranslationList.php?user='.$_GET['user'].'&action=userall" title="Zobrazit Všechny jeho přeložené texty"><strong>'.$LineUser['TranslatedCount'].'</strong></a><br />'); 41 37 echo('Email: <strong>'.$LineUser['Email'].'</strong><br />'); 42 38 echo('<br /> -
trunk/userlist.php
r349 r350 35 35 $TableColumns = array( 36 36 array('Name' => 'user', 'Title' => 'Jméno'), 37 array('Name' => ' NumberTranslate', 'Title' => 'Přeložených'),37 array('Name' => 'TranslatedCount', 'Title' => 'Přeložených'), 38 38 array('Name' => 'XP', 'Title' => 'Úroveň'), 39 39 array('Name' => 'GM', 'Title' => 'Oprávnění'), … … 43 43 echo($Order['Output']); 44 44 45 $Columns = '';46 $Joins = '';47 foreach($TranslationTree as $Group)48 if($Group['TablePrefix'] != '')49 {50 $Columns .= 'COALESCE(T'.$Group['Id'].'.Count, 0) + ';51 $Joins .= ' LEFT JOIN (SELECT User, COUNT(User) as Count FROM `'.$Group['TablePrefix'].'` WHERE (Complete = 1) AND (Language <> 0) GROUP BY User) as T'.$Group['Id'].' ON user.ID=T'.$Group['Id'].'.User';52 }53 45 54 $Query = 'SELECT ID, user.user, LastLogin, GM, ('.substr($Columns, 0, -3).') as NumberTranslate FROM `user`'.$Joins.''.$_SESSION['Where'].$Order['SQL'].$PageList['SQLLimit'];46 $Query = 'SELECT `ID`, `user`.`user`, `LastLogin`, `GM`, `TranslatedCount` FROM `user` '.$_SESSION['Where'].$Order['SQL'].$PageList['SQLLimit']; 55 47 56 48 $ID = $Database->SQLCommand($Query); … … 62 54 63 55 echo('<tr><td>'.$Name.'</td> 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>56 <td style="text-align: center;"><a href="TranslationList.php?user='.$Line['ID'].'&action=userall" title="Zobrazit Všechny jeho přeložené texty">'.$Line['TranslatedCount'].'</a></td> 65 57 <td><img src="tmp/user/'.$Line['user'].'/level.png" alt="Úroveň uživatele" /></td> 66 58 <td>'.$Moderators[$Line['GM']].'</td>
Note:
See TracChangeset
for help on using the changeset viewer.