Changeset 1111 for trunk


Ignore:
Timestamp:
Mar 28, 2006, 11:05:12 PM (19 years ago)
Author:
rub
Message:

Improvement issue 0000319:
Add new item on page administration/maintenance.
This item allow to repair and optimize database

Functionality tested with MySQL 4.1.9.
Please to report problem with previous version of MySql

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r1105 r1111  
    20932093    );
    20942094}
     2095
     2096/**
     2097 * Do maintenance on all PWG tables
     2098 *
     2099 * @return nono
     2100 */
     2101function do_maintenance_all_tables()
     2102{
     2103  global $prefixeTable;
     2104 
     2105  $all_tables = array();
     2106
     2107  // List all tables
     2108  $query = 'SHOW TABLES LIKE \''.$prefixeTable.'%\';';
     2109  $result = pwg_query($query);
     2110  while ($row = mysql_fetch_array($result))
     2111  {
     2112    array_push($all_tables, $row[0]);
     2113  }
     2114
     2115  // Repair all tables
     2116  $query = 'REPAIR TABLE '.implode(', ', $all_tables).';';
     2117  pwg_query($query);
     2118
     2119  // Re-Order all tables
     2120  foreach ($all_tables as $table_name)
     2121  {
     2122    $all_primary_key = array();
     2123   
     2124    $query = 'DESC '.$table_name.';';
     2125    $result = pwg_query($query);
     2126    while ($row = mysql_fetch_array($result))
     2127    {
     2128      if ($row['Key'] == 'PRI')
     2129      {
     2130        array_push($all_primary_key, $row['Field']);
     2131      }
     2132    }
     2133   
     2134    if (count($all_primary_key) != 0)
     2135    {
     2136      $query = 'ALTER TABLE '.$table_name.' ORDER BY '.implode(', ', $all_primary_key).';';
     2137      pwg_query($query);
     2138    }
     2139  }
     2140
     2141  // Optimize all tables
     2142  $query = 'OPTIMIZE TABLE '.implode(', ', $all_tables).';';
     2143  pwg_query($query);
     2144
     2145}
     2146
     2147
    20952148?>
  • trunk/admin/maintenance.php

    r1085 r1111  
    4242// +-----------------------------------------------------------------------+
    4343
    44 $action = isset($_GET['action']) ? $_GET['action'] : '';
     44$action = (isset($_GET['action']) and !is_adviser()) ? $_GET['action'] : '';
    4545
    4646switch ($action)
     
    8585    break;
    8686  }
     87  case 'database' :
     88  {
     89    do_maintenance_all_tables();
     90    break;
     91  }
    8792  default :
    8893  {
     
    99104$start_url = PHPWG_ROOT_PATH.'admin.php?page=maintenance&action=';
    100105
    101 if (!is_adviser())
    102 {
    103   $template->assign_vars(
    104     array(
    105       'U_MAINT_CATEGORIES' => $start_url.'categories',
    106       'U_MAINT_IMAGES' => $start_url.'images',
    107       'U_MAINT_HISTORY' => $start_url.'history',
    108       'U_MAINT_SESSIONS' => $start_url.'sessions',
    109       'U_MAINT_FEEDS' => $start_url.'feeds',
    110       'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=maintenance',
    111       )
    112     );
    113 }
    114 else
    115 {
    116   $template->assign_vars(
    117     array(
    118       'U_MAINT_CATEGORIES' => $start_url,
    119       'U_MAINT_IMAGES' => $start_url,
    120       'U_MAINT_HISTORY' => $start_url,
    121       'U_MAINT_SESSIONS' => $start_url,
    122       'U_MAINT_FEEDS' => $start_url,
    123       'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=maintenance',
    124       )
    125     );
    126 }
     106$template->assign_vars(
     107  array(
     108    'U_MAINT_CATEGORIES' => $start_url.'categories',
     109    'U_MAINT_IMAGES' => $start_url.'images',
     110    'U_MAINT_HISTORY' => $start_url.'history',
     111    'U_MAINT_SESSIONS' => $start_url.'sessions',
     112    'U_MAINT_FEEDS' => $start_url.'feeds',
     113    'U_MAINT_DATABASE' => $start_url.'database',
     114    'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=maintenance',
     115    )
     116  );
    127117
    128118// +-----------------------------------------------------------------------+
  • trunk/language/en_UK.iso-8859-1/admin.lang.php

    r1107 r1111  
    294294$lang['purge history'] = 'purge history';
    295295$lang['purge never used notification feeds'] = 'purge never used notification feeds';
     296$lang['repair and optimize database'] = 'repair and optimize database';
    296297$lang['purge sessions'] = 'purge sessions';
    297298$lang['randomly represented'] = 'randomly represented';
  • trunk/language/en_UK.iso-8859-1/help/maintenance.html

    r889 r1111  
    1212<ul>
    1313
    14   <li><strong>update categories informations</strong>. For each category,
     14  <li><strong>Update categories informations</strong>. For each category,
    1515  informations to update or control are the following : list of parent
    1616  categories, number of pictures, date of the last picture, position among
     
    1818  the coherence of representative picture.</li>
    1919
    20   <li><strong>update images informations</strong>. For each picture,
     20  <li><strong>Update images informations</strong>. For each picture,
    2121  informations to update are : full path to file, average
    2222  rate. <em>Warning</em>: do not get confuse with metadata informations
     
    2626  example).</li>
    2727
    28   <li><strong>purge history</strong>. Delete all lines from
     28  <li><strong>Purge history</strong>. Delete all lines from
    2929  <code>history</code> table. Screen <span class="pwgScreen">Administration,
    3030  General, History</span> shows no informations anymore on past
     
    3232  get informations back.</li>
    3333
    34   <li><strong>purge sessions</strong>. Delete expired user sessions.</li>
     34  <li><strong>Purge sessions</strong>. Delete expired user sessions.</li>
    3535
    36   <li><strong>purge never used notification feeds</strong></li>
     36  <li><strong>Purge never used notification feeds</strong></li>
     37
     38  <li><strong>Repair and optimize database</strong>
     39  For each table, re-odrer, repair and optimize operations are done.
     40  </li>
    3741
    3842</ul>
  • trunk/language/fr_FR.iso-8859-1/admin.lang.php

    r1107 r1111  
    294294$lang['purge history'] = 'purger l\'historique';
    295295$lang['purge never used notification feeds'] = 'purger les flux de notification jamais utilisés';
     296$lang['repair and optimize database'] = 'réparer et optimiser la base de données';
    296297$lang['purge sessions'] = 'purger les sessions';
    297298$lang['randomly represented'] = 'représentant au hasard';
  • trunk/language/fr_FR.iso-8859-1/help/maintenance.html

    r1099 r1111  
    2929class="pwgScreen">picture.php</span>).</li>
    3030
    31   <li><strong>purger l'historique</strong>. Supprime toutes les lignes de
     31  <li><strong>Purger l'historique</strong>. Supprime toutes les lignes de
    3232la table <code>history</code>. L'écran <span
    3333class="pwgScreen">Administration, Général, Historique</span> ne montre alors
     
    3535seront perdues et il n'existe aucun moyen de les récupérer.</li>
    3636
    37   <li><strong>purger les sessions</strong>. Supprimer les sessions
     37  <li><strong>Purger les sessions</strong>. Supprimer les sessions
    3838expirées..</li>
    3939
    40   <li><strong>purger les flux de notification jamais utilisés</strong></li>
     40  <li><strong>Purger les flux de notification jamais utilisés</strong></li>
     41
     42  <li><strong>Réparer et optimiser la base de données</strong>
     43Pour chaque tables de la base de données PhpWegGallery, les opérations de ré-ordonnancement, de réparation et d'optimisation sont effectuées.
     44  </li>
    4145
    4246</ul>
  • trunk/template/yoga/admin/maintenance.tpl

    r1085 r1111  
    1313  <li><a href="{U_MAINT_SESSIONS}" {TAG_INPUT_ENABLED}>{lang:purge sessions}</a></li>
    1414  <li><a href="{U_MAINT_FEEDS}" {TAG_INPUT_ENABLED}>{lang:purge never used notification feeds}</a></li>
     15  <li><a href="{U_MAINT_DATABASE}" {TAG_INPUT_ENABLED}>{lang:repair and optimize database}</a></li>
    1516</ul>
Note: See TracChangeset for help on using the changeset viewer.