$smarty = new cls_template(); $smarty->cache_lifetime = $_CFG['cache_time']; $smarty->template_dir = ROOT_PATH . 'wap/templates'; $smarty->cache_dir = ROOT_PATH . 'temp/caches'; $smarty->compile_dir = ROOT_PATH . 'temp/compiled/wap'; if ((DEBUG_MODE & 2) == 2) { $smarty->direct_output = true; $smarty->force_compile = true; } else { $smarty->direct_output = false; $smarty->force_compile = false; } } if (!defined('INIT_NO_USERS')) { /* 会员信息 */ $user =& init_users(); if (empty($_SESSION['user_id'])) { if ($user->get_cookie()) { /* 如果会员已经登录并且还没有获得会员的帐户余额、积分以及优惠券 */ if ($_SESSION['user_id'] > 0 && !isset($_SESSION['user_money'])) { update_user_info(); } } else { $_SESSION['user_id'] = 0; $_SESSION['user_name'] = ''; $_SESSION['email'] = ''; $_SESSION['user_rank'] = 0; $_SESSION['discount'] = 1.0; } } }
load_file(ROOT_PATH . 'include/base/function.php'); /* 初始化数据库类 */ require (ROOT_PATH . 'include/EcModel.class.php'); $db = new EcModel(C('DB')); /* 初始化session */ require (ROOT_PATH . 'include/library/EcsApiSession.class.php'); $sess_name = defined("SESS_NAME") ? SESS_NAME : 'ECS_ID'; $sess = new EcsApiSession($db, $db->pre .'sessions', $db->pre . 'sessions_data', $sess_name); /* 载入系统参数 */ $_CFG = load_config_uc(); C('CFG', $_CFG); /* 初始化用户插件 */ $user = init_users(); header('Content-type: text/html; charset=' . EC_CHARSET); // 数据验证 if (! defined('IN_UC')) { error_reporting(0); set_magic_quotes_runtime(0); defined('MAGIC_QUOTES_GPC') || define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()); $_DCACHE = $get = $post = array(); $code = @$_GET['code']; parse_str(_authcode($code, 'DECODE', UC_KEY), $get); if (MAGIC_QUOTES_GPC) { $get = _stripslashes($get);
admin_log(addslashes($username), 'edit', 'users'); make_json_result(stripcslashes($email)); } else { $msg = $users->error == ERR_EMAIL_EXISTS ? $GLOBALS['_LANG']['email_exists'] : $GLOBALS['_LANG']['edit_user_failed']; make_json_error($msg); } } else { make_json_error($GLOBALS['_LANG']['invalid_email']); } } elseif ($_REQUEST['act'] == 'remove') { /* 检查权限 */ admin_priv('users_drop'); $sql = "SELECT user_name FROM " . $ecs->table('users') . " WHERE user_id = '" . $_GET['id'] . "'"; $username = $db->getOne($sql); /* 通过插件来删除用户 */ $users =& init_users(); $users->remove_user($username); //已经删除用户所有数据 /* 记录管理员操作 */ admin_log(addslashes($username), 'remove', 'users'); /* 提示信息 */ $link[] = array('text' => $_LANG['go_back'], 'href' => 'users.php?act=list'); sys_msg(sprintf($_LANG['remove_success'], $username), 0, $link); } elseif ($_REQUEST['act'] == 'address_list') { $id = isset($_GET['id']) ? intval($_GET['id']) : 0; $sql = "SELECT a.*, c.region_name AS country_name, p.region_name AS province, ct.region_name AS city_name, d.region_name AS district_name " . " FROM " . $ecs->table('user_address') . " as a " . " LEFT JOIN " . $ecs->table('region') . " AS c ON c.region_id = a.country " . " LEFT JOIN " . $ecs->table('region') . " AS p ON p.region_id = a.province " . " LEFT JOIN " . $ecs->table('region') . " AS ct ON ct.region_id = a.city " . " LEFT JOIN " . $ecs->table('region') . " AS d ON d.region_id = a.district " . " WHERE user_id='{$id}'"; $address = $db->getAll($sql); $smarty->assign('address', $address); assign_query_info(); $smarty->assign('ur_here', $_LANG['address_list']); $smarty->assign('action_link', array('text' => $_LANG['01_users_list'], 'href' => 'users.php?act=list&' . list_link_postfix()));
protected function ecshop_init() { header('Cache-control: private'); header('Content-type: text/html; charset=utf-8'); $shop_closed = C('shop_closed'); if (!empty($shop_closed)) { $close_comment = C('close_comment'); $close_comment = empty($close_comment) ? 'closed.' : $close_comment; exit($close_comment); } //NULL // 初始化session self::$sess = new EcsSession(self::$db, self::$ecs->table('sessions'), self::$ecs->table('sessions_data'), 'ecsid'); define('SESS_ID', self::$sess->get_session_id()); // 创建 Smarty 对象 self::$view = new EcsTemplate(); self::$view->cache_lifetime = C('cache_time'); self::$view->template_dir = ROOT_PATH . 'themes/' . C('template'); self::$view->cache_dir = ROOT_PATH . 'data/cache/caches'; self::$view->compile_dir = ROOT_PATH . 'data/cache/compiled'; if ((DEBUG_MODE & 2) == 2) { self::$view->direct_output = true; self::$view->force_compile = true; } else { self::$view->direct_output = false; self::$view->force_compile = false; } self::$view->caching = true; // 会员信息 self::$user = init_users(); if (empty($_SESSION['user_id'])) { if (self::$user->get_cookie()) { // 如果会员已经登录并且还没有获得会员的帐户余额、积分以及优惠券 if ($_SESSION['user_id'] > 0 && !isset($_SESSION['user_money'])) { model('Users')->update_user_info(); } } else { $_SESSION['user_id'] = 0; $_SESSION['user_name'] = ''; $_SESSION['email'] = ''; $_SESSION['user_rank'] = 0; $_SESSION['discount'] = 1.0; } } // 判断是否支持gzip模式 if (gzip_enabled()) { ob_start('ob_gzhandler'); } // 设置推荐会员 if (isset($_GET['u'])) { set_affiliate(); } // session不存在,检查cookie if (!empty($_COOKIE['ECS']['user_id']) && !empty($_COOKIE['ECS']['password'])) { // 找到cookie,验证信息 $where['user_id'] = $_COOKIE['ECS']['user_id']; $where['password'] = $_COOKIE['ECS']['password']; $row = $this->model->table('users')->field('user_id, user_name, password')->where($where)->find(); if ($row) { $_SESSION['user_id'] = $row['user_id']; $_SESSION['user_name'] = $row['user_name']; model('Users')->update_user_info(); } else { // 没有找到这个记录 $time = time() - 3600; setcookie("ECS[user_id]", '', $time, '/'); setcookie("ECS[password]", '', $time, '/'); } } // search 关键词 $search_keywords = C('search_keywords'); if (!empty($search_keywords) && is_string($search_keywords)) { $keywords = explode(',', $search_keywords); $this->assign('hot_search_keywords', $keywords); } // 模板替换 defined('__TPL__') or define('__TPL__', __ROOT__ . '/themes/' . C('template')); $stylename = C('stylename'); if (!empty($stylename)) { $this->assign('ectouch_css_path', __ROOT__ . '/themes/' . C('template') . '/css/ectouch_' . C('stylename') . '.css'); } else { $this->assign('ectouch_css_path', __ROOT__ . '/themes/' . C('template') . '/css/ectouch.css'); } }
public function act_edit_password () { checkLogin(); include_once(RPC_ROOT . 'includes/lib_passport.php'); $old_password = isset($_GET['old_password']) ? trim($_GET['old_password']) : null; $new_password = isset($_GET['new_password']) ? trim($_GET['new_password']) : ''; $user =& init_users(); $user_id = intval($_SESSION['user_id']); if(isset($_SESSION['user_name'])) { $user_name = $_SESSION['user_name']; }else { $user_info = $user->get_profile_by_id($user_id); $user_name = $user_info['user_name']; } if($user->check_user($user_name, $old_password)) { if ($user->edit_user(array('username'=> $user_name, 'old_password'=>$old_password, 'password'=>$new_password), 1)) { $msg = rpcLang('user.php','edit_password_success'); $code = '0'; }else { $msg = rpcLang('user.php','edit_password_failure'); $code = '1'; } }else { $msg = rpcLang('user.php','edit_password_failure'); $code = '1'; } jsonExit("{\"status\":\"$msg\",\"code\":\"$code\"}"); }
/** * * Enter description here ... * @param unknown_type $user_name * @param unknown_type $user_pwd * @param int $integrate_id 第三方的数据ID * $user = array( 'integrate_id' => $uid, 'email' => $email, 'user_name' => $uname, 'password' => $passwordmd5, 'info' => $this->error, ); */ public function getUser($user_name_or_email, $user_pwd, $integrate_id = 0) { //int $isuid isuid 0:username; 1:uid; 2:email if ($integrate_id > 0) { $isuid = 1; } else { if (FS('Validate')->email($user_name_or_email)) { $isuid = 2; } else { $isuid = 0; } } //$isuid = 0; $users =& init_users($this->integrate_code, $this->integrate_config); $result = $users->getUser($user_name_or_email, $user_pwd, $isuid, $integrate_id); $this->info = $users->error; return $result; }
admin_log(addslashes($username), 'edit', 'users'); make_json_result(stripcslashes($email)); } else { $msg = $users->error == ERR_EMAIL_EXISTS ? $GLOBALS['_LANG']['email_exists'] : $GLOBALS['_LANG']['edit_user_failed']; make_json_error($msg); } } else { make_json_error($GLOBALS['_LANG']['invalid_email']); } } elseif ($_REQUEST['act'] == 'remove') { /* 检查权限 */ admin_priv('users_drop'); $sql = "SELECT user_name FROM " . $ecs->table('users') . " WHERE user_id = '" . $_GET['id'] . "'"; $username = $db->getOne($sql); /* 通过插件来删除用户 */ $users = init_users(); $users->remove_user($username); //已经删除用户所有数据 /* 记录管理员操作 */ admin_log(addslashes($username), 'remove', 'users'); /* 提示信息 */ $link[] = array('text' => $_LANG['go_back'], 'href' => 'users.php?act=list'); sys_msg(sprintf($_LANG['remove_success'], $username), 0, $link); } elseif ($_REQUEST['act'] == 'address_list') { $id = isset($_GET['id']) ? intval($_GET['id']) : 0; $sql = "SELECT a.*, c.region_name AS country_name, p.region_name AS province, ct.region_name AS city_name, d.region_name AS district_name " . " FROM " . $ecs->table('user_address') . " as a " . " LEFT JOIN " . $ecs->table('region') . " AS c ON c.region_id = a.country " . " LEFT JOIN " . $ecs->table('region') . " AS p ON p.region_id = a.province " . " LEFT JOIN " . $ecs->table('region') . " AS ct ON ct.region_id = a.city " . " LEFT JOIN " . $ecs->table('region') . " AS d ON d.region_id = a.district " . " WHERE user_id='{$id}'"; $address = $db->getAll($sql); $smarty->assign('address', $address); assign_query_info(); $smarty->assign('ur_here', $_LANG['address_list']); $smarty->assign('action_link', array('text' => $_LANG['03_users_list'], 'href' => 'users.php?act=list&' . list_link_postfix()));
function bindUser($wxid, $email, $pwd, $username = '') { if ($this->isBindUser($wxid)) { $GLOBALS['err']->add("用户已经绑定"); return false; } include_once '../includes/lib_passport.php'; $condi = $username ? "email='{$email}' or user_name='{$username}'" : "email='{$email}'"; $user = $GLOBALS['db']->getRow("SELECT * FROM " . $GLOBALS['ecs']->table('users') . " where {$condi}"); if ($user) { $userObj =& init_users(); if ($user['password'] == md5($pwd) || $userObj->login($user['user_name'], $pwd)) { $_SESSION['user_id'] = $user['user_id']; } else { $GLOBALS['err']->add("密码错误"); return false; } } else { $username = $username ? $username : "******" . date('md') . mt_rand(1, 99999); if (register($username, $pwd, $email, array()) === false) { //通过 $GLOBALS['err']->last_message(); 获取错误提示内容 return false; } } $user_id = intval($_SESSION['user_id']); if ($GLOBALS['db']->getOne("select ecuid from " . $GLOBALS['ecs']->table('weixin_user') . " where ecuid='{$user_id}'")) { $GLOBALS['err']->add("该用户已经绑定过其他微信帐号!"); return false; } $id = $GLOBALS['db']->getOne("select uid from " . $GLOBALS['ecs']->table('weixin_user') . " where fake_id='{$wxid}'"); if ($id > 0) { $sql = "update " . $GLOBALS['ecs']->table('weixin_user') . " set ecuid={$user_id},isfollow=1 where fake_id='{$wxid}'"; } else { $createtime = time(); $createymd = date('Y-m-d'); $sql = "insert into " . $GLOBALS['ecs']->table('weixin_user') . " (`ecuid`,`fake_id`,`createtime`,`createymd`,`isfollow`) \n\t\t\t\tvalue ({$user_id},'{$wxid}','{$createtime}','{$createymd}',1)"; } $GLOBALS['db']->query($sql); return true; }
function action_remove() { // 全局变量 $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; /* 检查权限 */ admin_priv('users_drop'); $sql = "SELECT user_name FROM " . $ecs->table('users') . " WHERE user_id = '" . $_GET['id'] . "'"; $username = $db->getOne($sql); /* 通过插件来删除用户 */ $users =& init_users(); $users->remove_user($username); // 已经删除用户所有数据 /* 记录管理员操作 */ admin_log(addslashes($username), 'remove', 'users'); /* 提示信息 */ $link[] = array('text' => $_LANG['go_back'], 'href' => 'users.php?act=list'); sys_msg(sprintf($_LANG['remove_success'], $username), 0, $link); }
/** * 行为操作 */ public function action() { if (IS_POST) { $data = I('post.data'); $rs = Check::rule(array(Check::must($data['username']), '用户名不能为空'), array(Check::must($data['password']), '请输入密码')); if ($rs !== true) { show_message($rs, '会员绑定', url('wechat/plugin_show', array('name' => $this->plugin_name))); } if (!isset($_SESSION['openid'])) { show_message('您未登陆,不能进行绑定操作!', '首页', url('index/index')); } //会员信息 $user = init_users(); if (empty($_SESSION['user_id'])) { if ($user->get_cookie()) { // 如果会员已经登录并且还没有获得会员的帐户余额、积分以及优惠券 if ($_SESSION['user_id'] > 0 && !isset($_SESSION['user_money'])) { model('Users')->update_user_info(); } } else { $_SESSION['user_id'] = 0; $_SESSION['user_name'] = ''; $_SESSION['email'] = ''; $_SESSION['user_rank'] = 0; $_SESSION['discount'] = 1.0; } } $old_uid = $_SESSION['user_id']; if ($user->login($data['username'], $data['password'], '')) { //绑定 $unionid = model('Base')->model->table('wechat_user')->field('unionid')->where('openid = "' . $_SESSION['openid'] . '"')->getOne(); if ($unionid) { model('Base')->model->table('wechat_user')->data('ect_uid = ' . $_SESSION['user_id'])->where('unionid = "' . $unionid . '"')->update(); } else { model('Base')->model->table('wechat_user')->data('ect_uid = ' . $_SESSION['user_id'])->where('openid = "' . $_SESSION['openid'] . '"')->update(); } model('Users')->update_user_info(); model('Users')->recalculate_price(); show_message('您的帐号:' . $data['username'] . '已绑定成功', '返回首页', url('index/index')); } else { if ($user->add_user($data['username'], $data['password'], time() . '@qq.com', '0', '0', time())) { if ($user->login($data['username'], $data['password'], '')) { model('Users')->update_user_info(); model('Users')->recalculate_price(); //绑定 $unionid = model('Base')->model->table('wechat_user')->field('unionid')->where('openid = "' . $_SESSION['openid'] . '"')->getOne(); if ($unionid) { model('Base')->model->table('wechat_user')->data('ect_uid = ' . $_SESSION['user_id'])->where('unionid = "' . $unionid . '"')->update(); } else { model('Base')->model->table('wechat_user')->data('ect_uid = ' . $_SESSION['user_id'])->where('openid = "' . $_SESSION['openid'] . '"')->update(); } show_message('您的新帐号:' . $data['username'] . '注册并绑定成功', '返回首页', url('index/index')); } else { show_message('登陆失败,请用已注册会员进行重新绑定', '返回会员绑定', url('wechat/plugin_show', array('name' => $this->plugin_name))); } } else { show_message('注册失败!会员名或已存在', '返回会员绑定', url('wechat/plugin_show', array('name' => $this->plugin_name))); } } } }