Beispiel #1
0
 function oncode()
 {
     ob_clean();
     $code = random(4);
     $_ENV['user']->save_code(strtolower($code));
     makecode($code);
 }
Beispiel #2
0
function is_user($type, $username = '', $password = '', $repassword = '', $oldpassword = '')
{
    global $path;
    $user['userid'] = isset($_COOKIE['userid']) ? AuthCode($_COOKIE['userid'], 'DECODE') : '';
    //id
    $user['username'] = isset($_COOKIE['username']) ? AuthCode($_COOKIE['username'], 'DECODE') : '';
    //会员用户名
    $user['lastlogintime'] = isset($_COOKIE['lastlogintime']) ? AuthCode($_COOKIE['lastlogintime'], 'DECODE') : '';
    //登陆时间
    $user['lastloginip'] = isset($_COOKIE['lastloginip']) ? AuthCode($_COOKIE['lastloginip'], 'DECODE') : '';
    //登陆ip
    //用户登录
    if ($type == 'center') {
        $user = MysqlOneSelect('lgsc_member', '*', "username='******'");
        //echo $user;
        if ($user == '-1') {
            return '-1';
            exit;
        }
        if (md5(md5($password)) !== $user['password']) {
            return '-2';
            exit;
        }
        //生成登陆认证
        $rnd = makecode(6);
        //生成COOkie
        $cookie_time = time() + 3600;
        setcookie('userid', AuthCode($user['id'], $rnd), $cookie_time, '/');
        setcookie('username', AuthCode($user['username'], $rnd), $cookie_time, '/');
        setcookie('lastlogintime', AuthCode($user['regtime'], $rnd), $cookie_time, '/');
        setcookie('lastloginip', AuthCode(GetIP(), $rnd), $cookie_time, '/');
        setcookie("qtrnd", $rnd, $cookie_time, '/');
        //更新最后登陆时间 和 登陆认证 登录IP
        mysql_query("update lgsc_member set logintime =" . time() . " , loginip=" . GetIP() . " where userid = " . $user['id']);
        //登录成功
        return true;
    }
    //判断是否登陆
    if ($type == 'islogin') {
        if (!isset($_COOKIE['userid']) && $user['userid'] == "") {
            return false;
        }
        return true;
    }
    //限制只能一个账号登陆
    if ($type == 'onlyone') {
        $OneRow = MysqlOneSelect('phome_enewsmember', 'rnd', "userid={$user['0']}");
        //print_r($OneRow);
        if ($_COOKIE["qtrnd"] == '' || $_COOKIE["qtrnd"] != $OneRow['rnd']) {
            //注销Cookie
            setcookie('userid', "", time() - 3600 * 10, '/');
            setcookie('username', "", time() - 3600 * 10, '/');
            setcookie('lastlogintime', "", time() - 3600 * 10, '/');
            setcookie('lastloginip', "", time() - 3600 * 10, '/');
            setcookie('qtrnd', "", time() - 3600 * 10, '/');
            //跳转登陆
            return true;
        }
        return false;
    }
    //退出登陆
    if ($type == "exit") {
        //注销Cookie
        setcookie('userid', "", time() - 3600 * 10, '/');
        setcookie('username', "", time() - 3600 * 10, '/');
        setcookie('lastlogintime', "", time() - 3600 * 10, '/');
        setcookie('lastloginip', "", time() - 3600 * 10, '/');
        setcookie('qtrand', "", time() - 3600 * 10, '/');
        //跳转登陆
        return true;
    }
    //修改密码
    if ($type == "password") {
        $one_user = MysqlOneSelect("lgsc_member", "*", "username = '******'");
        //echo "select * from lgsc_member where username = '******' limit 1";
        //判断是否存在该用户
        if ($one_user == '-1') {
            return -1;
            exit;
        }
        //对比密码是否正确
        if ($oldpassword !== "") {
            if ($one_user['password'] !== md5(md5($oldpassword))) {
                return -2;
                exit;
            }
        }
        //获取密码强度
        $password_strength = password_strength($password);
        //密码修改
        if ($password != '') {
            //两次密码不一致请从新输入
            if ($password !== $repassword) {
                return false;
            } else {
                $newpassword = md5(md5($password));
                $sql_password = "******" . $one_user['id'];
                $rest_password = mysql_query($sql_password);
                if (!$rest_password) {
                    return false;
                }
            }
        }
        return true;
    }
    //获取参数
    if ($type == 'par') {
        return $user;
    }
}
Beispiel #3
0
<?php

session_start();
include "function.php";
if (isset($_POST['url'])) {
    $url = $_POST['url'];
    if ($code = makecode($url)) {
        $_SESSION['feedback'] = "Generated url is : <a href=\"http://urls.ml/" . $code . "\">http://urls.ml/" . $code . "</a>";
    } else {
        $_SESSION['feedback'] = "There was a problem. Invalid url, perhaps ?";
    }
}
header("Location: /project/url");
?>
		
Beispiel #4
0
        $state = $sms->send($mobile_num, $send_content, '', 13, 1);
        if ($state == 'error' || $state == false) {
            echo 'send_error';
            exit;
        }
        $sql = 'INSERT INTO ' . $ecs->table('user_send') . " (`user_id`,`send_num`,`mobile_phone`,`send_time`,`check_start`,`check_time`) VALUES('0','{$send_num}','{$mobile_num}','{$now_time}','0','0')";
        $db->query($sql);
        echo 'success';
        exit;
    }
} elseif ($act == 'act_register') {
    $now_time = time();
    include_once ROOT_PATH . 'includes/lib_passport.php';
    $username = '******' . local_date('ymd') . makecode(6);
    $password = isset($_POST['password']) ? trim($_POST['password']) : '';
    $email = 'mbl' . makecode(6) . '@mbl.com';
    $phone_code = isset($_POST['phone-code']) ? trim($_POST['phone-code']) : '';
    $mobile_phone = isset($_POST['phone']) ? $_POST['phone'] : '';
    if (!is_mobile($mobile_phone)) {
        mobile_error('返回用户登录', $url = 'user.php', '您填写的非手机号码');
    }
    if (strlen($phone_code) > 6) {
        mobile_error('返回用户登录', $url = 'user.php', '手机验证码错误');
    } else {
        $sql = 'SELECT count(`id`)  FROM ' . $ecs->table('user_send') . " WHERE `send_num`='{$phone_code}' AND `send_time` > ({$now_time}-1800) AND  `mobile_phone`='{$mobile_phone}' ";
        $result = $db->getOne($sql);
        if (!$result) {
            mobile_error('返回用户登录', $url = 'user.php', '手机验证错误');
        }
    }
    if (strlen($password) > 22) {