人人商城

uc.php 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. error_reporting(0);
  7. define('UC_CLIENT_VERSION', '1.6.0');
  8. define('UC_CLIENT_RELEASE', '20110501');
  9. define('API_DELETEUSER', 1);
  10. define('API_RENAMEUSER', 1);
  11. define('API_GETTAG', 1);
  12. define('API_SYNLOGIN', 1);
  13. define('API_SYNLOGOUT', 1);
  14. define('API_UPDATEPW', 1);
  15. define('API_UPDATEBADWORDS', 1);
  16. define('API_UPDATEHOSTS', 1);
  17. define('API_UPDATEAPPS', 1);
  18. define('API_UPDATECLIENT', 1);
  19. define('API_UPDATECREDIT', 1);
  20. define('API_GETCREDIT', 1);
  21. define('API_GETCREDITSETTINGS', 1);
  22. define('API_UPDATECREDITSETTINGS', 1);
  23. define('API_ADDFEED', 1);
  24. define('API_RETURN_SUCCEED', '1');
  25. define('API_RETURN_FAILED', '-1');
  26. define('API_RETURN_FORBIDDEN', '1');
  27. define('IN_SYS', true);
  28. require '../framework/bootstrap.inc.php';
  29. $query = $_GET;
  30. if(is_array($query)) {
  31. $sql = "SELECT `uc` FROM " . tablename('uni_settings') . " WHERE `uniacid`=:uniacid LIMIT 1";
  32. $setting = pdo_fetch($sql, array(':uniacid' => $query['uniacid']));
  33. if(!empty($setting) && !empty($setting['uc'])) {
  34. $uc = iunserializer($setting['uc']);
  35. if(!empty($uc) && $uc['status'] == '1') {
  36. define('UC_CONNECT', $uc['connect'] == 'mysql' ? 'mysql' : '');
  37. define('UC_DBHOST', $uc['dbhost']);
  38. define('UC_DBUSER', $uc['dbuser']);
  39. define('UC_DBPW', $uc['dbpw']);
  40. define('UC_DBNAME', $uc['dbname']);
  41. define('UC_DBCHARSET', $uc['dbcharset']);
  42. define('UC_DBTABLEPRE', $uc['dbtablepre']);
  43. define('UC_DBCONNECT', $uc['dbconnect']);
  44. define('UC_CHARSET', $uc['charset']);
  45. define('UC_KEY', $uc['key']);
  46. define('UC_API', $uc['api']);
  47. define('UC_APPID', $uc['appid']);
  48. define('UC_IP', $uc['ip']);
  49. $get = $post = array();
  50. parse_str(authcode($query['code'], 'DECODE', UC_KEY), $get);
  51. if(TIMESTAMP - $get['time'] > 3600) {
  52. exit('Authracation has expiried');
  53. }
  54. if(empty($get)) {
  55. exit('Invalid Request');
  56. }
  57. include_once IA_ROOT . '/framework/library/uc/lib/xml.class.php';
  58. $input = file_get_contents('php://input');
  59. $post = xml_unserialize($input);
  60. if(in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcredit', 'getcreditsettings', 'updatecreditsettings', 'addfeed'))) {
  61. $note = new uc_note();
  62. echo $note->$get['action']($get, $post);
  63. exit();
  64. } else {
  65. exit(API_RETURN_FAILED);
  66. }
  67. }
  68. }
  69. }
  70. class uc_note {
  71. function _serialize($arr, $htmlon = 0) {
  72. return xml_serialize($arr, $htmlon);
  73. }
  74. function test($get, $post) {
  75. return API_RETURN_SUCCEED;
  76. }
  77. function deleteuser($get, $post) {
  78. if(!API_DELETEUSER) {
  79. return API_RETURN_FORBIDDEN;
  80. }
  81. return API_RETURN_SUCCEED;
  82. }
  83. function renameuser($get, $post) {
  84. if(!API_RENAMEUSER) {
  85. return API_RETURN_FORBIDDEN;
  86. }
  87. return API_RETURN_SUCCEED;
  88. }
  89. function gettag($get, $post) {
  90. if(!API_GETTAG) {
  91. return API_RETURN_FORBIDDEN;
  92. }
  93. return $this->_serialize(array($get['id'], array()), 1);
  94. }
  95. function synlogin($get, $post) {
  96. if(!API_SYNLOGIN) {
  97. return API_RETURN_FORBIDDEN;
  98. }
  99. header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
  100. $cookietime = 31536000;
  101. $uid = intval($get['uid']);
  102. if(($member = getuserbyuid($uid, 1))) {
  103. dsetcookie('auth', authcode("$member[password]\t$member[uid]", 'ENCODE'), $cookietime);
  104. }
  105. }
  106. function synlogout($get, $post) {
  107. if(!API_SYNLOGOUT) {
  108. return API_RETURN_FORBIDDEN;
  109. }
  110. header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
  111. dsetcookie('auth', '', -31536000);
  112. }
  113. function updatepw($get, $post) {
  114. if(!API_UPDATEPW) {
  115. return API_RETURN_FORBIDDEN;
  116. }
  117. return API_RETURN_SUCCEED;
  118. }
  119. function updatebadwords($get, $post) {
  120. if(!API_UPDATEBADWORDS) {
  121. return API_RETURN_FORBIDDEN;
  122. }
  123. return API_RETURN_SUCCEED;
  124. }
  125. function updatehosts($get, $post) {
  126. if(!API_UPDATEHOSTS) {
  127. return API_RETURN_FORBIDDEN;
  128. }
  129. return API_RETURN_SUCCEED;
  130. }
  131. function updateapps($get, $post) {
  132. if(!API_UPDATEAPPS) {
  133. return API_RETURN_FORBIDDEN;
  134. }
  135. return API_RETURN_SUCCEED;
  136. }
  137. function updateclient($get, $post) {
  138. if(!API_UPDATECLIENT) {
  139. return API_RETURN_FORBIDDEN;
  140. }
  141. return API_RETURN_SUCCEED;
  142. }
  143. function updatecredit($get, $post) {
  144. if(!API_UPDATECREDIT) {
  145. return API_RETURN_FORBIDDEN;
  146. }
  147. return API_RETURN_SUCCEED;
  148. }
  149. function getcredit($get, $post) {
  150. if(!API_GETCREDIT) {
  151. return API_RETURN_FORBIDDEN;
  152. }
  153. }
  154. function getcreditsettings($get, $post) {
  155. if(!API_GETCREDITSETTINGS) {
  156. return API_RETURN_FORBIDDEN;
  157. }
  158. }
  159. function updatecreditsettings($get, $post) {
  160. if(!API_UPDATECREDITSETTINGS) {
  161. return API_RETURN_FORBIDDEN;
  162. }
  163. return API_RETURN_SUCCEED;
  164. }
  165. function addfeed($get, $post) {
  166. if(!API_ADDFEED) {
  167. return API_RETURN_FORBIDDEN;
  168. }
  169. return API_RETURN_SUCCEED;
  170. }
  171. }