Chciałbym napisać skrypt, który Tworzy kopie zapasową plików na serwerze.
Mam przygotowany wstepny skrypt w php:
Kod
<?php
$when=date("Y-m-d");
if (!file_exists('../BackUp')) {
mkdir('../BackUp', 0777, true);
echo 'Utworzono katalog BackUp <br>';
}
else{
}
// Get real path for our folder
$rootPath = realpath('../');
// Initialize archive object
$zip = new ZipArchive();
$zip->open('../BackUp/'.$when.'-backup1.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file)
{
// Skip directories (they would be added automatically)
if (!$file->isDir())
{
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
if((strpos($relativePath, 'BackUp') !== false) || (strpos($relativePath, 'zipper') !== false)){
//Omija katalog Backupu i skryptu
}
// Add current file to archive
else{
echo $relativePath."<br>";
$zip->addFile($filePath, $relativePath);
}
}
}
// Zip archive will be created only after closing object
$zip->close();
echo "BackUp Gotowy";
//Remove zipper.php
//unlink("zipper.php");
?>
$when=date("Y-m-d");
if (!file_exists('../BackUp')) {
mkdir('../BackUp', 0777, true);
echo 'Utworzono katalog BackUp <br>';
}
else{
}
// Get real path for our folder
$rootPath = realpath('../');
// Initialize archive object
$zip = new ZipArchive();
$zip->open('../BackUp/'.$when.'-backup1.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
// Create recursive directory iterator
/** @var SplFileInfo[] $files */
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file)
{
// Skip directories (they would be added automatically)
if (!$file->isDir())
{
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
if((strpos($relativePath, 'BackUp') !== false) || (strpos($relativePath, 'zipper') !== false)){
//Omija katalog Backupu i skryptu
}
// Add current file to archive
else{
echo $relativePath."<br>";
$zip->addFile($filePath, $relativePath);
}
}
}
// Zip archive will be created only after closing object
$zip->close();
echo "BackUp Gotowy";
//Remove zipper.php
//unlink("zipper.php");
?>
Problem w tym, że chciałbym aby informacje zostały wyświetlane na bieżąco o procesie działania skryptu.
Wystarczy mi przykład działania czegoś takiego, że np wprowadza w dane elementy dane rzeczy z przebiegu skryptu.
próbowałęm coś takiego, ale to chyba zły pomysł i zresztą nie działa

Kod
$( document ).ready(function() {
var auto_refresh = setInterval(
function ()
{
$('#load_updates').load('ziper.php').fadeIn("slow");
}, 10000); // refresh every 10000 milliseconds
});
var auto_refresh = setInterval(
function ()
{
$('#load_updates').load('ziper.php').fadeIn("slow");
}, 10000); // refresh every 10000 milliseconds
});