Changeset 350 for trunk/admin.php
- Timestamp:
- Mar 3, 2010, 12:50:21 PM (15 years ago)
- File:
-
- 1 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í');
Note:
See TracChangeset
for help on using the changeset viewer.