commit | author | age
|
e2b48d
|
1 |
<?php |
B |
2 |
|
|
3 |
define('IN_ECS', true); |
|
4 |
|
|
5 |
require('../includes/init.php'); |
|
6 |
include('../includes/cls_json.php'); |
|
7 |
$json = new JSON; |
|
8 |
/* 载入语言文件 */ |
|
9 |
require_once('../languages/zh_cn/user.php'); |
|
10 |
|
|
11 |
//$user_id = $_SESSION['user_id']; |
|
12 |
|
|
13 |
if ($_POST['act'] == 'signin' && $_POST['acr'] == 'app') |
|
14 |
{ |
|
15 |
|
|
16 |
$username = !empty($_POST['user']) ? trim($_POST['user']) : ''; |
|
17 |
$password = !empty($_POST['pwd']) ? trim($_POST['pwd']) : ''; |
|
18 |
$result = array('code' => 0, 'info' => ''); |
|
19 |
|
|
20 |
if ($user->login($username, $password)) |
|
21 |
{ |
|
22 |
update_user_info(); //更新用户信息 |
|
23 |
recalculate_price(); // 重新计算购物车中的商品价格 |
|
24 |
//$smarty->assign('user_info', get_user_info()); |
|
25 |
$result['code'] = 1; |
|
26 |
|
|
27 |
$user = get_user_info(); |
|
28 |
/*查找代付款的数据 jx*/ |
|
29 |
$user_id = $user['user_id']; |
|
30 |
$sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('order_info')."WHERE user_id = '$user_id' AND pay_status = 0 AND order_status != 2 "; |
|
31 |
$user['payment'] = $GLOBALS['db']->getOne($sql); |
|
32 |
/*查找代发货的数据 jx*/ |
|
33 |
$sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('order_info')."WHERE user_id = '$user_id' AND shipping_status = 0 AND order_status != 2"; |
|
34 |
$user['deliver'] = $GLOBALS['db']->getOne($sql); |
|
35 |
/*查找代收货的数据 jx*/ |
|
36 |
$sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('order_info')."WHERE user_id = '$user_id' AND shipping_status = 1 AND order_status != 2"; |
|
37 |
$user['receipt'] = $GLOBALS['db']->getOne($sql); |
|
38 |
/*查找全部订单数据 jx*/ |
|
39 |
$sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('order_info')."WHERE user_id = '$user_id'"; |
|
40 |
$user['quan'] = $GLOBALS['db']->getOne($sql); |
|
41 |
$result['info']=$user; |
|
42 |
// $ucdata = empty($user->ucdata)? "" : $user->ucdata; |
|
43 |
//$result['ucdata'] = $ucdata; |
|
44 |
} |
|
45 |
else |
|
46 |
{ |
|
47 |
$result['info'] = $_LANG['login_failure']; |
|
48 |
} |
|
49 |
die($json->encode($result)); |
|
50 |
} |
|
51 |
elseif($_POST['act'] == 'oath_login') |
|
52 |
{ |
|
53 |
$result = array('code' => 0, 'info' => ''); |
|
54 |
// file_put_contents('1.txt','weibo:'.var_export($_REQUEST,true)); |
|
55 |
$type = empty($_POST['type']) ? '' : trim($_POST['type']); |
|
56 |
$openid = $_POST['openid']; |
|
57 |
$access_token = $_POST['access_token']; |
|
58 |
if(empty($type) || empty($openid) || empty($access_token)) |
|
59 |
{ |
|
60 |
$result['info'] = '参数错误'; |
|
61 |
die(json_encode($result)); |
|
62 |
} |
|
63 |
include_once(ROOT_PATH . 'json/includes/website/jntoo.php'); |
|
64 |
$c = &website($type); |
|
65 |
if($c) |
|
66 |
{ |
|
67 |
$c->setOpenId($openid); |
|
68 |
$c->setAccessToken(array('access_token'=>$access_token)); |
|
69 |
$info = $c->getMessage(); |
|
70 |
} |
|
71 |
else |
|
72 |
{ |
|
73 |
$result['info'] = '服务器错误'; |
|
74 |
die(json_encode($result)); |
|
75 |
} |
|
76 |
|
|
77 |
$count = $db->getOne('SELECT COUNT(*) FROM '.$ecs->table('users').' WHERE aite_id="'.$info['aite_id'].'"'); |
|
78 |
|
|
79 |
if($count == 0) |
|
80 |
{ |
|
81 |
$sql = 'INSERT INTO '.$ecs->table('users').'(user_name,password,aite_id,sex,alias,reg_time,froms) VALUES("'.$type.'_'.rand().'","'.MD5($info['aite_id']).'","'.$info['aite_id'].'","'.$info['sex'].'","'.$info['alias'].'","'.time().'","app")'; |
|
82 |
$try = 0; |
|
83 |
while(!$db->query($sql) && $try < 10) |
|
84 |
{ |
|
85 |
$try ++; |
|
86 |
} |
|
87 |
$user_id = $db->insert_id(); |
|
88 |
$_SESSION['user_id'] = $user_id; |
|
89 |
} |
|
90 |
else if($count == 1) |
|
91 |
{ |
|
92 |
$user_id = $db->getOne('SELECT user_id FROM '.$ecs->table('users').' WHERE aite_id="'.$aite_id.'"'); |
|
93 |
$_SESSION['user_id'] = $user_id; |
|
94 |
} |
|
95 |
else |
|
96 |
{ |
|
97 |
$result['info'] = '未知错误'; |
|
98 |
die(json_encode($result)); |
|
99 |
} |
|
100 |
|
|
101 |
update_user_info(); //更新用户信息 |
|
102 |
recalculate_price(); // 重新计算购物车中的商品价格 |
|
103 |
//$smarty->assign('user_info', get_user_info()); |
|
104 |
$result['code'] = 1; |
|
105 |
|
|
106 |
$user = get_user_info(); |
|
107 |
/*查找代付款的数据 jx*/ |
|
108 |
$user_id = $user['user_id']; |
|
109 |
$sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('order_info')."WHERE user_id = '$user_id' AND pay_status = 0 AND order_status != 2 "; |
|
110 |
$user['payment'] = $GLOBALS['db']->getOne($sql); |
|
111 |
/*查找代发货的数据 jx*/ |
|
112 |
$sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('order_info')."WHERE user_id = '$user_id' AND shipping_status = 0 AND order_status != 2"; |
|
113 |
$user['deliver'] = $GLOBALS['db']->getOne($sql); |
|
114 |
/*查找代收货的数据 jx*/ |
|
115 |
$sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('order_info')."WHERE user_id = '$user_id' AND shipping_status = 1 AND order_status != 2"; |
|
116 |
$user['receipt'] = $GLOBALS['db']->getOne($sql); |
|
117 |
/*查找全部订单数据 jx*/ |
|
118 |
$sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('order_info')."WHERE user_id = '$user_id'"; |
|
119 |
$user['quan'] = $GLOBALS['db']->getOne($sql); |
|
120 |
$result['info']=$user; |
|
121 |
//file_put_contents('1.txt',var_export($result,true)); |
|
122 |
die(json_encode($result)); |
|
123 |
// $ucdata = empty($user->ucdata)? "" : $user->ucdata; |
|
124 |
//$result['ucdata'] = $ucdata; |
|
125 |
} |
|
126 |
elseif($_POST['act'] == 'getinfo'){ |
|
127 |
$result = array('code' => 0, 'info' => ''); |
|
128 |
$userid = intval($_POST['user_id']); |
|
129 |
if($userid > 0){ |
|
130 |
$result['code'] = 1; |
|
131 |
$result['info']=get_user_info($userid); |
|
132 |
}else{ |
|
133 |
$result['info']='用户信息获取失败,请重新登陆!'; |
|
134 |
} |
|
135 |
die($json->encode($result)); |
|
136 |
}else |
|
137 |
{ |
|
138 |
$redirect_url = "http://".$_SERVER["HTTP_HOST"].str_replace("user.php", "index.php"); |
|
139 |
header('Location: '.$redirect_url); |
|
140 |
} |
|
141 |
?> |