function download_item($dir, $item)
{
    // download file
    // Security Fix:
    $item = basename($item);
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    $browser = id_browser();
    header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'));
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize($abs_item));
    if ($browser == 'IE') {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
    }
    @readfile($abs_item);
    exit;
}
示例#2
0
function download_item($dir, $item)
{
    // Security Fix:
    $item = basename($item);
    while (@ob_end_clean()) {
    }
    ob_start();
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    $browser = id_browser();
    header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'));
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize(realpath($abs_item)));
    //header("Content-Encoding: none");
    if ($browser == 'IE') {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
    }
    @set_time_limit(0);
    @readfile($abs_item);
    ob_end_flush();
    exit;
}
示例#3
0
function download_item($dir, $item, $unlink = false)
{
    // download file
    global $action, $mosConfig_cache_path;
    // Security Fix:
    $item = basename($item);
    while (@ob_end_clean()) {
    }
    ob_start();
    if (jx_isFTPMode()) {
        $abs_item = $dir . '/' . $item;
    } else {
        $abs_item = get_abs_item($dir, $item);
        if (!strstr($abs_item, realpath($GLOBALS['home_dir']))) {
            $abs_item = realpath($GLOBALS['home_dir']) . $abs_item;
        }
    }
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!$GLOBALS['jx_File']->file_exists($abs_item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    if (jx_isFTPMode()) {
        $abs_item = jx_ftp_make_local_copy($abs_item);
        $unlink = true;
    }
    $browser = id_browser();
    header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'));
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize(realpath($abs_item)));
    //header("Content-Encoding: none");
    if ($browser == 'IE') {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
    }
    @set_time_limit(0);
    @readFileChunked($abs_item);
    if ($unlink == true) {
        unlink($abs_item);
    }
    ob_end_flush();
    jx_exit();
}
示例#4
0
function _download_header($filename, $filesize = 0)
{
    $browser = id_browser();
    header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'));
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Transfer-Encoding: binary');
    if ($filesize != 0) {
        header('Content-Length: ' . $filesize);
    }
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    if ($browser == 'IE') {
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
    }
}
示例#5
0
function download_item($dir, $item)
{
    // download file
    // Security Fix:
    $item = base_name($item);
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    $browser = id_browser();
    header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'));
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . get_file_size($dir, $item));
    header('Content-Description: File Download');
    if ($browser == 'IE') {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
    }
    //@readfile($abs_item);
    flush();
    $fp = popen("tail -c " . get_file_size($dir, $item) . " {$abs_item} 2>&1", "r");
    while (!feof($fp)) {
        // Send the current file part to the browser.
        print fread($fp, 1024);
        // Flush the content to the browser.
        flush();
    }
    fclose($fp);
    exit;
}
示例#6
0
 function execAction($dir, $item, $unlink = false)
 {
     // Security Fix:
     $item = basename($item);
     while (@ob_end_clean()) {
     }
     ob_start();
     if (ext_isFTPMode()) {
         $abs_item = $dir . '/' . $item;
     } else {
         $abs_item = get_abs_item($dir, $item);
         //if( !strstr( $abs_item, $GLOBALS['home_dir']) )
         //	$abs_item = realpath($GLOBALS['home_dir']).$abs_item;
     }
     if (!$GLOBALS['ext_File']->file_exists($abs_item)) {
         ext_Result::sendResult('download', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]);
         return false;
     }
     if (!get_show_item($dir, $item)) {
         ext_Result::sendResult('download', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]);
         return false;
     }
     @set_time_limit(0);
     if (ext_isFTPMode()) {
         $abs_item = ext_ftp_make_local_copy($abs_item);
         $unlink = true;
     }
     $browser = id_browser();
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Content-Transfer-Encoding: binary');
     header('Content-Length: ' . filesize(realpath($abs_item)));
     //header("Content-Encoding: none");
     if (isset($_GET['action2']) && $_GET['action2'] == 'view') {
         $content_disposition = 'inline';
         include_once _EXT_PATH . '/libraries/Archive/file.php';
         $extension = extFile::getExt($item);
         switch (strtolower($extension)) {
             case 'doc':
             case 'dot':
                 $extension = 'msword';
                 break;
             case 'docx':
             case 'dotx':
                 $extension = 'vnd.openxmlformats-officedocument.wordprocessingml.template';
                 break;
             case 'docm':
                 $extension = 'vnd.ms-word.document.macroEnabled.12';
                 break;
             case 'docm':
                 $extension = 'vnd.ms-word.template.macroEnabled.12';
                 break;
             case 'xls':
             case 'xlt':
             case 'xla':
                 $extension = 'vnd.ms-excel';
                 break;
             case 'xlsx':
                 $extension = 'vnd.openxmlformats-officedocument.spreadsheetml.sheet';
                 break;
             case 'xltx':
                 $extension = 'vnd.openxmlformats-officedocument.spreadsheetml.template';
                 break;
             case 'xlsm':
                 $extension = 'vnd.ms-excel.sheet.macroEnabled.12';
                 break;
             case 'xltm':
                 $extension = 'vnd.ms-excel.template.macroEnabled.12';
                 break;
             case 'xlam':
                 $extension = 'vnd.ms-excel.addin.macroEnabled.12';
                 break;
             case 'xlsb':
                 $extension = 'vnd.ms-excel.sheet.binary.macroEnabled.12';
                 break;
             case 'ppt':
             case 'pot':
             case 'pps':
             case 'ppa':
                 $extension = 'vnd.ms-powerpoint';
                 break;
             case 'pptx':
                 $extension = 'vnd.openxmlformats-officedocument.presentationml.presentation';
                 break;
             case 'potx':
                 $extension = 'vnd.openxmlformats-officedocument.presentationml.template';
                 break;
             case 'ppsx':
                 $extension = 'vnd.openxmlformats-officedocument.presentationml.slideshow';
                 break;
             case 'ppam':
                 $extension = 'vnd.ms-powerpoint.addin.macroEnabled.12';
                 break;
             case 'pptm':
                 $extension = 'vnd.ms-powerpoint.presentation.macroEnabled.12';
                 break;
             case 'potm':
                 $extension = 'vnd.ms-powerpoint.template.macroEnabled.12';
                 break;
             case 'ppsm':
                 $extension = 'vnd.ms-powerpoint.slideshow.macroEnabled.12';
                 break;
             case 'rtf':
                 $extension = 'application/rtf';
                 break;
         }
         header('Content-Type: application/' . $extension . '; Charset=' . $GLOBALS["system_charset"]);
     } else {
         $content_disposition = 'attachment';
         if ($browser == 'IE' || $browser == 'OPERA') {
             header('Content-Type: application/octetstream; Charset=' . $GLOBALS["system_charset"]);
         } else {
             header('Content-Type: application/octet-stream; Charset=' . $GLOBALS["system_charset"]);
         }
     }
     if ($browser == 'IE') {
         // http://support.microsoft.com/kb/436616/ja
         header('Content-Disposition: ' . $content_disposition . '; filename="' . urlencode($item) . '"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     } else {
         header('Content-Disposition: ' . $content_disposition . '; filename="' . $item . '"');
         header('Cache-Control: no-cache, must-revalidate');
         header('Pragma: no-cache');
     }
     if ($GLOBALS['use_mb']) {
         if (mb_detect_encoding($abs_item) == 'ASCII') {
             @readFileChunked(utf8_decode($abs_item));
         } else {
             @readFileChunked($abs_item);
         }
     } else {
         @readFileChunked(utf8_decode($abs_item));
     }
     if ($unlink == true) {
         unlink(utf8_decode($abs_item));
     }
     ob_end_flush();
     ext_exit();
 }
示例#7
0
        // if the startup folder is defined all files are included
        glz_require_once_dir(org_glizy_Paths::get('APPLICATION_STARTUP'));
    }
}
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : NULL;
if (is_null($id)) {
    exit;
}
glz_import('org.glizycms.mediaArchive.MediaManager');
$media = org_glizycms_mediaArchive_MediaManager::getMediaById($id);
if (!$media || !$media->exists()) {
    header('HTTP/1.0 404 Not Found');
    echo "<h1>404 Not Found " . $media->originalFileName . "</h1>";
    exit;
}
$browser = id_browser();
$extension = strtolower(substr(strrchr($media->originalFileName, '.'), 1));
switch ($extension) {
    case "pdf":
        $ctype = "application/pdf";
        $disposition = "inline";
        break;
    case "vcf":
        $ctype = "application/vcard";
        break;
    case "exe":
        $ctype = $browser == 'IE' || $browser == 'OPERA' ? "application/octetstream" : "application/octet-stream";
        break;
    case "zip":
        $ctype = "application/zip";
        break;