client.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: client.php 1179 2014-11-03 07:11:25Z hypowang $
  6. */
  7. if(!defined('UC_API')) {
  8. exit('Access denied');
  9. }
  10. error_reporting(0);
  11. define('IN_UC', TRUE);
  12. define('UC_CLIENT_VERSION', '1.6.0');
  13. define('UC_CLIENT_RELEASE', '20170101');
  14. define('UC_ROOT', substr(__FILE__, 0, -10));
  15. define('UC_DATADIR', UC_ROOT.'./data/');
  16. define('UC_DATAURL', UC_API.'/data');
  17. define('UC_API_FUNC', UC_CONNECT == 'mysql' ? 'uc_api_mysql' : 'uc_api_post');
  18. $GLOBALS['uc_controls'] = array();
  19. function uc_addslashes($string, $force = 0, $strip = FALSE) {
  20. !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
  21. if(!MAGIC_QUOTES_GPC || $force) {
  22. if(is_array($string)) {
  23. foreach($string as $key => $val) {
  24. $string[$key] = uc_addslashes($val, $force, $strip);
  25. }
  26. } else {
  27. $string = addslashes($strip ? stripslashes($string) : $string);
  28. }
  29. }
  30. return $string;
  31. }
  32. if(!function_exists('daddslashes')) {
  33. function daddslashes($string, $force = 0) {
  34. return uc_addslashes($string, $force);
  35. }
  36. }
  37. if(!function_exists('dhtmlspecialchars')) {
  38. function dhtmlspecialchars($string, $flags = null) {
  39. if(is_array($string)) {
  40. foreach($string as $key => $val) {
  41. $string[$key] = dhtmlspecialchars($val, $flags);
  42. }
  43. } else {
  44. if($flags === null) {
  45. $string = str_replace(array('&', '"', '<', '>'), array('&amp;', '&quot;', '&lt;', '&gt;'), $string);
  46. if(strpos($string, '&amp;#') !== false) {
  47. $string = preg_replace('/&amp;((#(\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1', $string);
  48. }
  49. } else {
  50. if(PHP_VERSION < '5.4.0') {
  51. $string = htmlspecialchars($string, $flags);
  52. } else {
  53. if(strtolower(CHARSET) == 'utf-8') {
  54. $charset = 'UTF-8';
  55. } else {
  56. $charset = 'ISO-8859-1';
  57. }
  58. $string = htmlspecialchars($string, $flags, $charset);
  59. }
  60. }
  61. }
  62. return $string;
  63. }
  64. }
  65. if(!function_exists('fsocketopen')) {
  66. function fsocketopen($hostname, $port = 80, &$errno, &$errstr, $timeout = 15) {
  67. $fp = '';
  68. if(function_exists('fsockopen')) {
  69. $fp = @fsockopen($hostname, $port, $errno, $errstr, $timeout);
  70. } elseif(function_exists('pfsockopen')) {
  71. $fp = @pfsockopen($hostname, $port, $errno, $errstr, $timeout);
  72. } elseif(function_exists('stream_socket_client')) {
  73. $fp = @stream_socket_client($hostname.':'.$port, $errno, $errstr, $timeout);
  74. }
  75. return $fp;
  76. }
  77. }
  78. function uc_stripslashes($string) {
  79. !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
  80. if(MAGIC_QUOTES_GPC) {
  81. return stripslashes($string);
  82. } else {
  83. return $string;
  84. }
  85. }
  86. function uc_api_post($module, $action, $arg = array()) {
  87. $s = $sep = '';
  88. foreach($arg as $k => $v) {
  89. $k = urlencode($k);
  90. if(is_array($v)) {
  91. $s2 = $sep2 = '';
  92. foreach($v as $k2 => $v2) {
  93. $k2 = urlencode($k2);
  94. $s2 .= "$sep2{$k}[$k2]=".urlencode(uc_stripslashes($v2));
  95. $sep2 = '&';
  96. }
  97. $s .= $sep.$s2;
  98. } else {
  99. $s .= "$sep$k=".urlencode(uc_stripslashes($v));
  100. }
  101. $sep = '&';
  102. }
  103. $postdata = uc_api_requestdata($module, $action, $s);
  104. return uc_fopen2(UC_API.'/index.php', 500000, $postdata, '', TRUE, UC_IP, 20);
  105. }
  106. function uc_api_requestdata($module, $action, $arg='', $extra='') {
  107. $input = uc_api_input($arg);
  108. $post = "m=$module&a=$action&inajax=2&release=".UC_CLIENT_RELEASE."&input=$input&appid=".UC_APPID.$extra;
  109. return $post;
  110. }
  111. function uc_api_url($module, $action, $arg='', $extra='') {
  112. $url = UC_API.'/index.php?'.uc_api_requestdata($module, $action, $arg, $extra);
  113. return $url;
  114. }
  115. function uc_api_input($data) {
  116. $s = urlencode(uc_authcode($data.'&agent='.md5($_SERVER['HTTP_USER_AGENT'])."&time=".time(), 'ENCODE', UC_KEY));
  117. return $s;
  118. }
  119. function uc_api_mysql($model, $action, $args=array()) {
  120. global $uc_controls;
  121. if(empty($uc_controls[$model])) {
  122. if(function_exists("mysql_connect")) {
  123. include_once UC_ROOT.'./lib/db.class.php';
  124. } else {
  125. include_once UC_ROOT.'./lib/dbi.class.php';
  126. }
  127. include_once UC_ROOT.'./model/base.php';
  128. include_once UC_ROOT."./control/$model.php";
  129. eval("\$uc_controls['$model'] = new {$model}control();");
  130. }
  131. if($action{0} != '_') {
  132. $args = uc_addslashes($args, 1, TRUE);
  133. $action = 'on'.$action;
  134. $uc_controls[$model]->input = $args;
  135. return $uc_controls[$model]->$action($args);
  136. } else {
  137. return '';
  138. }
  139. }
  140. function uc_serialize($arr, $htmlon = 0) {
  141. include_once UC_ROOT.'./lib/xml.class.php';
  142. return xml_serialize($arr, $htmlon);
  143. }
  144. function uc_unserialize($s) {
  145. include_once UC_ROOT.'./lib/xml.class.php';
  146. return xml_unserialize($s);
  147. }
  148. function uc_authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
  149. $ckey_length = 4;
  150. $key = md5($key ? $key : UC_KEY);
  151. $keya = md5(substr($key, 0, 16));
  152. $keyb = md5(substr($key, 16, 16));
  153. $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
  154. $cryptkey = $keya.md5($keya.$keyc);
  155. $key_length = strlen($cryptkey);
  156. $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
  157. $string_length = strlen($string);
  158. $result = '';
  159. $box = range(0, 255);
  160. $rndkey = array();
  161. for($i = 0; $i <= 255; $i++) {
  162. $rndkey[$i] = ord($cryptkey[$i % $key_length]);
  163. }
  164. for($j = $i = 0; $i < 256; $i++) {
  165. $j = ($j + $box[$i] + $rndkey[$i]) % 256;
  166. $tmp = $box[$i];
  167. $box[$i] = $box[$j];
  168. $box[$j] = $tmp;
  169. }
  170. for($a = $j = $i = 0; $i < $string_length; $i++) {
  171. $a = ($a + 1) % 256;
  172. $j = ($j + $box[$a]) % 256;
  173. $tmp = $box[$a];
  174. $box[$a] = $box[$j];
  175. $box[$j] = $tmp;
  176. $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
  177. }
  178. if($operation == 'DECODE') {
  179. if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {
  180. return substr($result, 26);
  181. } else {
  182. return '';
  183. }
  184. } else {
  185. return $keyc.str_replace('=', '', base64_encode($result));
  186. }
  187. }
  188. function uc_fopen2($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
  189. $__times__ = isset($_GET['__times__']) ? intval($_GET['__times__']) + 1 : 1;
  190. if($__times__ > 2) {
  191. return '';
  192. }
  193. $url .= (strpos($url, '?') === FALSE ? '?' : '&')."__times__=$__times__";
  194. return uc_fopen($url, $limit, $post, $cookie, $bysocket, $ip, $timeout, $block);
  195. }
  196. function uc_fopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
  197. $return = '';
  198. $matches = parse_url($url);
  199. !isset($matches['scheme']) && $matches['scheme'] = '';
  200. !isset($matches['host']) && $matches['host'] = '';
  201. !isset($matches['path']) && $matches['path'] = '';
  202. !isset($matches['query']) && $matches['query'] = '';
  203. !isset($matches['port']) && $matches['port'] = '';
  204. $scheme = $matches['scheme'];
  205. $host = $matches['host'];
  206. $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
  207. $port = !empty($matches['port']) ? $matches['port'] : 80;
  208. if($post) {
  209. $out = "POST $path HTTP/1.0\r\n";
  210. $header = "Accept: */*\r\n";
  211. $header .= "Accept-Language: zh-cn\r\n";
  212. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  213. $header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
  214. $header .= "Host: $host\r\n";
  215. $header .= 'Content-Length: '.strlen($post)."\r\n";
  216. $header .= "Connection: Close\r\n";
  217. $header .= "Cache-Control: no-cache\r\n";
  218. $header .= "Cookie: $cookie\r\n\r\n";
  219. $out .= $header.$post;
  220. } else {
  221. $out = "GET $path HTTP/1.0\r\n";
  222. $header = "Accept: */*\r\n";
  223. $header .= "Accept-Language: zh-cn\r\n";
  224. $header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
  225. $header .= "Host: $host\r\n";
  226. $header .= "Connection: Close\r\n";
  227. $header .= "Cookie: $cookie\r\n\r\n";
  228. $out .= $header;
  229. }
  230. $fpflag = 0;
  231. if(!$fp = @fsocketopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout)) {
  232. $context = array(
  233. 'http' => array(
  234. 'method' => $post ? 'POST' : 'GET',
  235. 'header' => $header,
  236. 'content' => $post,
  237. 'timeout' => $timeout,
  238. ),
  239. );
  240. $context = stream_context_create($context);
  241. $fp = @fopen($scheme.'://'.($ip ? $ip : $host).':'.$port.$path, 'b', false, $context);
  242. $fpflag = 1;
  243. }
  244. if(!$fp) {
  245. return '';
  246. } else {
  247. stream_set_blocking($fp, $block);
  248. stream_set_timeout($fp, $timeout);
  249. @fwrite($fp, $out);
  250. $status = stream_get_meta_data($fp);
  251. if(!$status['timed_out']) {
  252. while (!feof($fp) && !$fpflag) {
  253. if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) {
  254. break;
  255. }
  256. }
  257. $stop = false;
  258. while(!feof($fp) && !$stop) {
  259. $data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit));
  260. $return .= $data;
  261. if($limit) {
  262. $limit -= strlen($data);
  263. $stop = $limit <= 0;
  264. }
  265. }
  266. }
  267. @fclose($fp);
  268. return $return;
  269. }
  270. }
  271. function uc_app_ls() {
  272. $return = call_user_func(UC_API_FUNC, 'app', 'ls', array());
  273. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  274. }
  275. function uc_feed_add($icon, $uid, $username, $title_template='', $title_data='', $body_template='', $body_data='', $body_general='', $target_ids='', $images = array()) {
  276. return call_user_func(UC_API_FUNC, 'feed', 'add',
  277. array( 'icon'=>$icon,
  278. 'appid'=>UC_APPID,
  279. 'uid'=>$uid,
  280. 'username'=>$username,
  281. 'title_template'=>$title_template,
  282. 'title_data'=>$title_data,
  283. 'body_template'=>$body_template,
  284. 'body_data'=>$body_data,
  285. 'body_general'=>$body_general,
  286. 'target_ids'=>$target_ids,
  287. 'image_1'=>$images[0]['url'],
  288. 'image_1_link'=>$images[0]['link'],
  289. 'image_2'=>$images[1]['url'],
  290. 'image_2_link'=>$images[1]['link'],
  291. 'image_3'=>$images[2]['url'],
  292. 'image_3_link'=>$images[2]['link'],
  293. 'image_4'=>$images[3]['url'],
  294. 'image_4_link'=>$images[3]['link']
  295. )
  296. );
  297. }
  298. function uc_feed_get($limit = 100, $delete = TRUE) {
  299. $return = call_user_func(UC_API_FUNC, 'feed', 'get', array('limit'=>$limit, 'delete'=>$delete));
  300. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  301. }
  302. function uc_friend_add($uid, $friendid, $comment='') {
  303. return call_user_func(UC_API_FUNC, 'friend', 'add', array('uid'=>$uid, 'friendid'=>$friendid, 'comment'=>$comment));
  304. }
  305. function uc_friend_delete($uid, $friendids) {
  306. return call_user_func(UC_API_FUNC, 'friend', 'delete', array('uid'=>$uid, 'friendids'=>$friendids));
  307. }
  308. function uc_friend_totalnum($uid, $direction = 0) {
  309. return call_user_func(UC_API_FUNC, 'friend', 'totalnum', array('uid'=>$uid, 'direction'=>$direction));
  310. }
  311. function uc_friend_ls($uid, $page = 1, $pagesize = 10, $totalnum = 10, $direction = 0) {
  312. $return = call_user_func(UC_API_FUNC, 'friend', 'ls', array('uid'=>$uid, 'page'=>$page, 'pagesize'=>$pagesize, 'totalnum'=>$totalnum, 'direction'=>$direction));
  313. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  314. }
  315. function uc_user_register($username, $password, $email, $questionid = '', $answer = '', $regip = '') {
  316. return call_user_func(UC_API_FUNC, 'user', 'register', array('username'=>$username, 'password'=>$password, 'email'=>$email, 'questionid'=>$questionid, 'answer'=>$answer, 'regip' => $regip));
  317. }
  318. function uc_user_login($username, $password, $isuid = 0, $checkques = 0, $questionid = '', $answer = '', $ip = '') {
  319. $isuid = intval($isuid);
  320. $return = call_user_func(UC_API_FUNC, 'user', 'login', array('username'=>$username, 'password'=>$password, 'isuid'=>$isuid, 'checkques'=>$checkques, 'questionid'=>$questionid, 'answer'=>$answer, 'ip' => $ip));
  321. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  322. }
  323. function uc_user_synlogin($uid) {
  324. $uid = intval($uid);
  325. if(@include UC_ROOT.'./data/cache/apps.php') {
  326. if(count($_CACHE['apps']) > 1) {
  327. $return = uc_api_post('user', 'synlogin', array('uid'=>$uid));
  328. } else {
  329. $return = '';
  330. }
  331. }
  332. return $return;
  333. }
  334. function uc_user_synlogout() {
  335. if(@include UC_ROOT.'./data/cache/apps.php') {
  336. if(count($_CACHE['apps']) > 1) {
  337. $return = uc_api_post('user', 'synlogout', array());
  338. } else {
  339. $return = '';
  340. }
  341. }
  342. return $return;
  343. }
  344. function uc_user_edit($username, $oldpw, $newpw, $email, $ignoreoldpw = 0, $questionid = '', $answer = '') {
  345. return call_user_func(UC_API_FUNC, 'user', 'edit', array('username'=>$username, 'oldpw'=>$oldpw, 'newpw'=>$newpw, 'email'=>$email, 'ignoreoldpw'=>$ignoreoldpw, 'questionid'=>$questionid, 'answer'=>$answer));
  346. }
  347. function uc_user_delete($uid) {
  348. return call_user_func(UC_API_FUNC, 'user', 'delete', array('uid'=>$uid));
  349. }
  350. function uc_user_deleteavatar($uid) {
  351. uc_api_post('user', 'deleteavatar', array('uid'=>$uid));
  352. }
  353. function uc_user_checkname($username) {
  354. return call_user_func(UC_API_FUNC, 'user', 'check_username', array('username'=>$username));
  355. }
  356. function uc_user_checkemail($email) {
  357. return call_user_func(UC_API_FUNC, 'user', 'check_email', array('email'=>$email));
  358. }
  359. function uc_user_addprotected($username, $admin='') {
  360. return call_user_func(UC_API_FUNC, 'user', 'addprotected', array('username'=>$username, 'admin'=>$admin));
  361. }
  362. function uc_user_deleteprotected($username) {
  363. return call_user_func(UC_API_FUNC, 'user', 'deleteprotected', array('username'=>$username));
  364. }
  365. function uc_user_getprotected() {
  366. $return = call_user_func(UC_API_FUNC, 'user', 'getprotected', array('1'=>1));
  367. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  368. }
  369. function uc_get_user($username, $isuid=0) {
  370. $return = call_user_func(UC_API_FUNC, 'user', 'get_user', array('username'=>$username, 'isuid'=>$isuid));
  371. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  372. }
  373. function uc_user_merge($oldusername, $newusername, $uid, $password, $email) {
  374. return call_user_func(UC_API_FUNC, 'user', 'merge', array('oldusername'=>$oldusername, 'newusername'=>$newusername, 'uid'=>$uid, 'password'=>$password, 'email'=>$email));
  375. }
  376. function uc_user_merge_remove($username) {
  377. return call_user_func(UC_API_FUNC, 'user', 'merge_remove', array('username'=>$username));
  378. }
  379. function uc_user_getcredit($appid, $uid, $credit) {
  380. return uc_api_post('user', 'getcredit', array('appid'=>$appid, 'uid'=>$uid, 'credit'=>$credit));
  381. }
  382. function uc_user_logincheck($username, $ip) {
  383. return call_user_func(UC_API_FUNC, 'user', 'logincheck', array('username' => $username, 'ip' => $ip));
  384. }
  385. function uc_pm_location($uid, $newpm = 0) {
  386. $apiurl = uc_api_url('pm_client', 'ls', "uid=$uid", ($newpm ? '&folder=newbox' : ''));
  387. @header("Expires: 0");
  388. @header("Cache-Control: private, post-check=0, pre-check=0, max-age=0", FALSE);
  389. @header("Pragma: no-cache");
  390. @header("location: $apiurl");
  391. }
  392. function uc_pm_checknew($uid, $more = 0) {
  393. $return = call_user_func(UC_API_FUNC, 'pm', 'check_newpm', array('uid'=>$uid, 'more'=>$more));
  394. return (!$more || UC_CONNECT == 'mysql') ? $return : uc_unserialize($return);
  395. }
  396. function uc_pm_send($fromuid, $msgto, $subject, $message, $instantly = 1, $replypmid = 0, $isusername = 0, $type = 0) {
  397. if($instantly) {
  398. $replypmid = @is_numeric($replypmid) ? $replypmid : 0;
  399. return call_user_func(UC_API_FUNC, 'pm', 'sendpm', array('fromuid'=>$fromuid, 'msgto'=>$msgto, 'subject'=>$subject, 'message'=>$message, 'replypmid'=>$replypmid, 'isusername'=>$isusername, 'type' => $type));
  400. } else {
  401. $fromuid = intval($fromuid);
  402. $subject = rawurlencode($subject);
  403. $msgto = rawurlencode($msgto);
  404. $message = rawurlencode($message);
  405. $replypmid = @is_numeric($replypmid) ? $replypmid : 0;
  406. $replyadd = $replypmid ? "&pmid=$replypmid&do=reply" : '';
  407. $apiurl = uc_api_url('pm_client', 'send', "uid=$fromuid", "&msgto=$msgto&subject=$subject&message=$message$replyadd");
  408. @header("Expires: 0");
  409. @header("Cache-Control: private, post-check=0, pre-check=0, max-age=0", FALSE);
  410. @header("Pragma: no-cache");
  411. @header("location: ".$apiurl);
  412. }
  413. }
  414. function uc_pm_delete($uid, $folder, $pmids) {
  415. return call_user_func(UC_API_FUNC, 'pm', 'delete', array('uid'=>$uid, 'pmids'=>$pmids));
  416. }
  417. function uc_pm_deleteuser($uid, $touids) {
  418. return call_user_func(UC_API_FUNC, 'pm', 'deleteuser', array('uid'=>$uid, 'touids'=>$touids));
  419. }
  420. function uc_pm_deletechat($uid, $plids, $type = 0) {
  421. return call_user_func(UC_API_FUNC, 'pm', 'deletechat', array('uid'=>$uid, 'plids'=>$plids, 'type'=>$type));
  422. }
  423. function uc_pm_readstatus($uid, $uids, $plids = array(), $status = 0) {
  424. return call_user_func(UC_API_FUNC, 'pm', 'readstatus', array('uid'=>$uid, 'uids'=>$uids, 'plids'=>$plids, 'status'=>$status));
  425. }
  426. function uc_pm_list($uid, $page = 1, $pagesize = 10, $folder = 'inbox', $filter = 'newpm', $msglen = 0) {
  427. $uid = intval($uid);
  428. $page = intval($page);
  429. $pagesize = intval($pagesize);
  430. $return = call_user_func(UC_API_FUNC, 'pm', 'ls', array('uid'=>$uid, 'page'=>$page, 'pagesize'=>$pagesize, 'filter'=>$filter, 'msglen'=>$msglen));
  431. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  432. }
  433. function uc_pm_ignore($uid) {
  434. $uid = intval($uid);
  435. return call_user_func(UC_API_FUNC, 'pm', 'ignore', array('uid'=>$uid));
  436. }
  437. function uc_pm_view($uid, $pmid = 0, $touid = 0, $daterange = 1, $page = 0, $pagesize = 10, $type = 0, $isplid = 0) {
  438. $uid = intval($uid);
  439. $touid = intval($touid);
  440. $page = intval($page);
  441. $pagesize = intval($pagesize);
  442. $pmid = @is_numeric($pmid) ? $pmid : 0;
  443. $return = call_user_func(UC_API_FUNC, 'pm', 'view', array('uid'=>$uid, 'pmid'=>$pmid, 'touid'=>$touid, 'daterange'=>$daterange, 'page' => $page, 'pagesize' => $pagesize, 'type'=>$type, 'isplid'=>$isplid));
  444. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  445. }
  446. function uc_pm_view_num($uid, $touid, $isplid) {
  447. $uid = intval($uid);
  448. $touid = intval($touid);
  449. $isplid = intval($isplid);
  450. return call_user_func(UC_API_FUNC, 'pm', 'viewnum', array('uid' => $uid, 'touid' => $touid, 'isplid' => $isplid));
  451. }
  452. function uc_pm_viewnode($uid, $type, $pmid) {
  453. $uid = intval($uid);
  454. $type = intval($type);
  455. $pmid = @is_numeric($pmid) ? $pmid : 0;
  456. $return = call_user_func(UC_API_FUNC, 'pm', 'viewnode', array('uid'=>$uid, 'type'=>$type, 'pmid'=>$pmid));
  457. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  458. }
  459. function uc_pm_chatpmmemberlist($uid, $plid = 0) {
  460. $uid = intval($uid);
  461. $plid = intval($plid);
  462. $return = call_user_func(UC_API_FUNC, 'pm', 'chatpmmemberlist', array('uid'=>$uid, 'plid'=>$plid));
  463. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  464. }
  465. function uc_pm_kickchatpm($plid, $uid, $touid) {
  466. $uid = intval($uid);
  467. $plid = intval($plid);
  468. $touid = intval($touid);
  469. return call_user_func(UC_API_FUNC, 'pm', 'kickchatpm', array('uid'=>$uid, 'plid'=>$plid, 'touid'=>$touid));
  470. }
  471. function uc_pm_appendchatpm($plid, $uid, $touid) {
  472. $uid = intval($uid);
  473. $plid = intval($plid);
  474. $touid = intval($touid);
  475. return call_user_func(UC_API_FUNC, 'pm', 'appendchatpm', array('uid'=>$uid, 'plid'=>$plid, 'touid'=>$touid));
  476. }
  477. function uc_pm_blackls_get($uid) {
  478. $uid = intval($uid);
  479. return call_user_func(UC_API_FUNC, 'pm', 'blackls_get', array('uid'=>$uid));
  480. }
  481. function uc_pm_blackls_set($uid, $blackls) {
  482. $uid = intval($uid);
  483. return call_user_func(UC_API_FUNC, 'pm', 'blackls_set', array('uid'=>$uid, 'blackls'=>$blackls));
  484. }
  485. function uc_pm_blackls_add($uid, $username) {
  486. $uid = intval($uid);
  487. return call_user_func(UC_API_FUNC, 'pm', 'blackls_add', array('uid'=>$uid, 'username'=>$username));
  488. }
  489. function uc_pm_blackls_delete($uid, $username) {
  490. $uid = intval($uid);
  491. return call_user_func(UC_API_FUNC, 'pm', 'blackls_delete', array('uid'=>$uid, 'username'=>$username));
  492. }
  493. function uc_domain_ls() {
  494. $return = call_user_func(UC_API_FUNC, 'domain', 'ls', array('1'=>1));
  495. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  496. }
  497. function uc_credit_exchange_request($uid, $from, $to, $toappid, $amount) {
  498. $uid = intval($uid);
  499. $from = intval($from);
  500. $toappid = intval($toappid);
  501. $to = intval($to);
  502. $amount = intval($amount);
  503. return uc_api_post('credit', 'request', array('uid'=>$uid, 'from'=>$from, 'to'=>$to, 'toappid'=>$toappid, 'amount'=>$amount));
  504. }
  505. function uc_tag_get($tagname, $nums = 0) {
  506. $return = call_user_func(UC_API_FUNC, 'tag', 'gettag', array('tagname'=>$tagname, 'nums'=>$nums));
  507. return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
  508. }
  509. function uc_avatar($uid, $type = 'virtual', $returnhtml = 1) {
  510. $uid = intval($uid);
  511. $uc_input = uc_api_input("uid=$uid");
  512. $uc_avatarflash = UC_API.'/images/camera.swf?inajax=1&appid='.UC_APPID.'&input='.$uc_input.'&agent='.md5($_SERVER['HTTP_USER_AGENT']).'&ucapi='.urlencode(str_replace('http://', '', UC_API)).'&avatartype='.$type.'&uploadSize=2048';
  513. if($returnhtml) {
  514. return '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="450" height="253" id="mycamera" align="middle">
  515. <param name="allowScriptAccess" value="always" />
  516. <param name="scale" value="exactfit" />
  517. <param name="wmode" value="transparent" />
  518. <param name="quality" value="high" />
  519. <param name="bgcolor" value="#ffffff" />
  520. <param name="movie" value="'.$uc_avatarflash.'" />
  521. <param name="menu" value="false" />
  522. <embed src="'.$uc_avatarflash.'" quality="high" bgcolor="#ffffff" width="450" height="253" name="mycamera" align="middle" allowScriptAccess="always" allowFullScreen="false" scale="exactfit" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
  523. </object>';
  524. } else {
  525. return array(
  526. 'width', '450',
  527. 'height', '253',
  528. 'scale', 'exactfit',
  529. 'src', $uc_avatarflash,
  530. 'id', 'mycamera',
  531. 'name', 'mycamera',
  532. 'quality','high',
  533. 'bgcolor','#ffffff',
  534. 'menu', 'false',
  535. 'swLiveConnect', 'true',
  536. 'allowScriptAccess', 'always'
  537. );
  538. }
  539. }
  540. function uc_mail_queue($uids, $emails, $subject, $message, $frommail = '', $charset = 'gbk', $htmlon = FALSE, $level = 1) {
  541. return call_user_func(UC_API_FUNC, 'mail', 'add', array('uids' => $uids, 'emails' => $emails, 'subject' => $subject, 'message' => $message, 'frommail' => $frommail, 'charset' => $charset, 'htmlon' => $htmlon, 'level' => $level));
  542. }
  543. function uc_check_avatar($uid, $size = 'middle', $type = 'virtual') {
  544. $url = UC_API."/avatar.php?uid=$uid&size=$size&type=$type&check_file_exists=1";
  545. $res = uc_fopen2($url, 500000, '', '', TRUE, UC_IP, 20);
  546. if($res == 1) {
  547. return 1;
  548. } else {
  549. return 0;
  550. }
  551. }
  552. function uc_check_version() {
  553. $return = uc_api_post('version', 'check', array());
  554. $data = uc_unserialize($return);
  555. return is_array($data) ? $data : $return;
  556. }
  557. ?>