Exemplo n.º 1
0
function weixin_oauth($callback, $scope = 'BASE')
{
    global $db;
    $rs = $db->getRow("SELECT * FROM `wxch_config` WHERE `id` = 1");
    $param['appid'] = $rs['appid'];
    $oauth = intval($_REQUEST['oauth']);
    if ($oauth == 0) {
        $param['redirect_uri'] = $callback . (strpos($callback, '?') > 0 ? '&' : '?') . 'oauth=1';
        $param['response_type'] = 'code';
        if ($scope == 'INFO') {
            $param['scope'] = 'snsapi_userinfo';
        } else {
            $param['scope'] = 'snsapi_base';
        }
        $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?' . http_build_query($param) . '#wechat_redirect';
        ecs_header("Location: {$url}\n");
        exit;
    } elseif ($oauth == 1) {
        $param['secret'] = $rs['appsecret'];
        $param['code'] = $_REQUEST['code'];
        $param['grant_type'] = 'authorization_code';
        $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?' . http_build_query($param);
        $content = file_get_contents($url);
        $token = json_decode($content, true);
        $user_info = $db->getRow("SELECT * FROM `wxch_user` WHERE `wxid` = '{$token[openid]}'");
        if (empty($user_info)) {
            //register
            if (register_openid($token['openid'])) {
                $user_info = $GLOBALS['user']->get_user_info($user_info['openid']);
            } else {
                return false;
            }
        } else {
            //login
            $user_info = $GLOBALS['user']->get_profile_by_id($user_info['uid']);
            if (!empty($user_info) && $user_info['status'] == 1) {
                $GLOBALS['user']->set_session($user_info);
                $GLOBALS['user']->set_cookie($user_info, TRUE);
                update_user_info();
                // 更新用户信息
                update_user_cart();
                recalculate_price();
                // 重新计算购物车中的商品价格
            } else {
                return false;
            }
        }
        if ($token['scope'] == 'snsapi_userinfo') {
            $url = "https://api.weixin.qq.com/sns/userinfo?access_token={$token[access_token]}&openid={$token[openid]}&lang=zh_CN";
            $content = file_get_contents($url);
            $info = json_decode($content, true);
            // 更新微信用户数据
            $db->autoExecute('wxch_user', array('nickname' => $info['nickname'], 'sex' => $info['sex'], 'city' => $info['city'], 'country' => $info['country'], 'province' => $info['province'], 'language' => $info['language'], 'headimgurl' => $info['headimgurl'], 'dateline' => time()), 'UPDATE', 'uid = ' . $user_info['uid']);
        }
        $_SESSION['openid'] = $token['openid'];
        return $user_info;
    }
}
Exemplo n.º 2
0
function check_login_status()
{
    $user = D('Users');
    $session_user_id = session('user_id');
    //session 不存在,检查cookie
    if (empty($session_user_id)) {
        $cookie_user_id = cookie('user_id');
        $cookie_user_id = intval($cookie_user_id);
        if (!empty($cookie_user_id)) {
            $info = $user->getUserInfo($cookie_user_id);
            if ($info && $info['password'] == cookie('password')) {
                session('user_id', $info['user_id']);
                session('user_name', $info['user_name']);
                update_user_info();
            } else {
                //没有找到这个记录. 则清除cookie
                $time = time() - 3600;
                cookie('user_id', null);
                cookie('password', null);
            }
        }
    }
}
Exemplo n.º 3
0
/**
 * 设置用户登陆
 *
 * @access public
 * @param int $uid            
 * @return void
 */
function set_login($user_id = '', $user_name = '')
{
    if (empty($user_id)) {
        return;
    } else {
        $sql = "SELECT user_name, email FROM {pre}users  WHERE user_id='$user_id' LIMIT 1";
        $row = $GLOBALS['db']->query($sql);
        $row = reset($row);
        if ($row) {
            set_cookie($user_id, $row['user_name'], $row['email']);
            set_session($user_id, $row['user_name'], $row['email']);
            update_user_info();
        } else {
            include_once (ROOT_PATH . 'plugins/uc_client/client.php');
            if ($data = uc_get_user($user_name)) {
                list ($uid, $uname, $email) = $data;
                $sql = "REPLACE INTO {pre}users (user_id, user_name, email) VALUES('$uid', '$uname', '$email')";
                $GLOBALS['db']->query($sql);
                set_login($uid);
            } else {
                return false;
            }
        }
    }
}
Exemplo n.º 4
0
/**
 * 用户注册,登录函数
 *
 * @access  public
 * @param   string       $username          注册用户名
 * @param   string       $password          用户密码
 * @param   string       $email             注册email
 * @param   array        $other             注册的其他信息
 *
 * @return  bool         $bool
 */
function register($username, $password, $other = array())
{
    /* 检查注册是否关闭 */
    if (!empty($GLOBALS['_CFG']['shop_reg_closed'])) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['shop_register_closed']);
    }
    /* 检查username */
    if (empty($username)) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['username_empty']);
    } else {
        if (preg_match('/\'\\/^\\s*$|^c:\\\\con\\\\con$|[%,\\*\\"\\s\\t\\<\\>\\&\'\\\\]/', $username)) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_invalid'], htmlspecialchars($username)));
        }
    }
    /* 检查是否和管理员重名 */
    if (admin_registered($username)) {
        $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_exist'], $username));
        return false;
    }
    if (!$GLOBALS['user']->add_user($username, $password, $email)) {
        if ($GLOBALS['user']->error == ERR_INVALID_USERNAME) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_invalid'], $username));
        } elseif ($GLOBALS['user']->error == ERR_USERNAME_NOT_ALLOW) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_not_allow'], $username));
        } elseif ($GLOBALS['user']->error == ERR_USERNAME_EXISTS) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_exist'], $username));
        } else {
            $GLOBALS['err']->add('UNKNOWN ERROR!');
        }
        //注册失败
        return false;
    } else {
        //注册成功
        /* 设置成登录状态 */
        $GLOBALS['user']->set_session($username);
        $GLOBALS['user']->set_cookie($username);
        /* 注册送积分 */
        if (!empty($GLOBALS['_CFG']['register_points'])) {
            log_account_change($_SESSION['user_id'], 0, 0, $GLOBALS['_CFG']['register_points'], $GLOBALS['_CFG']['register_points'], $GLOBALS['_LANG']['register_points']);
        }
        /*推荐处理*/
        $affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
        if (isset($affiliate['on']) && $affiliate['on'] == 1) {
            // 推荐开关开启
            $up_uid = get_affiliate();
            empty($affiliate) && ($affiliate = array());
            $affiliate['config']['level_register_all'] = intval($affiliate['config']['level_register_all']);
            $affiliate['config']['level_register_up'] = intval($affiliate['config']['level_register_up']);
            if ($up_uid) {
                if (!empty($affiliate['config']['level_register_all'])) {
                    if (!empty($affiliate['config']['level_register_up'])) {
                        $rank_points = $GLOBALS['db']->getOne("SELECT rank_points FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '{$up_uid}'");
                        if ($rank_points + $affiliate['config']['level_register_all'] <= $affiliate['config']['level_register_up']) {
                            log_account_change($up_uid, 0, 0, $affiliate['config']['level_register_all'], 0, sprintf($GLOBALS['_LANG']['register_affiliate'], $_SESSION['user_id'], $username));
                        }
                    } else {
                        log_account_change($up_uid, 0, 0, $affiliate['config']['level_register_all'], 0, $GLOBALS['_LANG']['register_affiliate']);
                    }
                }
                //设置推荐人
                $sql = 'UPDATE ' . $GLOBALS['ecs']->table('users') . ' SET parent_id = ' . $up_uid . ' WHERE user_id = ' . $_SESSION['user_id'];
                $GLOBALS['db']->query($sql);
            }
        }
        //定义other合法的变量数组
        $other_key_array = array('msn', 'qq', 'office_phone', 'home_phone', 'mobile_phone', 'sina_weibo_id');
        $update_data['reg_time'] = local_strtotime(local_date('Y-m-d H:i:s'));
        if ($other) {
            foreach ($other as $key => $val) {
                //删除非法key值
                if (!in_array($key, $other_key_array)) {
                    unset($other[$key]);
                } else {
                    $other[$key] = htmlspecialchars(trim($val));
                    //防止用户输入javascript代码
                }
            }
            $update_data = array_merge($update_data, $other);
        }
        $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('users'), $update_data, 'UPDATE', 'user_id = ' . $_SESSION['user_id']);
        update_user_info();
        // 更新用户信息
        recalculate_price();
        // 重新计算购物车中的商品价格
        return true;
    }
}
Exemplo n.º 5
0
                }

                /* 检查验证码 */
                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']);
                }
            }

            if ($user->login($_POST['username'], $_POST['password'],isset($_POST['remember'])))
            {
                update_user_info();  //更新用户信息
                recalculate_price(); // 重新计算购物车中的商品价格

                /* 检查购物车中是否有商品 没有商品则跳转到首页 */
                $sql = "SELECT COUNT(*) FROM " . $ecs->table('cart') . " WHERE session_id = '" . SESS_ID . "' ";
                if ($db->getOne($sql) > 0)
                {
                    ecs_header("Location: flow.php?step=checkout\n");
                }
                else
                {
                    ecs_header("Location:index.php\n");
                }

                exit;
            }
Exemplo n.º 6
0
/**
 * 手机注册
 */
function m_register($username, $password, $email, $other = array())
{
    /* 检查username */
    if (empty($username)) {
        echo '用户名不能为空';
        $Loaction = 'user.php?act=register';
        ecs_header("Location: {$Loaction}\n");
        return false;
    }
    if (preg_match('/\'\\/^\\s*$|^c:\\\\con\\\\con$|[%,\\*\\"\\s\\t\\<\\>\\&\'\\\\]/', $username)) {
        echo '用户名错误';
        $Loaction = 'user.php?act=register';
        ecs_header("Location: {$Loaction}\n");
        return false;
    }
    /* 检查email */
    if (empty($email)) {
        echo 'email不能为空';
        $Loaction = 'user.php?act=register';
        ecs_header("Location: {$Loaction}\n");
        return false;
    }
    if (!is_email($email)) {
        echo 'email错误';
        $Loaction = 'user.php?act=register';
        ecs_header("Location: {$Loaction}\n");
        return false;
    }
    /* 检查是否和管理员重名 */
    if (admin_registered($username)) {
        echo '此用户已存在!';
        $Loaction = 'user.php?act=register';
        ecs_header("Location: {$Loaction}\n");
        return false;
    }
    if (!$GLOBALS['user']->add_user($username, $password, $email)) {
        echo '注册失败!';
        $Loaction = 'user.php?act=register';
        ecs_header("Location: {$Loaction}\n");
        //注册失败
        return false;
    } else {
        //注册成功
        /* 设置成登录状态 */
        $GLOBALS['user']->set_session($username);
        $GLOBALS['user']->set_cookie($username);
    }
    //定义other合法的变量数组
    $other_key_array = array('msn', 'qq', 'office_phone', 'home_phone', 'mobile_phone');
    $update_data['reg_time'] = local_strtotime(local_date('Y-m-d H:i:s'));
    if ($other) {
        foreach ($other as $key => $val) {
            //删除非法key值
            if (!in_array($key, $other_key_array)) {
                unset($other[$key]);
            } else {
                $other[$key] = htmlspecialchars(trim($val));
                //防止用户输入javascript代码
            }
        }
        $update_data = array_merge($update_data, $other);
    }
    $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('users'), $update_data, 'UPDATE', 'user_id = ' . $_SESSION['user_id']);
    update_user_info();
    // 更新用户信息
    return true;
}
Exemplo n.º 7
0
/**
 * 手机注册
 */
function m_register($username, $password, $email, $other = array(), $birthday)
{
    /* 检查username */
    if (empty($username)) {
        echo '<script>alert("用户名必须填写!");window.location.href="user.php?act=register"; </script>';
        return false;
    }
    if (preg_match('/\'\\/^\\s*$|^c:\\\\con\\\\con$|[%,\\*\\"\\s\\t\\<\\>\\&\'\\\\]/', $username)) {
        echo '<script>alert("用户名错误!");window.location.href="user.php?act=register"; </script>';
        return false;
    }
    /* 检查是否和管理员重名 */
    if (admin_registered($username)) {
        echo '<script>alert("此用户已存在!");window.location.href="user.php?act=register"; </script>';
        return false;
    }
    if (!$GLOBALS['user']->add_user($username, $password, $email)) {
        echo '<script>alert("注册失败!");window.location.href="user.php?act=register"; </script>';
        //注册失败
        return false;
    } else {
        //注册成功
        /* 设置成登录状态 */
        $GLOBALS['user']->set_session($username);
        $GLOBALS['user']->set_cookie($username);
    }
    //定义other合法的变量数组
    $other_key_array = array('msn', 'qq', 'office_phone', 'home_phone', 'mobile_phone');
    $update_data['reg_time'] = local_strtotime(local_date('Y-m-d H:i:s'));
    if ($other) {
        foreach ($other as $key => $val) {
            //删除非法key值
            if (!in_array($key, $other_key_array)) {
                unset($other[$key]);
            } else {
                $other[$key] = htmlspecialchars(trim($val));
                //防止用户输入javascript代码
            }
        }
        $update_data = array_merge($update_data, $other);
    }
    $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('users'), $update_data, 'UPDATE', 'user_id = ' . $_SESSION['user_id']);
    update_user_info();
    // 更新用户信息
    $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 " . $GLOBALS['ecs']->table('weixin_user') . " (uid, wxid, nickname) VALUES ('" . $_SESSION['user_id'] . "', '" . $wxid . "', '" . $wxnm . "')";
        //echo $sql;
        //die;
        $GLOBALS['db']->query($sql);
    }
    //$birthday = isset($_POST['birthday_month']) ? compile_str(date('Y')."-".trim($_POST['birthday_month'])."-".trim($_POST['birthday_day'])) : '';
    //echo $birthday;
    $sql = 'UPDATE ' . $GLOBALS['ecs']->table('users') . " SET `birthday`='" . $birthday . "' WHERE `user_id`='" . $_SESSION['user_id'] . "'";
    //echo $sql;
    $GLOBALS['db']->query($sql);
    $Loaction = 'user.php?act=user_center';
    ecs_header("Location: {$Loaction}\n");
    return true;
}
Exemplo n.º 8
0
function action_signin()
{
    // 获取全局变量
    $user = $GLOBALS['user'];
    $_CFG = $GLOBALS['_CFG'];
    $_LANG = $GLOBALS['_LANG'];
    $smarty = $GLOBALS['smarty'];
    $db = $GLOBALS['db'];
    $ecs = $GLOBALS['ecs'];
    $user_id = $_SESSION['user_id'];
    include_once 'includes/cls_json.php';
    $json = new JSON();
    $username = !empty($_POST['username']) ? json_str_iconv(trim($_POST['username'])) : '';
    $password = !empty($_POST['password']) ? trim($_POST['password']) : '';
    $captcha = !empty($_POST['captcha']) ? json_str_iconv(trim($_POST['captcha'])) : '';
    $result = array('error' => 0, 'content' => '');
    $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($captcha)) {
            $result['error'] = 1;
            $result['content'] = $_LANG['invalid_captcha'];
            die($json->encode($result));
        }
        /* 检查验证码 */
        include_once 'includes/cls_captcha.php';
        $validator = new captcha();
        $validator->session_word = 'captcha_login';
        if (!$validator->check_word($_POST['captcha'])) {
            $result['error'] = 1;
            $result['content'] = $_LANG['invalid_captcha'];
            die($json->encode($result));
        }
    }
    if ($user->login($username, $password)) {
        update_user_info();
        // 更新用户信息
        recalculate_price();
        // 重新计算购物车中的商品价格
        $smarty->assign('user_info', get_user_info());
        $ucdata = empty($user->ucdata) ? "" : $user->ucdata;
        $result['ucdata'] = $ucdata;
        $result['content'] = $smarty->fetch('library/member_info.lbi');
    } else {
        $_SESSION['login_fail']++;
        if ($_SESSION['login_fail'] > 2) {
            $smarty->assign('enabled_captcha', 1);
            $result['html'] = $smarty->fetch('library/member_info.lbi');
        }
        $result['error'] = 1;
        $result['content'] = $_LANG['login_failure'];
    }
    die($json->encode($result));
}
Exemplo n.º 9
0
function user_login($account, $password, $account_type = 1, $uc_login = true, $expire = NULL)
{
    global $timestamp, $online_ip, $QS_pwdhash;
    $usinfo = $login = array();
    $success = false;
    if ($account_type == "1") {
        $usinfo = get_user_inusername($account);
    } elseif ($account_type == "2") {
        $usinfo = get_user_inemail($account);
    } elseif ($account_type == "3") {
        $usinfo = get_user_inmobile($account);
    }
    if (!empty($usinfo)) {
        $pwd_hash = $usinfo['pwd_hash'];
        $usname = addslashes($usinfo['username']);
        $pwd = md5(md5($password) . $pwd_hash . $QS_pwdhash);
        if ($usinfo['password'] == $pwd) {
            if ($usinfo['status'] == 2) {
                $usinfo = '';
                $success = false;
                $login['qs_login'] = '******';
            } else {
                update_user_info($usinfo['uid'], true, true, $expire);
                $login['qs_login'] = get_member_url($usinfo['utype']);
                $success = true;
                write_memberslog($usinfo['uid'], $usinfo['utype'], 1001, $usname, "成功登录");
            }
        } else {
            $usinfo = '';
            $success = false;
        }
    }
    if (defined('UC_API') && $uc_login) {
        include_once QISHI_ROOT_PATH . 'uc_client/client.php';
        $account = $usinfo['username'] ? $usinfo['username'] : $account;
        list($uc_uid, $uc_username, $uc_password, $uc_email) = uc_user_login($account, $password);
        if ($uc_uid > 0) {
            $login['uc_login'] = uc_user_synlogin($uc_uid);
            if ($success == false) {
                global $_CFG;
                $_SESSION['activate_username'] = $uc_username;
                $login['qs_login'] = $_CFG['site_dir'] . "user/user_reg.php?act=activate";
            }
        } elseif ($uc_uid === -1 && $success) {
            $uc_reg_uid = uc_user_register($usinfo['username'], $password, $usinfo['email']);
            if ($uc_reg_uid > 0) {
                $login['uc_login'] = uc_user_synlogin($uc_reg_uid);
            }
        }
    }
    return $login;
}
Exemplo n.º 10
0
/**
 * 处理会员登录
 */
function action_act_login()
{
    $user_id = $_SESSION['user_id'];
    $smarty = get_smarty();
    $ecs = get_ecs();
    $db = get_database();
    /* 处理会员的登录 */
    $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'])) {
            $smarty->assign('lang', $_LANG);
            $smarty->assign('action', 'login');
            $smarty->assign('error', $_LANG['invalid_captcha']);
            $smarty->display('chat_passport.dwt');
            return;
        }
        /* 检查验证码 */
        include_once 'includes/cls_captcha.php';
        $validator = new captcha();
        $validator->session_word = 'captcha_login';
        if (!$validator->check_word($_POST['captcha'])) {
            $smarty->assign('lang', $_LANG);
            $smarty->assign('action', 'login');
            $smarty->assign('error', $_LANG['invalid_captcha']);
            $smarty->display('chat_passport.dwt');
            return;
        }
    }
    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_res = $db->query($sql);
        $kkk = 0;
        while ($username_row = $db->fetchRow($username_res)) {
            $username_e = $username_row['user_name'];
            $kkk = $kkk + 1;
        }
        if ($kkk > 1) {
            $smarty->assign('lang', $_LANG);
            $smarty->assign('action', 'login');
            $smarty->assign('error', '本网站有多个会员ID绑定了和您相同的手机号,请使用其他登录方式,如:邮箱或用户名。');
            $smarty->display('chat_passport.dwt');
            return;
        }
        if ($username_e) {
            $username = $username_e;
        }
    }
    if ($GLOBALS['user']->login($username, $password, isset($_POST['remember']))) {
        update_user_info();
        recalculate_price();
        // 登录成功
        $ucdata = 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');
        // 刷新user_id
        $user_id = $_SESSION['user_id'];
        header('Location: chat.php?act=chat');
    } else {
        $_SESSION['login_fail']++;
        $smarty->assign('lang', $_LANG);
        $smarty->assign('action', 'login');
        $smarty->assign('error', $_LANG['login_failure']);
        $smarty->display('chat_passport.dwt');
        return;
    }
}
Exemplo n.º 11
0
function user_login($account, $password, $account_type = 1, $uc_login = true, $expire = NULL)
{
    global $timestamp, $online_ip, $QS_pwdhash;
    $usinfo = $login = array();
    $success = false;
    if ($account_type == "1") {
        $usinfo = get_user_inusername($account);
    } elseif ($account_type == "2") {
        $usinfo = get_user_inemail($account);
    } elseif ($account_type == "3") {
        $usinfo = get_user_inmobile($account);
    }
    if (!empty($usinfo)) {
        $pwd_hash = $usinfo['pwd_hash'];
        $usname = addslashes($usinfo['username']);
        $pwd = md5(md5($password) . $pwd_hash . $QS_pwdhash);
        if ($usinfo['password'] == $pwd) {
            update_user_info($usinfo['uid'], true, true, $expire);
            $login['qs_login'] = get_member_url($usinfo['utype']);
            $success = true;
            write_memberslog($usinfo['uid'], $usinfo['utype'], 1001, $usname, "成功登录");
        } else {
            $usinfo = '';
            $success = false;
        }
    }
    return $login;
}
Exemplo n.º 12
0
$log->log("POST func = $_POST[func]");

if ($spUser->mailbox) { 
  $vmUser = new VmUser($data->db,$spUser->username, $spUser->domain, $spUser->mailbox, $spUser->voicemail_db);
  $vmUser->get();
} else {
  $vmUser = null ;  
}


//  Are they updating, if so call the corresponding function
if ($_POST[func] == 'update_call_opts') { 
  $cpl_msgs = update_cpl(); 
} elseif ($_POST[func] == 'update_user_info'){
  $log->log("$_POST[func] is update_user_info"); 
  $user_info_msgs = update_user_info(); 
// um=Unified Messaged
} elseif ($_POST[func] == 'update_um'){
  $log->log("$_POST[func] is update_um"); 
  $um_msgs = update_um(); 
} elseif ($_POST[func] == 'update_vm_flags' ) {
  $log->log("$_POST[func] is update_um"); 
  $vm_flags_msgs = update_vm_flags(); 
} 

// we've got forms on this page, get them
get_cpl_form(      $account_smarty, $cpl_msgs ) ; 
get_user_info_form($account_smarty, $user_info_msgs ) ; 
get_um_form(       $account_smarty, $um_msgs ) ; 
get_vm_flags_form( $account_smarty, $user_info_msgs ) ; 
Exemplo n.º 13
0
<?php

session_start();
//Перенаправление на страницу входа
if (!$_SESSION['auth']) {
    header("Location: ../enter");
    exit;
}
//Деавторизация
if ($_POST['logout']) {
    session_destroy();
    header("Location: ../enter");
    exit;
}
//Подключение функций и БД
include "../core/functions.php";
db_connect();
//Определение $mode
if ($_POST['edit']) {
    $mode = "edit";
} else {
    $mode = "view";
}
if ($_POST['update']) {
    update_user_info($_SESSION['user_id'], $_POST['username'], $_POST['age']);
}
get_user_info($_SESSION['user_id']);
/**
 * 用户注册,登录函数
 *
 * @access  public
 * @param   string       $username          注册用户名
 * @param   string       $password          用户密码
 * @param   string       $email             注册email
 * @param   array        $other             注册的其他信息
 *
 * @return  bool         $bool
 */
function register($username, $password, $email, $other = array())
{
    /* 检查注册是否关闭 */
    if (!empty($GLOBALS['_CFG']['shop_reg_closed'])) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['shop_register_closed']);
    }
    /* 检查username */
    if (empty($username)) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['username_empty']);
    } else {
        if (preg_match('/\'\\/^\\s*$|^c:\\\\con\\\\con$|[%,\\*\\"\\s\\t\\<\\>\\&\'\\\\]/', $username)) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_invalid'], htmlspecialchars($username)));
        }
    }
    /* 检查email */
    if (empty($email)) {
        $GLOBALS['err']->add($GLOBALS['_LANG']['email_empty']);
    } else {
        if (!is_email($email)) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['email_invalid'], htmlspecialchars($email)));
        }
    }
    if ($GLOBALS['err']->error_no > 0) {
        return false;
    }
    /* 检查是否和管理员重名 */
    if (admin_registered($username)) {
        $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_exist'], $username));
        return false;
    }
    if (!$GLOBALS['user']->add_user($username, $password, $email)) {
        if ($GLOBALS['user']->error == ERR_INVALID_USERNAME) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_invalid'], $username));
        } elseif ($GLOBALS['user']->error == ERR_USERNAME_NOT_ALLOW) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_not_allow'], $username));
        } elseif ($GLOBALS['user']->error == ERR_USERNAME_EXISTS) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['username_exist'], $username));
        } elseif ($GLOBALS['user']->error == ERR_INVALID_EMAIL) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['email_invalid'], $email));
        } elseif ($GLOBALS['user']->error == ERR_EMAIL_NOT_ALLOW) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['email_not_allow'], $email));
        } elseif ($GLOBALS['user']->error == ERR_EMAIL_EXISTS) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['email_exist'], $email));
        } else {
            $GLOBALS['err']->add('UNKNOWN ERROR!');
        }
        //注册失败
        return false;
    } else {
        //注册成功
        /* 设置成登录状态 */
        $GLOBALS['user']->set_session($username);
        $GLOBALS['user']->set_cookie($username);
        /* 注册送积分 */
        if (!empty($GLOBALS['_CFG']['register_points'])) {
            log_account_change($_SESSION['user_id'], 0, 0, $GLOBALS['_CFG']['register_points'], $GLOBALS['_CFG']['register_points'], $GLOBALS['_LANG']['register_points']);
        }
        /*推荐处理*/
        $affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
        if (isset($affiliate['on']) && $affiliate['on'] == 1) {
            // 推荐开关开启
            $up_uid = get_affiliate();
            empty($affiliate) && ($affiliate = array());
            $affiliate['config']['level_register_all'] = intval($affiliate['config']['level_register_all']);
            $affiliate['config']['level_register_up'] = intval($affiliate['config']['level_register_up']);
            if ($up_uid) {
                if (!empty($affiliate['config']['level_register_all'])) {
                    if (!empty($affiliate['config']['level_register_up'])) {
                        $rank_points = $GLOBALS['db']->getOne("SELECT rank_points FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '{$up_uid}'");
                        if ($rank_points + $affiliate['config']['level_register_all'] <= $affiliate['config']['level_register_up']) {
                            log_account_change($up_uid, 0, 0, $affiliate['config']['level_register_all'], 0, sprintf($GLOBALS['_LANG']['register_affiliate'], $_SESSION['user_id'], $username));
                        }
                    } else {
                        log_account_change($up_uid, 0, 0, $affiliate['config']['level_register_all'], 0, $GLOBALS['_LANG']['register_affiliate']);
                    }
                }
                //设置推荐人
                $sql = 'UPDATE ' . $GLOBALS['ecs']->table('users') . ' SET parent_id = ' . $up_uid . ' WHERE user_id = ' . $_SESSION['user_id'];
                $GLOBALS['db']->query($sql);
            }
        }
        //定义other合法的变量数组
        $other_key_array = array('msn', 'qq', 'office_phone', 'home_phone', 'mobile_phone');
        $update_data['reg_time'] = local_strtotime(local_date('Y-m-d H:i:s'));
        if ($other) {
            foreach ($other as $key => $val) {
                //删除非法key值
                if (!in_array($key, $other_key_array)) {
                    unset($other[$key]);
                } else {
                    $other[$key] = htmlspecialchars(trim($val));
                    //防止用户输入javascript代码
                }
            }
            $update_data = array_merge($update_data, $other);
        }
        $GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('users'), $update_data, 'UPDATE', 'user_id = ' . $_SESSION['user_id']);
        update_user_info();
        // 更新用户信息
        recalculate_price();
        // 重新计算购物车中的商品价格
        /*ross 跟踪订单 */
        /* 取得订单来源 */
        $username1 = $_SESSION['user_name'];
        if (isset($_COOKIE['request_info'])) {
            $request_info = unserialize(strtr($_COOKIE['request_info'], array("\\" => "")));
            $from_cat = 1;
            $sql = "INSERT INTO " . "jindong_tongji " . "(order_sn, user_name,start_time,end_time,host,ip,start_url,end_url,from_cat) value('" . $order['order_sn'] . "','" . $username1 . "','" . $request_info['time'] . "','" . gmtime() . "','" . $request_info['host'] . "','" . $_SERVER['REMOTE_ADDR'] . "','" . $request_info['start_url'] . "','" . $request_info['end_url'] . "','" . $from_cat . "')";
        } else {
            $sql = "INSERT INTO " . "jindong_tongji " . "(order_sn, user_name,start_time,end_time,host,ip,start_url,end_url,from_cat) value('" . $order['order_sn'] . "','" . $username1 . "','" . gmtime() . "','" . gmtime() . "','本站','" . $_SERVER['REMOTE_ADDR'] . "','本站','本站',1)";
        }
        $GLOBALS['db']->query($sql);
        /*ross 跟踪订单  end */
        return true;
    }
}
Exemplo n.º 15
0
    if ($val['password'] != trim($_POST['rpassword'])) {
        exit("密码不一致");
    }
    require_once QISHI_ROOT_PATH . 'include/mysql.class.php';
    $db = new mysql($dbhost, $dbuser, $dbpass, $dbname);
    unset($dbhost, $dbuser, $dbpass, $dbname);
    require_once QISHI_ROOT_PATH . 'include/fun_user.php';
    $sql = "select * from " . table("members") . " where username='******'username']}' or email='{$val['email']}'";
    $row = $db->getall($sql);
    if (!empty($row)) {
        exit("用户名或邮箱已经存在!");
    }
    $userid = user_register($val['username'], $val['password'], $val['member_type'], $val['email']);
    if ($userid) {
        $db->query("UPDATE " . table('members') . " SET qq_openid = '{$_SESSION['openid']}'  WHERE uid='{$userid}' AND qq_openid='' LIMIT 1");
        update_user_info($userid);
        exit("ok");
    } else {
        require_once QISHI_ROOT_PATH . 'include/tpl.inc.php';
        exit("reg_err");
    }
} elseif ($act == 'binding') {
    $url = "https://graph.qq.com/oauth2.0/authorize?response_type=token&client_id={$_CFG['qq_appid']}&redirect_uri={$_CFG['wap_domain']}/connect_qq_client.php" . urlencode('?act=binding_check');
    header("Location:{$url}");
} elseif ($act == 'binding_check') {
    $html = "<script type=\"text/javascript\" src=\"http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js\" charset=\"utf-8\" data-callback=\"true\"></script> ";
    $html .= "<script type=\"text/javascript\">";
    $html .= "if(QC.Login.check())";
    $html .= "{";
    $html .= "QC.Login.getMe(function(openId, accessToken)";
    $html .= "{";
Exemplo n.º 16
0
    setcookie("QS[uid]", "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
    setcookie("QS[username]", "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
    setcookie("QS[password]", "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
    setcookie("QS[utype]", "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
    unset($_SESSION['activate_username']);
    unset($_SESSION['activate_email']);
    header("location:index.php");
} elseif ($act == 'weixin_login') {
    $openid = trim($_GET['openid']);
    $uid = intval($_GET['uid']);
    $event_key = intval($_GET['event_key']);
    weixin_login($openid, $uid, $event_key);
    $smarty->display('wap/scan/scan_success.html');
} elseif (!$_SESSION['uid'] && !$_SESSION['username'] && !$_SESSION['utype'] && $_COOKIE['QS']['username'] && $_COOKIE['QS']['password']) {
    if (check_cookie($_COOKIE['QS']['username'], $_COOKIE['QS']['password'])) {
        update_user_info($_COOKIE['QS']['username'], false, false);
        if ($_SESSION['utype'] == 2) {
            header("location:personal/wap_user.php");
        }
        if ($_SESSION['utype'] == 1) {
            header("location:company/wap_user.php");
        }
    } else {
        setcookie("QS[uid]", "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
        setcookie('QS[username]', "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
        setcookie('QS[password]', "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
        setcookie("QS[utype]", "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
        header("location:index.php");
    }
} elseif ($_SESSION['username'] && $_SESSION['utype']) {
    if ($_SESSION['utype'] == 2) {
Exemplo n.º 17
0
 * 版权所有: 骑士网络,并保留所有权利。
 * 网站地址: http://www.74cms.com;
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用;不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once dirname(__FILE__) . '/../include/common.inc.php';
$act = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'add';
require_once QISHI_ROOT_PATH . 'include/mysql.class.php';
$db = new mysql($dbhost, $dbuser, $dbpass, $dbname);
if ((empty($_SESSION['uid']) || empty($_SESSION['username']) || empty($_SESSION['utype'])) && $_COOKIE['QS']['username'] && $_COOKIE['QS']['password'] && $_COOKIE['QS']['uid']) {
    require_once QISHI_ROOT_PATH . 'include/fun_user.php';
    if (check_cookie($_COOKIE['QS']['uid'], $_COOKIE['QS']['username'], $_COOKIE['QS']['password'])) {
        update_user_info($_COOKIE['QS']['uid'], false, false);
        header("Location:" . get_member_url($_SESSION['utype']));
    } else {
        unset($_SESSION['uid'], $_SESSION['username'], $_SESSION['utype'], $_SESSION['uqqid'], $_SESSION['activate_username'], $_SESSION['activate_email'], $_SESSION["openid"]);
        setcookie("QS[uid]", "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
        setcookie('QS[username]', "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
        setcookie('QS[password]', "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
        setcookie("QS[utype]", "", time() - 3600, $QS_cookiepath, $QS_cookiedomain);
    }
}
if ($_SESSION['uid'] == '' || $_SESSION['username'] == '') {
    $captcha = get_cache('captcha');
    $smarty->assign('verify_userlogin', $captcha['verify_userlogin']);
    $smarty->display('plus/ajax_login.htm');
    exit;
}
Exemplo n.º 18
0
Arquivo: uc.php Projeto: noikiy/mdwp
/**
 * 设置用户登陆
 *
 * @access  public
 * @param int $uid
 * @return void
 */
function set_login($user_id = '', $user_name = '')
{
    if (empty($user_id)) {
        return;
    } else {
        $sql = "SELECT user_name, email FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id='{$user_id}' LIMIT 1";
        $row = $GLOBALS['db']->getRow($sql);
        if ($row) {
            set_cookie($user_id, $row['user_name'], $row['email']);
            set_session($user_id, $row['user_name'], $row['email']);
            include_once ROOT_PATH . 'includes/lib_main.php';
            update_user_info();
        } else {
            include_once ROOT_PATH . 'uc_client/client.php';
            if ($data = uc_get_user($user_name)) {
                list($uid, $uname, $email) = $data;
                $sql = "REPLACE INTO " . $GLOBALS['ecs']->table('users') . "(user_id, user_name, email) VALUES('{$uid}', '{$uname}', '{$email}')";
                $GLOBALS['db']->query($sql);
                set_login($uid);
            } else {
                return false;
            }
        }
    }
}
Exemplo n.º 19
0
         $result['error'] = 1;
         $result['content'] = $_LANG['invalid_captcha'];
         die($json->encode($result));
     }
     /* 检查验证码 */
     include_once 'includes/cls_captcha.php';
     $validator = new captcha();
     $validator->session_word = 'captcha_login';
     if (!$validator->check_word($_POST['captcha'])) {
         $result['error'] = 1;
         $result['content'] = $_LANG['invalid_captcha'];
         die($json->encode($result));
     }
 }
 if ($user->login($username, $password)) {
     update_user_info();
     //更新用户信息
     recalculate_price();
     // 重新计算购物车中的商品价格
     $smarty->assign('user_info', get_user_info());
     $ucdata = empty($user->ucdata) ? "" : $user->ucdata;
     $result['ucdata'] = $ucdata;
     $result['content'] = $smarty->fetch('library/member_info.lbi');
 } else {
     $_SESSION['login_fail']++;
     if ($_SESSION['login_fail'] > 2) {
         $smarty->assign('enabled_captcha', 1);
         $result['html'] = $smarty->fetch('library/member_info.lbi');
     }
     $result['error'] = 1;
     $result['content'] = $_LANG['login_failure'];
Exemplo n.º 20
0
<?php

// Import the "Grab Bag"
require "common.php";
// Open an (OO) MySQL Connection
$conn = new mysqli($GLOBALS["dbhost"], $GLOBALS["dbuser"], $GLOBALS["dbpass"], $GLOBALS["dbname"]);
// Check connection
if ($conn->connect_error || !session_start()) {
    die("{\"response\": \"Connection failed: " . $conn->connect_error . "\"}");
}
// Get the values from the POST parameters
$username = $_POST["username"];
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$password = $_POST["password"];
if (!check_parameters($username, $firstname, $lastname)) {
    die("{\"response\": \"You must specify the username, firstname and lastname!\"}");
}
// If we are updating the password, change it accordingly
if ($password && ($result = change_user_password($conn, $username, $password)) != "Successful") {
    die("{\"response\": \"{$result}\"}");
}
// Finally, update the other user information and die...
$result = update_user_info($conn, $username, $firstname, $lastname);
die("{\"response\": \"{$result}\"}");