<?
/*
* Description: MySQL Backup tool
* Author: Arne C. Blystad
* Copyright: 2008 WebCodebase
* License: LICENSE FREE - Use as you want too
*********** @ How to use this tool @ ***********
* At the start of your script add this line:
* $dump = new sqlbackup;
* Config part:
* $dump->config("Database Server", "Database Username" , "Database Password", "Database");
* Example of config:
* $dump->config("localhost", "root", "xfx", "cds");
* To take the backup add this line:
* $dump->backup("filename","sql_backup_dir");
* Change filename to the name you want the file to be,
* Example:
* $dump->backup("backup_102.sql","dir");
* Warning: This file must be placed before any text, because it modifies your header info,
* To download the SQL file
*/
// ====================
## Class sqlbackup // Create SQL Backup and give the user a chance to download it
// ====================
class sqlbackup
{
//=============================//
// Start Webcodebase Backup Tool
//=============================//
// Define some variables.
var $nocomments;
var $db_serv;
var $db;
var $filename;
//================================================================================//
// Function: Config($db_serv, $user, $password, $db)
// Description: Do all the basic configuration for the connection to the database
//================================================================================//
function config( $db_serv, $user, $password, $db)
{
$this->db=$db;
$this->db_serv=$db_serv;
}
//======================================//
// Function: db_write($fp,$val)
// Description: Write text to textfile
//======================================//
function db_write($fp, $val){
}
//======================================//
// Function: write_header($filename)
// Description: Sets the content header
//======================================//
function write_header($filename){
header( "Content-type: application/force-download");
header( "Content-Disposition: inline; filename=\"" . $filename . "\"");
header( "Expires: Mon, 1 Jul 2010 01:00:00 GMT");
header( "Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0");
}
//==========================================================================//
// Function: backup($b_file)
// Description: Gets the SQL information and writes the backup to text
// Then gets the user to download the text file, if $b_file
// is empty it will write to a file called
// backup_DBNAME_TODAYSDATE.sql
//==========================================================================//
function backup($b_file="")
{
# Not working at this moment # $this->nocomment=$nocomment;
if($b_file){
$this->filename=$this->bdir.$b_file;
}else{
$this->filename = $this->bdir."backup_".$this->db."_".date("Y_m_d__G_i").".sql";
}
$this->write_header($this->filename);
$this->db_write($fp,"-- WebCodebase.com SQL Backup Tool \n");
$this->db_write($fm,"-- Copyright: 2008 Webcodebase \n");
$this->db_write($fp,"--\n");
$this->db_write($fp,"-- Host : $this->db_serv Database : $this->db\n");
$this->db_write($fp,"-- ---------------------------------------------\n");
$i = 0;
while ($i < $nb_row)
if($this->nocomment!=1){
$this->db_write($fp,"\n");
$this->db_write($fp,"\n");
$this->db_write($fp,"--\n");
$this->db_write($fp,"-- Table structure for table '$tablename' \n");
$this->db_write($fp,"--\n");
$this->db_write($fp,"\n");
}
$this->db_write($fp,"DROP TABLE IF EXISTS `$tablename`;\n");
$query = "SHOW CREATE TABLE $tablename";
$create = $row[1].";";
$this->db_write($fp,"$create\n\n");
if($this->nocomment!=1){
$this->db_write($fp,"--\n");
$this->db_write($fp,"-- Dumping data for table '$tablename' \n");
$this->db_write($fp,"--\n");
$this->db_write($fp,"\n");
}
$query = "SELECT * FROM $tablename";
{
$qinsert = "LOCK TABLES $tablename WRITE; \n";
$qinsert .= "INSERT INTO `$tablename` values \n ";
{ //set_time_limit(30); // In case your server is in "SAFE MODE" uncomment this line to set excute time limit //
$data = "$qinsert($data)";
$this->db_write($fp,"$data\n");
$qinsert=", ";
}
$this->db_write($fp,";\n");
$this->db_write($fp,"UNLOCK TABLES; \n");
$this->db_write($fp,"\n");
}else{
if($this->nocomment!=1){
$this->db_write($fp,"--\n");
$this->db_write($fp,"-- table '$tablename' empty \n");
$this->db_write($fp,"--\n");
$this->db_write($fp,"\n");
}
}
$i++;
}
}
//==================================================================//
// Function: sql_sql($tbl)
// Description: Adds ' to start and to end of each value in table.
//==================================================================//
function sep_sql($tbl)
{
if(!$tbl){return "NULL";}
return "'".$tbl."'";
}
//===============================//
// EOS
//===============================//
}
?>
z6tcah <a href="http://qjqwbmaibcli.com/">qjqwbmaibcli</a>, [url=http://pqmpfpebyzmc.com/]pqmpfpebyzmc[/url], [link=http://tfzrwjlvfcft.com/]tfzrwjlvfcft[/link], http://bfwqodchyqym.com/
5vDd2b <a href="http://glfqscitwkts.com/">glfqscitwkts</a>, [url=http://ktsbkpienfps.com/]ktsbkpienfps[/url], [link=http://xwebhclqoxsa.com/]xwebhclqoxsa[/link], http://gdfyuttgocox.com/
dfjqOX <a href="http://hlgzxswhplcn.com/">hlgzxswhplcn</a>, [url=http://mqxpqrxknujq.com/]mqxpqrxknujq[/url], [link=http://httzkjoulxif.com/]httzkjoulxif[/link], http://llahtusqxrde.com/
ZlEY16 <a href="http://opbftqxwuqgz.com/">opbftqxwuqgz</a>, [url=http://rxyehagyvdku.com/]rxyehagyvdku[/url], [link=http://lifuahfkrdlb.com/]lifuahfkrdlb[/link], http://wcepswzfqzsg.com/
wH2hxO <a href="http://szigyrcgecet.com/">szigyrcgecet</a>, [url=http://mdpnfvwobbhx.com/]mdpnfvwobbhx[/url], [link=http://qvbrvimkmtbg.com/]qvbrvimkmtbg[/link], http://uwnftlbwizbi.com/
w35tHd <a href="http://ocnuoljoymij.com/">ocnuoljoymij</a>, [url=http://zgqwzmmgdsfq.com/]zgqwzmmgdsfq[/url], [link=http://ksemczxlvygo.com/]ksemczxlvygo[/link], http://sxetwdxuygge.com/