示例#1
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;
 }
示例#2
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;
         }
     }
 }
示例#3
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;
 }
示例#4
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;
 }
示例#5
0
 public function delete_by_aid($aid)
 {
     //删除附件
     global $_G;
     if (!($data = $this->fetch($aid))) {
         return false;
     }
     if ($data['copys'] > 1) {
         return $this->update($aid, array('copys' => $data['copys'] - 1));
     } else {
         if (io_remote::DeleteFromSpace($data)) {
             return $this->delete($aid);
         } else {
             return false;
         }
     }
     return true;
 }
示例#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;
 }
示例#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'));
     }
 }
示例#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;
}
示例#9
0
 * @link        http://www.dzzoffice.com
 * @author      zyx(zyx@dzz.cc)
 */
if (!defined('IN_DZZ') || !defined('IN_ADMIN')) {
    exit('Access Denied');
}
@ini_set('max_execution_time', 0);
@set_time_limit(0);
$gets = array('mod' => 'cloud', 'op' => 'movetool_run', 'oremoteid' => intval($_GET['oremoteid']), 'remoteid' => intval($_GET['remoteid']), 'exts' => trim($_GET['exts']), 'sizelt' => $_GET['sizelt'], 'sizegt' => $_GET['sizegt'], 'ignore' => trim($_GET['ignore']));
$runurl = BASESCRIPT . "?" . url_implode($gets);
//获取需要迁移的数据量
if ($attach = C::t('attachment')->getAttachByFilter($gets)) {
    //print_r($attach);exit($runurl);
    try {
        // error_reporting(E_ALL);
        if ($re = io_remote::Migrate($attach, $gets['remoteid'])) {
            //print_r($re);exit();
            include template('common/header_common');
            echo "<script type=\"text/javascript\">";
            echo "parent.setProgress(" . json_encode($re) . ");";
            if (!$re['error']) {
                echo "window.location.href='" . $runurl . "';";
            }
            echo "</script>";
            include template('common/footer');
            exit;
        }
    } catch (Exception $e) {
        $attach['error'] = $e->getMessage();
        include template('common/header_common');
        echo "<script type=\"text/javascript\">";
示例#10
0
<?php

/*
 * @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)
 */
ignore_user_abort(true);
@set_time_limit(0);
if (!defined('IN_DZZ')) {
    exit('Access Denied');
}
require_once DZZ_ROOT . './dzz/function/dzz_core.php';
$remoteid = intval($_GET['remoteid']);
$aid = intval($_GET['aid']);
if ($attach = C::t('attachment')->fetch($aid)) {
    $re = io_remote::Migrate($attach, $remoteid);
    if ($re['error']) {
        exit($re['error']);
    }
}
exit('success');
<?php

/*
 * 计划任务脚本 每周获取检查百度网盘的token,过期时间小于1周的全部刷新
 * @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)
 */
//按月清除未用附件(copys<=0)
if (!defined('IN_DZZ')) {
    exit('Access Denied');
}
$limit = 100;
//考虑到计划任务占用的系统资源,一次最大删除100个;
foreach (DB::fetch_all("select * from %t where copys<1 ORDER BY dateline limit {$limit}", array('attachment', $limit)) as $value) {
    if (io_remote::DeleteFromSpace($value)) {
        C::t('attachment')->delete($value['aid']);
    }
}
示例#12
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;