示例#1
0
 public function fetch_all_by_pid($pid)
 {
     global $_G;
     $data = array();
     //$openext=C::t('app_open')->fetch_all_orderby_ext($_G['uid']);
     foreach (DB::fetch_all("select * from %t where pid= %d", array($this->_table, $pid)) as $value) {
         if ($value['aid']) {
             $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;
             } else {
                 $attach['img'] = geticonfromext($attach['filetype'], '');
                 $attach['isimage'] = 0;
             }
             $attach['url'] = C::t('attachment')->getThumbByAid($attach, 120, 80, 1);
             $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;
 }
示例#2
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;
 }
示例#3
0
 public function fetch_by_vid($vid, $havecount = false)
 {
     //返回一条数据同时加载附件表数据
     $vid = intval($vid);
     $data = self::fetch($vid);
     $data['icon'] = $data['icon'] ? $data['icon'] : geticonfromext('', 'video');
     $data['ext'] = '';
     $data['size'] = 0;
     if ($havecount) {
         $count = C::t('count')->fetch_by_type($vid, 'video');
         $data['viewnum'] = intval($count['viewnum']);
         $data['replynum'] = intval($count['replynum']);
         $data['downnum'] = intval($count['downnum']);
         $data['star'] = intval($count['star']);
         $data['starnum'] = intval($count['starnum']);
     }
     return $data;
 }
示例#4
0
 function _formatMeta($meta, $bz)
 {
     global $_G, $documentexts, $imageexts;
     //判断是否为根目录
     $root = $bz . $this->_root;
     $icosdata = array();
     $bzarr = explode(':', $bz);
     if ($meta['isdir']) {
         $icoarr = array('icoid' => md5($bz . $meta['path']), 'path' => $bz . $meta['path'], 'dpath' => dzzencode($bz . $meta['path']), 'bz' => $bz, 'gid' => 0, 'name' => substr(strrchr($meta['path'], '/'), 1), 'username' => $_G['username'], 'uid' => $_G['uid'], 'oid' => md5($bz . $meta['path']), 'img' => 'dzz/images/default/system/folder.png', 'type' => 'folder', 'ext' => '', 'pfid' => md5(str_replace(strrchr($meta['path'], '/'), '', $bz . $meta['path'])), 'size' => 0, 'dateline' => intval($meta['mtime']), 'flag' => '');
         if ($icoarr['path'] == $root) {
             $icoarr['name'] = $this->_rootname;
             $icoarr['flag'] = self::BZ;
             $icoarr['pfid'] = 0;
         }
         $icoarr['fsize'] = formatsize($icoarr['size']);
         $icoarr['ftype'] = getFileTypeName($icoarr['type'], $icoarr['ext']);
         $icoarr['fdateline'] = dgmdate($icoarr['dateline']);
         $icosdata = $icoarr;
     } else {
         $ext = strtoupper(substr(strrchr($meta['path'], '.'), 1));
         if (in_array($ext, $imageexts)) {
             $type = 'image';
         } elseif (in_array($ext, $documentexts)) {
             $type = 'document';
         } else {
             $type = 'attach';
         }
         if ($type == 'image') {
             $img = $_G['siteurl'] . DZZSCRIPT . '?mod=io&op=thumbnail&width=256&height=256&path=' . dzzencode($bz . $meta['path']);
             $url = $_G['siteurl'] . DZZSCRIPT . '?mod=io&op=thumbnail&width=1440&height=900&path=' . dzzencode($bz . $meta['path']);
         } else {
             $img = geticonfromext($ext, $type);
             $url = $_G['siteurl'] . DZZSCRIPT . '?mod=io&op=getStream&path=' . rawurlencode($bz . $meta['path']);
         }
         $icoarr = array('icoid' => md5($bz . $meta['path']), 'path' => $bz . $meta['path'], 'dpath' => dzzencode($bz . $meta['path']), 'bz' => $bz, 'gid' => 0, 'name' => substr(strrchr($meta['path'], '/'), 1), 'username' => $_G['username'], 'uid' => $_G['uid'], 'oid' => md5($bz . $meta['path']), 'img' => $img, 'url' => $url, 'type' => $type, 'ext' => strtolower($ext), 'pfid' => md5(str_replace(strrchr($meta['path'], '/'), '', $bz . $meta['path'])), 'size' => $meta['size'], 'dateline' => intval($meta['mtime']), 'flag' => '');
         $icoarr['fsize'] = formatsize($icoarr['size']);
         $icoarr['ftype'] = getFileTypeName($icoarr['type'], $icoarr['ext']);
         $icoarr['fdateline'] = dgmdate($icoarr['dateline']);
         $icosdata = $icoarr;
     }
     return $icosdata;
 }
 public function save($file_path, $filename)
 {
     global $_G;
     $md5 = md5_file($file_path);
     $filesize = filesize($file_path);
     if ($md5 && ($attach = DB::fetch_first("select * from %t where md5=%s and filesize=%d", array('attachment', $md5, $filesize)))) {
         $attach['filename'] = $filename;
         $pathinfo = pathinfo($filename);
         $ext = $pathinfo['extension'] ? $pathinfo['extension'] : '';
         $attach['filetype'] = $ext;
         if (in_array(strtolower($attach['filetype']), array('png', 'jpeg', 'jpg', 'gif', 'bmp'))) {
             $attach['img'] = C::t('attachment')->getThumbByAid($attach, $this->options['thumbnail']['max-width'], $this->options['thumbnail']['max-height']);
             $attach['isimage'] = 1;
         } else {
             $attach['img'] = geticonfromext($ext);
             $attach['isimage'] = 0;
         }
         @unlink($file_path);
         return $attach;
     } else {
         $target = self::getPath($filename);
         $pathinfo = pathinfo($filename);
         $ext = $pathinfo['extension'] ? $pathinfo['extension'] : '';
         if ($ext && in_array(strtolower($ext), getglobal('setting/unRunExts'))) {
             $unrun = 1;
         } else {
             $unrun = 0;
         }
         $filepath = $_G['setting']['attachdir'] . $target;
         $handle = fopen($file_path, 'r');
         $handle1 = fopen($filepath, 'w');
         while (!feof($handle)) {
             fwrite($handle1, fread($handle, 8192));
         }
         fclose($handle);
         fclose($handle1);
         @unlink($file_path);
         $filesize = filesize($filepath);
         $remote = 0;
         $attach = array('filesize' => $filesize, 'attachment' => $target, 'filetype' => strtolower($ext), 'filename' => $filename, 'remote' => $remote, 'copys' => 0, 'md5' => $md5, 'unrun' => $unrun, 'dateline' => $_G['timestamp']);
         if ($attach['aid'] = C::t('attachment')->insert($attach, 1)) {
             C::t('local_storage')->update_usesize_by_remoteid($attach['remote'], $attach['filesize']);
             dfsockopen($_G['siteurl'] . 'misc.php?mod=movetospace&aid=' . $attach['aid'] . '&remoteid=0', 0, '', '', FALSE, '', 1);
             if (in_array(strtolower($attach['filetype']), array('png', 'jpeg', 'jpg', 'gif', 'bmp'))) {
                 $attach['img'] = C::t('attachment')->getThumbByAid($attach['aid'], $this->options['thumbnail']['max-width'], $this->options['thumbnail']['max-height']);
                 $attach['isimage'] = 1;
             } else {
                 $attach['img'] = geticonfromext($ext);
                 $attach['isimage'] = 0;
             }
             return $attach;
         } else {
             return false;
         }
     }
 }
示例#6
0
    $upload_handler = new uploadhandler($options);
    $type = $_GET['type'];
    $editorId = $_GET['editorid'];
    if (!($info = $upload_handler->getFileInfo())) {
        exit;
    }
    /**
     * 返回数据,调用父页面的ue_callback回调
     */
    if ($type == "ajax") {
        echo DZZSCRIPT . '?mod=io&op=thumbnail&width=700&height=500&path=' . dzzencode('attach::' . $info[0]['aid']) . '&original=1&attach=' . rawurlencode('attach::' . $info[0]['aid']);
    } elseif ($type == 'attach') {
        $info[0]['url'] = DZZSCRIPT . '?mod=io&op=getStream&path=' . dzzencode('attach::' . $info[0]['aid']) . '&attach=' . rawurlencode('attach::' . $info[0]['aid']);
        echo json_encode($info[0]);
    } else {
        $str = '';
        foreach ($info as $value) {
            $value['state'] = 'SUCCESS';
            if (in_array($value['filetype'], array('jpg', 'jpeg', 'png', 'gif', 'bmp'))) {
                $value['url'] = DZZSCRIPT . '?mod=io&op=thumbnail&width=700&height=500&path=' . dzzencode('attach::' . $value['aid']) . '&original=1';
                $str .= '<img class="attach-item image" path="' . rawurlencode('attach::' . $value['aid']) . '" src="' . $value['url'] . '" _src="' . $value['url'] . '" />';
            } else {
                $value['url'] = DZZSCRIPT . '?mod=io&op=download&path=' . dzzencode('attach::' . $value['aid']) . '&filename=' . urlencode($value['filename']);
                $value['img'] = geticonfromext($value['filetype'], '');
                $str .= '<p><span class="attach-item attach" path="' . rawurlencode('attach::' . $value['aid']) . '"><img src="' . $value['img'] . '" _src="' . $value['img'] . '"  /><a href="' . $value['url'] . '" _href="' . $value['url'] . '" title="' . $value['filename'] . '" target="_blank">' . $value['filename'] . '</a></span></p>';
            }
        }
        echo "<script>parent.UM.getEditor('" . $editorId . "').execCommand('insertHtml','" . $str . "',true )</script>";
    }
    exit;
}
示例#7
0
 public function save($file_path, $filename)
 {
     global $_G;
     $md5 = md5_file($file_path);
     $filesize = filesize($file_path);
     if ($md5 && ($attach = DB::fetch_first("select * from %t where md5=%s and filesize=%d", array('attachment', $md5, $filesize)))) {
         $attach['filename'] = $filename;
         $attach['filetype'] = trim($this->fileType, '.');
         if (in_array(strtolower($attach['filetype']), array('png', 'jpeg', 'jpg', 'gif', 'bmp'))) {
             $attach['url'] = C::t('attachment')->getThumbByAid($attach, 0, 0, 1);
             $attach['img'] = C::t('attachment')->getThumbByAid($attach, 256, 256);
             $attach['isimage'] = 1;
         } else {
             $attach['img'] = geticonfromext($attach['filetype']);
             $attach['url'] = (DZZSCRIPT ? DZZSCRIPT : 'index.php') . '?mod=io&op=getStream&path=' . dzzencode('attach::' . $attach['aid']);
             $attach['isimage'] = 0;
         }
         $attach['dpath'] = $attach['apath'] = dzzencode('attach::' . $attach['aid']);
         $attach['filesize'] = formatsize($attach['filesize']);
         @unlink($file_path);
         return $attach;
     } else {
         $target = self::getPath($filename);
         $ext = strtolower(trim($this->fileType, '.'));
         if ($ext && in_array($ext, getglobal('setting/unRunExts'))) {
             $unrun = 1;
         } else {
             $unrun = 0;
         }
         $filepath = $_G['setting']['attachdir'] . $target;
         $handle = fopen($file_path, 'r');
         $handle1 = fopen($filepath, 'w');
         while (!feof($handle)) {
             fwrite($handle1, fread($handle, 8192));
         }
         fclose($handle);
         fclose($handle1);
         @unlink($file_path);
         $filesize = filesize($filepath);
         $remote = 0;
         $attach = array('filesize' => $filesize, 'attachment' => $target, 'filetype' => strtolower($ext), 'filename' => $filename, 'remote' => $remote, 'copys' => 0, 'md5' => $md5, 'unrun' => $unrun, 'dateline' => $_G['timestamp']);
         if ($attach['aid'] = C::t('attachment')->insert($attach, 1)) {
             C::t('local_storage')->update_usesize_by_remoteid($attach['remote'], $attach['filesize']);
             dfsockopen(getglobal('siteurl') . 'misc.php?mod=movetospace&aid=' . $attach['aid'] . '&remoteid=0', 0, '', '', FALSE, '', 1);
             if (in_array(strtolower($attach['filetype']), array('png', 'jpeg', 'jpg', 'gif', 'bmp'))) {
                 $attach['url'] = C::t('attachment')->getThumbByAid($attach, 0, 0, 1);
                 $attach['img'] = C::t('attachment')->getThumbByAid($attach, 256, 256);
                 $attach['isimage'] = 1;
             } else {
                 $attach['img'] = geticonfromext($attach['filetype']);
                 $attach['url'] = (DZZSCRIPT ? DZZSCRIPT : 'index.php') . '?mod=io&op=getStream&path=' . dzzencode('attach::' . $attach['aid']);
                 $attach['isimage'] = 0;
             }
             $attach['dpath'] = $attach['apath'] = dzzencode('attach::' . $attach['aid']);
             $attach['filesize'] = formatsize($attach['filesize']);
             return $attach;
         } else {
             return false;
         }
     }
 }
示例#8
0
         $name = io_dzz::name_filter(trim($_GET['name']));
         if ($icoarr['name'] != $name) {
             $return = IO::rename($icoid, $name);
             if (empty($return['error'])) {
                 if ($return['type'] == 'folder') {
                     $return['folderdata'] = IO::getFolderByIcosdata($return);
                 }
                 $return['msg'] = 'success';
                 $return['oicoid'] = $icoarr['icoid'];
             }
         }
     }
     showmessage('do_success', $refer . '', $return, array());
 } else {
     $info = array();
     $info['icon'] = $icoarr['img'] ? $icoarr['img'] : geticonfromext($icoarr['ext'], $icoarr['type']);
     $info['name'] = getstr($icoarr['name'], 30);
     $info['ftype'] = $icoarr['ftype'];
     //获取路径
     if ($icoarr['bz']) {
         $bzarr = explode(':', $icoarr['path']);
         $info['path'] = $icoarr['path'];
         $info['size'] = lang('template', 'property_info_size', array('fsize' => $icoarr['size'] > 0 ? formatsize($icoarr['size']) : $icoarr['size'], 'size' => $icoarr['size']));
     } else {
         $arr = getPathByPfid($icoarr['pfid']);
         $patharr = array();
         while ($arr) {
             $patharr[] = array_pop($arr);
         }
         $info['path'] = implode('/', $patharr) . '/' . $icoarr['name'];
         switch ($icoarr['type']) {
示例#9
0
 function _formatMeta($meta, $arr)
 {
     global $_G, $documentexts, $imageexts;
     $icosdata = array();
     //print_r($meta);print_r($arr);
     if (strrpos($meta['key'], '/') == strlen($meta['key']) - 1) {
         $meta['isdir'] = true;
     }
     if ($meta['isdir']) {
         if (!$meta['key']) {
             if ($this->bucket) {
                 $name = $this->bucket;
                 $pfid = 0;
                 $pf = '';
                 $flag = '';
             } elseif ($arr['bucket']) {
                 $name = $arr['bucket'];
                 $pfid = md5($arr['bz']);
                 $pf = '';
                 $flag = '';
             } else {
                 $name = $this->_rootname;
                 $pfid = 0;
                 $pf = '';
                 $flag = self::BZ;
             }
             if ($arr['bucket']) {
                 $arr['bucket'] .= '/';
             }
         } else {
             if ($arr['bucket']) {
                 $arr['bucket'] .= '/';
             }
             $namearr = explode('/', $meta['key']);
             $name = $namearr[count($namearr) - 2];
             $pf = '';
             for ($i = 0; $i < count($namearr) - 2; $i++) {
                 $pf .= $namearr[$i] . '/';
             }
             $pf = $arr['bucket'] . $pf;
             $pfid = md5($arr['bz'] . $pf);
             $flag = '';
         }
         //print_r($namearr);
         $icoarr = array('icoid' => md5($arr['bz'] . $arr['bucket'] . $meta['key']), 'path' => $arr['bz'] . $arr['bucket'] . $meta['key'], 'dpath' => dzzencode($arr['bz'] . $arr['bucket'] . $meta['key']), 'bz' => $arr['bz'], 'gid' => 0, 'name' => $name, 'username' => $_G['username'], 'uid' => $_G['uid'], 'oid' => md5($arr['bz'] . $arr['bucket'] . $meta['key']), 'img' => 'dzz/images/default/system/folder.png', 'type' => 'folder', 'ext' => '', 'pfid' => $pfid, 'ppath' => $arr['bz'] . $pf, 'size' => 0, 'dateline' => strtotime($meta['last_modified']), 'flag' => $flag, 'nextMarker' => $meta['nextMarker'], 'IsTruncated' => $meta['IsTruncated']);
         $icoarr['fsize'] = formatsize($icoarr['size']);
         $icoarr['ftype'] = getFileTypeName($icoarr['type'], $icoarr['ext']);
         $icoarr['fdateline'] = dgmdate($icoarr['dateline']);
         $icosdata = $icoarr;
         //print_r($icosdata);
         //exit($meta['Key']);
     } else {
         if ($arr['bucket']) {
             $arr['bucket'] .= '/';
         }
         $namearr = explode('/', $meta['key']);
         $name = $namearr[count($namearr) - 1];
         $pf = '';
         for ($i = 0; $i < count($namearr) - 1; $i++) {
             $pf .= $namearr[$i] . '/';
         }
         $ext = strtoupper(substr(strrchr($meta['key'], '.'), 1));
         if (in_array($ext, $imageexts)) {
             $type = 'image';
         } elseif (in_array($ext, $documentexts)) {
             $type = 'document';
         } else {
             $type = 'attach';
         }
         if ($type == 'image') {
             $img = $_G['siteurl'] . DZZSCRIPT . '?mod=io&op=thumbnail&width=256&height=256&path=' . dzzencode($arr['bz'] . $arr['bucket'] . $meta['key']);
             $url = $_G['siteurl'] . DZZSCRIPT . '?mod=io&op=thumbnail&width=1440&height=900&path=' . dzzencode($arr['bz'] . $arr['bucket'] . $meta['key']);
         } else {
             $img = geticonfromext($ext, $type);
             $url = $_G['siteurl'] . DZZSCRIPT . '?mod=io&op=getStream&path=' . dzzencode($arr['bz'] . $arr['bucket'] . $meta['key']);
         }
         $icoarr = array('icoid' => md5($arr['bz'] . $arr['bucket'] . $meta['key']), 'path' => $arr['bz'] . $arr['bucket'] . $meta['key'], 'dpath' => dzzencode($arr['bz'] . $arr['bucket'] . $meta['key']), 'bz' => $arr['bz'], 'gid' => 0, 'name' => $name, 'username' => $_G['username'], 'uid' => $_G['uid'], 'oid' => md5($arr['bz'] . $arr['bucket'] . $meta['key']), 'img' => $img, 'url' => $url, 'type' => $type, 'ext' => strtolower($ext), 'pfid' => md5($arr['bz'] . $arr['bucket'] . $pf), 'ppath' => $arr['bz'] . $arr['bucket'] . $pf, 'size' => $meta['size'], 'dateline' => strtotime($meta['last_modified']), 'flag' => '');
         $icoarr['fsize'] = formatsize($icoarr['size']);
         $icoarr['ftype'] = getFileTypeName($icoarr['type'], $icoarr['ext']);
         $icoarr['fdateline'] = dgmdate($icoarr['dateline']);
         $icosdata = $icoarr;
     }
     return $icosdata;
 }
示例#10
0
        $data = DB::fetch_all("SELECT uid,icoid,oid,name,type,pfid,dateline,size,ext FROM " . DB::table('icos') . " WHERE {$sql} {$order} limit {$start},{$perpage}", $param);
        $multi = multi($count, $perpage, $page, $theurl, 'pull-right');
    }
    $list = array();
    foreach ($data as $value) {
        $user = getuserbyuid($value['uid']);
        $value['size'] = formatsize($value['size']);
        $value['dateline'] = dgmdate($value['dateline'], 'u');
        $value['ftype'] = getFileTypeName($value['type'], $value['ext']);
        $value['path'] = implode('/', array_reverse(getPathByPfid($value['pfid'])));
        $value['username'] = $user['username'];
        if (!($sourcedata = C::t('icos')->getsourcedata($value['type'], $value['oid']))) {
            continue;
        }
        $value = array_merge($sourcedata, $value);
        if ($value['type'] == 'image') {
            $value['img'] = DZZSCRIPT . '?mod=io&op=thumbnail&width=256&height=256&path=' . dzzencode($value['icoid']);
            $value['url'] = DZZSCRIPT . '?mod=io&op=thumbnail&width=1440&height=900&original=1&path=' . dzzencode($value['icoid']);
        } elseif ($value['type'] == 'attach' || $value['type'] == 'document') {
            $value['img'] = geticonfromext($value['ext'], $value['type']);
            $value['url'] = DZZSCRIPT . '?mod=io&op=getStream&path=' . dzzencode($value['icoid']);
        } elseif ($value['type'] == 'dzzdoc') {
            $value['url'] = DZZSCRIPT . '?mod=document&icoid=' . dzzencode($value['icoid']);
            $value['img'] = isset($value['icon']) ? $value['icon'] : geticonfromext($value['ext'], $value['type']);
        } else {
            $value['img'] = isset($value['icon']) ? $value['icon'] : geticonfromext($value['ext'], $value['type']);
        }
        $list[] = $value;
    }
    include template('main');
}
示例#11
0
 public function linktovideo($link, $pfid)
 {
     global $_G;
     @set_time_limit(60);
     $videoext = array('swf', 'flv');
     $fid = $pfid;
     $gid = DB::result_first("select gid from %t where fid =%d", array('folder', $pfid));
     if (!($cvideo = DB::fetch_first("select * from " . DB::table('cai_video') . " where ourl='{$link}'"))) {
         $arr = array();
         require_once dzz_libfile('function/video');
         if (!($arr = parseflv($link))) {
             return false;
         }
         //采集标题和描述
         if (!$arr['title'] || !$arr['description']) {
             require_once dzz_libfile('class/caiji');
             $caiji = new caiji($link);
             $arr['title'] = $caiji->getTitle();
             $arr['description'] = $caiji->getDescription();
         }
         $cvideo = array('url' => $arr['url'], 'ourl' => $link, 'img' => $arr['img'], 'desc' => $arr['description'], 'title' => $arr['title'], 'copys' => 0, 'dateline' => $_G['timestamp']);
         $cvideo['cid'] = DB::insert('cai_video', $cvideo, 1);
     }
     //如果原先的标题和描述没采集到,重新采集
     if (!$cvideo['title'] || !$cvideo['desc']) {
         require_once dzz_libfile('class/caiji');
         $caiji = new caiji($link);
         $cvideo['title'] = $caiji->getTitle();
         $cvideo['description'] = $caiji->getDescription();
         C::t('cai_video')->update($cvideo['cid'], array('title' => $cvideo['title'], 'desc' => $cvideo['desc']));
     }
     $sourcedata = array('uid' => $_G['uid'], 'username' => $_G['username'], 'url' => $cvideo['url'], 'icon' => $cvideo['img'], 'desc' => $cvideo['desc'], 'title' => $cvideo['title'], 'cid' => $cvideo['cid'], 'dateline' => $_G['timestamp'], 'gid' => $gid);
     if ($sourcedata['vid'] = DB::insert('source_video', $sourcedata, 1)) {
         C::t('cai_video')->update($cvideo['cid'], array('copys' => $cvideo['copys'] + 1));
         $sourcedata['icon'] = $sourcedata['icon'] ? $sourcedata['icon'] : geticonfromext('', 'video');
         $icoarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'oid' => $sourcedata['vid'], 'name' => self::getFileName($sourcedata['title'], $fid), 'type' => 'video', 'dateline' => $_G['timestamp'], 'pfid' => $fid, 'opuid' => $_G['uid'], 'gid' => $gid, 'ext' => 'swf', 'flag' => '', 'size' => 0);
         if ($icoarr['icoid'] = DB::insert('icos', $icoarr, 1)) {
             $icoarr['url'] = $sourcedata['url'];
             $icoarr['img'] = $sourcedata['icon'];
             $icoarr['bz'] = '';
             $icoarr['path'] = $icoarr['icoid'];
             $icoarr['dpath'] = dzzencode($icoarr['icoid']);
             addtoconfig($icoarr);
             $icoarr['fsize'] = formatsize($icoarr['size']);
             $icoarr['ftype'] = getFileTypeName($icoarr['type'], $icoarr['ext']);
             $icoarr['fdateline'] = dgmdate($icoarr['dateline']);
             //if($gid) C::t('group_log')->setLog($gid,$_G['uid'],'addvideo',lang('message','xiezuo_log_addvideo',array('username'=>$_G['username'],'position'=>getPositionName($fid),'name'=>$icoarr['name'])));
         } else {
             C::t('source_video')->delete_by_vid($sourcedata['vid']);
         }
     }
     if ($icoarr['icoid']) {
         return $icoarr;
     } else {
         return array('error' => lang('message', 'linktovideo_error'));
     }
 }