ecshop與Ucenter通訊失敗的一個很怪的問題

首先上一篇好文 http://blog.csdn.net/viqecel/article/details/52485774


       注意,uc.PHP接口如何調試,(api/uc.php的作用是把論壇等其它應用,傳送過來的用戶名等信息,向自己的系統中同步登錄,或同步註冊會員),查看這裏的教程.http://blog.csdn.net/viqecel/article/details/52492081


      ucenter 提示通信失敗,是因爲在\uc_server\control\admin\app.php  這個函數中,function onping()  返回的值不是1.

在大約132有這麼一句

    } else {  
                //echo $url;exit();  
                echo 'document.getElementById(\'status_'.$appid.'\').innerHTML = "<img src=\'images/error.gif\' border=\'0\' class=\'statimg\' \/><span class=\'red\'>'.$this->lang['app_connent_false'].'</span>";testlink();';  
            }  


       我們可以在else{ 的後面增加echo $url;exit();然後想辦法查看.他返回的網址是多少.

怎麼看呢.可以用谷歌瀏覽器,進後臺uc後臺應用管理後,點擊鍵盤上的f12,進入谷歌調試模式.然後.點擊左下角的小箭頭,如下圖一,點擊一下 通信失敗 這四個字.看下他對應的網址是多少.

如圖



        然後,下圖,注意紅框中的關鍵點,找到 源碼代碼中的 通信失敗或通信成功 四個字,他的下面,即對應的script裏面的網址,右鍵,複製網址,在瀏覽器中打開.即可返回我們要的內容.






         假如他返回的網址是http://www.viq.com/api/uc.php?code=612122

則直接打開這個網址,看下他返回什麼信息.如果404,則這個文件不存在,所以通信失敗.如果是空白內容,則找一下api/uc.php這個文件,把開頭的error_reporting(0); 這一句註釋掉,看一下這個文件是不是有什麼報錯.解決好php或sql錯誤後,再把error_reporting(0);前面的註釋去掉.

然後,\uc_server\control\admin\app.php 把這個文件的echo $url;exit();這一句註釋掉,重新打開上面,右鍵複製的那個網址,看下返回的是不是1,如果返回的是1,則應用管理列表中,會顯示通信成功.

當然前提是你有uc.php這個通信接口,並且接口中有一個test函數.具體看官方demo吧.

function test($get, $post) {return API_RETURN_SUCCEED;}

---------------------------------------------------------------------------------------------------------------

我根據上面的方法找url,訪問之後報錯,錯誤信息如下

Notice: Use of undefined constant DATA_DIR - assumed 'DATA_DIR' in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 260

Warning: file_put_contents(D:/phpStudy/WWW/www.xxxxxmall.com/DATA_DIR/mysql_query_8687db5154d5e169336cc55883a87bbd_2017_07_08.log): failed to open stream: No such file or directory in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 264

Notice: Use of undefined constant DATA_DIR - assumed 'DATA_DIR' in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 260

Warning: file_put_contents(D:/phpStudy/WWW/www.xxxxxmall.com/DATA_DIR/mysql_query_8687db5154d5e169336cc55883a87bbd_2017_07_08.log): failed to open stream: No such file or directory in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 264

Notice: Use of undefined constant DATA_DIR - assumed 'DATA_DIR' in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 260

Warning: file_put_contents(D:/phpStudy/WWW/www.xxxxxmall.com/DATA_DIR/mysql_query_8687db5154d5e169336cc55883a87bbd_2017_07_08.log): failed to open stream: No such file or directory in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 264

Notice: Use of undefined constant DATA_DIR - assumed 'DATA_DIR' in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 260

Warning: file_put_contents(D:/phpStudy/WWW/www.xxxxxmall.com/DATA_DIR/mysql_query_8687db5154d5e169336cc55883a87bbd_2017_07_08.log): failed to open stream: No such file or directory in D:\phpStudy\WWW\www.xxxxxmall.com\includes\cls_mysql.php on line 264
1

然後找到cls_mysql.php

  if (defined('DEBUG_MODE') && (DEBUG_MODE & 8) == 8)
        {
            $logfilename = $this->root_path . DATA_DIR . '/mysql_query_' . $this->dbhash . '_' . date('Y_m_d') . '.log';
            $str = $sql . "\n\n";
            if (PHP_VERSION >= '5.0')
            {
                file_put_contents($logfilename, $str, FILE_APPEND);
            }
            else
            {
                $fp = @fopen($logfilename, 'ab+');
                if ($fp)
                {
                    fwrite($fp, $str);
                    fclose($fp);
                }
            }
        }

在init.php中都已經定義了DATA_DIR常量,但是缺說沒定義,無解

/* 創建 ECSHOP 對象 */
$ecs = new ECS($db_name, $prefix);
define('DATA_DIR', $ecs->data_dir());
define('IMAGE_DIR', $ecs->image_dir());


最後在data/config中把DEBUG_MODE改成不包含8的就行了

define('DEBUG_MODE', 7);//修改調試模式

2017/7/8 深圳





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章