0byt3m1n1
Path:
/
home
/
kassiope
/
www
/
administrer
/
[
Home
]
File: optimize.php
<?php include("../configuration.inc.php"); necessite_identification(); necessite_priv("admin"); $DOC_TITLE = ""; include("modeles/haut.php"); //optimisation de la base ?> <table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr> <td align="center" class="entete" >::: Optimisation de la base de données :::</td> </tr></table> <? echo "<br /><br /><table width='100%' class='menuadmin' cellspacing='0' cellpadding='0' align='center'> <tr><td align='left' class='entete' width='40%'>Nom de la Table</td> <td align='left' class='entete' width='25%'>Taille</td> <td align='left' class='entete' width='25%'>Etat</td> <td align='left' class='entete' width='10%'>Gain</td> </tr>"; $db_clean = $nom_de_la_base; $tot_data = 0; $tot_idx = 0; $tot_all = 0; $total_gain = 0; $local_query = 'SHOW TABLE STATUS FROM '.$nom_de_la_base; $result = mysql_query_override($local_query); if (mysql_num_rows_override($result)) { while ($row = mysql_fetch_array_override($result)) { $tot_data = $row['Data_length']; $tot_idx = $row['Index_length']; $total = $tot_data + $tot_idx; $total = $total / 1024 ; $gain= $row['Data_free']; $gain = $gain / 1024 ; $total_gain += $gain; $local_query = 'OPTIMIZE TABLE '.$row[0]; $resultat = mysql_query_override($local_query); $i = 0; if ($gain == 0) { echo "<tr bgcolor='#ffffff'><td class='normal' width='40%'> <li> ".$row[0]."</li></td><td class='normal' width='25%'> ".$total." Ko</td><td class='normal' width='25%'> Déjà optimisée</td><td class='normal' width='10%'> 0 Ko</td></tr> "; $i++; } else { echo "<tr bgcolor='#ffffff'><td class='normal' width='40%'> <li> ".$row[0]."</li></td><td class='normal' width='25%'>".$total." Ko</td><td class='normal' width='25%'> Optimisée !</td><td class='normal' width='10%'>".$gain." Ko</td></tr>"; $i++;} } } echo "</table>"; echo "<br /><br /> <li><span class='label'>Gain total : "."$total_gain"." Ko</span></li>"; //Historique des gains ------------------------------------------------------------- //Creation de la table si necessaire $sql_query = "CREATE TABLE IF NOT EXISTS gaia_optimize_gain(gain decimal(10,3))"; $result = mysql_query_override($sql_query); //Enregistrement du nouveau gain" $sql_query = "INSERT INTO `gaia_optimize_gain` (`gain`) VALUES ('$total_gain')"; $result = mysql_query_override($sql_query); //Lecture des gains précedents et addition $sql_query = "SELECT * FROM gaia_optimize_gain"; $result = mysql_query_override ($sql_query); $histo = 0; $cpt = 0; while ($row = mysql_fetch_row_override($result)) { $histo += $row[0]; $cpt += 1; } // Affichage echo " <li><span class='label'>Vous avez optimisé la base de données "."$cpt"." fois </span></li>"; echo " <li><span class='label'>Vous avez gagné "."$histo"." Ko depuis son installation !</span></li>"; ?>