Hi,
was wondering if anyone could help me. i have the following script, the pages hosts online fine without any errors however when i click on the zip file to open and extract, it doesnt work. Can any of you more experience php developers help me out. i'm currently using adobe ds3.
<?php
if(!session_id()){
session_start();
}
// Set variable defaults
$ref = 0;
// *****************************
// Define functions
function select($docname) {
// Show a useful filename
$dispname = array(
'customer_user_guide.zip' => '[03]Customer User Guide',
'payment_terms.pdf' => '[05]Payment Terms',
'demo_document.zip' => '[05]Demo Document'
);
// This adds the number from above, but has no use if not a billing file
reset($dispname);
while(current($dispname)){
if(key($dispname) == $docname){
$docname = current($dispname);
break;
}
next($dispname);
}
return($docname);
}
function directory($flist) {
$fldr="document_files";
$rdir=opendir($fldr);
while ($file = readdir($rdir)) {
if ($file == "." || $file == ".."){
$_SESSION['MM_items']=$ref;
}
else
{
$ref++;
$_SESSION['MM_items']=$ref;
$_SESSION['$files['.$ref.']'] = $fldr."/".$file;
$size=round((filesize($fldr."/".$file)/1024),2);
$docname = $file;
$actname = substr(select($docname),4);
$icon = substr(select($docname),0,4);
if($size<'1024'){
$d_name = $actname;
$_SESSION['$savename['.$ref.']'] = $actname.'.zip';
$d_size = '['.$size.' KB]';
} else {
$size = round(($size/1024),2);
$d_name = $actname;
$_SESSION['$savename['.$ref.']'] = $actname.'.zip';
$d_size = '['.$size.' MB]';
}
print "
<table width='330' height='20' border='0' cellspacing='0' cellpadding='0'>
<tr align='left'>
<td width='35' align='center' valign='middle'><input type='image' src='images/".$icon.".jpg' title='".$d_name."' onClick='javascript:form1.Id.value=\"".$ref."\";document.form1.submit();'></></td>
<td width='295' align='left' valign='middle'><font class='plaintext'>".$d_name." <font color=#ff9900>".$d_size."</font></font></td>
</tr>
</table>
";
}
}
closedir($rdir);
return $flist;
}
// ************************
// Main Section
// Query user folder and get the whole directory of files
echo directory($flist);
if($_SESSION['MM_items']==0){
echo "<font class='plaintext'>Sorry, there are currently no files available for download.</font>";
}
?>