Manyou诚邀开发者加盟 | 常见问题
《站长》俱乐部官方群公布 城市联络员机会多多
立即免费下载 Discuz!7.0.0 正式版
安装升级指南 | 用户手册 | 新手建站学堂
基于.net架构的Discuz!NT2.6正式版发布
Comsenz公司2009年招贤纳士,期待您的加盟
Discuz!收费服务内容及价格
7月重庆、成都、西安三地社区运营实战特训速报名
Discuz!/UCHome 专用官方虚拟主机
牧场新服一起联运:豆浆机免费带回家
基于Discuz!的免费论坛空间5D6D
康盛创想《站长》俱乐部18城市互动之旅报名ing
返回列表 回复 发帖

Mediawiki 1.12+Discuz 6.1+Ucenter 1同步登陆整合方法(080409更新)

080409: 13楼加了段通过hook mediawiki自动登录功能实现自动同步登陆的演示代码,自动同步退出需要hook下mediawiki的自动退出功能。
【适用范围】
UCenter 1.0.0RC GBK
Discuz 6.1.0RC GBK
Mediawiki 1.12.0
实现了基于Ucenter的各产品之间的同步登陆、简单的权限管理(即DZ中某些用户组才具有编辑百科的权力)。时间关系,更多丰富的功能还没实现,大概的整合思路在代码里注释了,希望能抛砖引玉:)。因为我用的都是GBK的DZ,所以只做了GBK部分的工作,UTF8版本之间集成应该更方便。如果你有什么特别的DZ+Mw应用思路,欢迎到 www.allwiki.com 的QQ群交流。

【使用方法】
1、extensions目录下建立Auth_UC目录,复制Auth_Discuz.php、config.inc.php以及UC客户端的/client目录到Auth_UC下
2、设置LocalSettings.php,调用Auth_Discuz.php并设置相关参数,我的设置参考:
LocalSettings.php下添加:
  1. // 调用插件
  2. require_once './extensions/Auth_UC/Auth_Discuz.php';
  3.   
  4. // GroupID of your Discuz group 允许编辑百科的DZ用户组ID,这里随便写的
  5. $wgDiscuz_WikiGroupID = '9,10,11,12,13,14';

  6. $wgDiscuz_WikiGroupName = 'user'; // Name of your Discuz group
  7.   // users need to be a member
  8.   // of to use the wiki. (i.e. wiki)
  9.   
  10. $wgDiscuz_UseWikiGroup = true; // This tells the Plugin to require
  11.   // a user to be a member of the above
  12.   // Discuz group. (ie. wiki) Setting
  13.   // this to false will let any Discuz
  14.   // user edit the wiki.
  15.   
  16. $wgDiscuz_UseExtDatabase = true; // This tells the plugin that the Discuz tables
  17.   // are in a different database then the wiki.
  18.   // The default settings is false.
  19.   
  20. $wgDiscuz_Version = '6'; // This is what version of Discuz you are using.
  21.   // Current valid values are 5.5 and 6 修改过来的,就没改了
  22.   
  23. /*-[NOTE: You only need the next four settings if you set $wgDiscuz_UseExtDatabase to true.]-*/
  24. $wgDiscuz_MySQL_Host = 'localhost:6033'; // Discuz MySQL Host Name. 我个人的测试环境
  25. $wgDiscuz_MySQL_Username = 'root'; // Discuz MySQL Username. 这些是DZ里设置权限的数据库
  26. $wgDiscuz_MySQL_Password = 'root'; // Discuz MySQL Password. 就是说用DZ来决定哪些人可以编辑
  27. $wgDiscuz_MySQL_Database = 'dz61'; // Discuz MySQL Database Name. 权限应该还可以细化
  28.   
  29. $wgDiscuz_Charset = 'gbk'; // Discuz MySQL Database Name. GBK的数据库,utf8的设置有差异
  30. $wgDiscuz_UserTB = 'cdb_members'; // Name of your Discuz user table. (i.e. bbs_members)
  31. $wgDiscuz_UserFieldTB = 'cdb_memberfields'; // Name of your SMF user table. (i.e. bbs_memberfields)
  32. $wgDiscuz_GroupsTB = 'cdb_usergroups'; // Name of your Discuz groups table. (i.e. bbs_usergroups)
  33. $wgAuth = new Auth_Discuz(); // Auth_Discuz Plugin.
复制代码
我的config.inc.php文件,参照Ucenter设置:
  1. <?php

  2. // ============================================================================
  3. define('UC_CONNECT', 'mysql');
  4. define('UC_DBHOST', 'localhost:6033');
  5. define('UC_DBUSER', 'root');
  6. define('UC_DBPW', 'root');
  7. define('UC_DBNAME', 'test');
  8. define('UC_DBCHARSET', 'gbk');
  9. define('UC_DBTABLEPRE', '`test`.uc10_');
  10. define('UC_DBCONNECT', '0');
  11. define('UC_KEY', '12345');
  12. define('UC_API', 'http://localhost/passport');
  13. define('UC_CHARSET', 'gbk');
  14. define('UC_IP', '');
  15. define('UC_APPID', '7');
  16. define('UC_PPP', '20');
复制代码
【参考】
http://www.51ajax.com/blog/?p=99

[ 本帖最后由 outcrop 于 2008-4-9 14:21 编辑 ]

Auth_UC.rar (24.15 KB)

三个修改了的文件

修改过的代码

【修改过的文件】
请自行查找行号,我的修改变了
1、/extensions/Auth_UC/Auth_Discuz.php
  1. <?php

  2.     /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

  3.     /**
  4.      * This file makes MediaWiki use a SMF user database to
  5.      * authenticate with. This forces users to have a SMF account
  6.      * in order to log into the wiki. This should also force the user to
  7.      * be in a group called wiki.
  8.      *
  9.      * This program is free software; you can redistribute it and/or modify
  10.      * it under the terms of the GNU General Public License as published by
  11.      * the Free Software Foundation; either version 2 of the License, or
  12.      * (at your option) any later version.
  13.      *
  14.      * This program is distributed in the hope that it will be useful,
  15.      * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17.      * GNU General Public License for more details.
  18.      *
  19.      * You should have received a copy of the GNU General Public License along
  20.      * with this program; if not, write to the Free Software Foundation, Inc.,
  21.      * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22.      * http://www.gnu.org/copyleft/gpl.html
  23.      *
  24.      * @package MediaWiki
  25.      * @subpackage Auth_SMF
  26.      * @author Nicholas Dunnaway
  27.      * @copyright 2004-2006 php|uber.leet
  28.      * @license http://www.gnu.org/copyleft/gpl.html
  29.      * @CVS: $Id: Auth_SMF.php,v 1.3 2007/04/05 22:17:56 nkd Exp $
  30.      * @link http://uber.leetphp.com
  31.      * @version $Revision: 1.3 $
  32.      *
  33.      *
  34.      * @Modified By Hopesoft
  35.      * @link http://www.51ajax.com
  36.      * @2007-11-11
  37.      *
  38.      *
  39.      * @Modified By outcrop
  40.      * @email outcrop@163.com
  41.      * @2008-04-07
  42.      */

  43.     error_reporting(E_ALL); // Debug
  44. include './extensions/Auth_UC/config.inc.php';
  45. include './extensions/Auth_UC/client/client.php';

  46.     // First check if class has already been defined.
  47.     if (!class_exists('AuthPlugin'))
  48.     {
  49.         /**
  50.          * Auth Plugin
  51.          *
  52.          */
  53.         require_once './includes/AuthPlugin.php';
  54.     }

  55.     /**
  56.      * Handles the Authentication with the Discuz database.
  57.      *
  58.      * @package MediaWiki
  59.      * @subpackage Auth_Discuz
  60.      */
  61.     class Auth_Discuz extends AuthPlugin
  62.     {

  63.         /**
  64.          * Add a user to the external authentication database.
  65.          * Return true if successful.
  66.          *
  67.          * NOTE: We are not allowed to add users to Discuz from the
  68.          * wiki so this always returns false.
  69.          *
  70.          * @param User $user
  71.          * @param string $password
  72.          * @return bool
  73.          * @access public
  74.          */
  75.         function addUser( $user, $password )
  76.         {
  77.             return false;
  78.         }

  79.                 /**
  80.                  * Can users change their passwords?
  81.                  *
  82.                  * @return bool
  83.                  */
  84.                 function allowPasswordChange()
  85.                 {
  86.                         return true;
  87.                 }

  88.         /**
  89.          * Check if a username+password pair is a valid login.
  90.          * The name will be normalized to MediaWiki's requirements, so
  91.          * you might need to munge it (for instance, for lowercase initial
  92.          * letters).
  93.          *
  94.          * @param string $username
  95.          * @param string $password
  96.          * @return bool
  97.          * @access public
  98.          * @todo Check if the password is being changed when it contains a slash or an escape char.
  99.          */
  100.         function authenticate($username, $password)
  101.         {
  102.             // Clean $username and force lowercase username.
  103.             //echo "
  104. Authenticate Start";
  105.             $username = htmlentities(strtolower($username), ENT_QUOTES, 'UTF-8');
  106.             $username = str_replace(''', '\\\'', $username); // Allow apostrophes (Escape them though)
  107.            //调用client的uc_user_login判断用户密码,由于MediaWiki为utf8编码,因此转换为GBK后判断,主要是中文ID
  108.             list($uid, $username1, $password, $email) = uc_user_login(iconv("UTF-8", "GBK", $username), $password);
  109.             setcookie('WIKI_auth', '', -86400);
  110.             if ($uid > 0 && $this->isMemberOfWikiGroup($username)) {
  111.                     //用户登陆成功,设置 Cookie,加密直接用 uc_authcode 函数,用户使用自己的函数
  112.                                                         setcookie('WIKI_auth', uc_authcode($uid."\t".$username1, 'ENCODE'));
  113.                                                         //生成同步登录的代码
  114.                                                         //由于uc_user_synlogin返回string,必须要echo一下才能成功同步登陆
  115.                                                         echo uc_user_synlogin($uid);
  116.                                                         if(uc_pm_checknew($uid)) {
  117.                                                                 //echo "You have new message....";
  118.                                                                 }
  119.                     return true;
  120.                     }
  121.             if ($uid== -1){
  122.                     echo "No this username for login, please confirm";
  123.                     return false;
  124.                     }
  125.             if ($uid== -2){
  126.                     echo "assword Error";
  127.                     return false;
  128.                     }
  129.         }

  130.         /**
  131.          * Return true if the wiki should create a new local account automatically
  132.          * when asked to login a user who doesn't exist locally but does in the
  133.          * external auth database.
  134.          *
  135.          * If you don't automatically create accounts, you must still create
  136.          * accounts in some way. It's not possible to authenticate without
  137.          * a local account.
  138.          *
  139.          * This is just a question, and shouldn't perform any actions.
  140.          *
  141.          * NOTE: I have set this to true to allow the wiki to create accounts.
  142.          *       Without an accout in the wiki database a user will never be
  143.          *       able to login and use the wiki. I think the password does not
  144.          *       matter as long as authenticate() returns true.
  145.          *
  146.          * @return bool
  147.          * @access public
  148.          */
  149.         function autoCreate()
  150.         {
  151.             return true;
  152.         }

  153.         /**
  154.          * Check to see if external accounts can be created.
  155.          * Return true if external accounts can be created.
  156.          *
  157.          * NOTE: We are not allowed to add users to Discuz from the
  158.          * wiki so this always returns false.
  159.          *
  160.          * @return bool
  161.          * @access public
  162.          */
  163.         function canCreateAccounts()
  164.         {
  165.             return false;
  166.         }
  167.         
  168.         /**
  169.          * Connect to the database. All of these settings are from the
  170.          * LocalSettings.php file. This assumes that the Discuz uses the same
  171.          * database/server as the wiki.
  172.          *
  173.          * {@source }
  174.          * @return resource
  175.          */
  176.         function connect()
  177.         {
  178.                 //echo "
  179. ----connecting----";
  180.             $dbcharset = $GLOBALS['wgDiscuz_Charset'];
  181.             //echo "Charset: ".$dbcharset;
  182.             
  183.             // Check if the Discuz tables are in a different database then the Wiki.
  184.             if ($GLOBALS['wgDiscuz_UseExtDatabase'] == true) {

  185.                 // Connect to database. I supress the error here.
  186.                 $fresMySQLConnection = @mysql_connect($GLOBALS['wgDiscuz_MySQL_Host'],
  187.                                                       $GLOBALS['wgDiscuz_MySQL_Username'],
  188.                                                       $GLOBALS['wgDiscuz_MySQL_Password'],
  189.                                                       true);
  190.             if (mysql_get_server_info()>= 4.1)                        
  191.                                 if($dbcharset) {                           
  192.                                         mysql_query("SET character_set_connection=$dbcharset, character_set_results=$dbcharset, character_set_client=binary");
  193.                                 }               
  194.                
  195.                 // Check if we are connected to the database.
  196.                 if (!$fresMySQLConnection)
  197.                 {
  198.                     $this->mySQLError('There was a problem when connecting to the Discuz database.
  199. ' .
  200.                                       'Check your Host, Username, and Password settings.
  201. ');
  202.                 }

  203.                 // Select Database
  204.                 $db_selected = mysql_select_db($GLOBALS['wgDiscuz_MySQL_Database'], $fresMySQLConnection);

  205.                 // Check if we were able to select the database.
  206.                 if (!$db_selected)
  207.                 {
  208.                     $this->mySQLError('There was a problem when connecting to the Discuz database.
  209. ' .
  210.                                       'The database ' . $GLOBALS['wgDiscuz_MySQL_Database'] .
  211.                                       ' was not found.
  212. ');
  213.                 }

  214.             }
  215.             else
  216.             {

  217.                 // Connect to database.
  218.                 $fresMySQLConnection = mysql_connect($GLOBALS['wgDBserver'],
  219.                                                      $GLOBALS['wgDBuser'],
  220.                                                      $GLOBALS['wgDBpassword'],
  221.                                                      true);

  222.                 // Check if we are connected to the database.
  223.                 if (!$fresMySQLConnection)
  224.                 {
  225.                     $this->mySQLError('There was a problem when connecting to the Discuz database.
  226. ' .
  227.                                       'Check your Host, Username, and Password settings.
  228. ');
  229.                 }

  230.                 // Select Database: This assumes the wiki and Discuz are in the same database.
  231.                 $db_selected = mysql_select_db($GLOBALS['wgDBname']);

  232.                 // Check if we were able to select the database.
  233.                 if (!$db_selected)
  234.                 {
  235.                     $this->mySQLError('There was a problem when connecting to the Discuz database.
  236. ' .
  237.                                       'The database ' . $GLOBALS['wgDBname'] . ' was not found.
  238. ');
  239.                 }

  240.             }

  241.             $GLOBALS['gstrMySQLVersion'] = substr(mysql_get_server_info(), 0, 3); // Get the mysql version.

  242.             return $fresMySQLConnection;
  243.         }

  244.          /**
  245.          * If you want to munge the case of an account name before the final
  246.          * check, now is your chance.
  247.          */
  248.         function getCanonicalName( $username )
  249.         {
  250.             return $username;
  251.         }

  252.         /**
  253.          * When creating a user account, optionally fill in preferences and such.
  254.          * For instance, you might pull the email address or real name from the
  255.          * external user database.
  256.          *
  257.          * The User object is passed by reference so it can be modified; don't
  258.          * forget the & on your function declaration.
  259.          *
  260.          * NOTE: This gets the email address from Discuz for the wiki account.
  261.          *
  262.          * @param User $user
  263.          * @access public
  264.          */
  265.         function initUser(&$user)
  266.         {
  267.                 //echo "
  268. initUser Start";
  269.                 $username = htmlentities(strtolower($user->mName), ENT_QUOTES, 'UTF-8');
  270.           $username = str_replace(''', '\\\'', $username); // Allow apostrophes (Escape them though)
  271.          
  272.           //echo "
  273. Start init---";
  274.          
  275.                 if($data = uc_get_user(iconv("UTF-8", "GBK", $username))) { //Get information from UC
  276.                         //if($data = uc_get_user($username)) { //Get information from UC
  277.                         list($uid, $username1, $email) = $data;
  278.                         //$username=iconv("GBK", "UTF-8", $username);
  279.                         //echo "init uname1:".$username1;
  280.                         //echo $email.$uid;
  281.                         $user->mEmail=$email; //Get email from UC
  282.                         $user->mid=$uid; //Get address from UC
  283.                         } else {
  284.                                 echo 'No such user for initial: '.$username;
  285.                                 }
  286.                 //$username=iconv("GBK", "UTF-8", $username);
  287.         }

  288.         /**
  289.          * Checks if the user is a member of the Discuz group called wiki.
  290.          *
  291.          * @param string $username
  292.          * @access public
  293.          * @return bool
  294.          * @todo Remove 2nd connection to database. For function isMemberOfWikiGroup()
  295.          *
  296.          */
  297.         function isMemberOfWikiGroup($username)
  298.         {
  299.             // In LocalSettings.php you can control if being
  300.             //echo "
  301. ---IsMember Start---";
  302.             // a member of a wiki is required or not.
  303.             //return false;
  304.             if (isset($GLOBALS['wgDiscuz_UseWikiGroup']) && $GLOBALS['wgDiscuz_UseWikiGroup'] === false)
  305.             {
  306.                 return true;
  307.             }

  308.             // Connect to the database.
  309.             $fresMySQLConnection = $this->connect();

  310.             // Check MySQL Version
  311.             if ($GLOBALS['gstrMySQLVersion'] >= 4.1)
  312.             {
  313.                 // Get all the groups the user is a member of.
  314.                 $fstrMySQLQuery = 'SELECT `adminid`, `groupid`
  315.                                    FROM `' . $GLOBALS['wgDiscuz_UserTB'] . '`
  316.                                    WHERE `username` = CONVERT( _utf8 \'' . $username . '\' USING utf8 )
  317.                                    
  318.                                    LIMIT 1';
  319.             }
  320.             else
  321.             {
  322.                 // Get all the groups the user is a member of.
  323.                 $fstrMySQLQuery = 'SELECT `adminid`, `groupid`
  324.                                    FROM `' . $GLOBALS['wgDiscuz_UserTB'] . '`
  325.                                    WHERE `username` = \'' . $username . '\'
  326.                                    LIMIT 1';
  327.             }


  328.             // Query Database.
  329.             $fresMySQLResult = mysql_query($fstrMySQLQuery, $fresMySQLConnection)
  330.                                or die($this->mySQLError('Unable to view external table_2'));

  331.             //echo $fstrMySQLQuery;
  332.             while($faryMySQLResult = mysql_fetch_array($fresMySQLResult))
  333.             {               
  334.                 $GroupID = $faryMySQLResult['groupid'];
  335.                // echo  "groupID is: ".$GroupID;
  336.                                 $AdminID = $faryMySQLResult['adminid'];
  337.             }         
  338.                         
  339.                     $wgDiscuz_WikiGroupIDArray=explode(',',$GLOBALS['wgDiscuz_WikiGroupID']);
  340.             if (in_array($GroupID,$wgDiscuz_WikiGroupIDArray ) || $AdminID =="1") {
  341.                                 return true;
  342.             }
  343.             else
  344.             {
  345.                     return false;        
  346.             }
  347.         }

  348.         /**
  349.          * Modify options in the login template.
  350.          *
  351.          * NOTE: Turned off some Template stuff here. Anyone who knows where
  352.          * to find all the template options please let me know. I was only able
  353.          * to find a few.
  354.          *
  355.          * @param UserLoginTemplate $template
  356.          * @access public
  357.          */
  358.         function modifyUITemplate( &$template )
  359.         {
  360.             $template->set('usedomain',   false); // We do not want a domain name.
  361.             $template->set('create',      false); // Remove option to create new accounts from the wiki.
  362.             $template->set('useemail',    false); // Disable the mail new password box.
  363.         }

  364.         /**
  365.          * This prints an error when a MySQL error is found.
  366.          *
  367.          * @param string $message
  368.          * @access public
  369.          */
  370.         function mySQLError( $message )
  371.         {
  372.             echo $message . '
  373. ';
  374.             echo 'MySQL Error Number: ' . mysql_errno() . '
  375. ';
  376.             echo 'MySQL Error Message: ' . mysql_error() . '

  377. ';
  378.             exit;
  379.         }

  380.         /**
  381.          * Set the domain this plugin is supposed to use when authenticating.
  382.          *
  383.          * NOTE: We do not use this.
  384.          *
  385.          * @param string $domain
  386.          * @access public
  387.          */
  388.         function setDomain( $domain )
  389.         {
  390.             $this->domain = $domain;
  391.         }

  392.             /**
  393.              * Set the given password in the authentication database.
  394.              * Return true if successful.
  395.              *
  396.              * NOTE: We only allow the user to change their password via phpBB.
  397.              *
  398.              * @param string $password
  399.              * @return bool
  400.              * @access public
  401.              */
  402.             function setPassword( $password )
  403.             {
  404.                     return true;
  405.             }

  406.         /**
  407.          * Return true to prevent logins that don't authenticate here from being
  408.          * checked against the local database's password fields.
  409.          *
  410.          * This is just a question, and shouldn't perform any actions.
  411.          *
  412.          * Note: This forces a user to pass Authentication with the above
  413.          *       function authenticate(). So if a user changes their Discuz
  414.          *       password, their old one will not work to log into the wiki.
  415.          *       Wiki does not have a way to update it's password when Discuz
  416.          *       does. This however does not matter.
  417.          *
  418.          * @return bool
  419.          * @access public
  420.          */
  421.         function strict()
  422.         {
  423.             return true;
  424.         }

  425.                 /**
  426.                  * Update user information in the external authentication database.
  427.                  * Return true if successful.
  428.                  *
  429.                  * @param $user User object.
  430.                  * @return bool
  431.                  * @public
  432.                  */
  433.                 function updateExternalDB( $user )
  434.                 {
  435.                         return true;
  436.                 }

  437.         /**
  438.          * When a user logs in, optionally fill in preferences and such.
  439.          * For instance, you might pull the email address or real name from the
  440.          * external user database.
  441.          *
  442.          * The User object is passed by reference so it can be modified; don't
  443.          * forget the & on your function declaration.
  444.          *
  445.          * NOTE: Not useing right now.
  446.          *
  447.          * @param User $user
  448.          * @access public
  449.          */
  450.         function updateUser( &$user )
  451.         {
  452.             return true;
  453.         }

  454.         /**
  455.          * Check whether there exists a user account with the given name.
  456.          * The name will be normalized to MediaWiki's requirements, so
  457.          * you might need to munge it (for instance, for lowercase initial
  458.          * letters).
  459.          *
  460.          * NOTE: MediaWiki checks its database for the username. If it has
  461.          *       no record of the username it then asks. "Is this really a
  462.          *       valid username?" If not then MediaWiki fails Authentication.
  463.          *
  464.          * @param string $username
  465.          * @return bool
  466.          * @access public
  467.          * @todo write this function.
  468.          */
  469.         function userExists($username)
  470.         {
  471.             // Clean $username and force lowercase username.
  472.             //echo "
  473. userExists Start";
  474.             $username = htmlentities(strtolower($username), ENT_QUOTES, 'UTF-8');
  475.             $username = str_replace(''', '\\\'', $username); // Allow apostrophes (Escape them though)
  476.             //$username=iconv("UTF-8", "GBK", $username);
  477.             //echo "
  478. Start Exist---";
  479.             
  480. //---------------------------------------------------------------------------------------------------
  481. if($data = uc_get_user(iconv("UTF-8", "GBK", $username))) {
  482.         list($uid, $username1, $email) = $data;        
  483.         //$username=iconv("GBK", "UTF-8", $username);
  484.         //echo "Exist username :".$username;
  485.         //echo "---Exist username1 :".$username1;
  486.         return true;
  487. } else {
  488.         echo 'No such user:'.$username;
  489.         //echo iconv("UTF-8", "GBK", $username);
  490.         return false;
  491. }

  492.         }

  493.         /**
  494.          * Check to see if the specific domain is a valid domain.
  495.          *
  496.          * @param string $domain
  497.          * @return bool
  498.          * @access public
  499.          */
  500.         function validDomain( $domain )
  501.         {
  502.             return true;
  503.         }

  504.     }

  505. ?>
复制代码
2、./includes/Database.php第818行添加mysql_query("SET NAMES 'utf8';", $this->mConn );
修改这个主要是我的中文ID会出问题,不一定要求
  1. /*private*/ function doQuery( $sql ) {
  2.                 if( $this->bufferResults() ) {
  3.                         mysql_query("SET NAMES 'utf8';", $this->mConn );
  4.                         $ret = mysql_query( $sql, $this->mConn );
  5.                 } else {
  6.                         $ret = mysql_unbuffered_query( $sql, $this->mConn );
  7.                 }
  8.                 return $ret;
  9.         }
复制代码
3、./extensions/Auth_UC/client/lib/db.class.php 第71行和78行,分别设置了mysql_query方式,我的GBK对utf8,所以修改这里,utf8的dz和ucenter就不必了
  1. function query($sql, $type = '', $cachetime = FALSE) {
  2.                 mysql_query("SET NAMES 'GBK'"); //设定UC查询编码为GBK,避免编码冲突
  3.                 $func = $type == 'UNBUFFERED' && function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
  4.                 if(!($query = $func($sql, $this->link)) && $type != 'SILENT') {
  5.                         $this->halt('MySQL Query Error', $sql);
  6.                 }
  7.                 $this->querynum++;
  8.                 $this->histories[] = $sql;
  9.                 mysql_query("SET NAMES 'utf8'");//还原MW系统查询编码为UTF-8,避免编码冲突
  10.                 return $query;
  11.         }
复制代码
支持楼主:)
【点击进入:::哟哟城市:::】
新网互联 COM,NET 50元/年 联系QQ:5166143
★淘宝鞋店★ 主营NIKE ADIDAS 篮球鞋、板鞋
占楼支持~~~~~~~
这个兄弟好像认识的,好久没联系了,转战media了啊呵呵
生活就是....
支持个
战位!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
龙港网:www.lgbbs.cn
返回列表