First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
+111
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
$ValidAccess = 2010;
|
||||
|
||||
require_once("include/globals.php");
|
||||
|
||||
unset($file_name);
|
||||
|
||||
//
|
||||
// Get document record from database
|
||||
//
|
||||
if (array_key_exists('dnum',$_GET) && $_GET['dnum'] > 0) {
|
||||
$dnum = intval(db_escape_string($_GET['dnum']));
|
||||
if ($dnum > 0) {
|
||||
$query = "select * from documents " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $dnum";
|
||||
$results = db_query($query);
|
||||
|
||||
if (db_num_rows($results)) {
|
||||
$row = db_fetch_array($results);
|
||||
extract($row);
|
||||
$fname = "filename=\"$file_name\"";
|
||||
$filedir = $uploaddir;
|
||||
}
|
||||
else {
|
||||
echo("<p>Document Not Found</p>\n");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo("<p>Invalid Document</p>\n");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!isset($file_name) && array_key_exists('dn',$_GET) && strlen($_GET['dn']) > 0) {
|
||||
$file_name = db_escape_string(trim($_GET['dn']));
|
||||
$file = explode("/",$file_name);
|
||||
$file_name = $file[0];
|
||||
$fname = "filename=\"$file_name\"";
|
||||
$filedir = "docs";
|
||||
}
|
||||
|
||||
|
||||
if (isset($file_name)) {
|
||||
if (is_file("$filedir/$file_name")) {
|
||||
$file_parts = pathinfo($file_name);
|
||||
if (array_key_exists('extension', $file_parts)) {
|
||||
switch ($file_parts['extension']) {
|
||||
case 'pdf':
|
||||
header('Pragma: public');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Cache-Control: private',false);
|
||||
header('Content-Type: application/pdf');
|
||||
header("Content-Disposition: attachment; $fname");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
readfile("$filedir/$file_name");
|
||||
break;
|
||||
|
||||
case 'doc':
|
||||
case 'docx':
|
||||
case 'rtf':
|
||||
header('Pragma: public');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Cache-Control: private',false);
|
||||
header('Content-Type: application/octet-stream');
|
||||
header("Content-Disposition: attachment; $fname");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
readfile("$filedir/$file_name");
|
||||
break;
|
||||
|
||||
case 'xls':
|
||||
case 'xlsx':
|
||||
header('Pragma: public');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Cache-Control: private',false);
|
||||
header('Content-Type: application/octet-stream');
|
||||
header("Content-Disposition: attachment; $fname");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
readfile("$filedir/$file_name");
|
||||
break;
|
||||
|
||||
case 'gif':
|
||||
header('Content-Type: image/gif');
|
||||
header('Content-Length: '.filesize("$filedir/$file_name"));
|
||||
readfile("$filedir/$file_name");
|
||||
break;
|
||||
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'jpe':
|
||||
header('Content-Type: image/jpeg');
|
||||
header('Content-Length: '.filesize("$filedir/$file_name"));
|
||||
readfile("$filedir/$file_name");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!isset($file_name)) $file_name = 'unknown';
|
||||
echo("<p>Document Not Found</p>\n");
|
||||
echo("<p>$file_name</p>\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user