Jump to content

Require some help with php_zip.dll or a zip class so my script can zip files..


@method

Recommended Posts

Require some help with php_zip.dll or a zip class so my script can zip files..

I run a smf forum... I have coded so far coded this

 

if (stripslashes($_GET['DownloadZiped']))
{
$id_msg = $_GET['DownloadZiped'];
$queryresult = mysql_query("SELECT * FROM backup_smf_attachments JOIN backup_smf_messages ON
	    backup_smf_attachments.id_msg=backup_smf_messages.id_msg WHERE backup_smf_messages.id_msg = '$id_msg'") or die(mysql_error());
		while ($fetcharray = mysql_fetch_array($queryresult))
{
$file_name = $fetcharray['id_attach'];
$real_name = $fetcharray['filename'];
foreach (glob('C:/Files/attachments17/'.$file_name.'_*') as $file_name) 
echo"$file_name - $real_name <br>";
}
}

 

To see the results of above code:

http://www.heaven2k.com/development/index.php?DownloadZiped=536153

 

This is the attachments of a message on my smf forum..

 

The bit im finding tricky is that what i want todo is instead of showing the results i want topass the filepaths/name in an array to the zip code to zip them up, it doesnt have to be this code, just anything that will utilise the the filepaths and filenames and zip them..

<?PHP
// create object
$zip = new ZipArchive();

// open output file for writing
if ($zip->open('my-archive.zip', ZIPARCHIVE::CREATE) !== TRUE) {
    die ("Could not open archive");
}

// add file from disk
$zip->addFile('app/webroot/img/arrow-prev.gif', 'webroot/img/arrow-prev.gif') or die ("ERROR: Could not add file");        

// add text file as string
$str = "<?PHP die('Access denied'); ?>";
$zip->addFromString('webroot/index.php', $str) or die ("ERROR: Could not add file");        

// add binary file as string
$str = file_get_contents('app/webroot/img/arrow-next.gif');
$zip->addFromString('webroot/img/arrow-next.gif', $str) or die ("ERROR: Could not add file");        

// close and save archive
$zip->close();
echo "Archive created successfully.";    
?>

 

Idearly when sombody goes to http://www.heaven2k.com/development/index.php?DownloadZiped=536153 it will use headers to launch the attachment of the topic as a Zip file to be downloaded this is actualy just 2 lines witht he zip filename and headers to launch file.

 

I am not to bad with php but when it comes to arrays and zip functions ive just got stuck  :/

 

Anyone who can provide me this ill send you $40 papal right away, to help me thats best i can do for you..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.