"; while ($row=mysql_fetch_array($result, MYSQL_ASSOC)){ $dtable.="{$row['descriere']}"; $dtable.="
"; } $dtable.=""; } else{ $query="SELECT * FROM `download` WHERE `id`='".$id."'"; $result=mysql_query($query); $row=mysql_fetch_array($result, MYSQL_ASSOC); $fp=$path."download/{$row['fisier']}"; download($fp); exit; } $page=new ModulePage; $page->page_location("$path"."templates/download.html"); $page->parse_variable(array(PTITLU=>"{$sitename} :: Cititul nu dauneaza sanatatii.", TABEL=>$dtable) ); echo $page->send_page; exit; function download($fullPath){ if ($fd = fopen ($fullPath, "r")) { $fsize = filesize($fullPath); $path_parts = pathinfo($fullPath); $ext = strtolower($path_parts["extension"]); switch ($ext) { case "pdf": header("Content-type: application/pdf"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachement' to force a download case "doc": header("Content-type: application/doc"); // add here more headers for diff. extensions header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachement' to force a download break; default; header("Content-type: application/octet-stream"); header("Content-Disposition: filename=\"".$path_parts["basename"]."\""); } header("Content-length: $fsize"); header("Cache-control: private"); //use this to open files directly while(!feof($fd)) { $buffer = fread($fd, 2048); echo $buffer; } } fclose ($fd); return; } ?>