fixed db connection
This commit is contained in:
+40
-121
@@ -1,121 +1,40 @@
|
||||
␍
|
||||
<?php␍
|
||||
// dump db and backup folder yogasoul... placed into claudiosironi.com ... folder of backup = tempzip in the main ideezeur folder␍
|
||||
␍
|
||||
␍
|
||||
//dump database ␍
|
||||
/*␍
|
||||
ini_set('memory_limit', '-1');␍
|
||||
// Database configuration␍
|
||||
$host = "localhost";␍
|
||||
$username = "u00wiumd4xnrd";␍
|
||||
$password = "ukowysga7w5x";␍
|
||||
$database_name = "dbcov4clvrmrzn";␍
|
||||
␍
|
||||
// Get connection object and set the charset␍
|
||||
$conn = mysqli_connect($host, $username, $password, $database_name);␍
|
||||
$conn->set_charset("utf8");␍
|
||||
␍
|
||||
␍
|
||||
// Get All Table Names From the Database␍
|
||||
$tables = array();␍
|
||||
$sql = "SHOW TABLES";␍
|
||||
$result = mysqli_query($conn, $sql);␍
|
||||
␍
|
||||
while ($row = mysqli_fetch_row($result)) {␍
|
||||
$tables[] = $row[0];␍
|
||||
}␍
|
||||
?>␍
|
||||
<?php␍
|
||||
$sqlScript = "";␍
|
||||
foreach ($tables as $table) {␍
|
||||
␍
|
||||
// Prepare SQLscript for creating table structure␍
|
||||
$query = "SHOW CREATE TABLE $table";␍
|
||||
$result = mysqli_query($conn, $query);␍
|
||||
$row = mysqli_fetch_row($result);␍
|
||||
␍
|
||||
$sqlScript .= "\n\n" . $row[1] . ";\n\n";␍
|
||||
␍
|
||||
␍
|
||||
$query = "SELECT * FROM $table";␍
|
||||
$result = mysqli_query($conn, $query);␍
|
||||
␍
|
||||
$columnCount = mysqli_num_fields($result);␍
|
||||
␍
|
||||
// Prepare SQLscript for dumping data for each table␍
|
||||
for ($i = 0; $i < $columnCount; $i ++) {␍
|
||||
while ($row = mysqli_fetch_row($result)) {␍
|
||||
$sqlScript .= "INSERT INTO $table VALUES(";␍
|
||||
for ($j = 0; $j < $columnCount; $j ++) {␍
|
||||
$row[$j] = $row[$j];␍
|
||||
␍
|
||||
if (isset($row[$j])) {␍
|
||||
$sqlScript .= '"' . $row[$j] . '"';␍
|
||||
} else {␍
|
||||
$sqlScript .= '""';␍
|
||||
}␍
|
||||
if ($j < ($columnCount - 1)) {␍
|
||||
$sqlScript .= ',';␍
|
||||
}␍
|
||||
}␍
|
||||
$sqlScript .= ");\n";␍
|
||||
}␍
|
||||
}␍
|
||||
␍
|
||||
$sqlScript .= "\n"; ␍
|
||||
}␍
|
||||
?>␍
|
||||
<?php␍
|
||||
if(!empty($sqlScript))␍
|
||||
{␍
|
||||
// Save the SQL script to a backup file␍
|
||||
$backup_file_name = '../tempbck/'.$database_name . '_backup_.sql';␍
|
||||
$fileHandler = fopen($backup_file_name, 'w+');␍
|
||||
$number_of_lines = fwrite($fileHandler, $sqlScript);␍
|
||||
fclose($fileHandler); ␍
|
||||
} */␍
|
||||
?>␍
|
||||
␍
|
||||
<? ␍
|
||||
// archive into ZIP the folder␍
|
||||
ignore_user_abort(true);␍
|
||||
set_time_limit(3600);␍
|
||||
␍
|
||||
␍
|
||||
$main_path = '../modulo_certificazione';␍
|
||||
$zip_file = '../tempbck//cimac.tar';␍
|
||||
␍
|
||||
if (file_exists($main_path) && is_dir($main_path)) ␍
|
||||
{␍
|
||||
$zip = new ZipArchive();␍
|
||||
␍
|
||||
if (file_exists($zip_file)) {␍
|
||||
unlink($zip_file); // truncate ZIP␍
|
||||
}␍
|
||||
if ($zip->open($zip_file, ZIPARCHIVE::CREATE)!==TRUE) {␍
|
||||
die("cannot open <$zip_file>\n");␍
|
||||
}␍
|
||||
␍
|
||||
$files = 0;␍
|
||||
$paths = array($main_path);␍
|
||||
while (list(, $path) = each($paths))␍
|
||||
{␍
|
||||
foreach (glob($path.'/*') as $p)␍
|
||||
{␍
|
||||
if (is_dir($p)) {␍
|
||||
$paths[] = $p;␍
|
||||
} else {␍
|
||||
$zip->addFile($p);␍
|
||||
$files++;␍
|
||||
␍
|
||||
echo $p."<br>\n";␍
|
||||
}␍
|
||||
}␍
|
||||
}␍
|
||||
␍
|
||||
echo 'Total files: '.$files;␍
|
||||
␍
|
||||
$zip->close();␍
|
||||
} ␍
|
||||
?>␍
|
||||
<?php
|
||||
// Archivia in ZIP la cartella modulo_certificazione (backup)
|
||||
// NB: il vecchio blocco di dump database è stato rimosso perché conteneva
|
||||
// credenziali in chiaro ed era disattivato. Se serve un dump DB,
|
||||
// usare mysqldump o un comando artisan dedicato.
|
||||
|
||||
ignore_user_abort(true);
|
||||
set_time_limit(3600);
|
||||
|
||||
$main_path = '../modulo_certificazione';
|
||||
$zip_file = '../tempbck//cimac.tar';
|
||||
|
||||
if (file_exists($main_path) && is_dir($main_path)) {
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if (file_exists($zip_file)) {
|
||||
unlink($zip_file); // truncate ZIP
|
||||
}
|
||||
if ($zip->open($zip_file, ZIPARCHIVE::CREATE) !== TRUE) {
|
||||
die("cannot open <$zip_file>\n");
|
||||
}
|
||||
|
||||
$files = 0;
|
||||
$paths = array($main_path);
|
||||
|
||||
while (list(, $path) = each($paths)) {
|
||||
foreach (glob($path . '/*') as $p) {
|
||||
if (is_dir($p)) {
|
||||
$paths[] = $p;
|
||||
} else {
|
||||
$zip->addFile($p);
|
||||
$files++;
|
||||
echo $p . "<br>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo 'Total files: ' . $files;
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user