<?php
/****************************************************************
MYSQL INFORMATIE :
*****************************************************************/
$mysql_host = "localhost"; # server met mysql
$mysql_user = "dekoffie"; # gebruikersnaam voor mysql
$mysql_paswoord = "paswoordje"; # paswoord voor mysql
$schrijfbare_map = "h:/webserver/wwwroot/sitemasters.be/scripts/"; # een map waarin het script toegang heeft om files neer te schrijven en te deleten
/****************************************************************
HIER begint het eigenlijke script:
*****************************************************************/
if($_POST['action'] == "maak_backup") {
$database = $_POST['database'];
$bestandsnaam = $_POST['bestandsnaam'];
ini_set("max_execution_time",3600); // script mag maximaal een uur processen.
foreach($_POST as $key => $value) {
if($value == "invoegen") {
for ($i = 0; $i < $columns; $i++) {
// echo mysql_field_name($fields, $i) . "<br>\n";
}
$valuestr .= "\r\nDELETE FROM $key;\r\n";
// $valuestr .= "INSERT INTO $key ($fieldstr) VALUES ";
$valuestr .= "INSERT INTO $key VALUES ";
for ($i = 0; $i < $columns; $i++) {
$columnvalue = str_replace("\r\n","\\r\\n",$var->$column);
if($i > 0) { $valuestr .= ",'" . $columnvalue . "'"; }
else { $valuestr .= "('" . $columnvalue . "'"; }
}
//$valuestr = str_replace("<","<",$valuestr);
//$valuestr = str_replace(">",">",$valuestr);
//$valuestr = str_replace("\r\n","\\r\\n",$valuestr);
$valuestr .= ");\r\n";
}
}
}
$backfile = $schrijfbare_map . $bestandsnaam;
$fp = fopen($backfile,"w+");
$f = fopen($backfile, "r");
header("Content-type: application/force-download"); header("Content-Disposition: inline; filename=" . $bestandsnaam);
// echo str_replace(");\n",");<br>",$valuestr);
}
?>
<HTML>
<HEAD>
<TITLE>>>Backup Depot <<</TITLE>
</HEAD>
<script language = "Javascript">
var form='postform'
function SelecteerAlles() {
if (document.postform.check_all.checked==1) {
val=1;
} else {
val=0;
}
dml=document.forms[form];
len = dml.elements.length;
var i=0;
for( i=0 ; i<len ; i++) {
if (dml.elements[i].value=='invoegen') {
dml.elements[i].checked=val;
}
}
}
</script>
<BODY BGCOLOR="#CCCCCC">
<center>
<?php
if($_POST['action'] == "db_tabellen") {
$database = $_POST['database'];
?>
<form action="
<?php echo $PHP_SELF; ?>" name="postform" method="POST">
<input type="hidden" value="maak_backup" name="action">
<input type="hidden" value="
<?php echo $database; ?>" name="database">
<TABLE border="1" width="40%">
<TR><TD colspan="5"><b><center><font color=red>Backuping</font></center></b></TD></TR>
<TR>
<TD colspan="2"><center><b>Bestandsnaam van de backup</b></center></TD>
</TR>
<TR bgcolor="#E8E8E8">
<TD><center>Naam:</center></TD>
<TD width="5%"><center><input type="text" value="
<?php echo $database; ?>_backup.dko" name="bestandsnaam"></TD>
</TR>
<TR>
<TD><center><b>Tabel</b></center></TD>
<TD width="5%"><center><b>Invoegen?</b></center></TD>
</TR>
<?php
?>
<TR bgcolor="#E8E8E8">
<TD><center>
<?php echo $tabel; ?></center></TD>
<TD width="5%"><center><input type="checkbox" value="invoegen" name="
<?php echo $tabel; ?>"></TD>
</TR>
<?php
}
?>
<TR bgcolor="#CCCCCC"><TD COLSPAN="5"><center>
<input type="checkbox" name="check_all" value="checkall" onClick="javascript:SelecteerAlles()"> Alle items selecteren.
</center>
<TR><TD bgcolor="#CCCCCC" colspan="5"><center><input type="submit" value="Maak Backup File!" name="save"></center></TD></TR>
</TD></TR>
</TABLE>
</form>
<p>
Gemaakt door <a href="mailto:dekoffie@kfplan.be">dekoffie</a>.
<?php
} else {
?>
<form action="
<?php echo $PHP_SELF; ?>" name="postform" method="POST">
<input type="hidden" value="db_tabellen" name="action">
<TABLE border="1" width="40%">
<TR><TD colspan="5"><b><center><font color=red>Backuping</font></center></b></TD></TR>
<TR>
<TD><center><b>Databases</b></center></TD>
</TR>
<TR bgcolor="#E8E8E8">
<TD><center>
<select name="database">
<?php
echo "<option value=\"" . $var->Database . "\">" . $var->Database . "</option>\n"; }
?>
</select>
</center>
</TD>
</TR>
<TR bgcolor="#CCCCCC"><TD bgcolor="#CCCCCC"><center><input type="submit" value="Laat Tabellen zien!" name="tabelzien"></center></TD></TR>
</TABLE>
</form>
<p>
Gemaakt door <a href="mailto:dekoffie@kfplan.be">dekoffie</a>.
<?php
}
?>
</center>
</HTML>