广

织梦CMS教程

  • 帝国cms教程
  • 织梦CMS教程
  • PHP CMS教程
  • ECSHOP教程
  • WordPress教程
  • Discuz教程
  • CMS学习

    解决dedecms,ecshop,discuz整合后同步问题

    2018-04-02 20:46:00 次阅读 稿源:互联网
    广告

     其实发现的事1.6.0版的Ucenter对这几个CMS同步可以整合。但是同步登陆或者退出都多多少少存在问题。1.5.2版本就相对稳定的多。很少出现不同步的情况。所以如果用1.6.0版本的换回1.5.2版本吧。这是最有效的解决办法。

    1. 2.bbs-〉api-〉uc.php  
    2.  
    3. 替换为:  
    4.  
    5. <?php  
    6.  
    7.    
    8.  
    9. define('IN_DISCUZ', TRUE);  
    10.  
    11. define('UC_CLIENT_VERSION''1.5.1');  
    12. define('UC_CLIENT_RELEASE''20091001');  
    13.  
    14. define('API_DELETEUSER', 1);  
    15. define('API_RENAMEUSER', 1);  
    16. define('API_GETTAG', 1);  
    17. define('API_SYNLOGIN', 1);  
    18. define('API_SYNLOGOUT', 1);  
    19. define('API_UPDATEPW', 1);  
    20. define('API_UPDATEBADWORDS', 1);  
    21. define('API_UPDATEHOSTS', 1);  
    22. define('API_UPDATEAPPS', 1);  
    23. define('API_UPDATECLIENT', 1);  
    24. define('API_UPDATECREDIT', 1);  
    25. define('API_GETCREDITSETTINGS', 1);  
    26. define('API_GETCREDIT', 1);  
    27. define('API_UPDATECREDITSETTINGS', 1);  
    28. define('API_RETURN_SUCCEED''1');  
    29. define('API_RETURN_FAILED''-1');  
    30. define('API_RETURN_FORBIDDEN''-2');  
    31.  
    32. define('DISCUZ_ROOT'substr(diame(__FILE__), 0, -3));  
    33.  
    34. if(!defined('IN_UC')) {  
    35.  
    36. error_reporting(0);  
    37. set_magic_quotes_runtime(0);  
    38.  
    39. defined('MAGIC_QUOTES_GPC') || define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());  
    40. include_once DISCUZ_ROOT.'./config.inc.php';  
    41.  
    42. $_DCACHE = $get = $post = array();  
    43.  
    44. $code = @$_GET['code'];  
    45. parse_str(_authcode($code'DECODE', UC_KEY), $get);  
    46. if(MAGIC_QUOTES_GPC) {  
    47.    $get = _stripslashes($get);  
    48. }  
    49.  
    50. $timestamp = time();  
    51. if(empty($get)) {  
    52.    exit('Invalid Request');  
    53. elseif($timestamp - $get['time'] > 3600) {  
    54.    exit('Authracation has expiried');  
    55. }  
    56. $action = $get['action'];  
    57.  
    58. require_once DISCUZ_ROOT.'./uc_client/lib/xml.class.php';  
    59. $post = xml_unserialize(file_get_contents('php://input'));  
    60.  
    61. if(in_array($get['action'], array('test''deleteuser''renameuser''gettag''synlogin''synlogout''updatepw''updatebadwords''updatehosts''updateapps''updateclient''updatecredit''getcredit''getcreditsettings''updatecreditsettings'))) {  
    62.    require_once DISCUZ_ROOT.'./include/db_'.$database.'.class.php';  
    63.    $GLOBALS['db'] = new dbstuff;  
    64.    $GLOBALS['db']->connect($dbhost$dbuser$dbpw$dbname$pconnect, true, $dbcharset);  
    65.    $GLOBALS['tablepre'] = $tablepre;  
    66.    unset($dbhost$dbuser$dbpw$dbname$pconnect);  
    67.    $uc_note = new uc_note();  
    68.    exit($uc_note->$get['action']($get$post));  
    69. else {  
    70.    exit(API_RETURN_FAILED);  
    71. }  
    72.  
    73. else {  
    74.  
    75. /*$uc_note = new uc_note('../', '../config.inc.php');  
    76. $uc_note->deleteuser('3');*/ 
    77. define('DISCUZ_ROOT'$app['extra']['apppath']);  
    78. include DISCUZ_ROOT.'./config.inc.php';  
    79. require_once DISCUZ_ROOT.'./include/db_'.$database.'.class.php';  
    80. $GLOBALS['db'] = new dbstuff;  
    81. $GLOBALS['db']->connect($dbhost$dbuser$dbpw$dbname$pconnect, true, $dbcharset);  
    82. $GLOBALS['tablepre'] = $tablepre;  
    83. unset($dbhost$dbuser$dbpw$dbname$pconnect);  
    84. }  
    85.  
    86. class uc_note {  
    87.  
    88. var $db = '';  
    89. var $tablepre = '';  
    90. var $appdir = '';  
    91.  
    92. function _serialize($arr$htmlon = 0) {  
    93.    if(!function_exists('xml_serialize')) {  
    94.     include_once DISCUZ_ROOT.'./uc_client/lib/xml.class.php';  
    95.    }  
    96.    retu xml_serialize($arr$htmlon);  
    97. }  
    98.  
    99. function uc_note() {  
    100.    $this->appdir = DISCUZ_ROOT;  
    101.    $this->db = $GLOBALS['db'];  
    102.    $this->tablepre = $GLOBALS['tablepre'];  
    103. }  
    104.  
    105. function test($get$post) {  
    106.    retu API_RETURN_SUCCEED;  
    107. }  
    108.  
    109. function deleteuser($get$post) {  
    110.    $uids = $get['ids'];  
    111.    !API_DELETEUSER && exit(API_RETURN_FORBIDDEN);  
    112.  
    113.    $threads = array();  
    114.  
    115.    $query = $this->db->query("SELECT f.fid, t.tid FROM ".$this->tablepre."threads t LEFT JOIN ".$this->tablepre."forums f ON t.fid=f.fid WHERE t.authorid IN ($uids) ORDER BY f.fid");  
    116.    while($thread = $this->db->fetch_array($query)) {  
    117.     $threads[$thread['fid']] .= ($threads[$thread['fid']] ? ',' : '').$thread['tid'];  
    118.    }  
    119.  
    120.    if($threads) {  
    121.     require_once $this->appdir.'./forumdata/cache/cache_settings.php';  
    122.     foreach($threads as $fid => $tids) {  
    123.      $query = $this->db->query("SELECT attachment, thumb, remote FROM ".$this->tablepre."attachments WHERE tid IN ($tids)");  
    124.      while($attach = $this->db->fetch_array($query)) {  
    125.       @unlink($_DCACHE['settings']['attachdir'].'/'.$attach['attachment']);  
    126.       $attach['thumb'] && @unlink($_DCACHE['settings']['attachdir'].'/'.$attach['attachment'].'.thumb.jpg');  
    127.      }  
    128.  
    129.      foreach(array('threads''threadsmod''relatedthreads''posts''polls''polloptions''trades''activities''activityapplies''debates''debateposts''attachments''favorites''typeoptionvars''forumrecommend'as $value) {  
    130.       $this->db->query("DELETE FROM ".$this->tablepre."$value WHERE tid IN ($tids)"'UNBUFFERED');  
    131.      }  
    132.  
    133.      require_once $this->appdir.'./include/post.func.php';  
    134.      updateforumcount($fid);  
    135.     }  
    136.     if($globalstick && $stickmodify) {  
    137.      require_once $this->appdir.'./include/cache.func.php';  
    138.      updatecache('globalstick');  
    139.     }  
    140.    }  
    141.  
    142.    $query = $this->db->query("DELETE FROM ".$this->tablepre."members WHERE uid IN ($uids)");  
    143.    $this->db->query("DELETE FROM ".$this->tablepre."access WHERE uid IN ($uids)"'UNBUFFERED');  
    144.    $this->db->query("DELETE FROM ".$this->tablepre."memberfields WHERE uid IN ($uids)"'UNBUFFERED');  
    145.    $this->db->query("DELETE FROM ".$this->tablepre."favorites WHERE uid IN ($uids)"'UNBUFFERED');  
    146.    $this->db->query("DELETE FROM ".$this->tablepre."moderators WHERE uid IN ($uids)"'UNBUFFERED');  
    147.    $this->db->query("DELETE FROM ".$this->tablepre."validating WHERE uid IN ($uids)"'UNBUFFERED');  
    148.  
    149.    $query = $this->db->query("SELECT uid, attachment, thumb, remote FROM ".$this->tablepre."attachments WHERE uid IN ($uids)");  
    150.    while($attach = $this->db->fetch_array($query)) {  
    151.     @unlink($_DCACHE['settings']['attachdir'].'/'.$attach['attachment']);  
    152.     $attach['thumb'] && @unlink($_DCACHE['settings']['attachdir'].'/'.$attach['attachment'].'.thumb.jpg');  
    153.    }  
    154.    $this->db->query("DELETE FROM ".$this->tablepre."attachments WHERE uid IN ($uids)");  
    155.  
    156.    $this->db->query("DELETE FROM ".$this->tablepre."posts WHERE authorid IN ($uids)");  
    157.    $this->db->query("DELETE FROM ".$this->tablepre."trades WHERE sellerid IN ($uids)");  
    158.  
    159.    retu API_RETURN_SUCCEED;  
    160. }  
    161.  
    162. function renameuser($get$post) {  
    163.    $uid = $get['uid'];  
    164.    $useameold = $get['olduseame'];  
    165.    $useamenew = $get['newuseame'];  
    166.    if(!API_RENAMEUSER) {  
    167.     retu API_RETURN_FORBIDDEN;  
    168.    }  
    169.  
    170.    $this->db->query("UPDATE ".$this->tablepre."announcements SET author='$useamenew' WHERE author='$useameold'");  
    171.    $this->db->query("UPDATE ".$this->tablepre."banned SET admin='$useamenew' WHERE admin='$useameold'");  
    172.    $this->db->query("UPDATE ".$this->tablepre."forums SET lastpost=REPLACE(lastpost, 't$useameold', 't$useamenew')");  
    173.    $this->db->query("UPDATE ".$this->tablepre."members SET useame='$useamenew' WHERE uid='$uid'");  
    174.    $this->db->query("UPDATE ".$this->tablepre."posts SET author='$useamenew' WHERE authorid='$uid'");  
    175.    $this->db->query("UPDATE ".$this->tablepre."threads SET author='$useamenew' WHERE authorid='$uid'");  
    176.    $this->db->query("UPDATE ".$this->tablepre."threads SET lastposter='$useamenew' WHERE lastposter='$useameold'");  
    177.    $this->db->query("UPDATE ".$this->tablepre."threadsmod SET useame='$useamenew' WHERE uid='$uid'");  
    178.    retu API_RETURN_SUCCEED;  
    179. }  
    180.  
    181. function gettag($get$post) {  
    182.    $name = $get['id'];  
    183.    if(!API_GETTAG) {  
    184.     retu API_RETURN_FORBIDDEN;  
    185.    }  
    186.  
    187.    $name = trim($name);  
    188.    if(empty($name) || !preg_match('/^([x7f-xff_-]|w|s)+$/'$name) || strlen($name) > 20) {  
    189.     retu API_RETURN_FAILED;  
    190.    }  
    191.  
    192.    require_once $this->appdir.'./include/misc.func.php';  
    193.  
    194.    $tag = $this->db->fetch_first("SELECT * FROM ".$this->tablepre."tags WHERE tagname='$name'");  
    195.    if($tag['closed']) {  
    196.     retu API_RETURN_FAILED;  
    197.    }  
    198.  
    199.    $tpp = 10;  
    200.    $PHP_SELF = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];  
    201.    $boardurl = 'http://'.$_SERVER['HTTP_HOST'].preg_replace("//+(api)?/*$/i"''substr($PHP_SELF, 0, strrpos($PHP_SELF'/'))).'/';  
    202.    $query = $this->db->query("SELECT t.* FROM ".$this->tablepre."threadtags tt LEFT JOIN ".$this->tablepre."threads t ON t.tid=tt.tid AND t.displayorder>='0' WHERE tt.tagname='$name' ORDER BY tt.tid DESC LIMIT $tpp");  
    203.    $threadlist = array();  
    204.    while($tagthread = $this->db->fetch_array($query)) {  
    205.     if($tagthread['tid']) {  
    206.      $threadlist[] = array(  
    207.       'subject' => $tagthread['subject'],  
    208.       'uid' => $tagthread['authorid'],  
    209.       'useame' => $tagthread['author'],  
    210.       'dateline' => $tagthread['dateline'],  
    211.       'url' => $boardurl.'viewthread.php?tid='.$tagthread['tid'],  
    212.      );  
    213.     }  
    214.    }  
    215.  
    216.    $retu = array($name$threadlist);  
    217.    retu $this->_serialize($retu, 1);  
    218. }  
    219.  
    220. function synlogin($get$post) {  
    221.    $uid = $get['uid'];  
    222.    $useame = $get['useame'];    
    223.    if(!API_SYNLOGIN) {  
    224.     retu API_RETURN_FORBIDDEN;  
    225.    } 

     

    一起学吧部分文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与一起学吧进行文章共享合作。

    广告
    广告
    广告