Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

simosoft
Wednesday, August 6th, 2008 at 5:27:07am MDT 

  1. <?
  2. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  3. //ici les parametres pour la connexion
  4.    require_once('configs/config.php');
  5. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  6.  
  7. $action = @$_GET["action"];
  8.  
  9. if($action=="oui") {
  10.  
  11.    function Compacter($dbname) { // Permet de compacter la base avant de lancer toute la procédure
  12.       $tables = mysql_list_tables($dbname);
  13.       while ($enr = mysql_fetch_row($tables))
  14.          @mysql_query("OPTIMIZE TABLE ".$enr[0]);
  15.    }
  16.  
  17.    if($connexion = @mysql_connect($dbhost,$dbuser,$dbpasswd)) { // on effectue la connexion
  18.  
  19.       Compacter($dbname);
  20.      
  21.       $select_base=@mysql_select_db($dbname); // Selection de la base de données
  22.      
  23.       // CREATION DU FICHIER
  24.      
  25.       $fname = date('d-m-Y')."_"."[".$dbnick."]".".sql";
  26.       $f2 = fopen($fname,"w");
  27.      
  28.       fputs($f2,"# Sauvegarde de base de données\n");
  29.       fputs($f2,"# Batch par Florent MARIE aka fmarie - 2005\n\n");
  30.       $tables = mysql_list_tables($dbname);
  31.       while ($enr = mysql_fetch_row($tables)) {
  32.          fputs($f2,"# Les tables traitées sont ".$enr[0].";\n");
  33.       }
  34.       fputs($f2,"\n");
  35.       $tables = mysql_list_tables($dbname);
  36.       while ($enr = mysql_fetch_row($tables)) {
  37.          fputs($f2,"DELETE FROM $enr[0];\n");
  38.       }
  39.      
  40.       $tables = mysql_list_tables($dbname);
  41.       while ($enr = mysql_fetch_row($tables)) {
  42.          $res = mysql_query("SELECT * FROM $enr[0]");
  43.          // le nombre de champs de la table
  44.          $champs = mysql_num_fields($res)
  45.          // Pour chaque ligne
  46.          while($val=mysql_fetch_array($res)) {
  47.             $tmp = "INSERT INTO ".$enr[0]." VALUES(";
  48.             $c=0;
  49.             // Pour chaque champ
  50.             while($c < $champs) {
  51.                // Une virgule sauf au premier
  52.                if($c>0) $tmp .= ", ";
  53.                // Le contenu du champ
  54.                $tmp .= "'".AddSlashes($val[$c])."'";
  55.                $c++;
  56.             }
  57.             $tmp .= ");\n";
  58.             // Ecrit la ligne
  59.             fputs($f2,$tmp);
  60.          }
  61.       }
  62.       fclose($f2);
  63.      
  64.       // ZIP DU FICHIER
  65.      
  66.       include("configs/zip.lib.php");
  67.      
  68.       // Compresse le fichier
  69.       $zipfile = new zipfile();
  70.       $zipfile -> addFile(implode("",file($fname)), $fname);
  71.       // Sauve le zip
  72.       $f2=fopen($fname.".zip","w");
  73.       fputs($f2,$zipfile -> file());
  74.       fclose($f2);
  75.      
  76.       // NETTOYAGE
  77.      
  78.       // Détruit le fichier initial
  79.       // mais laisse le zip au cas où...
  80.       unlink($fname);
  81.      
  82.       // ENVOI LE ZIP EN PJ
  83.      
  84.       include("configs/mail.php");
  85.       // Original => sendMail($nomFrom,$mailFrom,$nomTo,$mailTo,$CC,$BCC,$sujet,$body,$pj)
  86.       sendMail($nomFrom,$mailFrom,$nomTo,$mailTo,$CC,$BCC,"[".date('d-M-Y')."] Sauvegarde SQL de $dbname","La voila, elle est toute chaude toute prête..."."\n"."Votre sauvegarde SQL du [".date('d-M-Y')."] de \"$dbnick\" sur Free","$fname".".zip")
  87.  
  88.       ?>
  89.       Sauvegarde effectuée avec succès...
  90.       <?
  91.    }
  92.  
  93.  
  94. }   
  95. else { ?>
  96.  
  97.    Cliquez <a href="save.php?action=oui">ICI</a> pour sauvegarder la base de donnée et l'envoyer par mail à l'administrateur...
  98.  
  99. <? }
  100. ?>

Paste Details

Tags: c

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right