mrrajabi
چهارشنبه 26 تیر 1387, 15:27 عصر
با سلام خدمت اساتید محترم
من میخوام از سایتم پشتیبان بگیرم,از دیتابیس رو مشکلی ندارم ولی از فایلها و پوشه ها به طوری که پوشه بندیهارو رعایت کنه یکم به مشکل خوردم.
// GRD ZIP ARCHIVER
// by Piotr GRD
// http://grd.go.pl/
// grd@gazeta.pl
// created 2008-05-05
// free to use and modify as long as you keep info above
// requirements: php zip extensions with ZipArchive class
// SETTINGS
// directory you want to compress with everything inside
// . - for root
// folder - for some folder
// folder/subfolder - for some subfolder
// do not add ending slash
$directory = '.';
//$directory = 'folder';
// the name of your zip archive to be created
$zipfile = 'myziparchive.zip';
// DO NOT TOUCH BELOW IF YOU DONT KNOW WHAT IT IS
// all the process below
$filenames = array();
// function that browse the directory and all subdirectories inside
function browse($dir) {
global $filenames;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file($dir.'/'.$file)) {
$filenames[] = $dir.'/'.$file;
}
else if ($file != "." && $file != ".." && is_dir($dir.'/'.$file)) {
browse($dir.'/'.$file);
}
}
closedir($handle);
}
return $filenames;
}
browse($directory);
// creating zip archive, adding browsed files
$zip = new ZipArchive();
if ($zip->open($zipfile, ZIPARCHIVE::CREATE) !== TRUE) {
exit("cannot open <$zipfile>\n");
}
foreach ($filenames as $filename) {
echo "Adding " . $filename . "<br/>";
$zip->addFile($filename,$filename);
}
echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";
$zip->close();
راستش این کدارو گیر آوردم ولی کلاس ziparchive رو پیدا نکردم.هر چی گشتم پیدا نشد.توی همه ی سایتا هم فقط اشاره به این کلاس کردن ولی کدای خود کلاس رو نذاشتن.
حالا میخوام ببینم از عزیزان کسی آدرس این کلاسو داره یا اصلا یه کد پشتیبان گیری آماده هست یا نه؟
با تشکر پیشاپیش
من میخوام از سایتم پشتیبان بگیرم,از دیتابیس رو مشکلی ندارم ولی از فایلها و پوشه ها به طوری که پوشه بندیهارو رعایت کنه یکم به مشکل خوردم.
// GRD ZIP ARCHIVER
// by Piotr GRD
// http://grd.go.pl/
// grd@gazeta.pl
// created 2008-05-05
// free to use and modify as long as you keep info above
// requirements: php zip extensions with ZipArchive class
// SETTINGS
// directory you want to compress with everything inside
// . - for root
// folder - for some folder
// folder/subfolder - for some subfolder
// do not add ending slash
$directory = '.';
//$directory = 'folder';
// the name of your zip archive to be created
$zipfile = 'myziparchive.zip';
// DO NOT TOUCH BELOW IF YOU DONT KNOW WHAT IT IS
// all the process below
$filenames = array();
// function that browse the directory and all subdirectories inside
function browse($dir) {
global $filenames;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file($dir.'/'.$file)) {
$filenames[] = $dir.'/'.$file;
}
else if ($file != "." && $file != ".." && is_dir($dir.'/'.$file)) {
browse($dir.'/'.$file);
}
}
closedir($handle);
}
return $filenames;
}
browse($directory);
// creating zip archive, adding browsed files
$zip = new ZipArchive();
if ($zip->open($zipfile, ZIPARCHIVE::CREATE) !== TRUE) {
exit("cannot open <$zipfile>\n");
}
foreach ($filenames as $filename) {
echo "Adding " . $filename . "<br/>";
$zip->addFile($filename,$filename);
}
echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";
$zip->close();
راستش این کدارو گیر آوردم ولی کلاس ziparchive رو پیدا نکردم.هر چی گشتم پیدا نشد.توی همه ی سایتا هم فقط اشاره به این کلاس کردن ولی کدای خود کلاس رو نذاشتن.
حالا میخوام ببینم از عزیزان کسی آدرس این کلاسو داره یا اصلا یه کد پشتیبان گیری آماده هست یا نه؟
با تشکر پیشاپیش