本文整理匯總了PHP中XWB_plugin::convertEncoding方法的典型用法代碼示例。如果您正苦於以下問題:PHP XWB_plugin::convertEncoding方法的具體用法?PHP XWB_plugin::convertEncoding怎麽用?PHP XWB_plugin::convertEncoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XWB_plugin
的用法示例。
在下文中一共展示了XWB_plugin::convertEncoding方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doCfg4setAuthKey
/**
* 評論回推設置:設置評論回推通訊密鑰
*/
function doCfg4setAuthKey()
{
if (!defined('XWB_S_IS_ADMIN') || !XWB_S_IS_ADMIN || !XWB_plugin::isRequestBy('POST')) {
XWB_plugin::deny('');
}
$pushInstance = XWB_Plugin::O('pushbackCommunicator');
$res = $pushInstance->getAuthKey();
if ($res['httpcode'] != 200 || !isset($res['data']['code'])) {
$ret = array(0, '向評論回推服務器請求通訊密鑰失敗,請重試或者向Xweibo求助。');
echo json_encode($ret);
} else {
//根據以前的評論回推設置,重置評論回推總開關is_pushback_open
$is_pushback_open = $this->_checkPushbackOpenConfig();
//注冊虛擬賬戶
$username = '微博評論';
$username_site = XWB_plugin::convertEncoding('微博評論', 'UTF-8', XWB_S_CHARSET);
$uid = $this->_setPushbackSiteAccount($username_site);
if ($uid > 0) {
XWB_Plugin::setPCfg(array('is_pushback_open' => $is_pushback_open, 'pushback_authkey' => strval($res['data']['code']), 'pushback_username' => $username, 'pushback_uid' => $uid));
} else {
XWB_Plugin::setPCfg(array('is_pushback_open' => $is_pushback_open, 'pushback_authkey' => strval($res['data']['code'])));
}
//根據is_pushback_open,進行評論回推服務器定製通知
$pushInstance->changePushbackAuthKey($res['data']['code']);
if (1 == $is_pushback_open) {
$pushInstance->setPushback('comment');
} else {
$pushInstance->cancelPushback();
}
$ret = array(1, '開啟成功!');
echo json_encode($ret);
}
}
示例2: _createContent
/**
* 根據發送過來的數據,組裝出已經轉碼的、要插入對應數據庫的回帖內容
*
* @param array $data API發送過來的數據
* @return string 要插入的回帖內容(已經轉碼)
*/
function _createContent($data)
{
//轉換為論壇所需要的字符集
if (empty($data['nick'])) {
$data['nick'] = '回推';
}
$nickname = XWB_plugin::convertEncoding((string) $data['nick'], 'UTF-8', XWB_S_CHARSET);
$content = XWB_plugin::convertEncoding((string) $data['text'], 'UTF-8', XWB_S_CHARSET);
//DZ函數
$content = dhtmlspecialchars($content);
$content = $this->_replaceSinaUrlToUBB($content);
$content = $this->_filterContent($content);
if (empty($content)) {
return '';
}
if (isset($data['pic']) && !empty($data['pic'])) {
$content .= "\n\n" . '[img]http://ww3.sinaimg.cn/large/' . $data['pic'] . '.jpg[/img]';
}
$content = $content . "\n\n" . '[img]' . XWB_plugin::getPluginUrl('images/bgimg/icon_logo.png') . '[/img] ' . '[size=2][color=gray]' . '[url=' . XWB_plugin::getWeiboProfileLink($data['uid']) . ']' . XWB_plugin::L('xwb_reply_from_2', $nickname) . '[/url][/color][/size]';
return $content;
}
示例3: foreach
<div class="active-s1">
<h4>他們已經綁定微博了,你還不行動?</h4>
<?php
foreach ($huwbUserRs as $value) {
?>
<div class="users">
<a href="<?php
echo XWB_plugin::getWeiboProfileLink($value['sina_uid']);
?>
" target="_blank"><?php
echo $value['avatar'];
?>
</a>
<div class="user-info">
<p><?php
echo XWB_plugin::convertEncoding($value['username'], XWB_S_CHARSET, 'UTF-8');
?>
</p>
<a class="addfollow-btn" href="<?php
echo XWB_plugin::getWeiboProfileLink($value['sina_uid']);
?>
" target="_blank"></a>
<a class="already-addfollow-btn hidden" href="javascript:void(0)#"></a>
</div>
</div>
<?php
}
?>
</div>
<?php
}
示例4: runhooks
runhooks();
//dx的設置文件中有個['output']['forceheader'],為1時會強製輸出一個header編碼,故隻能如此處理,防止幹擾插件,但不能做到100%完美
if (0 != $discuz->config['output']['forceheader'] && 'UTF-8' != strtoupper($discuz->config['output']['charset'])) {
@header("Content-type: text/html; charset=utf-8");
}
//在鉤子環境中,可能無法讀取$discuz實例,因此要做如此處理
} elseif (!isset($discuz) || !is_a($discuz, 'discuz_core')) {
$discuz =& discuz_core::instance();
}
$GLOBALS[XWB_SITE_GLOBAL_V_NAME]['site_db'] =& DB::object();
// 附屬站點所用的字符集 UTF8 GBK BIG5
define('XWB_S_CHARSET', str_replace("-", "", strtoupper($discuz->config['output']['charset'])));
// 附屬站點所用的表前綴
define('XWB_S_TBPRE', $discuz->db->tablepre);
// 附屬站點 的版本號
define('XWB_S_VERSION', substr($discuz->var['setting']['version'], 1));
// 附屬站點 的類型名稱
define('XWB_S_NAME', 'DiscuzX');
// 附屬站點 的標題名稱
define('XWB_S_TITLE', XWB_plugin::convertEncoding($discuz->var['setting']['bbname'], XWB_S_CHARSET, 'UTF-8'));
// 附屬站點 的用戶UID
define('XWB_S_UID', (int) $discuz->var['uid']);
define('XWB_S_IS_ADMIN', (int) $discuz->var['adminid'] == 1 ? true : false);
if (!defined('CURSCRIPT') || CURSCRIPT == '') {
$XWB_S_CURSCRIPT = isset($_SERVER['SCRIPT_FILENAME']) ? substr(basename($_SERVER['SCRIPT_FILENAME']), 0, -4) : 'unknown';
define('XWB_S_CURSCRIPT', $XWB_S_CURSCRIPT);
} else {
define('XWB_S_CURSCRIPT', CURSCRIPT);
}
//echo '<pre>';print_r(get_defined_constants());echo '</pre>';exit;
define('XWB_PLUGIN_SITE_ENV_LOADED', true);
示例5: _convert
/**
* 轉換為微博可以使用的編碼
*/
function _convert($msg)
{
return XWB_plugin::convertEncoding($msg, XWB_S_CHARSET, 'UTF-8');
}
示例6: setError
/**
* 設置錯誤提示
*
* @param string $error
* @return unknown
*/
function setError($error)
{
$errmsg = isset($error['error']) ? strtolower($error['error']) : 'UNDEFINED ERROR';
if (strpos($errmsg, 'token_')) {
$msg = XWB_plugin::L('xwb_token_error');
} elseif (strpos($errmsg, 'user does not exists')) {
$msg = XWB_plugin::L('xwb_user_not_exists');
} elseif (strpos($errmsg, 'target weibo does not exist')) {
$msg = XWB_plugin::L('xwb_target_weibo_not_exist');
} elseif (strpos($errmsg, 'weibo id is null')) {
$msg = XWB_plugin::L('xwb_weibo_id_null');
} elseif (strpos($errmsg, 'system error')) {
$msg = XWB_plugin::L('xwb_system_error');
} elseif (strpos($errmsg, 'consumer_key')) {
$msg = XWB_plugin::L('xwb_app_key_error');
} elseif (strpos($errmsg, 'ip request')) {
$msg = XWB_plugin::L('xwb_request_reach_api_maxium');
} elseif (strpos($errmsg, 'update comment')) {
$msg = XWB_plugin::L('xwb_comment_reach_api_maxium');
} elseif (strpos($errmsg, 'update weibo')) {
$msg = XWB_plugin::L('xwb_update_reach_api_maxium');
} elseif (strpos($errmsg, 'high level')) {
$msg = XWB_plugin::L('xwb_access_resource_api_denied');
} else {
$msg = XWB_plugin::L('xwb_system_error');
}
//DEBUG 日誌
$req_url = $this->last_req_url;
XWB_plugin::LOG("[WEIBO CLASS]\t[ERROR]\t#{$this->req_error_count}\t{$msg}\t{$req_url}\tERROR ARRAY:\r\n" . print_r($error, 1));
//DEBUG END
if (!$this->is_exit_error) {
return false;
}
if ('utf8' != strtolower(XWB_S_CHARSET)) {
$msg = XWB_plugin::convertEncoding($msg, XWB_S_CHARSET, 'UTF-8');
}
XWB_plugin::showError($msg);
}
示例7: doBindAtNotLog
/**
* 在未登錄論壇帳號,但已登錄新浪微博帳號的綁定頁麵進行用戶帳戶驗證和綁定
*/
function doBindAtNotLog()
{
if (!XWB_plugin::pCfg('is_account_binding')) {
XWB_plugin::showError('新浪微博綁定功能已經關閉!');
}
$this->_chkIsWaitingForReg();
$usernameS = trim((string) XWB_plugin::V('p:siteBindName'));
$password = trim((string) XWB_plugin::V('p:bindPwd'));
$username = XWB_plugin::convertEncoding($usernameS, "UTF8", XWB_S_CHARSET);
if (!empty($questionanswerS)) {
$questionanswer = XWB_plugin::convertEncoding($questionanswerS, "UTF8", XWB_S_CHARSET);
} else {
$questionanswer = '';
}
$uid = 0;
//第1關:數據輸入驗證關
if (empty($username)) {
$uid = -102;
}
if (empty($password)) {
$uid = -103;
}
$msg = '';
//第2關:用戶身份驗證關
if ($uid == 0) {
$verify = XWB_plugin::O('siteUserVerifier');
$verifyresult = $verify->verify($username, $password, $questionid, $questionanswer);
$uid = $verifyresult[0];
}
if ($uid > 0) {
$wbApi = XWB_plugin::getWB();
$uInfo = $wbApi->verifyCredentials();
$db = XWB_plugin::getDB();
//第3關:驗證微博帳號是否已經在當前站點中綁定,防止用戶通過多個瀏覽器惡意注冊用戶
$bInfo = $db->fetch_first("SELECT * FROM " . XWB_S_TBPRE . "xwb_bind_info WHERE sina_uid='" . $uInfo['id'] . "' or uid='" . $uid . "'");
if (!empty($bInfo) && is_array($bInfo)) {
$uid = -201;
} else {
$sess = XWB_plugin::getUser();
$sess->setInfo('sina_uid', $uInfo['id']);
$last_key = $sess->getOAuthKey(true);
$inData = array();
$inData['uid'] = $uid;
$inData['sina_uid'] = $uInfo['id'];
$inData['token'] = $last_key['oauth_token'];
$inData['tsecret'] = $last_key['oauth_token_secret'];
$inData['profile'] = '[]';
$sqlF = array();
$sqlV = array();
foreach ($inData as $k => $v) {
$sqlF[] = "`" . $k . "`";
$sqlV[] = "'" . mysql_real_escape_string($v) . "'";
}
$sql = "INSERT INTO " . XWB_S_TBPRE . "xwb_bind_info (" . implode(",", $sqlF) . ") VALUES (" . implode(",", $sqlV) . ") ;";
$rst = $db->query($sql, 'UNBUFFERED');
require_once XWB_P_ROOT . '/lib/xwbSite.inc.php';
xwb_setSiteUserLogin($uid);
setcookie('xwb_tips_type', '', 0);
$sess->setInfo('waiting_site_reg', '0');
jclass('misc')->update_account_bind_info($uid, '', '', 1);
$msg = "綁定 " . XWB_S_TITLE . " 帳號成功。下次你可以繼續使用新浪微博帳號登錄使用 " . XWB_S_TITLE . " 。";
$msg .= "<br>綁定帳號: <em>" . htmlspecialchars($usernameS) . "</em> ";
//正向綁定(在未登錄論壇帳號已登錄新浪微博帳號的綁定頁麵)統計上報
$sess->appendStat('bind', array('uid' => $uInfo['id'], 'type' => 1));
}
}
if ($uid <= 0) {
$msg = $this->_getBindTip($uid);
}
$this->_oScript('xwbSetTips', array($uid, $msg, 1));
}
示例8: setError
function setError($error)
{
if (!$this->error_exit) {
return;
}
$err = array('Access time failure' => '請求時間失效', 'Signature is not correct' => '簽名不正確', 'Request path is not correct' => '請求路徑不正確', 'Save faileds' => '數據保存失敗', 'Update faileds' => '數據更新失敗');
$errmsg = isset($error['error']) ? strtolower($error['error']) : 'UNDEFINED ERROR';
$msg = isset($err[$errmsg]) ? $err[$errmsg] : '未知錯誤';
if ('utf8' != strtolower(XWB_S_CHARSET)) {
$msg = XWB_plugin::convertEncoding($msg, XWB_S_CHARSET, 'UTF-8');
}
XWB_plugin::showError($msg);
}
示例9: doBindAtNotLog
/**
* 在未登錄論壇帳號,但已登錄新浪微博帳號的綁定頁麵進行用戶賬戶驗證和綁定
*/
function doBindAtNotLog()
{
if (!XWB_plugin::pCfg('is_account_binding') || !XWB_plugin::isRequestBy('POST')) {
XWB_plugin::showError('網站管理員關閉了插件功能“新浪微博綁定”。請稍後再試。');
}
$this->_chkIsWaitingForReg();
$usernameS = trim((string) XWB_plugin::V('p:siteBindName'));
$password = trim((string) XWB_plugin::V('p:bindPwd'));
$questionid = (int) XWB_plugin::V('p:questionid');
$questionanswerS = trim((string) XWB_plugin::V('p:questionanswer'));
$username = XWB_plugin::convertEncoding($usernameS, "UTF8", XWB_S_CHARSET);
if (!empty($questionanswerS)) {
$questionanswer = XWB_plugin::convertEncoding($questionanswerS, "UTF8", XWB_S_CHARSET);
} else {
$questionanswer = '';
}
$uid = 0;
//第1關:數據輸入驗證關
if (empty($username)) {
$uid = -102;
}
if (empty($password)) {
$uid = -103;
}
$msg = '';
//第2關:用戶身份驗證關
if ($uid == 0) {
$verify = XWB_plugin::O('siteUserVerifier');
$verifyresult = $verify->verify($username, $password, $questionid, $questionanswer);
$uid = $verifyresult[0];
}
if ($uid > 0) {
$wbApi = XWB_plugin::getWB();
$uInfo = $wbApi->verifyCredentials();
//第3關:驗證微博帳號是否已經在當前站點中綁定,防止用戶通過多個瀏覽器惡意注冊用戶
$bInfo = XWB_plugin::getBUById($uid, $uInfo['id']);
//遠程API
if (!empty($bInfo) && is_array($bInfo)) {
$uid = -201;
} else {
$sess = XWB_plugin::getUser();
$sess->setInfo('sina_uid', $uInfo['id']);
$last_key = $sess->getOAuthKey(true);
$rst = XWB_plugin::addBindUser($uid, $uInfo['id'], (string) $last_key['oauth_token'], (string) $last_key['oauth_token_secret'], $uInfo['screen_name']);
//遠程API
require_once XWB_P_ROOT . '/lib/xwbSite.inc.php';
xwb_setSiteUserLogin($uid);
dsetcookie($this->_getBindCookiesName($uid), (string) $uInfo['id'], 604800);
dsetcookie('xwb_tips_type', '', 0);
$sess->setInfo('waiting_site_reg', '0');
$msg = "綁定論壇帳號成功。下次你可以繼續使用新浪微博帳號登錄使用" . XWB_S_TITLE . "論壇。";
$msg .= "<br>綁定帳號: <em>" . htmlspecialchars($usernameS) . "</em> ";
//正向綁定(在未登錄論壇帳號已登錄新浪微博帳號的綁定頁麵)統計上報
$sess->appendStat('bind', array('uid' => $uInfo['id'], 'type' => 1));
//輸出UCenter同步JS
global $_G;
loaducenter();
$ucsynlogin = $_G['setting']['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
$this->_outputUJ($ucsynlogin);
}
}
if ($uid <= 0) {
$msg = $this->_getBindTip($uid);
}
$displayWindow = 0;
$this->_oScript('xwbSetTips', array($uid, $msg, $displayWindow));
}
示例10: define
}
*/
return $return;
}
//插件appkey定義
define('XWB_APP_KEY', $GLOBALS['_J']['config']['sina']['app_key'] ? $GLOBALS['_J']['config']['sina']['app_key'] : '3015840342');
define('XWB_APP_SECRET_KEY', $GLOBALS['_J']['config']['sina']['app_secret'] ? $GLOBALS['_J']['config']['sina']['app_secret'] : '484175eda3cf0da583d7e7231c405988');
/**
* 定義記事狗相關的常量
*
*/
define('XWB_S_CHARSET', str_replace("-", "", strtoupper($GLOBALS['_J']['config']['charset'])));
define('XWB_S_TBPRE', $GLOBALS['_J']['config']['db_table_prefix']);
define('XWB_S_VERSION', '2.5.0');
define('XWB_S_NAME', 'JishiGou');
define('XWB_S_TITLE', XWB_plugin::convertEncoding($GLOBALS['_J']['config']['site_name'], XWB_S_CHARSET, 'UTF-8'));
define('XWB_S_SITEURL', $GLOBALS['_J']['config']['site_url'] . "/");
/**
* 初始化記事狗數據庫操作類
*/
if (!$GLOBALS[XWB_SITE_GLOBAL_V_NAME]['site_db']) {
include_once XWB_P_ROOT . '/lib/xwbDB.class.php';
$GLOBALS[XWB_SITE_GLOBAL_V_NAME]['site_db'] = new xwbDB();
$GLOBALS[XWB_SITE_GLOBAL_V_NAME]['site_db']->connect($GLOBALS['_J']['config']['db_host'], $GLOBALS['_J']['config']['db_user'], $GLOBALS['_J']['config']['db_pass'], $GLOBALS['_J']['config']['db_name'], $GLOBALS['_J']['config']['db_persist'], true, XWB_S_CHARSET);
}
/**
* 初始化記事狗係統的用戶登錄信息
*/
if (!defined('MEMBER_ID')) {
$jsg_authcode = $_COOKIE["{$GLOBALS['_J']['config']['cookie_prefix']}auth"];
list($jsg_password, $jsg_uid) = $jsg_authcode ? explode("\t", authcode($jsg_authcode, 'DECODE')) : array('', '', 0);
示例11: _createContent
/**
* 根據發送過來的數據,組裝出已經轉碼的、要插入對應數據庫的回帖內容
*
* @param array $data API發送過來的數據
* @return string 要插入的回帖內容(已經轉碼)
*/
function _createContent($data)
{
//轉換為論壇所需要的字符集
if (empty($data['nick'])) {
$data['nick'] = '回推';
}
$nickname = XWB_plugin::convertEncoding((string) $data['nick'], 'UTF-8', XWB_S_CHARSET);
$content = XWB_plugin::convertEncoding((string) $data['text'], 'UTF-8', XWB_S_CHARSET);
//DZ函數
$content = dhtmlspecialchars($content);
$content = $this->_replaceSinaUrlToHTML($content);
$content = $this->_filterContent($content);
if (empty($content)) {
return '';
}
if (isset($data['pic']) && !empty($data['pic'])) {
$content .= "<br />" . '<img src="chttp://ww3.sinaimg.cn/large/' . $data['pic'] . '.jpg" />';
}
$content = '<img src="' . XWB_plugin::getPluginUrl('images/bgimg/icon_logo.png') . '" />' . $nickname . '(<a href="' . XWB_plugin::getWeiboProfileLink($data['uid']) . '" target="_blank">' . XWB_plugin::L('xwb_weibo') . '</a>): ' . $content;
return $content;
}