<?
// example of a back up for a base mysql
// to put in a folder of your site with the file phpmysqldump.pclass
// *************warning*********
// this folder must be reachable in writing by your web server
//
// put your parameters mysql
$host="localhost";
$base="database to backup";
$login="your mysql login";
$password="you mysql password";
// ou utiliser le formulaire
if($_REQUEST[host]){$host=$_REQUEST[host];}
if($_REQUEST[base]){$base=$_REQUEST[base];}
if($_REQUEST[login]){$login=$_REQUEST[login];}
if($_REQUEST[password]){$password=$_REQUEST[password];}
require("phpmysqldump.pclass");
// in this order a link mysql, the host address, the username, the password and the name of the base to back up
// if the link mysql is absnt we use the host, name et pass
// if the link is present it is the priority link, the other parameters must be ""
$sav = new phpmysqldump( $host, $login, $password, $base, "en", $link);
if($base=="database to backup"){$sav->errr="input informations";}
//$sav->format_out="no_comment"; // if we don’t want the comments in the dump uncomment this line
$sav->nettoyage(); // optional – erase the old back up files
$sav->fly=1; // not use drive send the dump directly to the browser
//$sav->compress_ok=1; // flag to activate compression
$sav->backup(); // launch the back up
// $sav->backup("test.sql"); // launch the back up with a filename chosen by the user
// $sav->compress(); // optional - compress to the gz format without using the shell
// it's better to use the compress_ok flag
// a little bit of HTML to display the example
if(!$sav->errr && $sav->fly){exit();}
?>
<html>
<head>
<title>TEST PHPMYSQLDUMP</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center"><font size="+2"><strong>MySQL database backup</strong></font><br>
</div>
<form name="form1" method="post" action="">
<table width="50%" border="1" align="center">
<tr>
<td>Server</td>
<td>-<? echo $sav->host; ?>-</td>
</tr>
<tr>
<td>Database</td>
<td>-<? echo $sav->base; ?>-</td>
</tr>
<tr>
<td>File to download</td>
<td>-<a href="<? echo $sav->filename; ?>"><? echo $sav->filename; ?></a>-</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>server to save</td>
<td><input name="host" type="text" value="<? echo $host; ?>"></td>
</tr>
<tr>
<td>database name to save</td>
<td><input type="text" name="base" value="<? echo $base; ?>"></td>
</tr>
<tr>
<td>Login MySQL</td>
<td> <input type="text" name="login" value="<? echo $login; ?>"> </tr>
<tr>
<td>Password MySQL</td>
<td><input type="text" name="password" value="<? echo $password; ?>"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="bouton" value="Envoyer"></td>
</tr>
</table>
</form>
<? if(!$_REQUEST[bouton]){ ?>
You can make backup :<br>
1 PHP and MySQL are on a distant WEB server you backup the database on your local
computer <br>
2 PHP is on your local computer MySQL is distant<br>
3 PHP and MySQL are on your local computer
<? } ?>
<p align="center"><font color="#FF0000" size="+1"><strong>-<? echo $sav->errr; ?>-</strong></font></p>
<p align="center"><strong><font size="-2">Contact me </font><font size="-2"> <a href="mailto:phpdev@cawete.com">pascal@cawete.com</a>
</font></strong></p>
</body>
</html>
|