/** * 获取插件目录所在的完整URL访问地址 * @param string $path 附加URL字符串,前面不能加/ * @return string */ function getPluginUrl($path = '') { return XWB_plugin::siteUrl() . XWB_P_DIR_NAME . "/" . $path; }
</div> </div> </form> </div> <div id="apihd_nv"> <ul> <?php $tmp = array('navname' => '微博', 'filename' => 'xweibo.php', 'available' => 1, 'nav' => 'id="mn_xweibo" ><a href="xweibo.php" hidefocus="true" title="Xweibo" class="current">微博<span>Xweibo</span></a', 'navid' => 'mn_xweibo', 'level' => 0); array_splice($_G['setting']['navs'], 1, 0, array($tmp)); ?> <?php foreach ($_G['setting']['navs'] as $nav) { ?> <?php $nav['nav'] = preg_replace('#href="(?!http)(.*?)"#', 'href="' . dirname(XWB_plugin::siteUrl()) . '/$1"', $nav['nav']); ?> <?php if ($nav['available'] && (!$nav['level'] || $nav['level'] == 1 && $_G['uid'] || $nav['level'] == 2 && $_G['adminid'] > 0 || $nav['level'] == 3 && $_G['adminid'] == 1)) { ?> <?php echo "<li {$nav['nav']}/li>"; ?> <?php } ?> <?php } ?> </ul> </div>
/** * 获取转发主题信息 For DiscuzX1.5 * @param $tid int 论坛thread id * @return array */ function forShare($tid) { /* 主题URL */ $baseurl = XWB_plugin::siteUrl(); $topic_url = $baseurl . 'index.php?mod=topic&code=' . $tid; if (function_exists('get_full_url')) { $topic_url = get_full_url($baseurl, 'index.php?mod=topic&code=' . $tid); } $url = ' ' . $topic_url; /* 获取微博信息 */ $db = XWB_plugin::getDB(); $topic = $db->fetch_first("SELECT `tid`,`content`,`imageid` FROM " . XWB_S_TBPRE . "topic WHERE tid='{$tid}'"); if (empty($topic)) { return FALSE; } /* 转码 */ $message = $this->_convert(trim($topic['content'])); /* 过滤UBB与表情 */ $message = $this->_filter($message); $message = strip_tags($message); /* 将最后附带的url给删除 */ $message = preg_replace("|\\s*http:/" . "/[a-z0-9-\\.\\?\\=&_@/%#]*\$|sim", "", $message); /* 合并标题和链接 */ $message = $message . $url; // 取出所有图片 $img_urls = array(); if ($topic['imageid'] && XWB_plugin::pCfg('is_upload_image')) { $image_file = "/images/topic/" . jsg_face_path($topic['imageid']) . $topic['imageid'] . "_o.jpg"; if (is_file(XWB_S_ROOT . $image_file)) { $img_urls[] = $baseurl . $image_file; } } return array('url' => $topic_url, 'message' => $message, 'pics' => array_map('trim', $img_urls)); }
echo XWB_plugin::getPluginUrl('images/xwb_' . XWB_S_VERSION . '.css'); ?> " /> </head> <body> <div class="bind-setting xwb-plugin"> <p class="alert-tips">出错啦!</p> <div class="bing-text"> <p><?php echo $info; ?> </p> </div> <div class="setting-box"> <p><a href="<?php echo XWB_plugin::siteUrl(); ?> ">返回首页</a></p> <p><a href="http://bbs.x.weibo.com/" target="_blank">我是站长,寻求帮助</a></p> </div> </div> </body> </html>
/** * 获取site的个人页面链接 * @param int $uid * @param string */ function _getSiteSpaceUrl($uid) { if (defined('XWB_S_SITEURL')) { return XWB_S_SITEURL . "/home.php?mod=space&uid=" . $uid; } else { return dirname(XWB_plugin::siteUrl()) . "/home.php?mod=space&uid=" . $uid; } }
/** * 根据在首页中显示的浮层显示对应的操作(内部函数,被authCallback最后调用) * 所有跟站点相关的对接,必须放到_showBinging * @param string $tipsType 类型 * @uses showmessage(dz函数) */ function _showBinging($tipsType) { global $_G; $sess = XWB_plugin::getUser(); $referer = $sess->getInfo('referer'); if (empty($referer)) { $referer = 'index.php'; } //用于启动浮层 $GLOBALS['xwb_tips_type'] = $tipsType; //不完美解决方案 if (0 != $_G['config']['output']['forceheader'] && 'UTF8' != XWB_S_CHARSET) { @header("Content-type: text/html; charset=" . $_G['config']['output']['charset']); } if ('autoLogin' == $tipsType) { $_G['cookie'][$this->_getBindCookiesName((int) $_G['uid'])] = 99999; //仅为了不显示绑定按钮 $_G['username'] = empty($_G['username']) ? 'SinaAPIUser' : $_G['username']; if ($_G['setting']['allowsynlogin'] && 0 < $_G['uid']) { loaducenter(); $ucsynlogin = $_G['setting']['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : ''; $param = array('username' => $_G['username'], 'uid' => $_G['uid'], 'usergroup' => ''); showmessage('login_succeed', $referer, $param, array('showdialog' => 1, 'locationtime' => true, 'extrajs' => $ucsynlogin)); } else { showmessage('login_succeed', $referer, array('username' => $_G['username'], 'uid' => 0, 'usergroup' => '')); } } elseif ('siteuserNotExist' == $tipsType) { showmessage(XWB_plugin::L('xwb_site_user_not_exist'), '', array(), array(), 1); } elseif ('reg' == $tipsType) { showmessage(XWB_plugin::L('xwb_process_binding', 'openReg4dx'), null, array(), array(), 1); } elseif ('hasBinded' == $tipsType) { showmessage(XWB_plugin::L('xwb_process_binding', 'hasBind'), null, array(), array(), 1); //直接跳转到bind页面 } else { if (version_compare(XWB_S_VERSION, '2', '>=')) { $pluginid = 'sina_xweibo_x2'; } else { $pluginid = 'sina_xweibo'; } XWB_plugin::redirect(XWB_plugin::siteUrl(0) . 'home.php?mod=spacecp&ac=plugin&id=' . $pluginid . ':home_binding', 3); } }
/** * 取得指定帖子图片的数组 * For DiscuzX1.5 增加去掉网络图片宽高值功能 * @param $pid int 论坛posts id * @param $msg string 发布内容 * @param $num int 需要返回的图片数,默认为1张 * @return array */ function _getImage($pid, $msg, $num = 1) { global $_G; require_once XWB_S_ROOT . '/source/function/function_attachment.php'; $db = XWB_plugin::getDB(); $attachfind = $attachreplace = $attachments = array(); //X2开始attachment才分表,摘抄getattachtablebypid函数 if (version_compare(XWB_S_VERSION, '2', '>=')) { $tableid = DB::result_first("SELECT tableid FROM " . DB::table('forum_attachment') . " WHERE pid='{$pid}' LIMIT 1"); $attachmentTableName = 'forum_attachment_' . ($tableid >= 0 && $tableid < 10 ? intval($tableid) : 'unused'); } else { $attachmentTableName = 'forum_attachment'; } $query = $db->query("SELECT * FROM " . DB::table($attachmentTableName) . " WHERE pid='{$pid}'"); while ($attach = $db->fetch_array($query)) { // 只使用附件为图片、没有阅读权限和金钱权限、并且大小小于1M的发送到微博 if ($attach['isimage'] && $attach['price'] == 0 && $attach['readperm'] == 0 && $attach['filesize'] <= 1024 * 1024) { if (!isset($_G['xwb_ftp_remote_url'])) { $_G['xwb_ftp_remote_url'] = isset($_G['setting']['ftp']['attachurl']) ? $_G['setting']['ftp']['attachurl'] : ''; } $attach['url'] = ($attach['remote'] ? $_G['xwb_ftp_remote_url'] : $_G['setting']['attachurl']) . 'forum/'; $attachfind[] = "/\\[attach\\]{$attach['aid']}\\[\\/attach\\]/i"; if (strpos($attach['url'], "://") != false) { $attachreplace[] = '[attachimg]' . $attach['url'] . '/' . $attach['attachment'] . '[/attachimg]'; } else { $attachreplace[] = '[attachimg]' . XWB_plugin::siteUrl() . $attach['url'] . '/' . $attach['attachment'] . '[/attachimg]'; } } $attachments[] = $attach; } if ($attachfind) { $msg = preg_replace($attachfind, $attachreplace, $msg); } /* 去掉网络图片宽高值 For DiscuzX1.5 2010-09-25 */ $msg = preg_replace('|\\[img=\\d+,\\d+](.*?)\\[/img\\]|', '[img]\\1[/img]', $msg); // 还原<img>为[img] $msg = preg_replace('/<img[^>]+src="([^\'"]+)"[^>]+>/', "[img]\\1[/img]", $msg); $image_list = array(); if (preg_match_all('!\\[(attachimg|img)\\]([^\\[]+)\\[/(attachimg|img)\\]!', $msg, $match, PREG_PATTERN_ORDER)) { if (count($match[2]) > $num) { $image_list = array_slice($match[2], 0, $num); } else { $image_list = $match[2]; } } return $image_list; }
/** * 根据在首页中显示的浮层显示对应的操作(内部函数,被authCallback最后调用) * 所有跟站点相关的对接,必须放到_showBinging * @param string $tipsType 类型 * @uses showmessage(dz函数) */ function _showBinging($tipsType) { //用于启动浮层 $GLOBALS['xwb_tips_type'] = $tipsType; //不完美解决方案 if ('UTF-8' != strtoupper($GLOBALS['_J']['config']['charset'])) { @header("Content-type: text/html; charset=utf-8"); } if ('autoLogin' == $tipsType) { $synlogin_result = ''; if (true === UCENTER) { //加载Ucenter客户端文件 include_once ROOT_PATH . './api/uc_client/client.php'; $ucuid = (int) $GLOBALS['_J']['config']['login_user']['ucuid']; if ($ucuid > 0) { $synlogin_result = uc_user_synlogin($ucuid); } } //直接跳转到首页 jsg_showmessage("登录成功{$synlogin_result}", $this->redirect_to, 5); } elseif ('siteuserNotExist' == $tipsType) { jsg_showmessage(XWB_plugin::L('xwb_site_user_not_exist')); } elseif ('reg' == $tipsType) { jsg_showmessage(XWB_plugin::L('xwb_process_binding', 'openReg4jsg')); } elseif ('hasBinded' == $tipsType) { jsg_showmessage(XWB_plugin::L('xwb_process_binding', 'hasBind')); //直接跳转到bind页面 } else { XWB_plugin::redirect(XWB_plugin::siteUrl(0) . 'index.php?mod=account&code=sina', 3); } }