/** * tm用户直接在o2o登陆 * @$username 用户名 * @$password 密码 **/ public function post_tm_user($username, $password) { if (!$username || !$password) { return 0; } //发送数据 $lu_compile = new lu_compile(); $data = $lu_compile->encrypt('username='******'&password='******''); //dump('username='******'&password='******''); $returnData = $this->post($data, $this->check_url); //dump($returnData); if (strlen($returnData) > 1) { $returnData = $lu_compile->decrypt(urldecode($returnData)); } //dump($returnData); //判断并插入数据 if ($returnData == '1') { return $this->add_agency(TMUSER . $username, $password, $username . '@163.com', '0'); } elseif ($returnData == '0') { return 0; } else { parse_str($returnData, $arr); $agencyNameId = $this->add_agency(TMUSER . $arr['username'], $arr['password'], $arr['username'] . '@163.com', '0', '1'); return $this->add_user(TMUSER . $username, $password, $username . '@163.com', $agencyNameId); } }
/** * 验证用户信息 * $user_info 加密后的用户信息 * return 失败 false **/ private function check_user($user_info) { $obj = new lu_compile(); $user = $obj->decrypt($user_info); $user_arr = explode('-', $user); if (!$user_arr) { return false; } $user_id = $this->db->getOne("SELECT user_id FROM " . $this->ecs->table('users') . " WHERE user_id = {$user_arr['0']} AND user_name = '{$user_arr['1']}'"); #进行数据库查询对比 if ($user_id) { $GLOBALS['user']->set_session($user_arr[1]); $this->user_id = $user_id; //成功 } else { return false; //失败 } }
/** * 重定向登陆 **/ function redirect($lg) { if (!$lg) { return false; } include_once 'lu_compile.php'; include_once 'tm_user.php'; $tm_use_obj = new tm_user(); $obj = new lu_compile(); $username = current($obj->turn_arr($obj->decrypt($lg))); $tm_use_obj->tm_login($username); }
<?php /** * 接收天猫修改密码通知信息 * 2014-07-15 * **/ define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; $data = isset($_REQUEST['data']) ? $_REQUEST['data'] : ''; if (!$data) { return false; } $obj = new lu_compile(); $data = $obj->decrypt($data); parse_str($data, $res); $username = TMUSER . $res[username]; $user_id = $db->getOne("select user_id from " . $ecs->table('users') . " where user_name = '{$username}' and password = '******'password_old']}'"); if (!$user_id) { echo '0'; die; } else { $password = md5($res['password_new']); $start = $db->query("update " . $ecs->table('users') . " set password = '******' where user_id={$user_id}"); echo $start ? '1' : '0'; die; }