public function fetch_all_by_cid($cid) { global $_G; $data = array(); //$openext=C::t('app_open')->fetch_all_orderby_ext($_G['uid']); foreach (DB::fetch_all("select * from %t where cid= %d", array($this->_table, $cid)) as $value) { if ($value['aid'] > 0) { $attach = C::t('attachment')->fetch($value['aid']); if (in_array(strtolower($attach['filetype']), array('png', 'jpeg', 'jpg', 'gif', 'bmp'))) { $attach['img'] = C::t('attachment')->getThumbByAid($attach); $attach['isimage'] = 1; $value['type'] = 'image'; } else { $attach['img'] = geticonfromext($attach['filetype'], ''); $attach['isimage'] = 0; } $attach['url'] = getAttachUrl($attach); //if(isset($openext[$attach['filetype']])) $attach['preview'] = 1; $attach['filesize'] = formatsize($attach['filesize']); $data[$value['qid']] = array_merge($value, $attach); } else { $value['preview'] = 1; $data[$value['qid']] = $value; } } return $data; }
public function downloadApp() { $map['develop_id'] = intval($_GET['develop_id']); $dao = D('develop', 'develop'); $info = $dao->getDetailDevelop($map['develop_id']); $info['packageURL'] = getAttachUrl($info['file']['filename']); $info['app_name'] = $info['package']; // 记录下载数 $dao->where($map)->setInc('download_count'); echo json_encode($info); }
* @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); @ob_end_clean(); if (getglobal('gzipcompress')) { @ob_start('ob_gzhandler'); } @readfile($attachurl); @flush();
function getAttachUrlByAttachId($attachid) { if ($attachInfo = model('Attach')->getAttachById($attachid)) { return getAttachUrl($attachInfo['save_path'] . $attachInfo['save_name']); } else { return false; } }
/** * 获取附件信息 * * @return array * @author Medz Seven <*****@*****.**> **/ public function getAttach() { list($hash, $method) = array($_REQUEST['hash'], $_REQUEST['method']); list($hash, $method) = array($hash, t($method)); $method or $method = 'stream'; // stream, url, redirect // # 解密成ID $hash = @desdecrypt($hash, C('SECURE_CODE')); if (!$hash) { $this->error(array('status' => '-1', 'msg' => '没有传递需要获取的附件ID')); } elseif (!in_array($method, array('stream', 'url', 'redirect'))) { $this->error(array('status' => '-2', 'msg' => '没有正确的传递获取模式')); } elseif (!($attach = model('Attach')->getAttachById(intval($hash)))) { $this->error(array('status' => '-3', 'msg' => '没有这个附件')); } elseif ($method == 'stream') { ob_end_clean(); header('Content-type:' . $attach['type']); echo file_get_contents(getAttachUrl($attach['save_path'] . $attach['save_name'])); exit; } elseif ($method == 'redirect') { ob_end_clean(); header('Location:' . getAttachUrl($attach['save_path'] . $attach['save_name'])); exit; } return array('status' => '1', 'url' => getAttachUrl($attach['save_path'] . $attach['save_name']), 'msg' => '获取成功'); }
public function getMeta($icoid) { if (strpos($icoid, 'dzz::') === 0) { $file = $_G['setting']['attachurl'] . preg_replace('/^dzz::/i', '', $icoid); $name = array_pop(explode('/', $icoid)); $ext = array_pop(explode('.', $name)); return array('icoid' => $icoid, 'name' => $name, 'ext' => $ext, 'size' => filesize($file), 'url' => $file); } elseif (strpos($icoid, 'attach::') === 0) { $attach = C::t('attachment')->fetch(intval(str_replace('attach::', '', $icoid))); return array('icoid' => $icoid, 'name' => $attach['filename'], 'ext' => $attach['filetype'], 'apath' => dzzencode('attach::' . $attach['aid']), 'dpath' => dzzencode('attach::' . $attach['aid']), 'size' => $attach['filesize'], 'url' => getAttachUrl($attach), 'bz' => io_remote::getBzByRemoteid($attach['remote'])); } else { return C::t('icos')->fetch_by_icoid($icoid); } }
/* * 下载 * @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']); $attach = C::t('comment_attach')->fetch_by_qid($qid); if (!$attach) { topshowmessage(lang('message', 'attachment_nonexistence')); } $attach['filename'] = $attach['title']; if ($attach['aid']) { $shareurl = $_G['siteurl'] . 'share.php?a=view&s=' . dzzencode('attach::' . $attach['aid']) . '&n=' . rawurlencode(trim($attach['filename'], '.' . $attach['filetype'])) . '.' . $attach['filetype']; } else { $shareurl = $attach['url']; } $icoarr = array('icoid' => 'preview_' . $qid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'oid' => 0, 'name' => $attach['title'], 'img' => $attach['img'], 'dateline' => $_G['timestamp'], 'pfid' => 0, 'type' => $attach['type'], 'flag' => '', 'gid' => 0, 'path' => $attach['aid'] ? 'attach::' . $attach['aid'] : '', 'dpath' => $attach['aid'] ? dzzencode('attach::' . $attach['aid']) : dzzencode('preview_' . $qid), 'url' => $attach['aid'] ? getAttachUrl($attach) : $attach['url'], 'bz' => 'feed_preview', 'ext' => $attach['type'] == 'video' ? 'swf' : ($attach['filetype'] ? $attach['filetype'] : $attach['ext']), 'size' => $attach['filesize']); include template('common/header_common'); echo "<script type=\"text/javascript\">"; //echo "top._config.sourcedata.icos['feed_attach_".$attach['qid']."']=".json_encode($icoarr).";"; echo "try{top._api.Open(" . json_encode($icoarr) . ");}catch(e){location.href='" . $shareurl . "';}"; echo "</script>"; include template('common/footer'); exit;
$count = count($arr); if ($open[$arr[$count - 1]]) { if (count($open[$arr[$count - 1]]) > $count) { $open[$arr[count($arr) - 1]] = $arr; } } else { $open[$arr[$count - 1]] = $arr; } } } $sel = implode(',', $sel); $openarr = json_encode(array('orgids' => $open)); $piclist = array(); $list = C::t('app_pic')->fetch_all_by_appid($appid, false, true); foreach ($list as $value) { $value['pic'] = getAttachUrl($value); $value['dateline'] = dgmdate($value['dateline'], 'd'); $piclist[] = $value; } } else { $app = array(); $app['hideInMarket'] = 0; $app['isshow'] = 1; $app['havetask'] = 1; $app['haveflash'] = 0; $app['group'] = 1; } include template('edit'); } function app_pic_delete($picids) {