require_once XWB_P_ROOT . '/lib/core.class.php'; //现阶段在本插件中主要用于存储db类。 //要注意附属站点的环境可能会会覆盖这个变量里面的内容 $GLOBALS[XWB_SITE_GLOBAL_V_NAME] = array(); /// 引入附属站点的环境 require_once XWB_P_ROOT . '/site.env.php'; //从common.cfg.php移出的内容 //要注意附属站点的环境可能会会覆盖这个变量里面的内容 //插件所需数据和php4兼容方案安全性初始化 $GLOBALS['__CLASS'] = array(); $GLOBALS['xwb_tips_type'] = ''; //初始单例化一个client user用户(兼初始化session) $sess = XWB_plugin::getUser(); if (!defined('IN_XWB_INSTALL_ENV')) { if (defined('XWB_S_UID') && XWB_S_UID) { $bInfo = XWB_plugin::getBindInfo(); if (!empty($bInfo) && is_array($bInfo)) { $keys = array('oauth_token' => $bInfo['token'], 'oauth_token_secret' => $bInfo['tsecret']); $sess->setInfo('sina_uid', $bInfo['sina_uid']); $sess->setOAuthKey($keys, true); } } $GLOBALS['xwb_tips_type'] = $sess->getInfo('xwb_tips_type'); if ($GLOBALS['xwb_tips_type']) { $sess->delInfo('xwb_tips_type'); setcookie('xwb_tips_type', '', time() - 3600); } $xwb_token = $sess->getToken(); if (empty($xwb_token)) { $sess->clearToken(); setcookie('xwb_tips_type', '', time() - 3600);
/** * 生成统计上报url(当$html参数为true时,可使用返回的内容,通过客户端进行上报) * @param string $type stat类型 * @param array $args stat参数 * @param bool 生成html?默认为否 * @param bool 是否产生random?默认为是 * @return string */ function statUrl($type, $args = array(), $html = false, $random = true) { if (defined('XWB_P_STAT_DISABLE')) { return ''; } $statUrl = 'http://beacon.x.weibo.com/a.gif'; //stat参数公用部分添加 $args['pjt'] = XWB_P_PROJECT; $args['dsz'] = XWB_S_VERSION; $args['ver'] = XWB_P_VERSION; $args['xt'] = $type; $args['akey'] = isset($args['akey']) ? $args['akey'] : XWB_APP_KEY; $args['ip'] = XWB_plugin::getIP(); //新浪用户uid,最好强制传值,否则会异步计算错误 if (!isset($args['uid'])) { $args['uid'] = XWB_plugin::getBindInfo("sina_uid"); } $args['uid'] = !is_numeric($args['uid']) || 1 > $args['uid'] ? '' : $args['uid']; if (true === $random) { $args['random'] = rand(1, 999999); } $statUrl .= '?' . http_build_query($args); if (defined('XWB_P_DEBUG') && true == XWB_P_DEBUG) { $logmsg = "上报的URL为:" . $statUrl; XWB_plugin::LOG($logmsg, 'statRecord', false); } if (false == $html) { return $statUrl; } else { return '<img src="' . $statUrl . '" style="display:none" />'; } }
/** * 获取用户信息 * @return array $rst 用户信息 */ function _getUserInfo() { /* 获取绑定信息 */ $sina_id = XWB_plugin::getBindInfo('sina_uid'); if (!$sina_id) { return array('error_no' => '10001', 'error' => '错误:用户未绑定.'); } /* 获取用户资料 */ $wbApi = XWB_plugin::getWB(); $keys = $this->_getTockenFromDB($sina_id); if (empty($keys)) { return array('error_no' => '10002', 'error' => '错误:无法获取绑定信息.'); } $wbApi->setTempToken($keys['oauth_token'], $keys['oauth_token_secret']); $wbApi->is_exit_error = false; $rst = $wbApi->getUserShow($sina_id); if (!is_array($rst) || isset($rst['error']) || empty($rst['id'])) { return array('error_no' => '10003', 'error' => "错误:无法从接口中获取用户信息."); } return $rst; }
/** * 加载新浪微博的底部信息 */ function jsg_sina_footer() { $tipsType = $GLOBALS['xwb_tips_type']; $site_uid = XWB_S_UID; $sina_uid = XWB_plugin::getBindInfo("sina_uid"); $siteVer = XWB_S_VERSION; $siteName = str_replace("'", "\\'", $GLOBALS['_J']['config']['site_name']); $pName = CURSCRIPT . '_' . CURMODULE; $regUrl = XWB_plugin::URL("xwbSiteInterface.reg"); $setUrl = XWB_plugin::URL("xwbSiteInterface.bind"); $bindUrl = XWB_plugin::URL("xwbSiteInterface.bind"); $signerUrl = XWB_plugin::URL("xwbSiteInterface.signer"); $authUrl = XWB_plugin::URL("xwbAuth.login"); $getTipsUrl = XWB_plugin::URL("xwbSiteInterface.getTips"); $attentionUrl = XWB_plugin::URL("xwbSiteInterface.attention"); $wbxUrl = XWB_plugin::pCfg("wbx_url"); $xwb_loadScript1 = $GLOBALS['_J']['site_url'] . '/images/xwb/dlg.js'; $xwb_loadScript2 = $GLOBALS['_J']['site_url'] . '/images/xwb/xwb.js'; $xwb_css_base = $GLOBALS['_J']['site_url'] . '/images/xwb/xwb_base.css'; $xwb_css_append = $GLOBALS['_J']['site_url'] . ('/images/xwb/xwb_' . XWB_S_VERSION . '.css'); $return = <<<EOF <script language="javascript"> var _xwb_cfg_data ={ \ttipsType:\t'{$tipsType}',site_uid:\t'{$site_uid}',sina_uid:\t'{$sina_uid}', \tsiteVer:\t'{$siteVer}',siteName:\t'{$siteName}',pName:'{$pName}', \tregUrl:\t\t'{$regUrl}', \tsetUrl:\t\t'{$setUrl}', \tbindUrl:\t'{$bindUrl}', \tsignerUrl:\t'{$signerUrl}', \tauthUrl:\t'{$authUrl}', \tgetTipsUrl:\t'{$getTipsUrl}', \tattentionUrl:\t'{$attentionUrl}', \twbxUrl:\t\t'{$wbxUrl}' }; function xwb_loadScript(file, charset){ \tvar script = document.createElement('SCRIPT'); \tscript.type = 'text/javascript'; script.charset = charset; script.src = file; \tdocument.getElementsByTagName('HEAD')[0].appendChild(script); } xwb_loadScript("{$xwb_loadScript1}", "UTF-8"); xwb_loadScript("{$xwb_loadScript2}", "UTF-8"); </script> <link href="{$xwb_css_base}" rel="stylesheet" type="text/css" /> <link href="{$xwb_css_append}" rel="stylesheet" type="text/css" /> EOF; /* $sess = XWB_plugin::getUser(); $xwb_statInfo = $sess->getStat(); foreach( $xwb_statInfo as $k => $stat ){ $xwb_statType = isset($stat['xt']) ? (string)$stat['xt'] : 'unknown'; $return .= XWB_plugin::statUrl( $xwb_statType, $stat, true ); } if( !empty($xwb_statInfo) ){ $sess->clearStat(); } */ return $return; }
/** * 分享同步 * @param integer $sid * @param array $arr */ function shareSync($sid, $arr) { global $_G; $type = $title = $pic = ''; if (isset($arr['image']) && !empty($arr['image']) && XWB_plugin::pCfg('is_upload_image')) { $pic = str_replace('.thumb.jpg', '', $arr['image']); } switch (strtolower($arr['type'])) { case 'space': $type = 'username'; break; case 'blog': $type = 'subject'; break; case 'album': $type = 'albumname'; break; case 'pic': $type = 'albumname'; break; case 'thread': $type = 'subject'; break; case 'article': $type = 'title'; break; case 'link': case 'video': case 'music': case 'flash': $type = 'link'; break; default: break; } $arr['body_data'] = unserialize($arr['body_data']); if (empty($type)) { return false; } elseif ('link' != $type) { $pattern = '/^<a[ ]+href[ ]*=[ ]*"([a-zA-Z0-9\\/\\\\@:%_+.~#*?&=\\-]+)"[ ]*>(.+)<\\/a>$/'; preg_match($pattern, $arr['body_data'][$type], $match); if (3 !== count($match)) { return false; } $link = $_G['siteurl'] . $match[1]; if (1 == XWB_plugin::pcfg('link_visit_promotion')) { $link .= '&fromuid=' . $_G['uid']; } $title = 'pic' == $type ? $arr['body_data']['title'] : $match[2]; } else { $link = $arr['body_data']['data']; } $message = !empty($arr['body_general']) ? (string) $arr['body_general'] : (string) $arr['title_template']; if (!empty($title)) { $message = $this->_convert($message . ' | ' . $title); } else { $message = $this->_convert($message); } $link = ' ' . $link; $length = 140 - ceil(strlen(urlencode($link)) * 0.5); $message = $this->_substr($message, $length); $message .= $link; $wb = XWB_plugin::getWB(); // 同步到微博 if (!empty($pic)) { $ret = $wb->upload($message, $pic, null, null, false); if (isset($ret['error_code']) && 400 == (int) $ret['error_code']) { $ret = $wb->update($message, false); } } else { $ret = $wb->update($message, false); } //同步微博后的ID if (!empty($ret['id'])) { //@todo json_decode可能存在解析超过int最大数的错误(#47644)问题 $mid = $ret['id']; $this->insertSyncId($sid, $ret['id'], 'share'); //日志同步统计上报 $sess = XWB_plugin::getUser(); $sess->appendStat('ryz', array('uid' => XWB_plugin::getBindInfo("sina_uid"), 'mid' => $mid, 'type' => 4)); } }
/** * 生成令牌token * @param string $hashadd * @param bool $useBindData 默认为false * @return string */ function make($hashadd = '', $useBindData = false) { global $_G; $skey = defined('XWB_APP_SECRET_KEY') ? XWB_APP_SECRET_KEY : rand(1, 100000000); $sina_uid = 0; if ($useBindData) { $sina_uid = XWB_plugin::getBindInfo('sina_uid', 0); } return substr(md5("{$_G['adminid']}#{$hashadd}#{$_G['uid']}#{$skey}#{$sina_uid}#{$_SERVER['HTTP_USER_AGENT']}" . __FILE__), 6, 10); }
<div class="sign-skin-setting" id="skin-list" onclick="checkSkin(event, this)"> <a href="javascript:void(0)"><span class="skin-01"></span></a> <a href="javascript:void(0)"><span class="skin-02"></span></a> <a href="javascript:void(0)"><span class="skin-03"></span></a> <a href="javascript:void(0)"><span class="skin-04"></span></a> <a href="javascript:void(0)"><span class="skin-05"></span></a> <a href="javascript:void(0)"><span class="skin-06 sign-setting-bg"></span></a> <a href="javascript:void(0)"><span class="skin-07 sign-setting-bg"></span></a> <a href="javascript:void(0)"><span class="skin-08 sign-setting-bg"></span></a> <a href="javascript:void(0)"><span class="skin-09 sign-setting-bg"></span></a> <a href="javascript:void(0)"><span class="skin-10 sign-setting-bg"></span></a> </div> <h3>效果预览</h3> <div class="sign-skin-preview"> <a href="<?php echo XWB_plugin::getWeiboProfileLink(XWB_plugin::getBindInfo('sina_uid')); ?> " target="_blank" id="view_img_wr"> <img border="0" alt="" src="" id="view_img"> </a> <div class="sign-skin-loading hidden" id="view_img_load"><p>正在加载,请稍候...</p></div> </div> <div class="btn-area"> <span class="xwb-plugin-btn"><input type="submit" value="取消" onclick="parent.XWBcontrol.close('signer');" class="button"></span> <span class="xwb-plugin-btn"><input type="submit" value="确定" onclick="parent.XWBcontrol.profile.onSignerDlgOk(gUid, gSkinNum, keyStr)" class="button"></span> </div> </div> <script type="text/javascript"> var gUid = "<?php echo $myid; ?>