Hey
So have managed to get so far now, have added a button to close thankfully found the way of doing so
and partialy have the zip working, how ever for some reason it zips the entire platform and not the files contained within the folder…
Test on lab was working nicely except for the files not being zipped correctly and on the live it times out, I guess because it is zipping the entire 400mb platform…
Any ideas on how to solve this and only zip the files within the selected folder?
?>
<script>
function CloseModal()
{
window.parent.tb_remove();
}
</script>
<center><input type = “button” name = “btn_return” value = “Close Window” onClick = ‘Javascript:CloseModal();’></center>
<?php
$root = $_SERVER[‘DOCUMENT_ROOT’];
// Check for project
$check_sql = “SELECT projectref, companyid_FK”
. " FROM projects"
. " WHERE projectid = ‘" . [projectid] . "’";
sc_lookup(rs2, $check_sql);
$projectref = {rs2[0][0]};
$companyid = {rs2[0][1]};
// Check for company
$check_sql = “SELECT ref”
. " FROM company"
. " WHERE companyid = ‘" . $companyid . "’";
sc_lookup(rs1, $check_sql);
$companyref = {rs1[0][0]};
// List Directory Contents
$url = “$root/_lib/file/doc/”; // URL to files
$path = “$url$companyref/$projectref/”; // full path to the folder
// open this directory
$myDirectory = opendir($path) or die(“Unable to open $path”);
// get each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// close directory
closedir($myDirectory);
// count elements in array
$indexCount = count($dirArray);
// sort 'em
sort($dirArray);
//setup zip file of files
$date = date(‘Y-m-d’);
$zipname = “$companyref$projectref-$folder-$date.zip”;
$ziplocation = “$path$zipname”;
sc_zip_file($dirArray, $ziplocation);
// print 'em
print("<h4>Project Files - Worked and Quality</h4>");
print("<TABLE style=‘width: 100%’ border=1 cellpadding=5 cellspacing=0 class=whitelinks>
“);
print(”<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th><th>Modified</th><th></th></TR>
“);
// loop through the array of files and print them all
for($index=0; $index < $indexCount; $index++) {
if (substr(”$dirArray[$index]", 0, 1) != “.”){ // don’t list hidden files
$fileDate = filemtime($dirArray[$index]);
if ($fileDate) {
$fileDate = date("$format",$fileDate);
}
print("<TR><TD>$dirArray[$index]</td>");
print("<td>");
print(filetype($dirArray[$index]));
print("</td>");
print("<td>");
print(filesize($dirArray[$index]));
print("</td>");
print("<td>");
print("$fileDate");
print("</td>");
print("<td>");
print("<a href=\"$path$dirArray[$index]\" target=\"_blank\"><img src=\"$root/_lib/img/sys__NM__nm_smallicons_bluehover_bdownload.gif\" alt=\"Download\"/></a>");
print("</td>");
print("</TR>
“);
}
}
print(”</TABLE>
“);
print(“Download Zip: <a href=”$ziplocation” target="_blank">$zipname</a><br/>");
Print ("$indexCount files - including hidden<br>
");