client.php 20 KB

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