-
Notifications
You must be signed in to change notification settings - Fork 5
/
user.php
4161 lines (3577 loc) · 151 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
/**
* ECSHOP 会员中心
* ============================================================================
* * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
* 网站地址: http://www.ecshop.com;
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
* 使用;不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* $Author: liubo $
* $Id: user.php 17217 2011-01-19 06:29:08Z liubo $
*/
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
/*新增会员头像功能*/
include_once(ROOT_PATH . '/includes/cls_image.php');//会员头像
$image = new cls_image($_CFG['bgcolor']);//会员头像
$allow_suffix = array('gif', 'jpg', 'png', 'jpeg', 'bmp');//会员头像
/* 载入语言文件 */
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/user.php');
$user_id = $_SESSION['user_id'];
$action = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'default';
if ( isset($_GET['act'] ) ) {
$action = trim($_GET['act']);
if( empty($action) ){
$action = 'default';
}
}
$affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
$smarty->assign('affiliate', $affiliate);
$back_act='';
// 不需要登录的操作或自己验证是否登录(如ajax处理)的act
$not_login_arr =
array('login','act_login','act_login_wechat','register','act_register','act_edit_password','get_password','send_pwd_email','password', 'signin', 'add_tag', 'collect', 'return_to_cart', 'logout', 'email_list', 'validate_email', 'send_hash_mail', 'order_query', 'is_registered', 'check_email','clear_history','qpassword_name', 'get_passwd_question', 'check_answer');
/* 显示页面的action列表 */
$ui_arr = array('register', 'login', 'profile', 'bindusercard','usercarddg','taocan_list','taocan_buy','edittaocan','deltaocan','order_list', 'order_detail', 'address_list', 'collection_list',
'message_list', 'tag_list', 'get_password', 'reset_password', 'booking_list', 'add_booking', 'account_raply','activity_list','share_list',
'account_deposit', 'account_log', 'account_detail', 'act_account', 'pay', 'default', 'bonus', 'group_buy', 'group_buy_detail', 'affiliate', 'comment_list','validate_email','track_packages', 'transform_points','qpassword_name', 'get_passwd_question', 'check_answer','user_card');
if ( isset($_REQUEST['wxid']) ) {
$_SESSION['wxid'] = trim($_REQUEST['wxid']);
$_SESSION['wxnm'] = isset($_REQUEST['wxnm']) ? $_REQUEST['wxnm'] : '';
}
//echo 'wxid:'.$_SESSION['wxid'].'<br />';
//echo 'wxnm:'.$_SESSION['wxnm'];
//die;
function SpGetPinyin($str, $ishead=0, $isclose=1)
{
//global $pinyins;
$restr = '';
$str = trim($str);
$slen = strlen($str);
if($slen < 2)
{
return $str;
}
/*if(count($pinyins) == 0)
{
$fp = fopen(DEDEINC.'/data/pinyin.dat', 'r');
while(!feof($fp))
{
$line = trim(fgets($fp));
$pinyins[$line[0].$line[1]] = substr($line, 3, strlen($line)-3);
}
fclose($fp);
}*/
for($i=0; $i<$slen; $i++)
{
if(ord($str[$i])>0x80)
{
$c = $str[$i].$str[$i+1];
$i++;
if(isset($pinyins[$c]))
{
if($ishead==0)
{
$restr .= $pinyins[$c];
}
else
{
$restr .= $pinyins[$c][0];
}
}else
{
$restr .= "_";
}
}else if( preg_match("/[a-z0-9]/i", $str[$i]) )
{
$restr .= $str[$i];
}
else
{
$restr .= "_";
}
}
if($isclose==0)
{
unset($pinyins);
}
return $restr;
}
/* 未登录处理 */
if (empty($_SESSION['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?' . strip_tags($_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']);
$sql = "SELECT value FROM " . $ecs->table('shop_config') . " WHERE id = 419";
$row = $db->getRow($sql);
$car_off = $row['value'];
$smarty->assign('car_off', $car_off);
/* 是否显示积分兑换 */
if (!empty($_CFG['points_rule']) && unserialize($_CFG['points_rule']))
{
$smarty->assign('show_transform_points', 1);
}
$smarty->assign('helps', get_shop_help()); // 网店帮助
$smarty->assign('data_dir', DATA_DIR); // 数据目录
$smarty->assign('action', $action);
$smarty->assign('lang', $_LANG);
}
if ($action == 'edittaocan') //套餐
{
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/user.php');
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/shopping_flow.php');
$id = $_REQUEST['id'];
$taocan = $db->getRow("select * from ".$ecs->table("user_taocan")." where id=".$id);
$glist = $db->getAll("select * from ".$ecs->table("user_tc_goods")." where tcid=".$id." order by id asc");
foreach($glist as $k=>$g){
$goodsid = unserialize($g['gids']);
$glist[$k]['province_list'] = get_regions(1,1);
$glist[$k]['city_list'] = get_regions(2,$g['province']);
$glist[$k]['district_list'] = get_regions(3,$g['city']);
$gnums = unserialize($g['gnums']);
$glist2 = $db->getAll("select g.goods_name,g.shop_price,g.goods_id from ".$ecs->table("goods")." g where g.goods_id ".db_create_in($goodsid)." ");
foreach($glist2 as $gg){
foreach($goodsid as $j=>$id){
if($gg['goods_id']==$id){
$gg['goods_num'] = $gnums[$j];
$glist[$k]['goods'][] = $gg;
}
}
}
}
$taocan['num'] = count($glist);
$smarty->assign('country_list', get_regions());
$smarty->assign('nglist',$glist);
$smarty->assign('taocan',$taocan);
$_LANG['select_please'] = '请选择';
$smarty->assign('lang', $_LANG);
$smarty->display("user_transaction.dwt");
}
if ($action == 'deltaocan') //套餐
{
$db->query("delete from ".$ecs->table("user_taocan")." where id=".$_REQUEST['id']);
$db->query("delete from ".$ecs->table("user_tc_goods")." where tcid=".$_REQUEST['id']);
show_message('删除套餐成功', '返回我的套餐', 'user.php?act=taocan_list');
}
if ($action == 'updatetaocan'){ //套餐
$id = $_REQUEST['id'];
for($i=0;$i<7;$i++){
if(isset($_POST['country'.$i])){
$tcgoods = array();
$tcgoods['id'] = $_POST['tcid'.$i];
$tcgoods['country'] = $_POST['country'.$i];
$tcgoods['province'] = $_POST['province'.$i];
$tcgoods['city'] = $_POST['city'.$i];
$tcgoods['district'] = $_POST['district'.$i];
$tcgoods['address'] = $_POST['address'.$i];
$tcgoods['zipcode'] = $_POST['zipcode'.$i];
$tcgoods['consignee'] = $_POST['consignee'.$i];
$tcgoods['email'] = $_POST['email'.$i];
$tcgoods['mobile'] = $_POST['mobile'.$i];
$tcgoods['weekdays'] = $_POST['weekdays'.$i];
$tcgoods['halfday'] = $_POST['halfday'.$i];
$db->query("update ".$ecs->table("user_tc_goods")." set country='".$tcgoods['country']."',province='".$tcgoods['province']."',city='".$tcgoods['city']."',
district='".$tcgoods['district']."',address='".$tcgoods['address']."',zipcode='".$tcgoods['zipcode']."',consignee='".$tcgoods['consignee']."',
email='".$tcgoods['email'] ."',mobile='".$tcgoods['mobile']."',weekdays='".$tcgoods['weekdays']."',halfday='".$tcgoods['halfday']."' where id=".$tcgoods['id']);
}
}
$db->query("update ".$ecs->table("user_taocan")." set status='".$_POST['status']."',beizhu='".$_POST['beizhu']."' where id=".$id);
show_message('套餐更新成功', '返回我的套餐', 'user.php?act=taocan_list');
}
if ($action == 'taocan_list') //套餐
{
$sql = " SELECT t.* ".
" FROM " . $GLOBALS['ecs']->table('user_taocan') . " t"
." where t.user_id =".$_SESSION['user_id'].
" ORDER BY id desc ";
$row = $GLOBALS['db']->getAll($sql);
foreach($row as $k=>$r){
$row[$k]['last_date'] = local_date("Y-m-d H:i:s",$r['last_date']);
$utaocangoods = $GLOBALS['db']->getAll("select weekdays,halfday from ".$GLOBALS['ecs']->table('user_tc_goods')." where tcid=".$r['id']);
$row[$k]['pingci'] = count($utaocangoods);
$row[$k]['tcinfolist'] = $utaocangoods;
}
$smarty->assign('taocan', $row);
$smarty->display('user_transaction.dwt');
}
if ($action == 'taocan_buy') //套餐
{
//合同到期
$todate = $db->getOne("select to_date from ".$ecs->table("users")." where user_id=".$_SESSION['user_id']);
if(empty($todate) || $todate<gmtime()){ //判断合同期限
ecs_header("Location: user.php?act=user_card \n");
exit;
}
$cardnum = $db->getone("select count(user_id) from ".$ecs->table("user_card")." where user_id=".$_SESSION['user_id']);
if(!$cardnum){
ecs_header("Location: user.php?act=user_card\n");
exit;
}
$sql = " SELECT * ".
" FROM " . $GLOBALS['ecs']->table('system_taocan');
$taocanlist = $db->getAll($sql);
foreach($taocanlist as $k=>$t){
$taocanlist[$k]['tprice'] = price_format($t['tprice']) ;
}
$smarty->assign('taocanlist', $taocanlist);
$smarty->display('user_transaction.dwt');
}
//用户中心欢迎页
if ($action == 'default')
{
include_once(ROOT_PATH .'includes/lib_clips.php');
if ($rank = get_rank_info())
{
$smarty->assign('rank_name', sprintf($_LANG['your_level'], $rank['rank_name']));
if (!empty($rank['next_rank_name']))
{
$smarty->assign('next_rank_name', sprintf($_LANG['next_level'], $rank['next_rank'] ,$rank['next_rank_name']));
}
}
$smarty->assign('info', get_user_default($user_id));
$smarty->assign('user_notice', $_CFG['user_notice']);
$smarty->assign('prompt', get_user_prompt($user_id));
$smarty->display('user_clips.dwt');
}
/* 显示会员注册界面 */
if ($action == 'register')
{
if ((!isset($back_act)||empty($back_act)) && isset($GLOBALS['_SERVER']['HTTP_REFERER']))
{
$back_act = strpos($GLOBALS['_SERVER']['HTTP_REFERER'], 'user.php') ? './index.php' : $GLOBALS['_SERVER']['HTTP_REFERER'];
}
/* 取出注册扩展字段 */
$sql = 'SELECT * FROM ' . $ecs->table('reg_fields') . ' WHERE type < 2 AND display = 1 ORDER BY dis_order, id';
$extend_info_list = $db->getAll($sql);
$smarty->assign('extend_info_list', $extend_info_list);
/* 验证码相关设置 */
if ((intval($_CFG['captcha']) & CAPTCHA_REGISTER) && gd_version() > 0)
{
$smarty->assign('enabled_captcha', 1);
$smarty->assign('rand', mt_rand());
}
/* 密码提示问题 */
$smarty->assign('passwd_questions', $_LANG['passwd_questions']);
/* Added by Jack, 2015.05.31 start */
require(dirname(__FILE__) . '/includes/lib_sms.php');
$_SESSION['sms_code']=getverifycode();
$smarty->assign('sms_code', $_SESSION['sms_code']);
$smarty->assign('ztime', $_CFG['ihuyi_sms_smsgap']);
/* Added by Jack, 2015.05.31 end */
/* 增加是否关闭注册 */
$smarty->assign('shop_reg_closed', $_CFG['shop_reg_closed']);
// $smarty->assign('back_act', $back_act);
$smarty->display('user_passport.dwt');
}
/* 注册会员的处理 */
elseif ($action == 'act_register')
{
/* 增加是否关闭注册 */
if ($_CFG['shop_reg_closed'])
{
$smarty->assign('action', 'register');
$smarty->assign('shop_reg_closed', $_CFG['shop_reg_closed']);
$smarty->display('user_passport.dwt');
}
else
{
include_once(ROOT_PATH . 'includes/lib_passport.php');
$birthday = trim($_POST['birthdayYear']) .'-'. trim($_POST['birthdayMonth']) .'-'. trim($_POST['birthdayDay']);
$username = isset($_POST['username']) ? trim($_POST['username']) : '';
$password = isset($_POST['password']) ? trim($_POST['password']) : '';
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$other['msn'] = isset($_POST['extend_field1']) ? $_POST['extend_field1'] : '';
$other['qq'] = isset($_POST['extend_field2']) ? $_POST['extend_field2'] : '';
$other['office_phone'] = isset($_POST['extend_field3']) ? $_POST['extend_field3'] : '';
$other['home_phone'] = isset($_POST['extend_field4']) ? $_POST['extend_field4'] : '';
$other['mobile_phone'] = isset($_POST['extend_field5']) ? $_POST['extend_field5'] : '';
$sel_question = empty($_POST['sel_question']) ? '' : $_POST['sel_question'];
$passwd_answer = isset($_POST['passwd_answer']) ? trim($_POST['passwd_answer']) : '';
$wx = isset($_POST['wx']) ? trim($_POST['wx']) : '';
$back_act = isset($_POST['back_act']) ? trim($_POST['back_act']) : '';
if(empty($_POST['agreement']))
{
show_message($_LANG['passport_js']['agreement']);
}
if (strlen($username) < 3)
{
show_message($_LANG['passport_js']['username_shorter']);
}
if (strlen($password) < 6)
{
show_message($_LANG['passport_js']['password_shorter']);
}
if (strpos($password, ' ') > 0)
{
show_message($_LANG['passwd_balnk']);
}
/* 验证码检查 */
if ((intval($_CFG['captcha']) & CAPTCHA_REGISTER) && gd_version() > 0 && 'wx' !== $wx)
{
if (empty($_POST['captcha']))
{
show_message($_LANG['invalid_captcha'], $_LANG['sign_up'], 'user.php?act=register', 'error');
}
/* 检查验证码 */
include_once('includes/cls_captcha.php');
$validator = new captcha();
if (!$validator->check_word($_POST['captcha']))
{
show_message($_LANG['invalid_captcha'], $_LANG['sign_up'], 'user.php?act=register', 'error');
}
}
if (register($username, $password, $email, $other,$birthday) !== false)
{
//echo '111';
//die;
/* Added by Jack, 2015.05.31 start */
if ($_CFG['ihuyi_sms_customer_registed'] == '1')
{
require_once(ROOT_PATH . 'includes/lib_sms.php');
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/sms.php');
$smarty->assign('shop_name', $_CFG['shop_name']);
$smarty->assign('user_name', $username);
$smarty->assign('user_pwd', $password);
$content = $smarty->fetch('str:' . $_CFG['ihuyi_sms_customer_registed_value']);
/* 发送注册成功短信提醒 */
$ret = sendsms($other['mobile_phone'], $content);
if($ret === true)
{
//插入注册成功短信提醒数据记录
$sql = "INSERT INTO " . $ecs->table('verify_code') . "(mobile, getip, verifycode, dateline, reguid, status) VALUES ('" . $other['mobile_phone'] . "', '" . real_ip() . "', '$password', '" . gmtime() ."', $_SESSION[user_id], 7)";
$db->query($sql);
}
}
$wxid = isset($_SESSION['wxid']) ? trim($_SESSION['wxid']) : '';
//echo 'wxid:'.$wxid;
//die;
if ( $wxid !== '' )
{
$wxnm = isset($_SESSION['wxnm']) ? $_SESSION['wxnm'] : '';
//echo $wxid;
//die();
//echo $ecs->table('weixin_user');
//die();
$sql = "INSERT INTO ".$ecs->table('weixin_user')." (uid, wxid, nickname) VALUES ('" . $_SESSION['user_id'] . "', '" . $wxid . "', '" . $wxnm ."')";
//echo $sql;
//die;
$db->query($sql);
}
$sql = "UPDATE " . $ecs->table('verify_code') . " SET reguid=" . $_SESSION['user_id'] . ",regdateline='" . gmtime() ."',status=2 WHERE mobile='$mobile' AND verifycode='$verifycode' AND getip='" . real_ip() . "' AND status=1 AND dateline>'" . gmtime() ."'-86400";
$db->query($sql);
/* Added by Jack, 2015.05.31 end */
/*把新注册用户的扩展信息插入数据库*/
$sql = 'SELECT id FROM ' . $ecs->table('reg_fields') . ' WHERE type = 0 AND display = 1 ORDER BY dis_order, id'; //读出所有自定义扩展字段的id
$fields_arr = $db->getAll($sql);
$extend_field_str = ''; //生成扩展字段的内容字符串
foreach ($fields_arr AS $val)
{
$extend_field_index = 'extend_field' . $val['id'];
if(!empty($_POST[$extend_field_index]))
{
$temp_field_content = strlen($_POST[$extend_field_index]) > 100 ? mb_substr($_POST[$extend_field_index], 0, 99) : $_POST[$extend_field_index];
$extend_field_str .= " ('" . $_SESSION['user_id'] . "', '" . $val['id'] . "', '" . $temp_field_content . "'),";
}
}
$extend_field_str = substr($extend_field_str, 0, -1);
if ($extend_field_str) //插入注册扩展数据
{
$sql = 'INSERT INTO '. $ecs->table('reg_extend_info') . ' (`user_id`, `reg_field_id`, `content`) VALUES' . $extend_field_str;
$db->query($sql);
}
$sql = 'UPDATE ' . $ecs->table('users') . " SET `birthday`='$birthday' WHERE `user_id`='" . $_SESSION['user_id'] . "'";
$db->query($sql);
/* 写入密码提示问题和答案 */
if (!empty($passwd_answer) && !empty($sel_question))
{
$sql = 'UPDATE ' . $ecs->table('users') . " SET `passwd_question`='$sel_question', `passwd_answer`='$passwd_answer' WHERE `user_id`='" . $_SESSION['user_id'] . "'";
$db->query($sql);
}
/* 判断是否需要自动发送注册邮件 */
if ($GLOBALS['_CFG']['member_email_validate'] && $GLOBALS['_CFG']['send_verify_email'])
{
send_regiter_hash($_SESSION['user_id']);
}
$ucdata = empty($user->ucdata)? "" : $user->ucdata;
show_message(sprintf($_LANG['register_success'], $username . $ucdata), array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act, 'user.php'), 'info');
}
else
{
$err->show($_LANG['sign_up'], 'user.php?act=register');
}
}
}
/* 验证用户注册邮件 */
elseif ($action == 'validate_email')
{
$hash = empty($_GET['hash']) ? '' : trim($_GET['hash']);
if ($hash)
{
include_once(ROOT_PATH . 'includes/lib_passport.php');
$id = register_hash('decode', $hash);
if ($id > 0)
{
$sql = "UPDATE " . $ecs->table('users') . " SET is_validated = 1 WHERE user_id='$id'";
$db->query($sql);
$sql = 'SELECT user_name, email FROM ' . $ecs->table('users') . " WHERE user_id = '$id'";
$row = $db->getRow($sql);
show_message(sprintf($_LANG['validate_ok'], $row['user_name'], $row['email']),$_LANG['profile_lnk'], 'user.php');
}
}
show_message($_LANG['validate_fail']);
}
/* 验证用户注册用户名是否可以注册 */
elseif ($action == 'is_registered')
{
include_once(ROOT_PATH . 'includes/lib_passport.php');
$username = trim($_GET['username']);
$username = json_str_iconv($username);
if ($user->check_user($username) || admin_registered($username))
{
echo 'false';
}
else
{
echo 'true';
}
}
/* 验证用户邮箱地址是否被注册 */
elseif($action == 'check_email')
{
$email = trim($_GET['email']);
if ($user->check_email($email))
{
echo 'false';
}
else
{
echo 'ok';
}
}
/* 用户登录界面 */
elseif ($action == 'login')
{
if (empty($back_act))
{
if (empty($back_act) && isset($GLOBALS['_SERVER']['HTTP_REFERER']))
{
$back_act = strpos($GLOBALS['_SERVER']['HTTP_REFERER'], 'user.php') ? './index.php' : $GLOBALS['_SERVER']['HTTP_REFERER'];
}
else
{
$back_act = 'user.php';
}
}
$captcha = intval($_CFG['captcha']);
if (($captcha & CAPTCHA_LOGIN) && (!($captcha & CAPTCHA_LOGIN_FAIL) || (($captcha & CAPTCHA_LOGIN_FAIL) && $_SESSION['login_fail'] > 2)) && gd_version() > 0)
{
$GLOBALS['smarty']->assign('enabled_captcha', 1);
$GLOBALS['smarty']->assign('rand', mt_rand());
}
$smarty->assign('back_act', $back_act);
$smarty->display('user_passport.dwt');
}
/* 处理会员的登录 */
elseif ($action == 'act_login')
{
$username = isset($_POST['username']) ? trim($_POST['username']) : '';
$password = isset($_POST['password']) ? trim($_POST['password']) : '';
$back_act = isset($_POST['back_act']) ? trim($_POST['back_act']) : '';
$captcha = intval($_CFG['captcha']);
if (($captcha & CAPTCHA_LOGIN) && (!($captcha & CAPTCHA_LOGIN_FAIL) || (($captcha & CAPTCHA_LOGIN_FAIL) && $_SESSION['login_fail'] > 2)) && gd_version() > 0)
{
if (empty($_POST['captcha']))
{
show_message($_LANG['invalid_captcha'], $_LANG['relogin_lnk'], 'user.php', 'error');
}
/* 检查验证码 */
include_once('includes/cls_captcha.php');
$validator = new captcha();
$validator->session_word = 'captcha_login';
if (!$validator->check_word($_POST['captcha']))
{
show_message($_LANG['invalid_captcha'], $_LANG['relogin_lnk'], 'user.php', 'error');
}
}
/* Added by Jack, 2015.05.31 start */
if ($_CFG['ihuyi_sms_mobile_log'] == '1')
{
require_once(ROOT_PATH . 'includes/lib_sms.php');
if (ismobile($username))
{
$sql = "SELECT user_name from " . $ecs->table('users') . " WHERE mobile_phone='$username'";
$row = $db->getRow($sql);
$username = $row['user_name'];
}
}
/* Added by Jack, 2015.05.31 end */
$login_type = intval($_POST['login_type']);
if($login_type ==1)
{
$email = $username;
/* 检查email */
if (empty($email))
{
show_message('登录邮箱不能为空', '请重新登录', 'user.php', 'error');
}
else
{
if (!is_email($email))
{
show_message('登录邮箱格式错误', '请重新登录', 'user.php', 'error');
}
}
$num = $db->getOne("select count(*) from " . $ecs->table('users') ." where email='$email' and password='" .md5($password) ."'" );
if($num ==1)
{
$row = $db->getRow("select user_id, user_name from " . $ecs->table('users') ." where email='$email' and password='" .md5($password) ."'");
if ($row)
{
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['user_name'] = $row['username'];
show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
else
{
$_SESSION['login_fail'] ++ ;
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php', 'error');
}
}
else
{
$num = $db->getOne("select count(*) from " . $ecs->table('users') ." where email='$email' " );
if($num==0)
{
show_message('此邮箱还未注册,您可以用此邮箱新注册一个会员帐号,如果您已有有本站会员帐号,请登录后填写邮箱后方可使用邮箱登录!', array('立即注册','重新登录'), array('user.php?act=register','user.php'), 'error');
}
elseif($num >1)
{
show_message('邮箱重复,请联系管理员验证专属你的邮箱!', array('立即用其它方式登录'), array('user.php?act=login'), 'error');
}
show_message('邮箱登录失败', '请重新登录', 'user.php', 'error');
}
}
if($login_type==2)
{
$mobile = $username;
if(!preg_match("/^13[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|189[0-9]{8}$/",$mobile))
{
show_message('手机号格式错误', '请重新登录', 'user.php', 'error');
}
$num = $db->getOne("select count(*) from " . $ecs->table('users') ." where mobile_phone='$mobile' and password='" .md5($password) ."'" );
if($num ==1)
{
$row = $db->getRow("select user_id, user_name from " . $ecs->table('users') ." where mobile_phone='$mobile' and password='" .md5($password) ."'");
if ($row)
{
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['user_name'] = $row['username'];
show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
else
{
$_SESSION['login_fail'] ++ ;
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php', 'error');
}
}
else
{
$num = $db->getOne("select count(*) from " . $ecs->table('users') ." where mobile_phone='$mobile' " );
if($num==0)
{
show_message('此手机号还未注册,您可以用此手机号新注册一个会员帐号,如果您已有有本站会员帐号,请登录后绑定手机号后方可使用手机登录!', array('立即注册此手机号','重新登录'), array('user.php?act=register&mobile='.$mobile,'user.php'), 'error');
}
elseif($num >1)
{
show_message('手机号重复,请联系管理员验证专属你的手机号!', array('立即用其它方式登录'), array('user.php?act=login'), 'error');
}
show_message('手机号登录失败', '请重新登录', 'user.php', 'error');
}
}
if($login_type==3)
{
$card_info = $db->getRow("select * from " . $ecs->table('user_card') ." where card_no='$username' and card_pass='$password' and is_show =1 " );
//var_dump($card_info);exit;
if($card_info)
{
$user_id = intval($card_info['user_id']);
if($user_id)
{
$user_name = $db->getOne("select user_name from " . $ecs->table('users') ." where user_id='$user_id'" );
if ($user_name)
{
$_SESSION['user_id'] = $user_id;
$_SESSION['user_name'] = $username;
show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
else
{
$_SESSION['login_fail'] ++ ;
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php', 'error');
}
}
else
{
$cu_user_name = 'cu_'.$card_info['card_no'];
$user_name = 'cu_'.$card_info['card_no'];
$email = $card_info['email']==''?$cu_user_name.'@temp.com':$card_info['email'];
$other = array();
include_once(ROOT_PATH . 'includes/lib_passport.php');
if (register($cu_user_name, $password, $email, $other) !== false)
{
$db->autoExecute($ecs->table('user_card'), array('user_id'=>$_SESSION['user_id'],'bind_time'=>gmtime(),'card_status'=>1), 'UPDATE', " id='$card_info[id]' ");
$ucdata = empty($user->ucdata)? "" : $user->ucdata;
show_message(sprintf($_LANG['login_success'], $cu_user_name . $ucdata), array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act, 'user.php'), 'info');
}
else
{
$_SESSION['login_fail'] ++ ;
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php', 'error');
}
}
}
else
{
$num = $db->getOne("select count(*) from " . $ecs->table('user_card') ." where card_no='$username' and card_pass ='$password' and user_id=0 and is_show=1 " );
if($num==1)
{
show_message('此卡号还未绑定,您可以用此新注册一个会员帐号并绑定此卡号,如果您已有本站会员帐号,请登录后在会员中心绑定此卡号后方可登录!', array('立即注册并绑定此卡号','重新登录'), array('user.php?act=register&card_no='.$username.'&card_pass='.$password,'user.php'), 'error');
}
show_message('会员卡卡号不存在', '请重新登录', 'user.php', 'error');
}
}
if(is_email($username))
{
$sql ="select user_name from ".$ecs->table('users')." where email='".$username."'";
$username_e = $db->getOne($sql);
if($username_e) $username=$username_e;
}
if(is_telephone($username))
{
$sql ="select user_name from ".$ecs->table('users')." where mobile_phone='".$username."'";
$username_e = $db->getOne($sql);
if($username_e) $username=$username_e;
}
if ($user->login($username, $password,isset($_POST['remember'])))
{
update_user_info();
recalculate_price();
//$todate = $db->getOne("select to_date from ".$ecs->table("users")." where user_id=".$_SESSION['user_id']);
$sql = "select to_date from ".$ecs->table("users") . " where member_novalid ='1' and user_id='".$_SESSION['user_id'] ."'";
$member_novalid = $db->getOne($sql);
if( !empty($member_novalid) and $member_novalid < gmtime()){ //判断合同期限
$_SESSION['is_login_tip'] = '1';
}
$ucdata = isset($user->ucdata)? $user->ucdata : '';
/*if ( false === strpos($back_act, "?")){
$back_act .= "?1=1";
}
$back_act .= "&euser=".$username;
*/
$row = $db->getRow("select user_name,avatar, alias,rank_points from " . $ecs->table('users') ." where user_id='".$_SESSION['user_id'] ."'");
if ($row)
{
$_SESSION['avatar'] = $row['avatar'];
$_SESSION['alias'] = $row['alias'];
$huiyuanrow = $db->getRow("SELECT rank_id, rank_name FROM " . $ecs->table('user_rank') ." WHERE min_points<=".$row['rank_points'] ." AND max_points>=".$row['rank_points'] ." and special_rank=0 ");
if($huiyuanrow)
{
$_SESSION['rankname'] = $huiyuanrow['rank_name'];
$_SESSION['rankid'] = $huiyuanrow['rank_id'];
}
}
$wxid = isset($_SESSION['wxid']) ? trim($_SESSION['wxid']) : '';
if ( $wxid !== '' )
{
//echo '123';
//die;
$wxnm = isset($_SESSION['wxnm']) ? $_SESSION['wxnm'] : '';
$sql = "select wxid from ".$ecs->table('weixin_user')." where `uid` = '".$_SESSION['user_id']."' ";
//echo $sql;
//die;
$row = $db->getOne($sql);
if (empty($row)){
$sql = "INSERT INTO " . $ecs->table('weixin_user') . "(uid, wxid, nickname) VALUES ('" . $_SESSION['user_id'] . "', '" . $wxid . "', '" . $wxnm ."')";
}else{
$sql = "update ".$ecs->table('weixin_user') ." set `wxid` = '".$wxid."', `nickname` = '".$wxnm."' where `uid` = '" . $_SESSION['user_id']."'";
}
//echo $sql;
//die;
$db->query($sql);
}
show_login_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
else
{
$_SESSION['login_fail'] ++ ;
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php', 'error');
}
}
// 微信
elseif ($action == 'act_login_wechat')
{
$wxid = isset($_GET['wxid']) ? trim($_GET['wxid']) : '';
$wxnm = isset($_GET['wxnm']) ? trim($_GET['wxnm']) : '';
$password = isset($_POST['password']) ? trim($_POST['password']) : '';
$back_act = isset($_GET['back_act']) ? trim($_GET['back_act']) : '';
//echo $wxid.'<br /><br />';
$row = $db->getRow("select uid from " . $ecs->table('weixin_user') ." where wxid='$wxid'");
if ($row)
{
$uid = $row['uid'];
//echo $row['uid'].'<br /><br />';
$row = $row = $db->getRow("select user_id, user_name from " . $ecs->table('users') ." where user_id='$uid'");
if ($row)
{
$username = $row['user_name'];
//echo $row['user_name'].'<br /><br />';
//echo $row['uid'].'<br /><br />';
}
}else {
ecs_header("Location:user.php?fromwx\n");
die;
}
//$username = isset($_POST['username']) ? trim($_POST['username']) : '';
$captcha = intval($_CFG['captcha']);
/* Added by Jack, 2015.05.31 start */
if ($_CFG['ihuyi_sms_mobile_log'] == '1')
{
require_once(ROOT_PATH . 'includes/lib_sms.php');
if (ismobile($username))
{
$sql = "SELECT user_name from " . $ecs->table('users') . " WHERE mobile_phone='$username'";
$row = $db->getRow($sql);
$username = $row['user_name'];
}
}
/* Added by Jack, 2015.05.31 end */
$login_type = intval($_POST['login_type']);
if($login_type ==1)
{
$email = $username;
/* 检查email */
if (empty($email))
{
show_message('登录邮箱不能为空', '请重新登录', 'user.php', 'error');
}
else
{
if (!is_email($email))
{
show_message('登录邮箱格式错误', '请重新登录', 'user.php', 'error');
}
}
$num = $db->getOne("select count(*) from " . $ecs->table('users') ." where email='$email' and password='" .md5($password) ."'" );
if($num ==1)
{
$row = $db->getRow("select user_id, user_name from " . $ecs->table('users') ." where email='$email' and password='" .md5($password) ."'");
if ($row)
{
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['user_name'] = $row['username'];
show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
else
{
$_SESSION['login_fail'] ++ ;
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php', 'error');
}
}
else
{
$num = $db->getOne("select count(*) from " . $ecs->table('users') ." where email='$email' " );
if($num==0)
{
show_message('此邮箱还未注册,您可以用此邮箱新注册一个会员帐号,如果您已有有本站会员帐号,请登录后填写邮箱后方可使用邮箱登录!', array('立即注册','重新登录'), array('user.php?act=register','user.php'), 'error');
}
elseif($num >1)
{
show_message('邮箱重复,请联系管理员验证专属你的邮箱!', array('立即用其它方式登录'), array('user.php?act=login'), 'error');
}
show_message('邮箱登录失败', '请重新登录', 'user.php', 'error');
}
}
if($login_type==2)
{
$mobile = $username;
if(!preg_match("/^13[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|189[0-9]{8}$/",$mobile))
{
show_message('手机号格式错误', '请重新登录', 'user.php', 'error');
}
$num = $db->getOne("select count(*) from " . $ecs->table('users') ." where mobile_phone='$mobile' and password='" .md5($password) ."'" );
if($num ==1)
{
$row = $db->getRow("select user_id, user_name from " . $ecs->table('users') ." where mobile_phone='$mobile' and password='" .md5($password) ."'");
if ($row)
{
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['user_name'] = $row['username'];
show_message($_LANG['login_success'] . $ucdata , array($_LANG['back_up_page'], $_LANG['profile_lnk']), array($back_act,'user.php'), 'info');
}
else
{
$_SESSION['login_fail'] ++ ;
show_message($_LANG['login_failure'], $_LANG['relogin_lnk'], 'user.php', 'error');
}
}
else
{
$num = $db->getOne("select count(*) from " . $ecs->table('users') ." where mobile_phone='$mobile' " );
if($num==0)
{
show_message('此手机号还未注册,您可以用此手机号新注册一个会员帐号,如果您已有有本站会员帐号,请登录后绑定手机号后方可使用手机登录!', array('立即注册此手机号','重新登录'), array('user.php?act=register&mobile='.$mobile,'user.php'), 'error');
}
elseif($num >1)
{
show_message('手机号重复,请联系管理员验证专属你的手机号!', array('立即用其它方式登录'), array('user.php?act=login'), 'error');
}
show_message('手机号登录失败', '请重新登录', 'user.php', 'error');
}
}
if($login_type==3)
{
$card_info = $db->getRow("select * from " . $ecs->table('user_card') ." where card_no='$username' and card_pass='$password' and is_show =1 " );
//var_dump($card_info);exit;
if($card_info)
{
$user_id = intval($card_info['user_id']);