start copy from cimac web
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// PHP program to delete all
|
||||
// file from a folder
|
||||
|
||||
// Folder path to be flushed
|
||||
$folder_path = "../../tempzip";
|
||||
|
||||
// List of name of files inside
|
||||
// specified folder
|
||||
$files = glob($folder_path.'/*');
|
||||
|
||||
// Deleting all the files in the list
|
||||
foreach($files as $file) {
|
||||
|
||||
if(is_file($file))
|
||||
|
||||
// Delete the given file
|
||||
unlink($file);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,4 @@
|
||||
[18-Feb-2023 07:57:55 UTC] PHP Fatal error: Uncaught Error: Call to a member function set_charset() on bool in /home/customer/www/cimac.it/public_html/modulo_certificazione/scripttool/zipfolder.php:16
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/customer/www/cimac.it/public_html/modulo_certificazione/scripttool/zipfolder.php on line 16
|
||||
@@ -0,0 +1,121 @@
|
||||
|
||||
<?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();
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user