Changeset 455 for trunk/admin.php


Ignore:
Timestamp:
Apr 13, 2010, 10:03:12 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Přístup k databázi převeden na objektový pomocí rozšířené PHP třídy mysqli. Při práci s databází použít globální objekt $System a jeho prvek $Database ($System->Database->query("SELECT ...");.
  • Upraveno: Při vkládání nové zprávy do Kecátka neprovádět přesměrování, ale rovnou zobrazit výpis. U některých překladatelů toto způsobovalo opakované vložení zprávy.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin.php

    r417 r455  
    4141function SaveNew()
    4242{
    43   global $Database, $Config, $User;
     43  global $System, $Config, $User;
    4444 
    4545  if(array_key_exists('text', $_POST))
    4646  {
    4747    $querty = 'INSERT INTO `News` ( `Time` ,`User` ,`Text`) VALUES ( NOW( ) , '.$User->Id.', "'.$_POST['text'].'")';
    48     $Database->SQLCommand($querty);
     48    $System->Database->query($querty);
    4949    echo('Aktualita uložena!');
    5050    WriteLog('Vložena nová aktualita', LOG_TYPE_ADMINISTRATION);
     
    5454function DeleteOldUsers()
    5555{
    56   global $Database;
     56  global $System;
    5757 
    58   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `User`');
    59   $DbRow2 = mysql_fetch_row($DbResult);
     58  $DbResult = $System->Database->query('SELECT COUNT(*) FROM `User`');
     59  $DbRow2 = $DbResult->fetch_row();
    6060
    6161  $Condition = ' WHERE (`TranslatedCount`= 0)'. // Without translated texts
     
    6767    ' AND (NOT EXISTS (SELECT `ID` FROM `ShoutBox` WHERE `User`.`Name` = `ShoutBox`.`User`))'. // Without shoutbox messages
    6868    '';
    69   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `User`'.$Condition);
    70   $DbRow = mysql_fetch_row($DbResult);
    71   $Database->SQLCommand('DELETE FROM `User`'.$Condition);
     69  $DbResult = $System->Database->query('SELECT COUNT(*) FROM `User`'.$Condition);
     70  $DbRow = $DbResult->fetch_row();
     71  $System->Database->query('DELETE FROM `User`'.$Condition);
    7272  echo('Smazáno '.$DbRow[0].' účtů ze všech '.$DbRow2[0].'<br/>');
    7373
    7474  // Delete logs without user
    75   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Log`');
    76   $DbRow2 = mysql_fetch_row($DbResult);
    77   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Log` WHERE (NOT EXISTS (SELECT `ID` FROM `User` WHERE `User`.`ID` = `Log`.`User`)) AND (`User` != 0)');
    78   $DbRow = mysql_fetch_row($DbResult);
    79   $Database->SQLCommand('DELETE FROM `Log` WHERE (NOT EXISTS (SELECT `ID` FROM `User` WHERE `User`.`ID` = `Log`.`User`)) AND (`User` != 0)');
     75  $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Log`');
     76  $DbRow2 = $DbResult->fetch_row();
     77  $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Log` WHERE (NOT EXISTS (SELECT `ID` FROM `User` WHERE `User`.`ID` = `Log`.`User`)) AND (`User` != 0)');
     78  $DbRow = $DbResult->fetch_row();
     79  $System->Database->query('DELETE FROM `Log` WHERE (NOT EXISTS (SELECT `ID` FROM `User` WHERE `User`.`ID` = `Log`.`User`)) AND (`User` != 0)');
    8080  echo('Smazáno '.$DbRow[0].' položek logu ze všech '.$DbRow2[0].'<br/>');     
    8181     
    8282  // Delete invalid ExportUser
    83   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `ExportUser`');
    84   $DbRow2 = mysql_fetch_row($DbResult);
    85   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `ExportUser` WHERE (NOT EXISTS (SELECT `Id` FROM `User` WHERE `User`.`ID` = `ExportUser`.`User`))');
    86   $DbRow = mysql_fetch_row($DbResult);
    87   $Database->SQLCommand('DELETE FROM `ExportUser` WHERE (NOT EXISTS (SELECT `Id` FROM `User` WHERE `User`.`ID` = `ExportUser`.`User`))');
     83  $DbResult = $System->Database->query('SELECT COUNT(*) FROM `ExportUser`');
     84  $DbRow2 = $DbResult->fetch_row();
     85  $DbResult = $System->Database->query('SELECT COUNT(*) FROM `ExportUser` WHERE (NOT EXISTS (SELECT `Id` FROM `User` WHERE `User`.`ID` = `ExportUser`.`User`))');
     86  $DbRow = $DbResult->fetch_row();
     87  $System->Database->query('DELETE FROM `ExportUser` WHERE (NOT EXISTS (SELECT `Id` FROM `User` WHERE `User`.`ID` = `ExportUser`.`User`))');
    8888  echo('Smazáno '.$DbRow[0].' položek výběru překladatelů u exportů ze všech '.$DbRow2[0].'<br/>');     
    8989
    9090  // Delete all teams without users
    91   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Team`');
    92   $DbRow2 = mysql_fetch_row($DbResult);
    93   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');
    94   $DbRow = mysql_fetch_row($DbResult);
    95   $Database->SQLCommand('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`team` = `Team`.`Id`) = 0');
     91  $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Team`');
     92  $DbRow2 = $DbResult->fetch_row();
     93  $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) = 0');
     94  $DbRow = $DbResult->fetch_row();
     95  $System->Database->query('DELETE FROM `Team` WHERE (SELECT COUNT(*) FROM `User` WHERE `User`.`team` = `Team`.`Id`) = 0');
    9696  echo('Smazáno '.$DbRow[0].' týmů ze všech '.$DbRow2[0].'<br/>');     
    9797       
    9898  // Set new leader for teams where old leader went to other team
    99   $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`);');
     99  $System->Database->query('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`);');
    100100 
    101101  WriteLog('Smazány staré uživatelské účty', LOG_TYPE_ADMINISTRATION);
     
    104104function DeleteErrorLog()
    105105{
    106   global $Database;
     106  global $System;
    107107 
    108   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM `Log` WHERE `Type`='.LOG_TYPE_ERROR);
    109   $DbRow = mysql_fetch_row($DbResult);
    110   $Database->SQLCommand('DELETE FROM `Log` WHERE `Type`='.LOG_TYPE_ERROR);
     108  $DbResult = $System->Database->query('SELECT COUNT(*) FROM `Log` WHERE `Type`='.LOG_TYPE_ERROR);
     109  $DbRow = $DbResult->fetch_row();
     110  $System->Database->query('DELETE FROM `Log` WHERE `Type`='.LOG_TYPE_ERROR);
    111111  WriteLog('Vymazány chybové záznamy', LOG_TYPE_ADMINISTRATION); 
    112112  echo('Smazáno všech '.$DbRow[0].' chybových záznamů.<br/>');     
Note: See TracChangeset for help on using the changeset viewer.