File: old mirari open.php - Tab length: 1 2 4 8 - Lines: on off - No wrap: on offfunction Open ($mysql, $code)
{
$file = PATH_FILE . '/' . $code;
if (!is_file ($file))
return 2;
if ($mysql->Query ('SELECT `force`, `name` FROM `' . MYSQL_PREF . 'file` WHERE `code` = \'#\'', array ($code)))
{
$this->err = $mysql->Error ();
return 1;
}
if (!($fetch = $mysql->Fetch ()))
return 2;
$mysql->Close ();
$known = array ( 'avi' => 'video/x-msvideo',
'bmp' => 'image/x-ms-bmp',
'bz2' => 'application/octet-stream',
'c' => 'text/plain',
'cc' => 'text/plain',
'cpp' => 'text/plain',
'doc' => 'application/msword',
'exe' => 'application/octet-stream',
'gif' => 'image/gif',
'h' => 'text/plain',
'hh' => 'text/plain',
'hpp' => 'text/plain',
'htm' => 'text/plain',
'html' => 'text/plain',
'jpeg' => 'image/jpg',
'jpg' => 'image/jpg',
'mp3' => 'audio/mpeg',
'mpe' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mov' => 'video/quicktime',
'nfo' => 'text/plain',
'pdf' => 'application/pdf',
'php' => 'text/plain',
'php3' => 'text/plain',
'php4' => 'text/plain',
'php5' => 'text/plain',
'png' => 'image/png',
'ppt' => 'application/vnd.ms-powerpoint',
'rtf' => 'text/richtext',
'swf' => 'application/x-shockwave-flash',
'tar' => 'application/octet-stream',
'txt' => 'text/plain',
'xls' => 'application/vnd.ms-excel',
'wav' => 'audio/x-wav',
'zip' => 'application/zip');
$ext = $this->Ext (basename ($fetch['name']));
if (isset ($known[$ext]))
{
$force = $fetch['force'];
$type = $known[$ext];
}
else
{
$force = true;
$type = 'application/force-download';
}
// header ('Content-Description: ' . ($force ? 'File Transfer' : $type));
header ('Content-Type: ' . $type);
header ('Content-Length: ' . filesize ($file));
header ('Content-Disposition: ' . ($force ? 'attachment' : 'inline') . '; filename="' . $fetch['name'] . '";');
header ('Content-Transfer-Encoding: binary');
readfile ($file);
exit (0);
}