Repository navigation
Expand file tree
/
Copy pathclient.php
More file actions
659 lines (569 loc) · 23.7 KB
/
Copy pathclient.php
File metadata and controls
659 lines (569 loc) · 23.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: client.php 1079 2011-04-02 07:29:36Z zhengqingpeng $
*/
if(!defined('UC_API')) {
exit('Access denied');
}
error_reporting(0);
define('IN_UC', TRUE);
define('UC_CLIENT_VERSION', '1.6.0');
define('UC_CLIENT_RELEASE', '20110501');
define('UC_ROOT', substr(__FILE__, 0, -10));
define('UC_DATADIR', UC_ROOT.'./data/');
define('UC_DATAURL', UC_API.'/data');
define('UC_API_FUNC', UC_CONNECT == 'mysql' ? 'uc_api_mysql' : 'uc_api_post');
$GLOBALS['uc_controls'] = array();
function uc_addslashes($string, $force = 0, $strip = FALSE) {
!defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
if(!MAGIC_QUOTES_GPC || $force) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = uc_addslashes($val, $force, $strip);
}
} else {
$string = addslashes($strip ? stripslashes($string) : $string);
}
}
return $string;
}
if(!function_exists('daddslashes')) {
function daddslashes($string, $force = 0) {
return uc_addslashes($string, $force);
}
}
function uc_stripslashes($string) {
!defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
if(MAGIC_QUOTES_GPC) {
return stripslashes($string);
} else {
return $string;
}
}
function uc_api_post($module, $action, $arg = array()) {
$s = $sep = '';
foreach($arg as $k => $v) {
$k = urlencode($k);
if(is_array($v)) {
$s2 = $sep2 = '';
foreach($v as $k2 => $v2) {
$k2 = urlencode($k2);
$s2 .= "$sep2{$k}[$k2]=".urlencode(uc_stripslashes($v2));
$sep2 = '&';
}
$s .= $sep.$s2;
} else {
$s .= "$sep$k=".urlencode(uc_stripslashes($v));
}
$sep = '&';
}
$postdata = uc_api_requestdata($module, $action, $s);
return uc_fopen2(UC_API.'/index.php', 500000, $postdata, '', TRUE, UC_IP, 20);
}
function uc_api_requestdata($module, $action, $arg='', $extra='') {
$input = uc_api_input($arg);
$post = "m=$module&a=$action&inajax=2&release=".UC_CLIENT_RELEASE."&input=$input&appid=".UC_APPID.$extra;
return $post;
}
function uc_api_url($module, $action, $arg='', $extra='') {
$url = UC_API.'/index.php?'.uc_api_requestdata($module, $action, $arg, $extra);
return $url;
}
function uc_api_input($data) {
$s = urlencode(uc_authcode($data.'&agent='.md5($_SERVER['HTTP_USER_AGENT'])."&time=".time(), 'ENCODE', UC_KEY));
return $s;
}
function uc_api_mysql($model, $action, $args=array()) {
global $uc_controls;
if(empty($uc_controls[$model])) {
include_once UC_ROOT.'./lib/db.class.php';
include_once UC_ROOT.'./model/base.php';
include_once UC_ROOT."./control/$model.php";
eval("\$uc_controls['$model'] = new {$model}control();");
}
if($action{0} != '_') {
$args = uc_addslashes($args, 1, TRUE);
$action = 'on'.$action;
$uc_controls[$model]->input = $args;
return $uc_controls[$model]->$action($args);
} else {
return '';
}
}
function uc_serialize($arr, $htmlon = 0) {
include_once UC_ROOT.'./lib/xml.class.php';
return xml_serialize($arr, $htmlon);
}
function uc_unserialize($s) {
include_once UC_ROOT.'./lib/xml.class.php';
return xml_unserialize($s);
}
function uc_authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
$ckey_length = 4;
$key = md5($key ? $key : UC_KEY);
$keya = md5(substr($key, 0, 16));
$keyb = md5(substr($key, 16, 16));
$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
$cryptkey = $keya.md5($keya.$keyc);
$key_length = strlen($cryptkey);
$string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
$string_length = strlen($string);
$result = '';
$box = range(0, 255);
$rndkey = array();
for($i = 0; $i <= 255; $i++) {
$rndkey[$i] = ord($cryptkey[$i % $key_length]);
}
for($j = $i = 0; $i < 256; $i++) {
$j = ($j + $box[$i] + $rndkey[$i]) % 256;
$tmp = $box[$i];
$box[$i] = $box[$j];
$box[$j] = $tmp;
}
for($a = $j = $i = 0; $i < $string_length; $i++) {
$a = ($a + 1) % 256;
$j = ($j + $box[$a]) % 256;
$tmp = $box[$a];
$box[$a] = $box[$j];
$box[$j] = $tmp;
$result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
}
if($operation == 'DECODE') {
if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {
return substr($result, 26);
} else {
return '';
}
} else {
return $keyc.str_replace('=', '', base64_encode($result));
}
}
function uc_fopen2($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
$__times__ = isset($_GET['__times__']) ? intval($_GET['__times__']) + 1 : 1;
if($__times__ > 2) {
return '';
}
$url .= (strpos($url, '?') === FALSE ? '?' : '&')."__times__=$__times__";
return uc_fopen($url, $limit, $post, $cookie, $bysocket, $ip, $timeout, $block);
}
function uc_fopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) {
$return = '';
$matches = parse_url($url);
!isset($matches['host']) && $matches['host'] = '';
!isset($matches['path']) && $matches['path'] = '';
!isset($matches['query']) && $matches['query'] = '';
!isset($matches['port']) && $matches['port'] = '';
$host = $matches['host'];
$path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/';
$port = !empty($matches['port']) ? $matches['port'] : 80;
if($post) {
$out = "POST $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
//$out .= "Referer: $boardurl\r\n";
$out .= "Accept-Language: zh-cn\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out .= "Host: $host\r\n";
$out .= 'Content-Length: '.strlen($post)."\r\n";
$out .= "Connection: Close\r\n";
$out .= "Cache-Control: no-cache\r\n";
$out .= "Cookie: $cookie\r\n\r\n";
$out .= $post;
} else {
$out = "GET $path HTTP/1.0\r\n";
$out .= "Accept: */*\r\n";
//$out .= "Referer: $boardurl\r\n";
$out .= "Accept-Language: zh-cn\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n";
$out .= "Cookie: $cookie\r\n\r\n";
}
if(function_exists('fsockopen')) {
$fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);
} elseif (function_exists('pfsockopen')) {
$fp = @pfsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);
} else {
$fp = false;
}
if(!$fp) {
return '';
} else {
stream_set_blocking($fp, $block);
stream_set_timeout($fp, $timeout);
@fwrite($fp, $out);
$status = stream_get_meta_data($fp);
if(!$status['timed_out']) {
while (!feof($fp)) {
if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) {
break;
}
}
$stop = false;
while(!feof($fp) && !$stop) {
$data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit));
$return .= $data;
if($limit) {
$limit -= strlen($data);
$stop = $limit <= 0;
}
}
}
@fclose($fp);
return $return;
}
}
function uc_app_ls() {
$return = call_user_func(UC_API_FUNC, 'app', 'ls', array());
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_feed_add($icon, $uid, $username, $title_template='', $title_data='', $body_template='', $body_data='', $body_general='', $target_ids='', $images = array()) {
return call_user_func(UC_API_FUNC, 'feed', 'add',
array( 'icon'=>$icon,
'appid'=>UC_APPID,
'uid'=>$uid,
'username'=>$username,
'title_template'=>$title_template,
'title_data'=>$title_data,
'body_template'=>$body_template,
'body_data'=>$body_data,
'body_general'=>$body_general,
'target_ids'=>$target_ids,
'image_1'=>$images[0]['url'],
'image_1_link'=>$images[0]['link'],
'image_2'=>$images[1]['url'],
'image_2_link'=>$images[1]['link'],
'image_3'=>$images[2]['url'],
'image_3_link'=>$images[2]['link'],
'image_4'=>$images[3]['url'],
'image_4_link'=>$images[3]['link']
)
);
}
function uc_feed_get($limit = 100, $delete = TRUE) {
$return = call_user_func(UC_API_FUNC, 'feed', 'get', array('limit'=>$limit, 'delete'=>$delete));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_friend_add($uid, $friendid, $comment='') {
return call_user_func(UC_API_FUNC, 'friend', 'add', array('uid'=>$uid, 'friendid'=>$friendid, 'comment'=>$comment));
}
function uc_friend_delete($uid, $friendids) {
return call_user_func(UC_API_FUNC, 'friend', 'delete', array('uid'=>$uid, 'friendids'=>$friendids));
}
function uc_friend_totalnum($uid, $direction = 0) {
return call_user_func(UC_API_FUNC, 'friend', 'totalnum', array('uid'=>$uid, 'direction'=>$direction));
}
function uc_friend_ls($uid, $page = 1, $pagesize = 10, $totalnum = 10, $direction = 0) {
$return = call_user_func(UC_API_FUNC, 'friend', 'ls', array('uid'=>$uid, 'page'=>$page, 'pagesize'=>$pagesize, 'totalnum'=>$totalnum, 'direction'=>$direction));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_user_register($username, $password, $email, $questionid = '', $answer = '', $regip = '') {
return call_user_func(UC_API_FUNC, 'user', 'register', array('username'=>$username, 'password'=>$password, 'email'=>$email, 'questionid'=>$questionid, 'answer'=>$answer, 'regip' => $regip));
}
function uc_user_login($username, $password, $isuid = 0, $checkques = 0, $questionid = '', $answer = '') {
$isuid = intval($isuid);
$return = call_user_func(UC_API_FUNC, 'user', 'login', array('username'=>$username, 'password'=>$password, 'isuid'=>$isuid, 'checkques'=>$checkques, 'questionid'=>$questionid, 'answer'=>$answer));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_user_synlogin($uid) {
$uid = intval($uid);
if(@include UC_ROOT.'./data/cache/apps.php') {
if(count($_CACHE['apps']) > 1) {
$return = uc_api_post('user', 'synlogin', array('uid'=>$uid));
} else {
$return = '';
}
}
return $return;
}
function uc_user_synlogout() {
if(@include UC_ROOT.'./data/cache/apps.php') {
if(count($_CACHE['apps']) > 1) {
$return = uc_api_post('user', 'synlogout', array());
} else {
$return = '';
}
}
return $return;
}
function uc_user_edit($username, $oldpw, $newpw, $email, $ignoreoldpw = 0, $questionid = '', $answer = '') {
return call_user_func(UC_API_FUNC, 'user', 'edit', array('username'=>$username, 'oldpw'=>$oldpw, 'newpw'=>$newpw, 'email'=>$email, 'ignoreoldpw'=>$ignoreoldpw, 'questionid'=>$questionid, 'answer'=>$answer));
}
function uc_user_delete($uid) {
return call_user_func(UC_API_FUNC, 'user', 'delete', array('uid'=>$uid));
}
function uc_user_deleteavatar($uid) {
uc_api_post('user', 'deleteavatar', array('uid'=>$uid));
}
function uc_user_checkname($username) {
return call_user_func(UC_API_FUNC, 'user', 'check_username', array('username'=>$username));
}
function uc_user_checkemail($email) {
return call_user_func(UC_API_FUNC, 'user', 'check_email', array('email'=>$email));
}
function uc_user_addprotected($username, $admin='') {
return call_user_func(UC_API_FUNC, 'user', 'addprotected', array('username'=>$username, 'admin'=>$admin));
}
function uc_user_deleteprotected($username) {
return call_user_func(UC_API_FUNC, 'user', 'deleteprotected', array('username'=>$username));
}
function uc_user_getprotected() {
$return = call_user_func(UC_API_FUNC, 'user', 'getprotected', array('1'=>1));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_get_user($username, $isuid=0) {
$return = call_user_func(UC_API_FUNC, 'user', 'get_user', array('username'=>$username, 'isuid'=>$isuid));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_user_merge($oldusername, $newusername, $uid, $password, $email) {
return call_user_func(UC_API_FUNC, 'user', 'merge', array('oldusername'=>$oldusername, 'newusername'=>$newusername, 'uid'=>$uid, 'password'=>$password, 'email'=>$email));
}
function uc_user_merge_remove($username) {
return call_user_func(UC_API_FUNC, 'user', 'merge_remove', array('username'=>$username));
}
function uc_user_getcredit($appid, $uid, $credit) {
return uc_api_post('user', 'getcredit', array('appid'=>$appid, 'uid'=>$uid, 'credit'=>$credit));
}
function uc_pm_location($uid, $newpm = 0) {
$apiurl = uc_api_url('pm_client', 'ls', "uid=$uid", ($newpm ? '&folder=newbox' : ''));
@header("Expires: 0");
@header("Cache-Control: private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
@header("location: $apiurl");
}
function uc_pm_checknew($uid, $more = 0) {
$return = call_user_func(UC_API_FUNC, 'pm', 'check_newpm', array('uid'=>$uid, 'more'=>$more));
return (!$more || UC_CONNECT == 'mysql') ? $return : uc_unserialize($return);
}
function uc_pm_send($fromuid, $msgto, $subject, $message, $instantly = 1, $replypmid = 0, $isusername = 0, $type = 0) {
if($instantly) {
$replypmid = @is_numeric($replypmid) ? $replypmid : 0;
return call_user_func(UC_API_FUNC, 'pm', 'sendpm', array('fromuid'=>$fromuid, 'msgto'=>$msgto, 'subject'=>$subject, 'message'=>$message, 'replypmid'=>$replypmid, 'isusername'=>$isusername, 'type' => $type));
} else {
$fromuid = intval($fromuid);
$subject = rawurlencode($subject);
$msgto = rawurlencode($msgto);
$message = rawurlencode($message);
$replypmid = @is_numeric($replypmid) ? $replypmid : 0;
$replyadd = $replypmid ? "&pmid=$replypmid&do=reply" : '';
$apiurl = uc_api_url('pm_client', 'send', "uid=$fromuid", "&msgto=$msgto&subject=$subject&message=$message$replyadd");
@header("Expires: 0");
@header("Cache-Control: private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
@header("location: ".$apiurl);
}
}
function uc_pm_delete($uid, $folder, $pmids) {
return call_user_func(UC_API_FUNC, 'pm', 'delete', array('uid'=>$uid, 'pmids'=>$pmids));
}
function uc_pm_deleteuser($uid, $touids) {
return call_user_func(UC_API_FUNC, 'pm', 'deleteuser', array('uid'=>$uid, 'touids'=>$touids));
}
function uc_pm_deletechat($uid, $plids, $type = 0) {
return call_user_func(UC_API_FUNC, 'pm', 'deletechat', array('uid'=>$uid, 'plids'=>$plids, 'type'=>$type));
}
function uc_pm_readstatus($uid, $uids, $plids = array(), $status = 0) {
return call_user_func(UC_API_FUNC, 'pm', 'readstatus', array('uid'=>$uid, 'uids'=>$uids, 'plids'=>$plids, 'status'=>$status));
}
function uc_pm_list($uid, $page = 1, $pagesize = 10, $folder = 'inbox', $filter = 'newpm', $msglen = 0) {
$uid = intval($uid);
$page = intval($page);
$pagesize = intval($pagesize);
$return = call_user_func(UC_API_FUNC, 'pm', 'ls', array('uid'=>$uid, 'page'=>$page, 'pagesize'=>$pagesize, 'filter'=>$filter, 'msglen'=>$msglen));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_pm_ignore($uid) {
$uid = intval($uid);
return call_user_func(UC_API_FUNC, 'pm', 'ignore', array('uid'=>$uid));
}
function uc_pm_view($uid, $pmid = 0, $touid = 0, $daterange = 1, $page = 0, $pagesize = 10, $type = 0, $isplid = 0) {
$uid = intval($uid);
$touid = intval($touid);
$page = intval($page);
$pagesize = intval($pagesize);
$pmid = @is_numeric($pmid) ? $pmid : 0;
$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));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_pm_view_num($uid, $touid, $isplid) {
$uid = intval($uid);
$touid = intval($touid);
$isplid = intval($isplid);
return call_user_func(UC_API_FUNC, 'pm', 'viewnum', array('uid' => $uid, 'touid' => $touid, 'isplid' => $isplid));
}
function uc_pm_viewnode($uid, $type, $pmid) {
$uid = intval($uid);
$type = intval($type);
$pmid = @is_numeric($pmid) ? $pmid : 0;
$return = call_user_func(UC_API_FUNC, 'pm', 'viewnode', array('uid'=>$uid, 'type'=>$type, 'pmid'=>$pmid));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_pm_chatpmmemberlist($uid, $plid = 0) {
$uid = intval($uid);
$plid = intval($plid);
$return = call_user_func(UC_API_FUNC, 'pm', 'chatpmmemberlist', array('uid'=>$uid, 'plid'=>$plid));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_pm_kickchatpm($plid, $uid, $touid) {
$uid = intval($uid);
$plid = intval($plid);
$touid = intval($touid);
return call_user_func(UC_API_FUNC, 'pm', 'kickchatpm', array('uid'=>$uid, 'plid'=>$plid, 'touid'=>$touid));
}
function uc_pm_appendchatpm($plid, $uid, $touid) {
$uid = intval($uid);
$plid = intval($plid);
$touid = intval($touid);
return call_user_func(UC_API_FUNC, 'pm', 'appendchatpm', array('uid'=>$uid, 'plid'=>$plid, 'touid'=>$touid));
}
function uc_pm_blackls_get($uid) {
$uid = intval($uid);
return call_user_func(UC_API_FUNC, 'pm', 'blackls_get', array('uid'=>$uid));
}
function uc_pm_blackls_set($uid, $blackls) {
$uid = intval($uid);
return call_user_func(UC_API_FUNC, 'pm', 'blackls_set', array('uid'=>$uid, 'blackls'=>$blackls));
}
function uc_pm_blackls_add($uid, $username) {
$uid = intval($uid);
return call_user_func(UC_API_FUNC, 'pm', 'blackls_add', array('uid'=>$uid, 'username'=>$username));
}
function uc_pm_blackls_delete($uid, $username) {
$uid = intval($uid);
return call_user_func(UC_API_FUNC, 'pm', 'blackls_delete', array('uid'=>$uid, 'username'=>$username));
}
function uc_domain_ls() {
$return = call_user_func(UC_API_FUNC, 'domain', 'ls', array('1'=>1));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_credit_exchange_request($uid, $from, $to, $toappid, $amount) {
$uid = intval($uid);
$from = intval($from);
$toappid = intval($toappid);
$to = intval($to);
$amount = intval($amount);
return uc_api_post('credit', 'request', array('uid'=>$uid, 'from'=>$from, 'to'=>$to, 'toappid'=>$toappid, 'amount'=>$amount));
}
function uc_tag_get($tagname, $nums = 0) {
$return = call_user_func(UC_API_FUNC, 'tag', 'gettag', array('tagname'=>$tagname, 'nums'=>$nums));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
function uc_avatar($uid, $type = 'virtual', $returnhtml = 1) {
$uid = intval($uid);
$uc_input = uc_api_input("uid=$uid");
$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';
if($returnhtml) {
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">
<param name="allowScriptAccess" value="always" />
<param name="scale" value="exactfit" />
<param name="wmode" value="transparent" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="movie" value="'.$uc_avatarflash.'" />
<param name="menu" value="false" />
<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" />
</object>';
} else {
return array(
'width', '450',
'height', '253',
'scale', 'exactfit',
'src', $uc_avatarflash,
'id', 'mycamera',
'name', 'mycamera',
'quality','high',
'bgcolor','#ffffff',
'menu', 'false',
'swLiveConnect', 'true',
'allowScriptAccess', 'always'
);
}
}
function uc_mail_queue($uids, $emails, $subject, $message, $frommail = '', $charset = 'gbk', $htmlon = FALSE, $level = 1) {
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));
}
function uc_check_avatar($uid, $size = 'middle', $type = 'virtual') {
$url = UC_API."/avatar.php?uid=$uid&size=$size&type=$type&check_file_exists=1";
$res = uc_fopen2($url, 500000, '', '', TRUE, UC_IP, 20);
if($res == 1) {
return 1;
} else {
return 0;
}
}
function uc_check_version() {
$return = uc_api_post('version', 'check', array());
$data = uc_unserialize($return);
return is_array($data) ? $data : $return;
}
/**
*
*/
function uc_get_object($username, $isuid = 0, $type = null) {
$data = uc_get_user($username, $isuid);
if ($data <= 0) {
return $data;
}
$return = call_user_func(UC_API_FUNC, 'object', 'get', array('isuid' => intval($isuid), 'username' => $username, 'type' => $type));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
}
/**
*
*/
function uc_object_set($username, $isuid = 0, $filed = null, $value = null) {
$data = uc_get_user($username, $isuid);
if ($data <= 0) {
return $data;
}
if ($filed == null) {
return false;
}
$return = call_user_func('uc_api_post', 'object', 'set', array('isuid' => intval($isuid), 'username' => $username, 'filed' => $filed, 'value' => $value));
return $return;
}
/**
* 返回-11分数不足
*/
function uc_object_addint($username, $isuid = 0, $filed = null, $value = null) {
$data = uc_get_user($username, $isuid);
if ($data <= 0) {
return $data;
}
if (!in_array($filed, array('credit'))) {
$return = false;
} else {
$return = call_user_func('uc_api_post', 'object', 'add', array('isuid' => intval($isuid), 'username' => $username, 'filed' => $filed, 'value' => $value));
}
return $return;
}
/*
*
*
* 这里面的三个函数主要功能是
uc_get_object是返回用户的扩展资料。第三个参数如果指定为扩展资料的某一项时则返回数组(用户ID,用户名,指定扩展项)否则返回数组(用户ID,用户名, 数据库中的所有扩展项)。
uc_object_set(),uc_object_addint(),这两个函数是设置,增减用户扩展资料功能。其中 uc_object_addint是专门针对int型扩展字段。如果这些扩展资料在应用中的数据库里也有那么这些字段在设置和更新时要进行同步,而只要将返回的字符输出到页面就可以了。如
echo uc_object_set(1,1,'credit',1);
echo uc_object_set(1,1,'addr','北京市');
复制代码
上面将同步各个应用中的积分,当然还是要修改每一个应用下面的api/uc.php。改法附后。
设置多个字段目前无法同步 因此echo uc_object_set(1,1,array('credit'=>1,'addr'=>'北京市'));是没有效果的。但是ucenter中会更新资料,应用程序可以找一个合适的时机自行同步。
uc_object_addint()中的$filed不能为数组,$value为增加的值,如果为负就会减少减少用户的指定扩展int型数据。
uc_object_addint(1,1,'credit',1);增加用户1分。
uc_object_addint(1,1,'credit',-5);扣除5分。
同样增加如果应用中有相应的字段那么也要进行同步。同步方法是echo ,同uc_object_set。
uc_object_addint中的if(!in_array($filed,array('credit'))){里面可以增加更多int类型的字段以便扩展你的功能,请根据需要进行增加。
对于同步用户扩展的功能和从uc中取用户资料是差别同步是要同应用的api/uc.php进行通讯,而且uc_client是不知道其它应用的authkey但是ucenter知道,所以同步只能使用ucenter是知道所有的应用authkey。看下面是两种区别。
要求同步的必须使用远程ucenter中的方法
$return= call_user_func('uc_api_post', 'object', 'add', array('isuid'=>intval($isuid), 'username'=>$username,'filed'=>$filed,'value'=>$value));
return $return;
复制代码
只取用户资料
一般语句如下
$return= call_user_func(UC_API_FUNC, 'object', 'get', array('isuid'=>intval($isuid), 'username'=>$username,'type'=>$type));
return UC_CONNECT == 'mysql' ? $return : uc_unserialize($return);
复制代码
注意call_user_func中的第一个参数。
*/
?>