Soyez le premier à donner votre avis sur cette source.
Snippet vu 4 614 fois - Téléchargée 28 fois
<?php // **************************** // Démarrage de la session PHP // **************************** session_start(); // ******************************** // Valeurs par défaut des variables // ******************************** $mail_ligne_1 = ''; $mail_ligne_2 = ''; $mail_ligne_3 = ''; $mail_ligne_4 = ''; $mail_ligne_5 = ''; $mail_ligne_6 = ''; $mail_ligne_7 = ''; $mail_ligne_8 = ''; $mail_ligne_9 = ''; $mail_ligne_10 = ''; $mail_ligne_11 = ''; $mail_ligne_12 = ''; $mail_ligne_13 = ''; $mail_ligne_14 = ''; $mail_ligne_15 = ''; $mail_ligne_16 = ''; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title></title> <?php // ******************************** // Récupération des ID de connexion // ******************************** $_SESSION['hote_mysql'] = '*****'; $_SESSION['user_mysql'] = '*****'; $_SESSION['passwd_mysql'] = '*****'; $_SESSION['base_mysql'] = '*****'; // Connexion à la BDD mysql_connect($_SESSION['hote_mysql'], $_SESSION['user_mysql'], $_SESSION['passwd_mysql']); @mysql_select_db($_SESSION['base_mysql']) or die ("!! Impossible de sélectionner la BDD"); //optimisation de la base $mail_ligne_1 = "<center>"; $mail_ligne_2 = "<div class='texte_bleu_grand'>"; $mail_ligne_3 = "Optimisation de la base de données ".$_SESSION['base_mysql']; $mail_ligne_4 = "<br>"; $mail_ligne_5 = "Le ".date('d m Y')." à ".date('H')."h ".date('i')."mn</div>"; $mail_ligne_6 = "<br><b>"; $mail_ligne_7 = "<table border=1><tr><td BGCOLOR='#D6DDE7'><div align=center class='texte_bleu_moyen'>Table</div></td><td><div align=center style='background-color: #D6DDE7;' class='texte_bleu_moyen'>Taille</div></td><td><div align=center style='background-color: #D6DDE7;' class='texte_bleu_moyen'>Etat</div></td><td><div align=center style='background-color: #D6DDE7;' class='texte_bleu_moyen'>Gain</div></td></tr>"; $mail_ligne_8 = "</b>"; $db_clean = $_SESSION['base_mysql']; $tot_data = 0; $tot_idx = 0; $tot_all = 0; $poids_bdd = 0; $local_query = 'SHOW TABLE STATUS FROM '.$_SESSION['base_mysql']; $result = @mysql_query($local_query); if(@mysql_num_rows($result)) { while($row = mysql_fetch_array($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($local_query); if($gain == 0) { $mail_ligne_9 = $mail_ligne_9."<tr><td><div class='texte_bleu_fin_italique'>".$row[0]."</div></td>"."<td><div class='texte_bleu_fin_italique'>".round($total , 2)." Ko"."</div></td>"."<td><div class='texte_bleu_italique'>Déjà optimisée</div></td><td><div class='texte_bleu_fin_italique'>0 Ko</div></td></tr> "; } else { $mail_ligne_9 = $mail_ligne_9."<tr><td><div class='texte_rouge_italique'>".$row[0]."</div></td>"."<td><div class='texte_rouge_italique'>".round($total , 2)." Ko"."</div></td>"."<td><div class='texte_rouge_italique'>"."Optimisée !"."</div></td><td><div class='texte_rouge_italique'>".round($gain , 2)." Ko</div></td></tr>"; } $poids_bdd = $poids_bdd + $total; } } if($total_gain == 0) { $mail_ligne_10 = "</table>"; $mail_ligne_11 = "<br><hr color=#141C56 width=50%><center><div class='texte_bleu_grand'><br>"; $mail_ligne_12 = "Gain total : ".round($total_gain , 2)." Ko"; $mail_ligne_13 = "</div>"; $mail_ligne_14 = "<div class='texte_bleu_grand'>"; $mail_ligne_15 = "Poids de la base de données : ".round($poids_bdd , 2)." Ko"; $mail_ligne_16 = "</div>"; } else { $mail_ligne_10 = "</table>"; $mail_ligne_11 = "<br><hr color=#141C56 width=50%><center><div class='texte_bleu_grand'><br>"; $mail_ligne_12 = "Gain total : <span class='texte_rouge_grand'>".round($total_gain , 2)." Ko</span>"; $mail_ligne_13 = "</div>"; $mail_ligne_14 = "<div class='texte_bleu_grand'>"; $mail_ligne_15 = "Poids de la base de données après : ".round(($poids_bdd - $total_gain) , 2)." Ko"; $mail_ligne_16 = "</div>"; } // **************** // Envoi de l'amail // **************** // Destinataire $_SESSION['destinataire_mail_optimisation_des_tables'] = 'bal@mon_site.fr'; // Sujet $_SESSION['objet_mail_optimisation_des_tables'] = 'Optimisation des tables de la base de données'; // Message HTML $_SESSION['message_mail_optimisation_des_tables'] = ' <html> <head> <title>Optimisation des tables de la base de données</title> <style type="text/css"> .texte_bleu_normal { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #141C56; } .texte_bleu_moyen { font-size: 15px; font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #141C56; } .texte_bleu_grand { font-size: 18px; font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #141C56; } .texte_bleu_fin_italique { font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; color: #141C56; font-style: italic; } .texte_bleu_italique { font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; color: #141C56; font-style: italic; } .texte_rouge_italique { font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; color: #FF0000; font-style: italic; } .texte_rouge_grand { font-size: 18px; font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FF0000; } </style> </head> <body>' .$mail_ligne_1 .$mail_ligne_2 .$mail_ligne_3 .$mail_ligne_4 .$mail_ligne_5 .$mail_ligne_6 .$mail_ligne_7 .$mail_ligne_8 .$mail_ligne_9 .$mail_ligne_10 .$mail_ligne_11 .$mail_ligne_12 .$mail_ligne_13 .$mail_ligne_14 .$mail_ligne_15 .$mail_ligne_16. '</body> </html> '; // Pour envoyer un mail HTML, l'en-tête Content-type doit être défini $_SESSION['headers_mail_optimisation_des_tables'] = 'MIME-Version: 1.0' . "\r\n"; $_SESSION['headers_mail_optimisation_des_tables'] .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // En-têtes additionnels $_SESSION['headers_mail_optimisation_des_tables'] .= 'To: ' . "\r\n"; $_SESSION['headers_mail_optimisation_des_tables'] .= 'From: mon_site.fr <bal@mon_site.fr>' . "\r\n"; $_SESSION['headers_mail_optimisation_des_tables'] .= 'Cc: ' . "\r\n"; $_SESSION['headers_mail_optimisation_des_tables'] .= 'Bcc:' . "\r\n"; // Envoi du mail mail($_SESSION['destinataire_mail_optimisation_des_tables'], $_SESSION['objet_mail_optimisation_des_tables'], $_SESSION['message_mail_optimisation_des_tables'], $_SESSION['headers_mail_optimisation_des_tables']); // ************************************************ // Déconnection de la BDD et mise à 0 des variables // ************************************************ mysql_close($_SESSION['connexion_bd']); $_SESSION['hote_mysql'] = ''; $_SESSION['user_mysql'] = ''; $_SESSION['passwd_mysql'] = ''; $_SESSION['base_mysql'] = ''; ?> </head> <body> </body> </html>
8 nov. 2006 à 12:32
ps : si c'est pas une blague volontaire, explique moi pourquoi creer $mail_ligne_x au lieu de $mail_lignes que tu concatene avec .= ?
8 nov. 2006 à 20:35
Bref J'le di au cas ou t'aurais pas compris,
l'explication de JulioDelphi,
Tu peux ajouter un comptenu a une variable deja existant,
Voila un exemple :
$la_chaine = 'a'; // Initialisation
$la_chaine .= 'b';
Echo $la_chaine; // "ab"
Voila,
Cordialement ~~ DotWizard512 ~~
9 nov. 2006 à 12:06
Moi aussi j'ai trouvé que le gars qui a fait cette source povais faire la concaténation...
9 nov. 2006 à 12:40
en meme temps, j'ai beau cherché je trouve pas d'auteur ni de droits ® alors laissons là ici =)
j'ai ça : http://dreamweaver.media-box.net/index.php?showtopic=17002&pid=118353&mode=threaded&show=&st=& rien de mieux
9 nov. 2006 à 16:37
et oui jaurai pu la modifier chui con ou quoi ??
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.