Example #1
0
 public function Migrate($attach, $remoteid)
 {
     global $_G;
     if (is_numeric($re = self::MoveToSpace($attach, $remoteid))) {
         $remoteid = $re;
         if (C::t('attachment')->update($attach['aid'], array('remote' => $re))) {
             //删除原文件
             $obz = io_remote::getBzByRemoteid($attach['remote']);
             if ($obz == 'dzz') {
                 @unlink($_G['setting']['attachdir'] . $attach['attachment']);
             } else {
                 $opath = $obz . '/' . $attach['attachment'];
                 IO::Delete($opath);
             }
         }
         C::t('local_storage')->update_usesize_by_remoteid($remoteid, $attach['filesize']);
         C::t('local_storage')->update_usesize_by_remoteid($attach['remote'], -$attach['filesize']);
         $attach['remote'] = $remoteid;
         return $attach;
     } else {
         if ($re['error']) {
             $attach['error'] = $re['error'];
             return $attach;
         } else {
             return false;
         }
     }
 }
Example #2
0
 public function MoveToSpace($path, $attach, $ondup = 'overwrite')
 {
     global $_G;
     /*
      *移动附件到百度网盘
      *
      */
     $filename = substr($path, strrpos($path, '/') + 1);
     $fpath = substr($path, 0, strrpos($path, '/'));
     //echo $path.'===='.$fpath.'===='.$filename;
     if (($re = $this->makeDir($fpath)) && $re['error']) {
         //创建目录
         return $re;
     }
     $obz = io_remote::getBzByRemoteid($attach['remote']);
     if ($obz == 'dzz') {
         $opath = 'dzz::' . $attach['attachment'];
     } else {
         $opath = $obz . '/' . $attach['attachment'];
     }
     //exit($opath.'==='.$fpath.'/'.$filename);
     if ($re = $this->multiUpload($opath, $fpath, $filename, $attach, $ondup)) {
         if ($re['error']) {
             return $re;
         } else {
             return true;
         }
     }
     return false;
 }
Example #3
0
 public function getThumbByAid($aid, $width = 256, $height = 256, $original = 0)
 {
     //通过附件获取缩略图
     //可以让$aid 带入$attach数组.
     if (!is_array($aid)) {
         $attach = self::fetch($aid);
     } else {
         $attach = $aid;
     }
     if (!$width || !$height) {
         $original = 1;
     }
     $bz = io_remote::getBzByRemoteid($attach['remote']);
     if ($bz == 'dzz') {
         $path = 'attach::' . $attach['aid'];
     } else {
         $path = $bz . '/' . $attach['attachment'];
     }
     return (defined('DZZSCRIPT') ? DZZSCRIPT : 'index.php') . '?mod=io&op=thumbnail&width=' . $width . '&height=' . $height . '&original=' . $original . '&path=' . dzzencode($path);
 }
Example #4
0
 public function MoveToSpace($path, $attach)
 {
     global $_G;
     /*
      *移动附件到百度网盘
      *
      */
     $arr = self::parsePath($path);
     $arr['object'] = str_replace('/', '_', $arr['object']);
     $jss = self::init($arr['bz']);
     if (is_array($jss) && $jss['error']) {
         return $jss;
     }
     //exit($fpath);
     $obz = io_remote::getBzByRemoteid($attach['remote']);
     if ($obz == 'dzz') {
         $opath = 'dzz::' . './' . $attach['attachment'];
     } else {
         $opath = $obz . '/' . $attach['attachment'];
     }
     if (is_array($url = IO::getStream($opath))) {
         return array('error' => $filepath['error']);
     }
     $file = fopen($url, 'rb');
     if (!$file) {
         return array('error' => '文件打开错误');
     }
     try {
         $jss->delete_object($arr['bucket'], $arr['object']);
     } catch (Exception $e) {
     }
     try {
         $response = $jss->put_mpu_object($arr['bucket'], $arr['object'], $file);
     } catch (Exception $e) {
         return array('error' => $e->getMessage());
     }
     if (!$response->is_ok()) {
         return array('error' => $response->get_code());
     }
     return true;
 }
Example #5
0
 public function MoveToSpace($path, $attach)
 {
     global $_G;
     $filename = substr($path, strrpos($path, '/') + 1);
     $fpath = substr($path, 0, strrpos($path, '/'));
     $obz = io_remote::getBzByRemoteid($attach['remote']);
     if ($obz == 'dzz') {
         $opath = 'dzz::' . $attach['attachment'];
     } else {
         $opath = $obz . '/' . $attach['attachment'];
     }
     //exit($opath.'==='.$fpath.'/'.$filename);
     if ($re = self::multiUpload($opath, $fpath, $filename, $attach, 'overwrite')) {
         if ($re['error']) {
             return $re;
         } else {
             return true;
         }
     }
     return false;
 }
Example #6
0
 public function fetch_by_icoid($icoid)
 {
     //返回一条数据同时加载资源表数据
     global $_G;
     $icoid = intval($icoid);
     $data = $icodata = $soucedata = array();
     //if($force_from_db || ($data = $this->fetch_cache('parse_'.$icoid)) === false) {
     if (!($icodata = self::fetch($icoid))) {
         return array();
     }
     if (!($sourcedata = self::getsourcedata($icodata['type'], $icodata['oid']))) {
         return array();
     }
     if ($icodata['type'] == 'pan' || $icodata['type'] == 'storage') {
         $icodata['oid'] = $sourcedata['fid'];
     }
     $data = array_merge($sourcedata, $icodata);
     $data['size'] = isset($sourcedata['filesize']) ? $sourcedata['filesize'] : 0;
     if ($data['type'] == 'image') {
         $data['img'] = DZZSCRIPT . '?mod=io&op=thumbnail&width=256&height=256&path=' . dzzencode($data['icoid']);
         $data['url'] = DZZSCRIPT . '?mod=io&op=thumbnail&width=1440&height=900&original=1&path=' . dzzencode($data['icoid']);
     } elseif ($data['type'] == 'attach' || $data['type'] == 'document') {
         $data['img'] = geticonfromext($data['ext'], $data['type']);
         $data['url'] = DZZSCRIPT . '?mod=io&op=getStream&path=' . dzzencode($data['icoid']);
     } elseif ($data['type'] == 'shortcut') {
         $data['img'] = isset($data['tdata']['img']) ? $data['tdata']['img'] : geticonfromext($data['tdata']['ext'], $data['tdata']['type']);
         $data['ttype'] = $data['tdata']['type'];
         $data['ext'] = $data['tdata']['ext'];
     } elseif ($data['type'] == 'dzzdoc') {
         $data['url'] = DZZSCRIPT . '?mod=document&icoid=' . dzzencode($data['icoid']);
         $data['img'] = isset($data['icon']) ? $data['icon'] : geticonfromext($data['ext'], $data['type']);
     } else {
         $data['img'] = isset($data['icon']) ? $data['icon'] : geticonfromext($data['ext'], $data['type']);
     }
     if (empty($data['name'])) {
         $data['name'] = $data['title'];
     }
     $data['url'] = isset($data['url']) ? replace_canshu($data['url']) : '';
     $data['ftype'] = getFileTypeName($data['type'], $data['ext']);
     $data['fdateline'] = dgmdate($data['dateline']);
     $data['fsize'] = formatsize($data['size']);
     $data['path'] = $data['icoid'];
     $data['bz'] = '';
     if ($data['remote'] > 1) {
         $data['rbz'] = io_remote::getBzByRemoteid($data['remote']);
     }
     //增加安全相关的路径
     $data['dpath'] = dzzencode($data['path']);
     $data['apath'] = $data['aid'] ? dzzencode('attach::' . $data['aid']) : $data['dpath'];
     //$data['like']=C::t('icos_like')->fetch_by_icoid_uid($icoid,$data['uid']);
     //获取sperm
     if (!$data['sperm']) {
         $data['sperm'] = perm_FileSPerm::typePower($data['type'], $data['ext']);
     }
     //if(!empty($data)) $this->store_cache('parse_'.$icoid, $data);
     //}
     return $data;
 }
Example #7
0
 public function linktoimage($link, $pfid)
 {
     global $_G, $space;
     $fid = $pfid;
     $gid = DB::result_first("select gid from %t where fid =%d", array('folder', $pfid));
     if (!($cimage = DB::fetch_first("select * from " . DB::table('cai_image') . " where ourl='{$link}'"))) {
         if ($attach = self::dzz_imagetoattach($link, $gid)) {
             if ($attach['error']) {
                 return $attach;
             }
             $cimage = array('ourl' => $link, 'aid' => $attach['aid'], 'copys' => 0, 'dateline' => $_G['timestamp']);
             $cimage['cid'] = DB::insert('cai_image', $cimage, 1);
         } else {
             return array('error' => lang('message', 'image_to_local_error'));
         }
     } else {
         $attach = C::t('attachment')->fetch($cimage['aid']);
     }
     //判断空间大小
     if (!SpaceSize($attach['filesize'], $gid)) {
         return array('error' => lang('message', 'inadequate_capacity_space'));
     }
     $imginfo = @getimagesize($attachment);
     $sourcedata = array('uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'title' => $attach['filename'], 'desc' => '', 'postip' => $_G['clientip'], 'desc' => $cimage['title'], 'cid' => $cimage['cid'], 'aid' => $cimage['aid'], 'width' => $imginfo[0], 'height' => $imginfo[1], 'gid' => $gid);
     if ($sourcedata['picid'] = DB::insert('source_image', $sourcedata, 1)) {
         C::t('cai_image')->update($cimage['cid'], array('copys' => $cimage['copys'] + 1));
         if ($cimage['aid']) {
             C::t('attachment')->update($cimage['aid'], array('copys' => $attach['copys'] + 1));
         }
         $icoarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'oid' => $sourcedata['picid'], 'name' => self::getFileName(strtolower(substr(strrchr($link, '/'), 1, 50)), $fid), 'flag' => '', 'type' => 'image', 'dateline' => $_G['timestamp'], 'pfid' => $fid, 'opuid' => $_G['uid'], 'gid' => $gid, 'ext' => $attach['filetype'], 'size' => $attach['filesize']);
         if ($icoarr['icoid'] = DB::insert('icos', $icoarr, 1)) {
             $icoarr['img'] = DZZSCRIPT . '?mod=io&op=thumbnail&width=256&height=256&path=' . rawurlencode($icoarr['icoid']);
             $icoarr['url'] = DZZSCRIPT . '?mod=io&op=thumbnail&width=1440&height=900&path=' . rawurlencode($icoarr['icoid']);
             $icoarr['bz'] = '';
             $icoarr['aid'] = $sourcedata['aid'];
             $data['rbz'] = io_remote::getBzByRemoteid($icoarr['remote']);
             $icoarr['path'] = $icoarr['icoid'];
             $icoarr['dpath'] = dzzencode($icoarr['icoid']);
             $icoarr['apath'] = dzzencode('attach::' . $icoarr['aid']);
             //$icoarr=array_merge($sourcedata,$icoarr);
             if ($icoarr['size']) {
                 SpaceSize($icoarr['size'], $gid, true);
             }
             addtoconfig($icoarr);
             $icoarr['fsize'] = formatsize($icoarr['size']);
             $icoarr['ftype'] = getFileTypeName($icoarr['type'], $icoarr['ext']);
             $icoarr['fdateline'] = dgmdate($icoarr['dateline']);
         } else {
             C::t('source_image')->delete_by_picid($sourcedata['picid']);
         }
     }
     if ($icoarr['icoid']) {
         return $icoarr;
     } else {
         return array('error' => lang('message', 'linktoimage_error'));
     }
 }
Example #8
0
function getDzzPath($attach)
{
    global $_G;
    $url = '';
    $bz = io_remote::getBzByRemoteid($attach['remote']);
    if ($bz == 'dzz') {
        $url = 'attach::' . $attach['aid'];
    } else {
        $url = $bz . '/' . $attach['attachment'];
    }
    return $url;
}
Example #9
0
 * @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('feed_attach')->fetch_by_qid($qid);
if (!$attach) {
    topshowmessage(lang('message', 'attachment_nonexistence'));
}
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'];
}
$attach['filename'] = $attach['title'];
$icoarr = array('icoid' => 'preview_' . $attach['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' => '', 'rbz' => io_remote::getBzByRemoteid($attach['remote']), 'ext' => $attach['type'] == 'video' ? 'swf' : ($attach['filetype'] ? $attach['filetype'] : $attach['ext']), 'size' => $attach['filesize']);
if (isset($icoarr['error'])) {
    topshowmessage($icoarr['error']);
}
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;