示例#1
0
            $success = dl_file_resume($fileinfo['file'], $fileinfo, true);
        }
    }
    // we hack in the stream.php here
} elseif ($file = isset($_GET['file']) ? clean_slweg($_GET['file'], 40) : '') {
    $filename = basename($file);
    $file = PHPWCMS_ROOT . '/' . PHPWCMS_FILES . $filename;
    if (is_file($file)) {
        $mime = empty($_GET['type']) ? '' : clean_slweg($_GET['type'], 100);
        if (!is_mimetype_format($mime)) {
            $mime = get_mimetype_by_extension(which_ext($file));
        }
        header('Content-Type: ' . $mime);
        if (BROWSER_OS == 'iOS') {
            require_once PHPWCMS_ROOT . '/include/inc_lib/functions.file.inc.php';
            rangeDownload($file);
        } else {
            header('Content-Transfer-Encoding: binary');
            if (!isset($_GET['ios'])) {
                header('Content-Disposition: inline; filename="' . ($phpwcms['sanitize_dlname'] ? phpwcms_remove_accents($filename) : $filename) . '"');
            }
            header('Content-Length: ' . filesize($file));
            readfile($file);
        }
        $success = true;
    }
}
if ($success) {
    $sql = "UPDATE " . DB_PREPEND . "phpwcms_file SET f_dlfinal=f_dlfinal+1 ";
    $sql .= "WHERE f_hash=" . _dbEscape($download["f_hash"]) . " LIMIT 1";
    _dbQuery($sql, 'UPDATE');
示例#2
0
文件: movie.php 项目: codeix/superPi8
header("Content-Length: " . filesize($path));
if ($_REQUEST['download']) {
    header("Content-Disposition: attachment; filename=" . basename($path));
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header("Content-Description: File Transfer");
} else {
    if (isset($_SERVER['HTTP_RANGE'])) {
        header('Content-Type: ' . $MAP[$type]['mime']);
    }
}
$line = date('Y-m-d H:i:s') . " - {$_SERVER['REMOTE_ADDR']} File:{$path}" . ($_REQUEST['download'] ? ' as download' : ' as stream');
file_put_contents('../logs/visitors.log', $line . PHP_EOL, FILE_APPEND);
if (isset($_SERVER['HTTP_RANGE'])) {
    rangeDownload($path);
} else {
    readfile($path);
}
// http://mobiforge.com/design-development/content-delivery-mobile-devices
function rangeDownload($file)
{
    $fp = @fopen($file, 'rb');
    $size = filesize($file);
    // File size
    $length = $size;
    // Content length
    $start = 0;
    // Start byte
    $end = $size - 1;
    // End byte
示例#3
0
function view_media()
{
    global $accepted_media_qualities;
    global $accepted_media_types;
    global $input;
    // 0) Sanity checks
    if (!ezmam_album_exists($input['album'])) {
        error_print_http(404);
        log_append('warning', 'view_media: tried to access non-existant album ' . $input['album']);
        die;
    }
    if (!ezmam_asset_exists($input['album'], $input['asset'])) {
        error_print_http(404);
        log_append('warning', 'view_media: tried to access non-existant asset ' . $input['asset'] . ' from album ' . $input['album']);
        die;
    }
    if (!ezmam_album_token_check($input['album'], $input['token']) && !ezmam_asset_token_check($input['album'], $input['asset'], $input['token'])) {
        error_print_http(404);
        log_append('warning', 'view_media: tried to access asset ' . $input['asset'] . ' from album ' . $input['album'] . ' with invalid token ' . $input['token']);
        die;
    }
    if (!isset($input['quality'])) {
        $input['quality'] = 'high';
    }
    if (!accepted_quality($input['quality'])) {
        error_print_http(403);
        log_append('warning', 'view_media: tried to access forbidden quality "' . $input['quality'] . '"');
        die;
    }
    if (!accepted_type($input['type'])) {
        error_print_http(403);
        log_append('warning', 'view_media: tried to access forbidden media type "' . $input['type'] . '"');
        die;
    }
    // 1) First we retrieve the media path
    $quality = strtolower($input['quality']);
    $type = strtolower($input['type']);
    $media_name = $quality . '_' . $type;
    $media_handle = ezmam_media_getpath($input['album'], $input['asset'], $media_name, false);
    // If we couldn't find our file, we check whether it exists in another quality
    if (!$media_handle) {
        if ($quality == 'low') {
            $quality = 'high';
        } else {
            if ($quality == 'high') {
                $quality = 'low';
            }
        }
        $media_name = $quality . '_' . $type;
        $media_handle = ezmam_media_getpath($input['album'], $input['asset'], $media_name, false);
        // If we still can't find a file, we just tell the users so
        if (!$media_handle) {
            error_print_http(404);
            log_append('view_media: couldn\'t find the media file for asset ' . $input['asset'] . ' of album ' . $input['album']);
            die;
        }
    }
    // 2) Then we save some statistics on it
    ezmam_media_viewcount_increment($input['album'], $input['asset'], $media_name, $input['origin']);
    // 3) And finally, we deliver it!
    $filename = suffix_remove($input['album']);
    $filename .= '_-_';
    $filename .= get_user_friendly_date($input['asset'], '_', true, 'fr-ASCII');
    //add a quality part in filename
    if ($quality == 'low') {
        $quality_fn_part = 'SQ';
    } else {
        $quality_fn_part = 'HQ';
    }
    $filename .= '_' . $quality_fn_part;
    //add a type video/slide part in filename
    if ($type == 'cam') {
        $type_fn_part = 'video';
    } else {
        $type_fn_part = 'slide';
    }
    $filename .= '_' . $type_fn_part;
    //  header('Content-Type: video/x-m4v');
    header('Content-Type: video/mp4');
    if (isset($_SERVER['HTTP_RANGE'])) {
        rangeDownload($media_handle);
    } else {
        header('Content-Disposition: attachment; filename=' . $filename . '.m4v');
        //header('Content-Transfer-Encoding: binary');
        //header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Content-Length: ' . filesize($media_handle));
        header('Accept-Ranges: bytes');
        //readfile($media_handle);
        //fpassthru($fh);
        passthru('/bin/cat ' . escapeshellarg($media_handle));
        fclose($fh);
    }
}
示例#4
0
<?php

require_once "../../config.php";
require_once "lib.php";
$fileid = optional_param('file', NULL, PARAM_INT);
$file = voiceshadow_getfileid($fileid);
header("Content-type: audio/x-mpeg");
if (isset($_SERVER['HTTP_RANGE'])) {
    rangeDownload($file->fullpatch);
} else {
    header("Content-Length: " . filesize($file->fullpatch));
    readfile($file->fullpatch);
}
示例#5
0
session_start();
if ($_SESSION['file_auth'][$file_namespace] != '1') {
    echo '授權失敗!!';
    exit;
}
if (is_file($file_url)) {
    if (is_array($_SESSION["fileauth_array"][$file_namespace]) && in_array(base64_encode($file_url), $_SESSION["fileauth_array"][$file_namespace]) && strtotime(date("Y-m-d H:i:s")) >= $_SESSION["fileauth_time_array"][$file_namespace][array_search(base64_encode($file_url), $_SESSION["fileauth_array"][$file_namespace])] * 1 + $time_set) {
        echo '已超過授權時限!!';
        exit;
    }
    header("Content-type: " . get_mime_type($file_url));
    header("Pragma:no-cache");
    header("Expires:0");
    if (isset($_SERVER['HTTP_RANGE'])) {
        // 支援各種裝置 僅不支援IPHONE
        rangeDownload($file_url);
    } else {
        header("Content-length: " . filesize($file_url));
        readfile($file_url);
    }
    $_SESSION["fileauth_array"][$file_namespace][] = base64_encode($file_url);
    $_SESSION["fileauth_time_array"][$file_namespace][] = strtotime(date("Y-m-d H:i:s"));
}
function rangeDownload($file)
{
    global $_SESSION;
    $fp = @fopen($file, 'rb');
    $size = filesize($file);
    // 文件大小
    $length = $size;
    // 內容長度
    if (file_exists($realPath)) {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_file($finfo, $realPath);
        finfo_close($finfo);
        if ($ext == "mp3") {
            $mimeType = "audio/mpeg";
        }
        rangeDownload($realPath, $mimeType);
    } elseif (file_exists($realPath1)) {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_file($finfo, $realPath1);
        finfo_close($finfo);
        if ($ext == "mp3") {
            $mimeType = "audio/mpeg";
        }
        rangeDownload($realPath1, $mimeType);
    } else {
        header("HTTP/1.0 404 Not Found");
        return;
    }
    exit(0);
}
if ($actionAjax == "fileMobile") {
    $app_uid = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
    $inp_doc_uid = isset($_REQUEST['d']) ? $_REQUEST['d'] : null;
    $structure = file_get_contents(PATH_HTML . "/mobile/index.json");
    $structure = json_decode($structure);
    foreach ($structure as $build) {
        foreach ($build as $file) {
            $file->lastModified = date("D, d M Y H:i:s \\G\\M\\T", filemtime(PATH_HTML . "/mobile/" . $file->file));
        }