コード例 #1
0
ファイル: io_baiduPCS.php プロジェクト: druphliu/dzzoffice
 public function download($path)
 {
     global $_G;
     $path = rawurldecode($path);
     $url = self::getStream($path);
     try {
         // Download the file
         $file = self::getMeta($path);
         if ($file['type'] == 'folder') {
             //目录压缩下载
             self::zipdownload($path);
             exit;
         } else {
             //文件直接跳转到文件源地址;不再通过服务器中转
             @header("Location: {$url}");
             exit;
         }
         $file['name'] = '"' . (strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'rv:11')) ? urlencode($file['name']) : $file['name']) . '"';
         dheader('Date: ' . gmdate('D, d M Y H:i:s', $file['dateline']) . ' GMT');
         dheader('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['dateline']) . ' GMT');
         dheader('Content-Encoding: none');
         dheader('Content-Disposition: attachment; filename=' . $file['name']);
         dheader('Content-Type: application/octet-stream');
         dheader('Content-Length: ' . $file['size']);
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         @readfile($url);
         @flush();
         @ob_flush();
         exit;
     } catch (Exception $e) {
         // The file wasn't found at the specified path/revision
         //echo 'The file was not found at the specified path/revision';
         topshowmessage($e->getMessage());
     }
 }
コード例 #2
0
ファイル: down.php プロジェクト: druphliu/dzzoffice
/*
 * 下载
 * @copyright   Leyun internet Technology(Shanghai)Co.,Ltd
 * @license     http://www.dzzoffice.com/licenses/license.txt
 * @package     DzzOffice
 * @link        http://www.dzzoffice.com
 * @author      zyx(zyx@dzz.cc)
 */
if (!defined('IN_DZZ')) {
    exit('Access Denied');
}
$qid = intval($_GET['qid']);
$attachexists = FALSE;
$attach = C::t('feed_attach')->fetch_by_qid($qid);
if (!$attach) {
    topshowmessage(lang('message', 'attachment_nonexistence'));
}
//更新下载数量
C::t('feed_attach')->update($attach['qid'], array('downloads' => $attach['downloads'] + 1));
$filename = $_G['setting']['attachdir'] . $attach['attachment'];
$filesize = !$attach['remote'] ? filesize($filename) : $attach['filesize'];
$attachurl = getAttachUrl($attach, true);
$db = DB::object();
$db->close();
$attach['filename'] = '"' . (strtolower(CHARSET) == 'utf-8' && strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? urlencode($attach['title']) : $attach['title']) . '"';
dheader('Date: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT');
dheader('Last-Modified: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT');
dheader('Content-Encoding: none');
dheader('Content-Disposition: attachment; filename=' . $attach['filename']);
dheader('Content-Type: application/octet-stream');
dheader('Content-Length: ' . $filesize);
コード例 #3
0
ファイル: down.php プロジェクト: druphliu/dzzoffice
/*
 * 下载
 * @copyright   Leyun internet Technology(Shanghai)Co.,Ltd
 * @license     http://www.dzzoffice.com/licenses/license.txt
 * @package     DzzOffice
 * @link        http://www.dzzoffice.com
 * @author      zyx(zyx@dzz.cc)
 */
if (!defined('IN_DZZ')) {
    exit('Access Denied');
}
$qid = intval($_GET['qid']);
$attachexists = FALSE;
$attach = C::t('comment_attach')->fetch_by_qid($qid);
if (!$attach['aid']) {
    topshowmessage('附件不存在,或不是可下载的文件');
}
//更新下载数量
C::t('comment_attach')->update($attach['qid'], array('downloads' => $attach['downloads'] + 1));
$filename = $_G['setting']['attachdir'] . $attach['attachment'];
$filesize = !$attach['remote'] ? filesize($filename) : $attach['filesize'];
if (strpos(strtolower($attach['filename']), $attach['filetype']) === false) {
    $attach['filename'] .= '.' . $attach['filetype'];
}
$attachurl = getAttachUrl($attach, true);
if ($attach['title']) {
    $attach['filename'] = '"' . (strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'rv:11')) ? urlencode($attach['title']) : $attach['title']) . '"';
} else {
    $attach['filename'] = '"' . (strtolower(CHARSET) == 'utf-8' && strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? urlencode($attach['title']) : $attach['title']) . '"';
}
$db = DB::object();
コード例 #4
0
ファイル: io_ftp.php プロジェクト: druphliu/dzzoffice
 public function download($path)
 {
     global $_G;
     $path = rawurldecode($path);
     try {
         // Download the file
         $file = self::getMeta($path);
         if ($file['type'] == 'folder') {
             self::zipdownload($path);
             exit;
         }
         $url = self::getStream($path);
         if (!($fp = @fopen($attachurl, 'rb'))) {
             topshowmessage('文件不存在');
         }
         $db = DB::object();
         $db->close();
         $chunk = 10 * 1024 * 1024;
         //$file['data'] = self::getFileContent($path);
         //if($file['data']['error']) IO::topshowmessage($file['data']['error']);
         $file['name'] = '"' . (strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'rv:11')) ? urlencode($file['name']) : $file['name']) . '"';
         dheader('Date: ' . gmdate('D, d M Y H:i:s', $file['dateline']) . ' GMT');
         dheader('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['dateline']) . ' GMT');
         dheader('Content-Encoding: none');
         dheader('Content-Disposition: attachment; filename=' . $file['name']);
         dheader('Content-Type: application/octet-stream');
         dheader('Content-Length: ' . $file['size']);
         @ob_end_clean();
         if (getglobal('gzipcompress')) {
             @ob_start('ob_gzhandler');
         }
         while (!feof($fp)) {
             echo fread($fp, $chunk);
             @ob_flush();
             // flush output
             @flush();
         }
         @fclose($fp);
         exit;
     } catch (Exception $e) {
         // The file wasn't found at the specified path/revision
         //echo 'The file was not found at the specified path/revision';
         topshowmessage($e->getMessage());
     }
 }
コード例 #5
0
ファイル: saveto.php プロジェクト: druphliu/dzzoffice
 */
if (!defined('IN_DZZ')) {
    exit('Access Denied');
}
if (empty($_G['uid'])) {
    include template('common/header_reload');
    echo "<script type=\"text/javascript\">";
    echo "try{top._login.logging();}catch(e){}";
    echo "try{win.Close();}catch(e){}";
    echo "</script>";
    include template('common/footer_reload');
    exit('<a href="user.php?mod=logging&action=login">需要登录</a>');
}
$qid = intval($_GET['qid']);
$attach = C::t('comment_attach')->fetch_by_qid($qid);
if (!$attach) {
    topshowmessage(lang('message', 'attachment_nonexistence'));
}
$attach['filename'] = $attach['title'];
$pfid = DB::result_first("select fid from %t where flag='document' and uid= %d", array('folder', $_G['uid']));
$icoarr = io_dzz::uploadToattachment($attach, $pfid);
if (isset($icoarr['error'])) {
    topshowmessage($icoarr['error']);
}
include template('common/header_simple');
echo "<script type=\"text/javascript\">";
echo "try{top._ico.createIco(" . json_encode($icoarr) . ");}catch(e){alert('已保存到我的文档!')}";
echo "try{top.Alert('”" . $attach['title'] . "“ 成功添加到桌面“我的文档”中!',3,'','','info');}catch(e){}";
echo "</script>";
include template('common/footer');
exit;
コード例 #6
0
ファイル: io_dzz.php プロジェクト: druphliu/dzzoffice
 public function download($path, $filename)
 {
     global $_G;
     $attachexists = FALSE;
     if (strpos($path, 'attach::') === 0) {
         $attachment = C::t('attachment')->fetch(intval(str_replace('attach::', '', $path)));
         $attachment['name'] = $filename ? $filename : $attachment['filename'];
         $path = getDzzPath($attachment);
         $attachurl = IO::getStream($path);
     } elseif (strpos($path, 'dzz::') === 0) {
         $attachment = array('attachment' => preg_replace("/^dzz::/i", '', $path), 'name' => $filename ? $filename : substr(strrpos($path, '/')));
         $attachurl = $_G['setting']['attachdir'] . $attachment['attachment'];
     } elseif (is_numeric($path)) {
         $icoid = intval($path);
         $icoarr = C::t('icos')->fetch_by_icoid($path);
         if (!$icoarr['icoid']) {
             topshowmessage(lang('message', 'attachment_nonexistence'));
         } elseif ($icoarr['type'] == 'folder') {
             self::zipdownload($path);
             exit;
         }
         if (!$icoarr['aid']) {
             topshowmessage(lang('message', 'attachment_nonexistence'));
         }
         $attachment = $icoarr;
         $attachurl = IO::getStream($path);
     }
     //$filename = $_G['setting']['attachdir'].$attachment['attachment'];
     $filesize = !$attachment['remote'] ? filesize($attachurl) : $attachment['filesize'];
     if ($attachment['ext'] && strpos(strtolower($attachment['name']), $attachment['ext']) === false) {
         $attachment['name'] .= '.' . $attachment['ext'];
     }
     $attachment['name'] = '"' . (strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'rv:11')) ? urlencode($attachment['name']) : $attachment['name']) . '"';
     if (!($fp = @fopen($attachurl, 'rb'))) {
         topshowmessage('文件不存在');
     }
     $db = DB::object();
     $db->close();
     $chunk = 10 * 1024 * 1024;
     dheader('Date: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT');
     dheader('Last-Modified: ' . gmdate('D, d M Y H:i:s', $attach['dateline']) . ' GMT');
     dheader('Content-Encoding: none');
     dheader('Content-Disposition: attachment; filename=' . $attachment['name']);
     dheader('Content-Type: application/octet-stream');
     dheader('Content-Length: ' . $filesize);
     @ob_end_clean();
     if (getglobal('gzipcompress')) {
         @ob_start('ob_gzhandler');
     }
     while (!feof($fp)) {
         echo fread($fp, $chunk);
         @ob_flush();
         // flush output
         @flush();
     }
     fclose($fp);
     //@readfile($attachurl);
     // @ob_flush();@flush();
     exit;
 }