Ejemplo n.º 1
0
function plugin_cache_ref_action()
{
    global $vars;
    $usage = 'Usage: plugin=cache_ref&src=filename';
    if (!isset($vars['src'])) {
        return array('msg' => 'Invalid argument', 'body' => $usage);
    }
    $filename = $vars['src'];
    $ref = CACHE_DIR . $filename;
    if (!file_exists($ref)) {
        return array('msg' => 'Cache file not found', 'body' => $usage);
    }
    $got = @getimagesize($ref);
    if (!isset($got[2])) {
        $got[2] = FALSE;
    }
    switch ($got[2]) {
        case 1:
            $type = 'image/gif';
            break;
        case 2:
            $type = 'image/jpeg';
            break;
        case 3:
            $type = 'image/png';
            break;
        case 4:
            $type = 'application/x-shockwave-flash';
            break;
        default:
            return array('msg' => 'Seems not an image', 'body' => $usage);
    }
    // Care for Japanese-character-included file name
    if (LANG == 'ja_JP') {
        switch (UA_NAME . '/' . UA_PROFILE) {
            case 'Opera/default':
                // Care for using _auto-encode-detecting_ function
                $filename = mb_convert_encoding($filename, 'UTF-8', 'auto');
                break;
            case 'MSIE/default':
                $filename = mb_convert_encoding($filename, 'SJIS', 'auto');
                break;
        }
    }
    $file = htmlspecialchars($filename);
    $size = filesize($ref);
    // Output
    pkwk_common_headers();
    header('Content-Disposition: inline; filename="' . $filename . '"');
    header('Content-Length: ' . $size);
    header('Content-Type: ' . $type);
    // @readfile($ref);
    plus_readfile($ref);
    exit;
}
Ejemplo n.º 2
0
function download_tarfile($tempnam, $arc_kind)
{
    $size = filesize($tempnam);
    $filename = strftime('tar%Y%m%d', time());
    if ($arc_kind == 'tgz') {
        $filename .= '.tar.gz';
    } else {
        $filename .= '.tar';
    }
    pkwk_common_headers();
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    header('Content-Length: ' . $size);
    header('Content-Type: application/octet-stream');
    header('Pragma: no-cache');
    // @readfile($tempnam);
    plus_readfile($tempnam);
}
Ejemplo n.º 3
0
 function open()
 {
     $this->getstatus();
     $this->status['count'][$this->age]++;
     $this->putstatus();
     $filename = $this->file;
     // Care for Japanese-character-included file name
     if (LANG == 'ja_JP') {
         switch (UA_NAME . '/' . UA_PROFILE) {
             case 'Opera/default':
                 // Care for using _auto-encode-detecting_ function
                 $filename = mb_convert_encoding($filename, 'UTF-8', 'auto');
                 break;
             case 'MSIE/default':
                 $filename = mb_convert_encoding($filename, 'SJIS', 'auto');
                 break;
         }
     }
     $filename = htmlspecialchars($filename);
     ini_set('default_charset', '');
     mb_http_output('pass');
     pkwk_common_headers();
     if ($this->type == 'text/html' || $this->type == 'application/octet-stream') {
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header('Content-Type: application/octet-stream; name="' . $filename . '"');
         header('Content-Length: ' . $this->size);
     } else {
         header('Content-Disposition: inline; filename="' . $filename . '"');
         header('Content-Type: ' . $this->type);
         header('Content-Length: ' . $this->size);
     }
     // For BugTrack2/102
     // @readfile($this->filename);
     plus_readfile($this->filename);
     log_put_download($this->page, $this->file);
     exit;
 }