Potrebna m je skripta gde cu da ubacim kod sebe u html (nema baze) i kad kliknem na nju da sam zipuje i svuce sve sa hostinga. Da neidem u cpanel pa backup nego jedanklik bukvalno.Hvala
Skidanje celog sajt???
Zakačeno
Za to ces morati da koristis php.
Kreiraj stranicu download.php (ili neko drugo ime) i dodaj kod:
Posle samo otvori tu stranicu 'download.php'
Postavi i neku zastitu da ne moze bas svako da pristupi stranici.
Obavezno testiraj pre nego postavis na server (sigurno radi, koristio sam davno, al' ipak proveri)
Kreiraj stranicu download.php (ili neko drugo ime) i dodaj kod:
Code:
<?php
$rootPath = realpath('../public'); // path do root foldera za skidanje
$zip = new ZipArchive(); // kreiranje zip-a
$zip_file = 'file.zip';
$zip->open($zip_file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
if (!$file->isDir()) {
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
$zip->addFile($filePath, $relativePath);
}
}
$zip->close();
// DOWNLOAD kreiranog zipa
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.basename($zip_file).'"');
header("Content-length: " . filesize($zip_file));
header("Pragma: no-cache");
header("Expires: 0");
ob_clean();
flush();
readfile($zip_file);
unlink($zip_file); // Obrisi zip da ne zauzima prostor
exit;
<?php
$rootPath = realpath('../public'); // path do root foldera za skidanje
$zip = new ZipArchive(); // kreiranje zip-a
$zip_file = 'file.zip';
$zip->open($zip_file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootPath),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
if (!$file->isDir()) {
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
$zip->addFile($filePath, $relativePath);
}
}
$zip->close();
// DOWNLOAD kreiranog zipa
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.basename($zip_file).'"');
header("Content-length: " . filesize($zip_file));
header("Pragma: no-cache");
header("Expires: 0");
ob_clean();
flush();
readfile($zip_file);
unlink($zip_file); // Obrisi zip da ne zauzima prostor
exit;
Posle samo otvori tu stranicu 'download.php'
Postavi i neku zastitu da ne moze bas svako da pristupi stranici.
Obavezno testiraj pre nego postavis na server (sigurno radi, koristio sam davno, al' ipak proveri)
Izbacim ovo
Ova stranica ne funkcioniše
Host mojsajt.rs trenutno ne može da obradi ovaj zahtev.
HTTP ERROR 500
Ova stranica ne funkcioniše
Host mojsajt.rs trenutno ne može da obradi ovaj zahtev.
HTTP ERROR 500
Uspeo,nisam lepo putanju postavio... Ali mi sajt od 3 mb pakuje 2 minuta