I need to zip all the files in a directory (not including the folder). i tried to use an example on
www.php.net/sip to help me but i get a parse error. heres the whole code i have. The SQL statments insert it into a PHP nuke evo database. it already puts the files in the downloads section but i want it to include the ZIP file (as if to download all files).
<?php
$server = 'cali';
$etmain_cid = '3';
$etpub_cid = '';
$jaymod_cid = '4';
$etpro_cid = '';
$date = date('Y-m-d H-i-s');
$etmain = './etmain';
$etpub = './etpub';
$jaymod = './jaymod';
mysql_connect('localhost','***','***');
////////////////////////////////////
////////////Etmain/////////////////
//////////////////////////////////
$zip = new ZipArchive();
$filename = "./allfiles-$date";
while($file1 = readdir($directory1)) {
if($file1 != "." && $file1 != ".." && $file1 != "index.html"){
$stat1 = stat("$etmain/$file1");
$filesize1 = $stat[7];
echo '<tr><td>' . $file1 . '</td><td>' . $filesize1 . '</td></tr>';
if ($zip->open($filename1, ZIPARCHIVE::CREATE)!==TRUE) {
** exit("cannot open <$filename>\n");
}
$zip->addFile($etmain . "/$file1");
echo "numfiles: " . $zip->numFiles . "\n";
echo "status:" . $zip->status . "\n";
$zip->close();
}
}
mysql_query("DELETE FROM c1hess_phpnuke.nuke_downloads_downloads WHERE cid='$etmain_cid'");
if($directory = opendir($etmain)){
echo '<table border="1">Etmain additions:';
while($file = readdir($directory)) {
if($file != "." && $file != ".." && $file != "index.html"){
$stat = stat("$etmain/$file");
$filesize = $stat[7];
echo '<tr><td>' . $file . '</td><td>' . $filesize . '</td></tr>';
mysql_query("INSERT INTO c1hess_phpnuke.nuke_downloads_downloads (`cid`,`title`,`url`,`description`,`date`,`submitter`,`filesize`,`sub_ip`,`active`) VALUES ('$etmain_cid','$file','http://www.1hess.com/modsandmaps/$server/etmain/$file','Game File for [HESS] $server download to etmain.','$date','Piercy\'s directory bot','$filesize','$ip','1')");
}
}
echo '</table>';
closedir($directory);
}
?>
the parse error i get is:
Parse error: parse error, expecting `'('' in /Users/mike/sites/untitled folder/index.php on line 37
line 37 is:
if ($zip->open($filename1, ZIPARCHIVE::CREATE)!==TRUE) {
usually parse errors are easy to solve but i dont really know what im doing with the zip code.
Thanks in advance,
Piercy