이 코드를 사용하여 (protect)라는 보호 된 디렉토리 (사용자 이름 & 암호) 내용을 읽습니다. 내가 보호 된 디렉토리 위치가 아닌 differerent 위치에 내 코드 파일을 배치하면PHP에서 ZipArchive 클래스 사용
<?php
require_once("admin/global.inc.php");
// increase script timeout value
ini_set('max_execution_time', 300);
//Generate a new flag
$random = (rand(000000,999999));
$date = date("y-m-d");
// create object
$zip = new ZipArchive();
// open archive
if ($zip->open("$date-$random.zip", ZIPARCHIVE::CREATE) !== TRUE) {
die ("Could not open archive");
}
// initialize an iterator
// pass it the directory to be processed
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("protect/")); //check question #2
// iterate over the directory
// add each file found to the archive
foreach ($iterator as $key=>$value) {
if ($key != 'protect/.htaccess')
{
$zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
$query="INSERT INTO `archives_logs` (`id`, `file`, `flag`, `date`) VALUES (NULL, '$key', '$random', '$date')";
$query_result = mysql_query ($query);
}
}
// close and save archive
$zip->close();
echo "Archive created successfully.";
?>
, 내가 잘되는 압축 할 디렉토리의 경로를 변경해야하지만, 문제는 경로에있는 모든 디렉토리가 있다는 것입니다 Zip 아카이브에 포함되어 있습니다. 그래서 내가 얻을 압축 된 파일을 열 경우 : www /에서 사용자 이름/public_html을/등등 ... 여기
는 디렉토리 strcuture입니다 : www /에서 여기 (/ (여기에 압축 할 파일) www /에서 compress_code.php를 보호 내 현재 코드 파일)나는이 내 코드 파일을 저장하고자하는 경로 : www /에서/관리/파일/compress_code.php 보호
나는 내 코드 파일을 유지하려면 어떻게Q1) 내 ZipArchive 파일에 경로를 포함하지 않고 마지막으로 언급 한 위치?
Q2) 내 코드가 압축 될 디렉토리의 동일한 위치에 있고 내가 볼 때 압축 파일을 열 때/(파일)을 보호하십시오. 디렉토리 자체를 제외하지 않고 Zip 아카이브에 protect 디렉토리의 내용 만 추가 할 수 있습니까?