function lib_changyan(&$ctag, &$refObj) { global $dsql, $envs; //属性处理 $attlist = "type|code,config|,class|_DEDECY,style|"; FillAttsDefault($ctag->CAttribute->Items, $attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $reval = ""; if (!$dsql->IsTable("#@__plus_changyan_setting")) { return '没安装畅言模块'; } $client_id = changyan_get_setting('appid'); if (empty($client_id)) { return '尚未注册畅言帐号,请到后台注册'; } if ($type == 'code' or $type == 'code2') { $reval .= "<div class='{$class}' style='{$style}'>"; $prefix = 'changyan'; $key = 'code'; $row = GetCache($prefix, $key); if (!is_array($row)) { $appid = changyan_get_setting('appid'); $user = changyan_get_setting('user'); $sign = changyan_gen_sign($user); $result = changyan_getcode(CHANGYAN_CLIENT_ID, $user, false, $sign, $appid); $row['reval'] = htmlspecialchars($result['code']); SetCache($prefix, $key, $row, 60 * 60 * 1); } if (!empty($config)) { $config_arr = array(); $configs = explode(',', $config); if (count($configs) > 0) { foreach ($configs as $c) { $item = explode(':', $c); $config_arr[$item[0]] = $item[1]; } } $config_str = json_encode($config_arr); $reval .= <<<EOT <script> var_config={$config_str}; </script> EOT; } $reval .= htmlspecialchars_decode($row['reval']); $reval = str_replace("id='SOHUCS'", "id='SOHUCS' sid='{$refObj->ArcID}'", $reval); if ($type == 'code2') { $reval = preg_replace("#window.SCS_NO_IFRAME[ ]?=[ ]?true;#i", "", $reval); } $reval = str_replace("<script>", "</div><script>", $reval); } elseif ($type == 'count') { if (!$GLOBALS['changyan_count_js']) { $reval .= "<script type=\"text/javascript\" src=\"http://assets.changyan.sohu.com/upload/plugins/plugins.count.js\"></script>"; } $reval .= "<a href=\"#SOHUCS\" id=\"changyan_count_unit\"></a>"; $GLOBALS['changyan_count_js'] = TRUE; } return $reval; }
<br> </p> </body> </html> EOT; } elseif ($dopost == 'save_appinfo') { if (empty($appInfo)) { ShowMsg("请选择正确的AppID信息!", '?dopost=change_appinfo'); exit; } list($appid, $isv_app_key) = explode('|', $appInfo); changyan_set_setting('appid', $appid); changyan_set_setting('isv_app_key', $isv_app_key); $user = changyan_get_setting('user'); $sign = changyan_gen_sign($user); $result = changyan_getcode(CHANGYAN_CLIENT_ID, $user, false, $sign, $appid); $isv_id = $result['isv_id']; changyan_set_setting('isv_id', $isv_id); changyan_clearcache(); $isv_id = intval($isv_id); $changge_isv_url = CHANGYAN_API_CHANGE_ISV . $isv_id; echo <<<EOT <iframe src="{$changge_isv_url}" scrolling="no" width="0" height="0" style="border:none"></iframe> EOT; ShowMsg("成功设置新的AppID及APPKEY!", '?', 0, 3000); exit; } elseif ($dopost == 'logout') { echo <<<EOT <iframe src="http://changyan.kuaizhan.com/logout" scrolling="no" width="0" height="0"></iframe> EOT; $_SESSION['changyan'] = 0;