public function wx_sendMsg($data) { if (!getglobal('setting/CorpID') || !getglobal('setting/CorpSecret')) { return false; } $user = C::t('user')->fetch($data['uid']); if (!$user['wechat_userid'] || $user['wechat_status'] != 1) { C::t('notification')->update($data['id'], array('wx_new' => $data['wx_new'] + 1)); return false; } $agentid = 0; if ($data['from_idtype'] == 'app' && $data['from_id'] && ($wxapp = C::t('wx_app')->fetch($data['from_id']))) { if ($wxapp['agentid'] && $wxapp['status'] < 1) { $agentid = $wxapp['agentid']; } } $wx = new qyWechat(array('appid' => getglobal('setting/CorpID'), 'appsecret' => getglobal('setting/CorpSecret'))); $msg = array("touser" => "dzz-" . $data['uid'], "safe" => 0, "agentid" => $agentid, "msgtype" => "news", "news" => array("articles" => array(array("title" => $data['title'], "description" => getstr($data['wx_note'], 0, 0, 0, 0, -1), "url" => $wx->getOauthRedirect(getglobal('siteurl') . 'index.php?mod=system&op=wxredirect&url=' . dzzencode($data['redirecturl'])))))); if ($ret = $wx->sendMessage($msg)) { C::t('notification')->update($data['id'], array('wx_new' => 0)); return true; } else { C::t('notification')->update($data['id'], array('wx_new' => $data['wx_new'] + 1)); $message = 'wx_notification:errCode:' . $wx->errCode . ';errMsg:' . $wx->errMsg; runlog('wxlog', $message); return false; } }
/** * 设置回复图文 * @param array $newsData * 数组结构: * array( * "0"=>array( * 'Title'=>'msg title', * 'Description'=>'summary text', * 'PicUrl'=>'http://www.domain.com/1.jpg', * 'Url'=>'http://www.domain.com/1.html' * ), * "1"=>.... * ) */ function getLatestData($wx, $uid, $limit = 10) { $param = array('news'); $sql = "status<2"; $orderby = "ORDER BY dateline DESC"; //阅读范围查询语句 $sql .= " and ("; $sql_gid = array("orgids=''"); $orgarr = getDepartmentByUid($uid); //获取当前用户所在的部门数组 foreach ($orgarr as $value) { foreach ($value as $value1) { $sql_gid[] = "FIND_IN_SET(%d,orgids)"; $param[] = $value1['orgid']; } } $sql .= "(" . implode(' OR ', $sql_gid) . ") and ( uids='' OR FIND_IN_SET(%d,uids)))"; $param[] = $uid; $data = array(); $limit = intval($limit); if (!$limit) { $limit = 10; } foreach (DB::fetch_all("select * from %t where {$sql} {$orderby} limit {$limit} ", $param) as $value) { $temp = array(); $temp['Title'] = $value['subject']; $url = getglobal('siteurl') . 'index.php?mod=news&op=view&newid=' . $value['newid']; if ($value['type'] == 0) { //文本模式 $temp['Description'] = getstr($value['content'], 300, 0, 0, 0, -1); $temp['Url'] = getOauthRedirect($url); } elseif ($value['type'] == 1) { //图片模式 $temp['Description'] = ''; $temp['Url'] = getOauthRedirect($url); if ($pic = DB::fetch_first("select aid from %t where newid=%d limit 1", array('news_pic', $value['newid']))) { $temp['PicUrl'] = getglobal('siteurl') . 'index.php?mod=io&op=thumbnail&original=1&path=' . dzzencode('attach::' . $pic['aid']); } } else { //链接模式 $temp['Url'] = $value['url']; $temp['Description'] = ''; } $data[] = $temp; } return $data; }
public function fetch_by_voteid($voteid, $type = 0) { $data = array(); $sql = 'voteid=%d'; $param = array($this->_table, $voteid); if ($type) { $sql .= " and type=%d"; } foreach (DB::fetch_all("select * from %t where {$sql} order by disp", $param) as $value) { if ($value['type'] && $value['aid']) { $value['img'] = (DZZSCRIPT ? DZZSCRIPT : 'index.php') . '?mod=io&op=thumbnail&width=240&height=160&path=' . dzzencode('attach::' . $value['aid']); $value['url'] = (DZZSCRIPT ? DZZSCRIPT : 'index.php') . '?mod=io&op=thumbnail&width=240&height=160&original=1&path=' . dzzencode('attach::' . $value['aid']); } $data['type_' . $value['type']][] = $value; } return $data; }
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); }
C::t('setting')->update('feed_wxsetting', $setting); if ($appid) { C::t('wx_app')->update($appid, array('menu' => serialize($data))); } updatecache('setting'); //发布菜单到微信 if (getglobal('setting/CorpID') && getglobal('setting/CorpSecret') && $setting['agentid']) { $wx = new qyWechat(array('appid' => getglobal('setting/CorpID'), 'appsecret' => getglobal('setting/CorpSecret'))); //处理菜单数据,所有本站链接添加oauth2地址 foreach ($data['button'] as $key => $value) { if ($value['url'] && strpos($value['url'], $_G['siteurl']) === 0) { $data['button'][$key]['url'] = $wx->getOauthRedirect(getglobal('siteurl') . 'index.php?mod=system&op=wxredirect&url=' . dzzencode($value['url'])); } elseif ($value['sub_button']) { foreach ($value['sub_button'] as $key1 => $value1) { if ($value1['url'] && strpos($value1['url'], $_G['siteurl']) === 0) { $data['button'][$key]['sub_button'][$key1]['url'] = $wx->getOauthRedirect(getglobal('siteurl') . 'index.php?mod=system&op=wxredirect&url=' . dzzencode($value1['url'])); } } } } if ($wx->createMenu($data, $setting['agentid'])) { exit(json_encode(array('msg' => 'success'))); } else { exit(json_encode(array('error' => '发布失败,errCode:' . $wx->errCode . ',errMsg:' . $wx->errMsg))); } } else { exit(json_encode(array('error' => '发布失败,应用还没有创建微信agentid'))); } } elseif ($_GET['action'] == 'menu_default') { //恢复默认 $setting['menu'] = array('button' => array(array('type' => 'view', 'name' => '全部动态', 'url' => $_G['siteurl'] . DZZSCRIPT . '?mod=feed&feedType=all'), array('type' => 'view', 'name' => '与我相关', 'url' => $_G['siteurl'] . DZZSCRIPT . '?mod=feed&feedType=aboutme'), array('name' => '我的动态', 'sub_button' => array(array('type' => 'view', 'name' => '我发布的', 'url' => $_G['siteurl'] . DZZSCRIPT . '?mod=feed&feedType=fromme'), array('type' => 'view', 'name' => '@我的', 'url' => $_G['siteurl'] . DZZSCRIPT . '?mod=feed&feedType=atme'), array('type' => 'view', 'name' => '回复我的', 'url' => $_G['siteurl'] . DZZSCRIPT . '?mod=feed&feedType=replyme'), array('type' => 'view', 'name' => '我收藏的', 'url' => $_G['siteurl'] . DZZSCRIPT . '?mod=feed&feedType=collect')))));
include template('textviewer'); } else { if (!($path = dzzdecode($_GET['path']))) { showmessage('参数错误!'); } $dpath = dzzencode($path); $error = ''; $table = ''; $icoarr = IO::getMeta($path); $maxputsize = 0; //get_config_bytes(ini_get('post_max_size')); if (!$maxputsize) { $maxputsize = 2000000; } if ($icoarr['size'] > $maxputsize) { $url = DZZSCRIPT . '?mod=textviewer&path=' . dzzencode($path); header("Location: {$url}"); exit; } if (isset($icoarr['error'])) { exit($icoarr['error']); } //根据ext获取加载codemirror的mode; $ext = isset($icoarr['ext']) ? $icoarr['ext'] : ''; require_once DZZ_ROOT . './dzz/document/codemirror/exttomodes.php'; $mode = isset($modes[$ext]) ? $modes[$ext] : ''; //获取文件地址,如果文件可以执行的话(如php,html,js等) 必须使用绝对地址,否则会得到运行后的内容; //判断有无编辑权限 $isadmin = perm_check::checkperm('edit', $icoarr); $str = IO::getFileContent($path); require_once DZZ_ROOT . './dzz/class/class_encode.php';
$new = 0; } //存储文档内容到文本文件内 $_GET['message'] = helper_security::checkhtml($_GET['message']); $message = str_replace(array("\r\n", "\r", "\n"), "", $_GET['message']); //去除换行 if (!($attach = getTxtAttachByMd5($message, $icoarr['name'] . '.dzzdoc'))) { showmessage('保存文档错误,请检查您的磁盘是否有足够空间或写入权限', dreferer()); } //获取文档内附件 $attachs = getAidsByMessage($message); $setarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'aid' => $attach['aid'], 'did' => $did); if (!($did = C::t('document')->insert($setarr, $attachs, $area, $areaid, $new))) { showmessage('保存文档错误,请检查您数据库是否正常'); } $return = array('did' => $did, 'autosave' => $autosave, 'icoid' => dzzencode($icoid)); showmessage('do_success', dreferer(), array('data' => rawurlencode(json_encode($return))), array('showmsg' => true)); } else { $navtitle = ''; $icoid = intval(dzzdecode($_GET['icoid'])); if ($icoid && ($icoarr = C::t('icos')->fetch_by_icoid($icoid))) { if (!perm_check::checkperm('edit', $icoarr)) { showmessage('no_privilege'); } $did = $icoarr['did']; } else { showmessage('文档不存在'); } if ($document = C::t('document')->fetch_by_did($did)) { $dzzpath = getDzzPath($document); $str = trim(IO::getFileContent($dzzpath));
} else { include template('common/share_password'); exit; } } $sharestatus = array('-4' => '已屏蔽', '-3' => '文件已删除', '-2' => '次数用尽', '-1' => '已过期', '0' => '正常'); $typearr = array('folder' => '目录', 'image' => '图片', 'app' => '应用', 'link' => '网址', 'video' => '视频', 'attach' => '文件', 'document' => '文档', 'dzzdoc' => 'Dzz文档', 'url' => '其他'); $asc = intval($_GET['asc']); $page = empty($_GET['page']) ? 1 : intval($_GET['page']); $perpage = 20; $start = ($page - 1) * $perpage; $gets = array('mod' => 'folder', 'sid' => $sid); $theurl = BASESCRIPT . "?" . url_implode($gets); $orderby = "order by dateline DESC"; $path = $share['path']; $dpath = dzzencode($path); $icoarr = IO::getMeta($path); $navtitle = $icoarr['name']; $icoarr['fsize'] = '-'; $list = array(); $marker = ''; if ($bz = $icoarr['bz']) { $order = $asc > 0 ? 'asc' : "desc"; $by = 'time'; $limit = $start . '-' . ($start + $perpage); if (strpos($bz, 'ALIOSS') === 0 || strpos($bz, 'JSS') === 0 || strpos($bz, 'qiniu') === 0) { $order = $_GET['marker']; $limit = $perpage; } $icosdata = IO::listFiles($path, $by, $order, $limit, $force); if ($icosdata['error']) {
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; } } }
echo json_encode(array('error' => '添加快捷方式失败')); exit; } elseif ($do == 'applinkto') { //添加应用快捷方式到特定容器 $appid = intval($_GET['appid']); $pfid = intval($_GET['pfid']); if (!($app = C::t('app_market')->fetch_by_appid($appid))) { echo json_encode(array('error' => '应用已不存在')); exit; } $icoarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'oid' => $app['appid'], 'name' => $app['title'], 'flag' => '', 'type' => 'app', 'dateline' => $_G['timestamp'], 'pfid' => $pfid, 'gid' => 0, 'ext' => '', 'size' => 0); if ($icoid = DB::result_first("select icoid from %t where oid=%d and uid=%d and type='app'", array('icos', $icoarr['oid'], $_G['uid']))) { C::t('icos')->update($icoid, $icoarr); $icoarr['icoid'] = $icoid; $icoarr['path'] = $icoid; $icoarr['dpath'] = dzzencode($icoid); $icoarr['url'] = $app['url']; $icoarr['img'] = $app['appico']; $icoarr['bz'] = ''; $icoarr = array_merge($app, $icoarr); $icoarr['fsize'] = formatsize($icoarr['size']); $icoarr['ftype'] = getFileTypeName($icoarr['type'], $icoarr['ext']); $icoarr['fdateline'] = dgmdate($icoarr['dateline']); echo json_encode($icoarr); exit; } elseif ($icoarr['icoid'] = DB::insert('icos', $icoarr, 1)) { //$icoarr=array_merge($sourcedata,$icoarr); $icoarr['url'] = $app['url']; $icoarr = array_merge($app, $icoarr); addtoconfig($icoarr); $icoarr['img'] = $app['appico'];
/* * 下载 * @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;
if ($icoarr['type'] == 'link' || $icoarr['type'] == 'video') { $url = $icoarr['url']; if (strpos($url, '?') !== false && strpos($url, 'sid=') === false) { $url .= '&sid=' . $sid; } @header("Location: " . $url); exit; } elseif ($icoarr['type'] == 'dzzdoc') { $url = "index.php?mod=document&icoid=" . $dpath; if (strpos($url, '?') !== false && strpos($url, 'sid=') === false) { $url .= '&sid=' . $sid; } @header("Location: " . $url); exit; } elseif ($icoarr['type'] == 'folder') { $dpath = dzzencode($path, '', 60 * 60); $url = "index.php?mod=folder&sid=" . $sid; @header("Location: " . $url); exit; } elseif ($icoarr['type'] == 'app') { $url = str_replace(array('{dzzscript}', '{adminscript}'), array('index.php', 'admin.php'), $icoarr['appurl']); if (strpos($url, 'dzzjs:') !== false) { //dzzjs形式时 showmessage('不支持此应用'); } else { //替换参数 $url = preg_replace("/{(\\w+)}/ie", "cansu_replace('\\1')", $url); //添加sid参数; if (strpos($url, '?') !== false && strpos($url, 'sid=') === false) { $url .= '&sid=' . $sid; }
//版本比较模式,显示当前版本与前一版本的差异 $current = $versions[$version]; if (isset($versions[$version])) { $dzzpath = getDzzPath($versions[$version]); $str_new = str_replace(array("\r\n", "\r", "\n"), "", IO::getFileContent($dzzpath)); } else { $dzzpath = getDzzPath($document); $str_new = str_replace(array("\r\n", "\r", "\n"), "", IO::getFileContent($dzzpath)); } if ($versions[$version - 1]) { $dzzpath_old = getDzzPath($versions[$version - 1]); $str_old = str_replace(array("\r\n", "\r", "\n"), "", IO::getFileContent($dzzpath_old)); } else { $str_old = $str_new; } include_once dzz_libfile('class/html_diff', 'document'); $diff = new html_diff(); $str = $diff->compare($str_old, $str_new); } else { $current = $document; $dzzpath = getDzzPath($document); $str = str_replace(array("\r\n", "\r", "\n"), "", IO::getFileContent($dzzpath)); $navtitle = $document['subject']; } } else { showmessage('文档不存在或已经删除', dreferer()); } $dicoid = dzzencode($icoid); $editperm = perm_check::checkperm('edit', $icoarr); include template('document_view'); }
} } else { $share['times'] = ''; } $share['stitle'] = $sharestatus[$share['status']]; $share['shareurl'] = $_G['siteurl'] . 's.php?sid=' . $share['sid']; } else { $share = array('title' => $icoarr['name']); } } else { $share = $_GET['share']; if ($share['endtime']) { $share['endtime'] = strtotime($share['endtime']); } if ($share['password']) { $share['password'] = dzzencode($share['password']); } $share['times'] = intval($share['times']); $share['count'] = 0; if ($ret = C::t('share')->insert_by_sid($share)) { $ret['msg'] = 'success'; exit(json_encode($ret)); } else { exit(json_encode(array('error' => '创建失败!'))); } } } elseif ($do == 'property') { $icoid = rawurldecode($_GET['icoid']); $icoarr = IO::getMeta($icoid); $perm = perm_check::checkperm('rename', $icoarr); if ($icoarr['error']) {
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; }
function getOauthRedirect($url) { //获取链接的auth地址 $wx = new qyWechat(array('appid' => getglobal('setting/CorpID'), 'appsecret' => getglobal('setting/CorpSecret'))); return $wx->getOauthRedirect(getglobal('siteurl') . 'index.php?mod=system&op=wxredirect&url=' . dzzencode($url)); }
$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'); }
public function linktourl($link, $pfid) { global $_G; $fid = $pfid; $gid = DB::result_first("select gid from %t where fid =%d", array('folder', $pfid)); $clink = array(); if (!($clink = DB::fetch_first("select * from " . DB::table("cai_link") . " where url='{$link}'"))) { $arr = array(); require_once dzz_libfile('class/caiji'); $caiji = new caiji($link); $arr['title'] = $caiji->getTitle(); $arr['description'] = $caiji->getDescription(); if ($arr['title']) { $clink = array('url' => $link, 'img' => '', 'desc' => $arr['description'], 'title' => $arr['title'], 'copys' => 0, 'dateline' => $_G['timestamp']); $clink['cid'] = DB::insert('cai_link', $clink, 1); } } $parseurl = parse_url($link); $clink['title'] = self::getFileName($clink['title'] ? $clink['title'] : $parseurl['host'], $fid); $icondata = getUrlIcon($link); $sourcedata = array('uid' => $_G['uid'], 'username' => $_G['username'], 'url' => $link, 'desc' => $clink['desc'], 'title' => $clink['title'], 'cid' => $clink['cid'], 'did' => $icondata['did'], 'icon' => $icondata['img'], 'dateline' => $_G['timestamp'], 'gid' => $gid, 'ext' => $icondata['ext']); if ($sourcedata['lid'] = DB::insert('source_link', $sourcedata, 1)) { if ($sourcedata['did']) { C::t('icon')->update_copys_by_did($sourcedata['did'], 1); } if ($sourcedata['cid']) { C::t('cai_link')->update($clink['cid'], array('copys' => $clink['copys'] + 1)); } $icoarr = array('uid' => $_G['uid'], 'username' => $_G['username'], 'oid' => $sourcedata['lid'], 'name' => $sourcedata['title'], 'flag' => '', 'type' => 'link', 'dateline' => $_G['timestamp'], 'pfid' => $fid, 'opuid' => $_G['uid'], 'gid' => $gid, 'ext' => $sourcedata['ext'], 'size' => 0); if ($icoarr['icoid'] = DB::insert('icos', $icoarr, 1)) { //$icoarr=array_merge($sourcedata,$icoarr); $icoarr['url'] = $sourcedata['url']; $icoarr['img'] = $sourcedata['icon']; $icoarr['bz'] = ''; $icoarr['path'] = $icoarr['icoid']; $icoarr['dpath'] = dzzencode($icoarr['icoid']); addtoconfig($icoarr); $icoarr['container'] = $container; $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'],'addlink',lang('message','xiezuo_log_addlink',array('username'=>$_G['username'],'position'=>getPositionName($fid),'name'=>$icoarr['name']))); } else { C::t('soouce_link')->delete($sourcedata['lid']); } } if ($icoarr['icoid']) { return $icoarr; } else { return array('error' => lang('message', 'linktourl_error')); } }
$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; }
function getAttachUrl($attach, $absolute = false) { global $_G; $attachment = ''; $bz = io_remote::getBzByRemoteid($attach['remote']); if ($bz == 'dzz') { if ($absolute) { $attachment = $_G['setting']['attachdir'] . './' . $attach['attachment']; } else { $attachment = $_G['siteurl'] . $_G['setting']['attachurl'] . $attach['attachment']; } return $attachment; } elseif (strpos($bz, 'FTP') === 0) { return $_G['siteurl'] . DZZSCRIPT . '?mod=io&op=getStream&path=' . dzzencode($bz . '/' . $attach['attachment']); } else { return IO::getFileUri($bz . '/' . $attach['attachment']); } }
$path = dzzdecode($_GET['path']); $pcs = new io_baiduPCS($path); if ($_GET['do'] == 'ajax') { $update = 1; if ($content = $pcs->getM3U8Uri($path)) { $target = 'cache/' . md5($path) . '.m3u8'; if (strlen($content) > filesize($_G['setting']['attachdir'] . $target)) { file_put_contents($_G['setting']['attachdir'] . $target, $content); $update = 1; } elseif (strlen($content) == filesize($_G['setting']['attachdir'] . $target)) { $update = 2; } else { $update = 0; } } echo json_encode(array('update' => $update, 'target' => $target)); exit; } else { $ajaxurl = DZZSCRIPT . '?mod=player:t5player&path=' . dzzencode($path) . '&do=ajax'; $target = 'cache/' . md5($path) . '.m3u8'; if (!is_file($_G['setting']['attachdir'] . $target)) { if ($content = $pcs->getM3U8Uri($path)) { file_put_contents($_G['setting']['attachdir'] . $target, $content); } } $url = $_G['setting']['attachurl'] . $target; $cloud = C::t('connect')->fetch('baiduPCS'); $ak = $cloud['key']; $sk = substr($cloud['secret'], 0, 16); include template('t5player'); }
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 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; }