2009年7月29日星期三

UCENTER 1.5与discuz 6.1通讯中的BUG



Normal
0



7.8 磅
0
2

false
false
false

EN-US
ZH-CN
X-NONE




















MicrosoftInternetExplorer4





























































































































































/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-font-kerning:1.0pt;}



症状:



         ucenter的后台应用管理里修改了设置或者新增了应用后,discuz后台ucenter设置中的ucenter地址会变成空,导致discuz无法正常访问ucenter,具体表现为用户短信无法打开,头像无法显示等。



 



分析与测试:



         Ucenterxml的方式传递数据给discuzdiscuz中相应的负责接收的程序为api/uc.php,该文件中看到这样一句:



$UC_API = $post['UC_API'];



         在此处,经测试发现,$post变量的数组值如下:



array (



  'item' =>



  array (



    '0_attr' =>



    array (



      'id' => '6',



    ),



    0 =>



    array (



      'item' =>



      array (



        '0_attr' =>



        array (



          'id' =>
'appid',



        ),



        0 => '6',



        '1_attr' =>



        array (



          'id' =>
'type',



        ),



        1 =>
'ECSHOP',



        '2_attr' =>



        array (



          'id' =>
'name',



        ),



        2 =>
'ECSHOP
网店',



        '3_attr' =>



        array (



          'id' =>
'url',



        ),



        3 =>
'http://workshop',



        '4_attr' =>



        array (



          'id' =>
'ip',



        ),



        4 => '',



        '5_attr' =>



        array (



          'id' =>
'viewprourl',



        ),



        5 =>
'/space.php?uid=%s',



        '6_attr' =>



        array (



          'id' =>
'apifilename',



        ),



        6 =>
'uc.php',



        '7_attr' =>



        array (



          'id' =>
'charset',



        ),



        7 => 'gbk',



        '8_attr' =>



        array (



          'id' =>
'synlogin',



        ),



        8 => '1',



        '9_attr' =>



        array (



          'id' =>
'extra',



        ),



        9 =>



        array (



          'item' =>
'',



          0 =>



          array (



            'id' =>
'apppath',



          ),



        ),



        '10_attr'
=>



        array (



          'id' =>
'recvnote',



        ),



        10 => '1',



      ),



    ),



    ......



    ......



    ......



    '6_attr' =>



    array (



      'id' =>
'UC_API',



    ),



    6 =>
'http://workuchome/ucenter',



  ),



)



         显然,$post['UC_API']得不到任何值。在uc.php中,又将获得的$UC_API写入config.inc.php文件中:



if(is_writeable(DISCUZ_ROOT.'./config.inc.php'))
{



       $configfile
= trim(file_get_contents(DISCUZ_ROOT.'./config.inc.php'));



       $configfile
= substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) :
$configfile;



       $configfile
= preg_replace("/define\('UC_API',\s*'.*?'\);/i",
"define('UC_API', '$UC_API');", $configfile);



       if($fp
= @fopen(DISCUZ_ROOT.'./config.inc.php', 'w')) {



           @fwrite($fp,
trim($configfile));



           @fclose($fp);



       }



}



    这样的话,就造成config.inc.php文件中的UC_API变为空:



define('UC_API', '');



 



解决:



         uchomeapi/uc.php中,相应的代码是这样的:



$UC_API = '';



if($post['UC_API']) {



    $UC_API
= $post['UC_API'];



    unset($post['UC_API']);



}



……



……



if($UC_API &&
is_writeable(S_ROOT.'./config.php')) {



           $configfile
= trim(file_get_contents(S_ROOT.'./config.php'));



           $configfile
= substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) :
$configfile;



           $configfile
= preg_replace("/define\('UC_API',\s*'.*?'\);/i",
"define('UC_API', '$UC_API');", $configfile);



           if($fp
= @fopen(S_ROOT.'./config.php', 'w')) {



              @fwrite($fp,
trim($configfile));



              @fclose($fp);



           }



}



    可以看出,这样的代码并不会更新config.inc.php文件,当然也不会出问题,故将discuzuc.php也改为上述形式。



    修改后经测试已

Normal
0



7.8 磅
0
2

false
false
false

EN-US
ZH-CN
X-NONE




















MicrosoftInternetExplorer4
















































































































<w:LsdException Locked="false"

没有评论: