/
user.php
1402 lines (1401 loc) · 62.1 KB
/
user.php
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
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* SKYUC! 会员中心
* ============================================================================
* 版权所有 (C) 2012 天空网络,并保留所有权利。
* 网站地址: http://www.skyuc.com
* ----------------------------------------------------------------------------
* This is NOT a freeware, use is subject to license terms
* ============================================================================
*/
// ####################### 设置 PHP 环境 ###########################
error_reporting(E_ALL & ~ E_NOTICE);
// #################### 定义重要常量 #######################
define('THIS_SCRIPT', 'user');
define('CSRF_PROTECTION', true);
define('CSRF_SKIP_LIST', '');
define('IN_USER_PANEL', true);
// 从缓存中获取指定数据
$specialtemplates = array('players');
require (dirname(__FILE__) . '/global.php');
//载入语言文件
require_once (DIR . '/languages/' . $skyuc->options['lang'] . '/user.php');
$skyuc->input->clean_gpc('r', 'act', TYPE_STR);
$action = iif($skyuc->GPC_exists['act'], $skyuc->GPC['act'], 'default');
// 不需要登录的操作或自己验证是否登录(如ajax处理)的act
$not_login_arr = array('login', 'act_login', 'register', 'act_register',
'act_edit_password', 'get_password', 'send_pwd_email', 'password', 'signin',
'return_to_cart', 'logout', 'is_registered', 'validate_email', 'check_email',
'send_hash_mail', 'add_tag');
// 显示页面的action列表
$ui_arr = array('register', 'login', 'profile', 'order_list', 'order_detail',
'message_list', 'get_password', 'reset_password', 'account_raply',
'account_deposit', 'account_log', 'act_account', 'pay', 'default', 'buyrank',
'buydone', 'card', 'play_log', 'get_integral', 'tag_list', 'comment_list',
'transform_points');
// 检查是否登陆
$user_id = $skyuc->session->vars['userid'];
// 未登录处理
if (empty($user_id)) {
if (! in_array($action, $not_login_arr)) {
if (in_array($action, $ui_arr)) {
// 如果需要登录,并是显示页面的操作,记录当前操作,用于登录后跳转到相应操作
if ($action == 'login') {
if (isset($_REQUEST['back_act'])) {
$back_act = trim($_REQUEST['back_act']);
}
} else {
if (! empty($_SERVER['QUERY_STRING'])) {
$back_act = 'user.php?' . $_SERVER['QUERY_STRING'];
}
$action = 'login';
}
} else {
//未登录提交数据。非正常途径提交数据!
die($_LANG['require_login']);
}
}
}
// 如果是显示页面,对页面进行相应赋值
if (in_array($action, $ui_arr)) {
assign_template();
$position = assign_ur_here(0, $_LANG['user_center']);
$smarty->assign('page_title', $position['title']); // 页面标题
$smarty->assign('ur_here', $position['ur_here']);
// 是否显示积分兑换
if (! empty($skyuc->options['points_rule']) &&
unserialize($skyuc->options['points_rule'])) {
$smarty->assign('show_transform_points', 1);
}
$smarty->assign('nav_list', get_navigator()); // 导航栏
$smarty->assign('action', $action);
$smarty->assign('lang', $_LANG);
}
//用户中心欢迎页
if ($action == 'default') {
require_once (DIR . '/includes/functions_users.php');
$smarty->assign('info', get_user_default($user_id));
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
}
/*------------------------------------------------------ */
//-- 显示会员注册界面
/*------------------------------------------------------ */
if ($action == 'register') {
if ($skyuc->options['regusers_closed'] == 1) {
header('Content-type: text/html; charset=utf-8');
echo '<div style="margin: 150px; text-align: center; font-size: 14px"><p>' .
$_LANG['regusers_closed'] . '</p><p>' .
$skyuc->options['regusers_comment'] . '</p></div>';
exit();
}
if (! isset($back_act) && defined(REFERRER)) {
$back_act = iif(strpos(REFERRER, 'user.php'), './index.php', REFERRER);
}
//验证码相关设置
if ((intval($skyuc->options['humanverify']) & HV_REGISTER)) {
$smarty->assign('enabled_captcha', 1);
}
$smarty->assign('referrer',
$skyuc->input->clean_gpc('c', COOKIE_PREFIX . 'referrer', TYPE_STR));
$smarty->display('user_passport.dwt');
} /*------------------------------------------------------ */
//-- 注册会员的处理
/*------------------------------------------------------ */
elseif ($action == 'act_register') {
require (DIR . '/includes/functions_passport.php');
require_once (DIR . '/includes/functions_users.php');
$skyuc->input->clean_array_gpc('p',
array('username' => TYPE_STR, 'password' => TYPE_STR, 'email' => TYPE_STR,
'humanverify' => TYPE_ARRAY_STR, 'other' => TYPE_ARRAY_STR));
$username = $skyuc->GPC['username'];
$password = $skyuc->GPC['password'];
$email = $skyuc->GPC['email'];
$other = iif($skyuc->GPC_exists['other'], $skyuc->GPC['other'], array());
if (! empty($other['referrer'])) {
$other['referrer'] = preg_replace("#[^a-zA-Z0-9_]#", '',
$other['referrer']);
}
if (strlen($username) < 3) {
show_message($_LANG['passport_js']['username_shorter']);
}
if (strlen($password) < 6) {
show_message($_LANG['passport_js']['password_shorter']);
}
// 验证码检查
if ((intval($skyuc->options['humanverify']) & HV_REGISTER)) {
if (empty($skyuc->GPC['humanverify'])) {
show_message($_LANG['invalid_captcha'], $_LANG['sign_up'],
'user.php?act=register', 'error');
}
// 检查验证码
require_once (DIR . '/includes/class_humanverify.php');
$verify = & HumanVerify::fetch_library($skyuc);
if (! $verify->verify_token($skyuc->GPC['humanverify'])) {
show_message($_LANG['invalid_captcha'], $_LANG['sign_up'],
'user.php?act=register', 'error');
}
}
if (register($username, $password, $email, $other) === false) {
$err->show($_LANG['sign_up'], 'user.php?act=register');
} else {
$ucdata = iif(empty($user->ucdata), '', $user->ucdata);
//send_regiter_hash($skyuc->session->vars['userid']);
show_message(
sprintf($_LANG['register_success'], $username . $ucdata), 'reg_succeed',
'user.php', 'info');
}
} /*------------------------------------------------------ */
//-- ajax 发送验证邮件
/*------------------------------------------------------ */
elseif ($action == 'send_hash_mail') {
require (DIR . '/includes/class_json.php');
require (DIR . '/includes/functions_passport.php');
$json = new JSON();
$result = array('error' => 0, 'message' => '', 'content' => '');
if ($user_id == 0) {
// 用户没有登录
$result['error'] = 1;
$result['message'] = $_LANG['login_please'];
die($json->encode($result));
}
if (send_regiter_hash($user_id)) {
$result['message'] = $_LANG['validate_mail_ok'];
die($json->encode($result));
} else {
$result['error'] = 1;
$result['message'] = $GLOBALS['err']->last_message();
}
die($json->encode($result));
} /*------------------------------------------------------ */
//-- 验证用户注册邮件
/*------------------------------------------------------ */
elseif ($action == 'validate_email') {
$hash = $skyuc->input->clean_gpc('g', 'hash', TYPE_STR);
if ($hash) {
require (DIR . '/includes/functions_passport.php');
$id = register_hash('decode', $hash);
if ($id > 0) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'users' .
' SET is_validated = 1 WHERE user_id=' . $id;
$db->query_write($sql);
$sql = 'SELECT user_name, email FROM ' . TABLE_PREFIX . 'users' .
' WHERE user_id = ' . $id;
$row = $db->query_first_slave($sql);
show_message(
sprintf($_LANG['validate_ok'], $row['user_name'], $row['email']),
$_LANG['profile_lnk'], 'user.php');
}
}
show_message($_LANG['validate_fail']);
} /*------------------------------------------------------ */
//-- AJAX 验证用户注册用户名是否可以注册
/*------------------------------------------------------ */
elseif ($action == 'is_registered') {
require (DIR . '/includes/functions_passport.php');
$username = $skyuc->input->clean_gpc('g', 'username', TYPE_STR);
if ($user->check_user($username) || admin_registered($username)) {
echo 'false';
} else {
echo 'true';
}
} /*------------------------------------------------------ */
//-- AJAX 验证用户邮箱地址是否被注册
/*------------------------------------------------------ */
elseif ($action == 'check_email') {
$email = $skyuc->input->clean_gpc('g', 'email', TYPE_STR);
if ($user->check_email($email)) {
echo 'false';
} else {
echo 'true';
}
} /*------------------------------------------------------ */
//-- 用户登录界面
/*------------------------------------------------------ */
elseif ($action == 'login') {
if (empty($back_act) && defined(REFERRER)) {
$back_act = iif(strpos(REFERRER, 'user.php'), './index.php', REFERRER);
} else {
$back_act = 'user.php';
}
if (intval($skyuc->options['humanverify']) & HV_LOGIN) {
$smarty->assign('enabled_captcha', 1);
}
$smarty->assign('back_act', $back_act);
$smarty->display('user_passport.dwt');
} /*------------------------------------------------------ */
//-- 处理会员的登录
/*------------------------------------------------------ */
elseif ($action == 'act_login') {
require_once (DIR . '/includes/functions_users.php');
$skyuc->input->clean_array_gpc('p',
array('username' => TYPE_STR, 'password' => TYPE_STR,
'back_act' => TYPE_STR, 'humanverify' => TYPE_ARRAY_STR));
$username = $skyuc->GPC['username'];
$password = $skyuc->GPC['password'];
$back_act = $skyuc->GPC['back_act'];
if (($skyuc->options['humanverify'] & HV_LOGIN)) {
if (empty($skyuc->GPC['humanverify'])) {
show_message($_LANG['invalid_captcha'], $_LANG['relogin_lnk'],
'user.php', 'error');
}
// 检查验证码
require_once (DIR . '/includes/class_humanverify.php');
$verify = & HumanVerify::fetch_library($skyuc);
if (! $verify->verify_token($skyuc->GPC['humanverify'])) {
show_message($_LANG['invalid_captcha'], $_LANG['relogin_lnk'],
'user.php', 'error');
}
}
/* require (DIR . '/includes/functions_passport.php');
card_login ( $username, $password );*/
if ($user->login($username, $password) > 0) {
update_user_info();
$ucdata = iif(isset($user->ucdata), $user->ucdata, '');
show_message($_LANG['login_success'] . $ucdata,
array($_LANG['back_up_page'], $_LANG['profile_lnk']),
array($back_act, 'user.php'), 'info');
} elseif ($user->login($username, $password) == 0) {
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php',
'error');
} else {
show_message($_LANG['was_login_success'], $_LANG['relogin_lnk'],
'user.php', 'error');
}
} /*------------------------------------------------------ */
//-- 处理会员 AJAX 的登录请求
/*------------------------------------------------------ */
elseif ($action == 'signin') {
require_once (DIR . '/includes/functions_users.php');
require (DIR . '/includes/class_json.php');
$json = new JSON();
$skyuc->input->clean_array_gpc('p',
array('username' => TYPE_STR, 'password' => TYPE_STR));
$username = $skyuc->GPC['username'];
$password = $skyuc->GPC['password'];
/* require (DIR . '/includes/functions_passport.php');
card_login ( $username, $password );*/
$result = array('error' => 0, 'content' => '');
if ($user->login($username, $password) > 0) {
update_user_info(); //更新用户信息
$smarty->assign('user_info', get_member_info());
$ucdata = iif(isset($user->ucdata), $user->ucdata, '');
$result['ucdata'] = $ucdata;
$result['content'] = $smarty->fetch('library/member_info.lbi');
} elseif ($user->login($username, $password) == 0) {
$result['error'] = 1;
$result['content'] = $_LANG['login_failure'];
} else {
$result['error'] = 1;
$result['content'] = $_LANG['was_login_success'];
}
//执行session关闭脚本
exec_shut_down();
die($json->encode($result));
} /*------------------------------------------------------ */
//-- 获取积分页面
/*------------------------------------------------------ */
elseif ($action == 'get_integral') {
$smarty->assign('hosturl', get_url());
$smarty->assign('userid', $user_id);
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 退出会员中心
/*------------------------------------------------------ */
elseif ($action == 'logout') {
if (! isset($back_act) && defined(REFERER)) {
$back_act = iif(strpos(REFERER, 'user.php'), './index.php', REFERER);
}
$back_act = iif(empty($back_act), './index.php', $back_act);
$user->logout();
$ucdata = iif(isset($user->ucdata), $user->ucdata, '');
show_message($_LANG['logout_success'] . $ucdata,
array($_LANG['back_up_page'], $_LANG['back_home_lnk']),
array($back_act, 'index.php'), 'info');
} /*------------------------------------------------------ */
//-- 个人资料页面
/*------------------------------------------------------ */
elseif ($action == 'profile') {
require_once (DIR . '/includes/functions_users.php');
$smarty->assign('profile', get_profile($user_id));
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 修改个人资料的处理
/*------------------------------------------------------ */
elseif ($action == 'act_edit_profile') {
require_once (DIR . '/includes/functions_users.php');
$skyuc->input->clean_array_gpc('p',
array('birthdayYear' => TYPE_UINT, 'birthdayMonth' => TYPE_UINT,
'birthdayDay' => TYPE_UINT, 'email' => TYPE_STR, 'gender' => TYPE_UINT,
'other' => TYPE_ARRAY_STR));
$birthday = skyuc_mktime(0, 0, 0, $skyuc->GPC['birthdayMonth'],
$skyuc->GPC['birthdayDay'], $skyuc->GPC['birthdayYear']);
if (! empty($skyuc->GPC['other']['phone']) &&
! preg_match('/^[\d|\_|\-|\s]+$/', $skyuc->GPC['other']['phone'])) {
show_message($_LANG['passport_js']['phone_invalid']);
}
if (! validate($skyuc->GPC['email'], 4)) {
show_message($_LANG['msg_email_format']);
}
if (! empty($skyuc->GPC['other']['qq']) &&
! preg_match('/^\d+$/', $skyuc->GPC['other']['qq'])) {
show_message($_LANG['passport_js']['qq_invalid']);
}
$profile = array('user_id' => $user_id, 'email' => $skyuc->GPC['email'],
'gender' => $skyuc->GPC['gender'], 'birthday' => $birthday,
'other' => iif($skyuc->GPC_exists['other'], $skyuc->GPC['other'], array()));
if (edit_profile($profile)) {
show_message($_LANG['edit_profile_success'], $_LANG['profile_lnk'],
'user.php?act=profile', 'info');
} else {
show_message($_LANG['edit_profile_failed'], '', '', 'info');
}
} /*------------------------------------------------------ */
//-- 观看记录页面
/*------------------------------------------------------ */
elseif ($action == 'play_log') {
$skyuc->input->clean_gpc('r', 'page', TYPE_UINT);
$page = iif($skyuc->GPC_exists['page'], $skyuc->GPC['page'], 1);
$total = $db->query_first_slave(
'SELECT COUNT(*) AS total FROM ' . TABLE_PREFIX . 'play_log' .
' WHERE user_id = ' . $user_id);
$pager = get_pager('user.php', array('act' => $action), $total['total'],
$page);
$sql = 'SELECT * FROM ' . TABLE_PREFIX . 'play_log' . ' WHERE user_id = ' .
$user_id . ' ORDER BY id DESC';
$sql = $skyuc->db->query_limit($sql, $pager['size'], $pager['start']);
$res = $db->query_read_slave($sql);
$play_log = array();
while ($row = $db->fetch_array($res)) {
$row['looktime'] = skyuc_date(
$skyuc->options['date_format'] . ' ' . $skyuc->options['time_format'],
$row['time']);
$row['looktype'] = iif(! empty($row['player']),
$skyuc->players["$row[player]"]['title'], 'N/A');
$row['lookid'] = iif(! empty($row['url_id']),
sprintf($_LANG['play_log_lookid'], $row['url_id']), 0);
$play_log[] = $row;
}
$smarty->assign('pager', $pager);
$smarty->assign('play_log', $play_log);
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 充值卡页面
/*------------------------------------------------------ */
elseif ($action == 'card') {
$username = $skyuc->userinfo['user_name'];
$smarty->assign('username', $username);
$smarty->assign('user_notice', $_CFG['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 充值卡提交处理
/*------------------------------------------------------ */
elseif ($action == 'act_card_ok') {
$skyuc->input->clean_array_gpc('p',
array('carduser' => TYPE_STR, 'cardid' => TYPE_STR, 'cardpwd' => TYPE_STR));
$sql = 'SELECT c.*, u.rank_type AS rank_type FROM ' . TABLE_PREFIX . 'card' .
' AS c' . ' LEFT JOIN ' . TABLE_PREFIX . 'user_rank' .
' AS u ON u.rank_id=c.rank_id' . " WHERE c.cardid ='" .
$db->escape_string($skyuc->GPC['cardid']) . "' AND c.cardpass ='" .
$db->escape_string($skyuc->GPC['cardpwd']) . "'";
$row = $db->query_first_slave($sql);
if (empty($row)) {
show_message($_LANG['card_ok_failed'] . $_LANG['card_error'], '', '',
'info');
}
//卡号过期检查
if (TIMENOW > $row['endtime']) {
show_message($_LANG['card_ok_failed'] . $_LANG['card_date_over'], '',
'', 'info');
}
$rank_id = $row['rank_id']; //卡号等级
$rank_type = $row['rank_type']; //卡号类型
$cid = $row['id']; //卡编号
//用户存在检查
$sql = 'SELECT COUNT(*) AS total FROM ' . TABLE_PREFIX . 'users' .
" WHERE user_name = '" . $db->escape_string($skyuc->GPC['carduser']) . "'";
$total = $db->query_first_slave($sql);
if ($total['total'] == 0) {
show_message($_LANG['card_ok_failed'] . $_LANG['user_error'], '', '',
'info');
} else {
//充入帐户
$sql = 'SELECT usertype, unit_date, user_point FROM ' .
TABLE_PREFIX . 'users' . " WHERE user_name='" .
$db->escape_string($skyuc->GPC['carduser']) . "'";
$arr = $db->query_first_slave($sql);
if (! empty($arr)) {
$date = max($arr['unit_date'], TIMENOW);
//计时会员添加天数
$unit_date = 86400 * $row['cardvalue'] + $date;
//计点会员添加点数
$user_point = iif(! empty($arr['user_point']),
$arr['user_point'] + $row['cardvalue'], $row['cardvalue']);
//计时会员
if ($rank_type == 1) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'users' .
" SET usertype=1, user_rank='" . $rank_id . "',unit_date='" .
$unit_date . "' WHERE user_name='" .
$db->escape_string($skyuc->GPC['carduser']) . "'";
} //计点会员
elseif ($rank_type == 0) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'users' .
" SET usertype=0, user_rank='" . $rank_id . "',user_point='" .
$user_point . "' WHERE user_name='" .
$db->escape_string($skyuc->GPC['carduser']) . "'";
}
$db->query_write($sql);
// 添加充值记录
$sql = 'INSERT INTO ' . TABLE_PREFIX . 'card_log' .
' (cardid, cardpass, rank_id, cardvalue, money, addtime, username, userip) ' .
" VALUES('" . $db->escape_string($skyuc->GPC['cardid']) . "', '" .
$db->escape_string($skyuc->GPC['cardpwd']) . "', '" . $rank_id .
"', '" . $row['cardvalue'] . "', '" . $row['money'] . "', '" .
TIMENOW . "', '" . $db->escape_string($skyuc->GPC['carduser']) .
"', '" . ALT_IP . "')";
$db->query_write($sql);
//删除影卡
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'card' .
" WHERE id='" . $cid . "'";
$db->query_write($sql);
show_message(
$_LANG['card_ok_success'] . $_LANG['carduser'] .
$skyuc->GPC['carduser'], $_LANG['card_lnk'], 'user.php?act=card',
'info');
}
}
} /*------------------------------------------------------ */
//-- 密码找回-->修改密码界面
/*------------------------------------------------------ */
elseif ($action == 'get_password') {
$skyuc->input->clean_array_gpc('g',
array('code' => TYPE_STR, 'uid' => TYPE_UINT));
//从邮件处获得的act
if ($skyuc->GPC_exists['code'] && $skyuc->GPC_exists['uid']) {
$code = $skyuc->GPC['code'];
$uid = $skyuc->GPC['uid'];
// 判断链接的合法性
$user_info = $user->get_profile_by_id($uid);
if (empty($user_info) ||
($user_info &&
md5($user_info['user_id'] . COOKIE_SALT . $user_info['password']) !=
$code)) {
show_message($_LANG['parm_error'], $_LANG['back_home_lnk'], './',
'info');
}
$smarty->assign('uid', $uid);
$smarty->assign('code', $code);
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->assign('action', 'reset_password');
$smarty->display('user_passport.dwt');
} else {
//显示用户名和email表单
$smarty->display('user_passport.dwt');
}
} /*------------------------------------------------------ */
//-- 发送密码修改确认邮件
/*------------------------------------------------------ */
elseif ($action == 'send_pwd_email') {
require (DIR . '/includes/functions_passport.php');
// 初始化会员用户名和邮件地址
$skyuc->input->clean_array_gpc('p',
array('user_name' => TYPE_STR, 'email' => TYPE_STR));
$user_name = $skyuc->GPC['user_name'];
$email = $skyuc->GPC['email'];
//用户名和邮件地址是否匹配
$user_info = $user->get_user_info($user_name);
if ($user_info && $user_info['email'] == $email) {
//生成code
$code = md5(
$user_info['user_id'] . COOKIE_SALT . $user_info['password']);
//发送邮件的函数
if (send_pwd_email($user_info['user_id'], $user_name, $email,
$code)) {
show_message($_LANG['send_success'] . $email,
$_LANG['back_home_lnk'], './', 'info');
} else {
//发送邮件出错
show_message($_LANG['fail_send_password'],
$_LANG['back_page_up'], './', 'info');
}
} else {
//用户名与邮件地址不匹配
show_message($_LANG['username_no_email'],
$_LANG['back_page_up'], '', 'info');
}
} /*------------------------------------------------------ */
//-- 重置新密码
/*------------------------------------------------------ */
elseif ($action == 'reset_password') {
//显示重置密码的表单
$smarty->display('user_passport.dwt');
} /*------------------------------------------------------ */
//-- 修改会员密码
/*------------------------------------------------------ */
elseif ($action == 'act_edit_password') {
require (DIR . '/includes/functions_passport.php');
$skyuc->input->clean_array_gpc('p',
array('old_password' => TYPE_STR, 'new_password' => TYPE_STR,
'uid' => TYPE_UINT, 'code' => TYPE_STR));
$old_password = $skyuc->GPC['old_password'];
$new_password = $skyuc->GPC['new_password'];
$user_id = iif($skyuc->GPC_exists['uid'], $skyuc->GPC['uid'], $user_id);
$code = $skyuc->GPC['code'];
if (strlen($new_password) < 6) {
show_message($_LANG['passport_js']['password_shorter']);
}
$user_info = $user->get_profile_by_id($user_id); //论坛记录
if (($user_info &&
(! empty($code) &&
md5($user_info['user_id'] . COOKIE_SALT . $user_info['password']) == $code)) || ($skyuc->session->vars['userid'] >
0 && $skyuc->session->vars['userid'] == $user_id &&
$user->check_user($skyuc->userinfo['user_name'], $old_password))) {
if ($user->edit_user(
array(
'username' => empty($code) ? $skyuc->userinfo['user_name'] : $user_info['user_name'],
'old_password' => $old_password, 'password' => $new_password))) {
$user->logout();
show_message($_LANG['edit_password_success'], $_LANG['relogin_lnk'],
'user.php?act=login', 'info');
} else {
show_message($_LANG['edit_password_failure'],
$_LANG['back_page_up'], '', 'info');
}
} else {
show_message($_LANG['edit_password_failure'], $_LANG['back_page_up'],
'', 'info');
}
} /*------------------------------------------------------ */
//-- 查看会员购买
/*------------------------------------------------------ */
elseif ($action == 'buyrank') {
require_once (DIR . '/includes/functions_users.php');
require (DIR . '/includes/functions_order.php');
// 获取价格列表
$arr = array();
foreach ($skyuc->usergroup as $row) {
//格式化金额
$row['b_money'] = price_format($row['money']);
$row['b_count'] = iif($row['type'] != 0,
$row['count'] . $_LANG['look_day'], $row['count'] . $_LANG['look_count']);
$row['b_type'] = iif($row['type'] != 0, $_LANG['is_day'],
$_LANG['is_count']);
$arr[] = $row;
}
$user_info = get_user_info($user_id);
// 如果使用余额,取得用户余额
if ((! isset($skyuc->options['use_surplus']) ||
$skyuc->options['use_surplus'] == 1) && $user_info['user_money'] > 0) {
// 能使用余额
$smarty->assign('allow_use_surplus', 1);
$smarty->assign('your_surplus', $user_info['user_money']);
}
// 如果使用积分,取得用户可用积分及本订单最多可以使用的积分
if ((! isset($skyuc->options['use_integral']) ||
$skyuc->options['use_integral'] == 1) && $user_info['pay_point'] > 0) {
// 能使用积分
$smarty->assign('allow_use_integral', 1);
$smarty->assign('your_integral', $user_info['pay_point']); // 用户积分
}
$account = get_surplus_info($user_id);
$smarty->assign('payment', get_online_payment_list());
$smarty->assign('order', $account);
$smarty->assign('flow_no_payment', $_LANG['flow_no_payment']);
$smarty->assign('buyrank', $arr);
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 检查用户输入的余额
/*------------------------------------------------------ */
elseif ($action == 'check_surplus') {
require (DIR . '/includes/class_json.php');
require_once (DIR . '/includes/functions_users.php');
$result = array('error' => '', 'content' => '');
$surplus = floatval($_GET['surplus']);
$user_info = get_user_info($user_id);
$result['error'] = iif($user_info['user_money'] < $surplus,
$_LANG['surplus_not_enough'], '');
$json = new JSON();
die($json->encode($result));
} /*------------------------------------------------------ */
//-- 检查用户输入的积分
/*------------------------------------------------------ */
elseif ($action == 'check_integral') {
require (DIR . '/includes/class_json.php');
require_once (DIR . '/includes/functions_users.php');
$result = array('error' => '', 'content' => '');
$points = floatval($_GET['points']);
$user_info = get_user_info($user_id);
$result['error'] = iif($user_info['pay_point'] < $points,
$_LANG['integral_not_enough'], '');
$json = new JSON();
die($json->encode($result));
} /*------------------------------------------------------ */
//-- 完成所有订单操作,提交到数据库
/*------------------------------------------------------ */
elseif ($action == 'buydone') {
require_once (DIR . '/includes/functions_users.php');
require (DIR . '/includes/functions_order.php');
require (DIR . '/includes/functions_payment.php');
$skyuc->input->clean_array_gpc('p',
array('buy_id' => TYPE_UINT, 'payment' => TYPE_UINT, 'surplus' => TYPE_UNUM,
'points' => TYPE_UINT, 'multiple' => TYPE_UINT));
// 取得提交的购买价格信息
$buy_id = $skyuc->GPC['buy_id'];
//购买倍数
$multiple = iif($skyuc->GPC['multiple'] == 0, 1,
$skyuc->GPC['multiple']);
$order = array('pay_id' => $skyuc->GPC['payment'],
'surplus' => floatval($skyuc->GPC['surplus']),
'integral' => $skyuc->GPC['points'], 'order_amount' => 0, 'pay_amount' => 0,
'user_id' => $user_id, 'pay_status' => PS_UNPAYED);
$row = array();
$row = $skyuc->usergroup["$buy_id"];
$order['order_count'] = $row['count'] * $multiple; //购买点数或天数
$order['usertype'] = $row['type']; //购买会员类型
$order['rank_id'] = $row['id']; //购买会员等级
$order['order_amount'] = $row['money'] * $multiple; //订单金额
// 获取用户信息
$user_info = get_user_info($user_id);
// 用户IP和订单时间
$order['order_time'] = TIMENOW;
$order['user_ip'] = ALT_IP;
// 支付方式
if ($order['pay_id'] > 0) {
$payment = payment_info($order['pay_id']);
$order['pay_name'] = $payment['pay_name'];
}
$order['pay_amount'] = $order['order_amount'] +
pay_fee($order['pay_id'], $order['order_amount']);
// 插入订单表
$error_no = 0;
do {
$order['order_sn'] = get_order_sn(); //获取新订单号
$db->query_write(fetch_query_sql($order, 'order_info'));
$error_no = $db->errno();
} while ($error_no == 1062); //如果是订单号重复则重新提交数据
$new_order_id = $db->insert_id();
$order['order_id'] = $new_order_id;
// 如果全部使用余额支付,检查余额是否足够
if ($payment['pay_code'] == 'balance' && $order['order_amount'] > 0) {
if ($order['order_amount'] > $user_info['user_money']) {
show_message($_LANG['balance_not_enough']);
} elseif ($order['user_id'] > 0) { //处理余额
log_account_change($order['user_id'],
$order['order_amount'] * (- 1), 0,
sprintf($_LANG['pay_order'], $order['order_sn']));
// 实时开通会员权限
payment_finsh($order['order_count'], $order['usertype'],
$order['rank_id'], $user_id, $order['order_id'],
$order['order_amount']);
$order['surplus'] = $order['order_amount']; //支付的余额
// 订单状态设为已付款
$order['pay_status'] = PS_PAYED;
}
}
// 如果全部使用积分支付,检查积分是否足够
if ($payment['pay_code'] == 'integral' && $order['order_amount'] > 0) {
//订单的金额转成积分
$order_ponits = integral_of_value($order['order_amount']);
if ($order_ponits > $user_info['pay_point']) {
show_message($_LANG['integral_not_enough']);
} elseif ($order['user_id'] > 0 && $order_ponits > 0) { // 处理积分
log_account_change($order['user_id'], 0,
$order_ponits * (- 1),
sprintf($_LANG['pay_order'], $order['order_sn']));
// 实时开通会员权限
payment_finsh($order['order_count'], $order['usertype'],
$order['rank_id'], $user_id, $order['order_id'],
$order['order_amount']);
$order['integral'] = $order_ponits; //支付的积分
// 订单状态设为已付款
$order['pay_status'] = PS_PAYED;
}
}
if ($payment['pay_code'] == 'integral' || $payment['pay_code'] == 'balance') {
$sql = 'UPDATE ' . TABLE_PREFIX . 'order_info' . ' SET pay_time=' .
TIMENOW . ', integral=' . $order['integral'] . ', surplus=' .
$order['surplus'] . ', pay_status =' . $order['pay_status'] .
' WHERE order_id =' . $order['order_id'] . '';
$db->query_write($sql);
}
// 插入支付日志
$order['log_id'] = insert_pay_log($new_order_id, $order['pay_amount'],
PAY_ORDER);
$order['amount_formated'] = price_format($order['pay_amount']); //格式化实际支付的金额
// 取得支付信息,生成支付代码
$payment = payment_info($order['pay_id']);
require_once (DIR . '/includes/modules/payment/' . $payment['pay_code'] .
'.php');
$pay_obj = new $payment['pay_code']();
$pay_online = $pay_obj->get_code($order,
unserialize_config($payment['pay_config']));
$order['pay_desc'] = $payment['pay_desc'];
$smarty->assign('pay_online', $pay_online);
// 订单信息
$smarty->assign('order', $order);
$smarty->assign('order_submit_back',
sprintf($_LANG['order_submit_back'], $_LANG['back_home'],
$_LANG['goto_user_center'])); // 返回提示
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 查看订单列表
/*------------------------------------------------------ */
elseif ($action == 'order_list') {
require (DIR . '/includes/functions_order.php');
$skyuc->input->clean_gpc('r', 'page', TYPE_UINT);
$page = iif($skyuc->GPC_exists['page'], $skyuc->GPC['page'], 1);
$total = $db->query_first_slave(
'SELECT COUNT(*) AS total FROM ' . TABLE_PREFIX . 'order_info' .
' WHERE user_id = ' . $user_id);
$record_count = $total['total'];
$pager = get_pager('user.php', array('act' => $action), $record_count,
$page);
$orders = get_user_orders($user_id, $pager['size'], $pager['start']);
$smarty->assign('pager', $pager);
$smarty->assign('orders', $orders);
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 查看订单详情
/*------------------------------------------------------ */
elseif ($action == 'order_detail') {
require (DIR . '/includes/functions_order.php');
$order_id = $skyuc->input->clean_gpc('g', 'order_id', TYPE_UINT);
// 订单详情
$order = get_order_detail($order_id, $user_id);
if ($order === false) {
$err->show($_LANG['back_home_lnk'], './');
exit();
}
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->assign('order', $order);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 取消订单
/*------------------------------------------------------ */
elseif ($action == 'cancel_order') {
require (DIR . '/includes/functions_order.php');
$order_id = $skyuc->input->clean_gpc('g', 'order_id', TYPE_UINT);
if (cancel_order($order_id, $user_id)) {
header("Location: user.php?act=order_list\n");
exit();
} else {
$err->show($_LANG['order_list_lnk'], 'user.php?act=order_list');
}
} /*------------------------------------------------------ */
//-- 显示留言列表
/*------------------------------------------------------ */
elseif ($action == 'message_list') {
require_once (DIR . '/includes/functions_users.php');
$skyuc->input->clean_gpc('r', 'page', TYPE_UINT);
$page = iif($skyuc->GPC_exists['page'], $skyuc->GPC['page'], 1);
// 获取用户留言的数量
$sql = 'SELECT COUNT(*) AS total FROM ' . TABLE_PREFIX . 'feedback' .
' WHERE parent_id = 0 AND user_id = ' . $user_id;
$total = $db->query_first_slave($sql);
$record_count = $total['total'];
$pager = get_pager('user.php', array('act' => $action), $record_count,
$page, 5);
$smarty->assign('message_list',
get_message_list($user_id, $skyuc->userinfo['user_name'], $pager['size'],
$pager['start']));
$smarty->assign('pager', $pager);
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 添加我的留言
/*------------------------------------------------------ */
elseif ($action == 'act_add_message') {
require_once (DIR . '/includes/functions_users.php');
require (DIR . '/includes/control/message.php');
$skyuc->input->clean_array_gpc('p',
array('msg_type' => TYPE_UINT, 'msg_title' => TYPE_STR,
'msg_content' => TYPE_STR));
$message = array('user_id' => $user_id,
'user_name' => $skyuc->userinfo['user_name'],
'user_email' => $skyuc->userinfo['email'],
'msg_type' => $skyuc->GPC['msg_type'],
'msg_title' => $skyuc->GPC['msg_title'],
'msg_content' => $skyuc->GPC['msg_content'],
'upload' => (isset($_FILES['message_img']['error']) &&
$_FILES['message_img']['error'] == 0) ||
(! isset($_FILES['message_img']['error']) &&
$_FILES['message_img']['tmp_name'] != 'none') ? $_FILES['message_img'] : array());
if (add_message($message)) {
if ($skyuc->options['send_admin'] == 1) {
// 发送Email通知管理员
$sql = 'SELECT email FROM ' . TABLE_PREFIX . 'admin' .
" WHERE action_list = 'all'";
$row = $db->query_first_slave($sql);
$template = get_mail_template('admin_message'); //获取邮件模板
$smarty->assign('send_date',
skyuc_date($skyuc->options['date_format'], TIMENOW, true, false));
$smarty->assign('sent_date',
skyuc_date($skyuc->options['date_format'], TIMENOW, true, false));
$content = $smarty->fetch('str:' . $template['template_content']);
// 发送邮件
skyuc_mail($row['email'], $template['template_subject'],
$content, true, $template['is_html']);
}
show_message($_LANG['add_message_success'], $_LANG['message_list_lnk'],
'user.php?act=message_list', 'info');
} else {
$err->show($_LANG['message_list_lnk'], 'user.php?act=message_list');
}
} /*------------------------------------------------------ */
//-- AJAX 添加标签
/*------------------------------------------------------ */
elseif ($action == 'add_tag') {
require (DIR . '/includes/class_json.php');
require_once (DIR . '/includes/functions_users.php');
$result = array('error' => 0, 'message' => '', 'content' => '');
$skyuc->input->clean_array_gpc('p',
array('id' => TYPE_UINT, 'tag' => TYPE_STR));
$id = $skyuc->GPC['id'];
$tag = $skyuc->GPC['tag'];
if ($user_id == 0) {
//用户没有登录
$result['error'] = 1;
$result['message'] = $_LANG['tag_anonymous'];
} else {
add_tag($id, $tag); // 添加tag
// 重新获得该影片的所有标签
$arr = get_tags($id, 0, $skyuc->options['related_tags'],
true);
foreach ($arr as $row) {
$result['content'][] = array(
'word' => htmlspecialchars($row['tag_words']),
'count' => $row['tag_count']);
}
}
$json = new JSON();
echo $json->encode($result);
exit();
} /*------------------------------------------------------ */
//-- 标签云列表
/*------------------------------------------------------ */
elseif ($action == 'tag_list') {
require_once (DIR . '/includes/functions_users.php');
$show_id = $skyuc->input->clean_gpc('g', 'id', TYPE_UINT);
$smarty->assign('tags', get_user_tags($user_id));
$smarty->assign('tags_from', 'user');
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 删除标签云的处理
/*------------------------------------------------------ */
elseif ($action == 'act_del_tag') {
require_once (DIR . '/includes/functions_users.php');
$tag_words = $skyuc->input->clean_gpc('g', 'tag_words', TYPE_STR);
delete_tag($tag_words, $user_id);
header("Location: user.php?act=tag_list\n");
exit();
} /*------------------------------------------------------ */
//-- 显示评论列表
/*------------------------------------------------------ */
elseif ($action == 'comment_list') {
require_once (DIR . '/includes/functions_users.php');
$skyuc->input->clean_gpc('r', 'page', TYPE_UINT);
$page = iif($skyuc->GPC_exists['page'], $skyuc->GPC['page'], 1);
// 获取用户留言的数量
$sql = 'SELECT COUNT(*) AS total FROM ' . TABLE_PREFIX . 'comment' .
' WHERE parent_id = 0 AND user_name = ' . $user_id;
$total = $db->query_first_slave($sql);
$record_count = $total['total'];
$pager = get_pager('user.php', array('act' => $action), $record_count,
$page, 5);
$smarty->assign('comment_list',
get_comment_list($user_id, $pager['size'], $pager['start']));
$smarty->assign('pager', $pager);
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 删除评论
/*------------------------------------------------------ */
elseif ($action == 'del_cmt') {
$id = $skyuc->input->clean_gpc('g', 'id', TYPE_UINT);
if ($id > 0) {
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'comment' . ' WHERE comment_id = ' .
$id . ' AND user_id = ' . $user_id;
$db->query_write($sql);
}
header("Location: user.php?act=comment_list\n");
exit();
} /*------------------------------------------------------ */
//-- 会员退款申请界面
/*------------------------------------------------------ */
elseif ($action == 'account_raply') {
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 会员预付款界面
/*------------------------------------------------------ */
elseif ($action == 'account_deposit') {
require_once (DIR . '/includes/functions_users.php');
$surplus_id = $skyuc->input->clean_gpc('g', 'id', TYPE_UINT);
$account = get_surplus_info($surplus_id);
$smarty->assign('payment', get_online_payment_list(false));
$smarty->assign('order', $account);
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 会员充值和提现申请记录
/*------------------------------------------------------ */
elseif ($action == 'account_log') {
require_once (DIR . '/includes/functions_users.php');
$skyuc->input->clean_gpc('r', 'page', TYPE_UINT);
$page = iif($skyuc->GPC_exists['page'], $skyuc->GPC['page'], 1);
// 获取记录条数
$sql = 'SELECT COUNT(*) AS total FROM ' . TABLE_PREFIX . 'user_account' .
' WHERE user_id = ' . $user_id . ' AND process_type ' .
db_create_in(array(SURPLUS_SAVE, SURPLUS_RETURN));
$total = $db->query_first_slave($sql);
$record_count = $total['total'];
//分页函数
$pager = get_pager('user.php', array('act' => $action), $record_count,
$page);
//获取剩余余额
$surplus_amount = get_user_surplus($user_id);
if (empty($surplus_amount)) {
$surplus_amount = 0;
}
//获取余额记录
$account_log = get_account_log($user_id, $pager['size'],
$pager['start']);
//模板赋值
$smarty->assign('surplus_amount', price_format($surplus_amount));
$smarty->assign('account_log', $account_log);
$smarty->assign('pager', $pager);
$smarty->assign('user_notice', $skyuc->options['user_notice']);
$smarty->display('user_center.dwt');
} /*------------------------------------------------------ */
//-- 会员充值和提现申请记录
/*------------------------------------------------------ */
elseif ($action == 'act_account') {
require_once (DIR . '/includes/functions_users.php');
require (DIR . '/includes/functions_order.php');
require (DIR . '/includes/functions_payment.php');
$skyuc->input->clean_array_gpc('p',
array('amount' => TYPE_UNUM, 'rec_id' => TYPE_UINT,
'surplus_type' => TYPE_UINT, 'payment_id' => TYPE_UINT,
'user_note' => TYPE_STR));
$amount = iif($skyuc->GPC_exists['amount'], floatval($skyuc->GPC['amount']),
0);
if ($amount <= 0) {
show_message($_LANG['amount_gt_zero']);
}
// 变量初始化
$surplus = array('user_id' => $user_id,
'rec_id' => $skyuc->GPC['rec_id'],
'process_type' => $skyuc->GPC['surplus_type'],
'payment_id' => $skyuc->GPC['payment_id'],
'user_note' => $skyuc->GPC['user_note'], 'amount' => $amount);
/*
* 退款申请的处理
*/