Esempio n. 1
0
$ac = $_GET['ac'];
switch ($ac) {
    case 'signup':
        signup($_POST);
        break;
    case 'login':
        login($_POST);
        break;
    case 'logout':
        logout();
        break;
    case 'checkemail':
        checkEmail($_POST);
        break;
    case 'checkusername':
        checkUserName($_POST);
        break;
    case 'checktel':
        checkTel($_POST);
        break;
}
function logout()
{
    cleanSessionCookie();
    $response['status'] = 1;
    echo json_encode($response);
}
function login($req)
{
    $emailOrTel = trim($req['user']);
    $password = $req['password'];
Esempio n. 2
0
/**
 * Function channelDescriptionModel is used to insert channel description and channel name
 * @param int $userID user id
 * @param string $description channel description
 * @param string $userName channel name
 * @return array
 */
function channelDescriptionModel($userID, $description, $userName)
{
    global $tablePrefix, $db, $query, $user;
    $decodedDescription = json_decode(bannerImageDetails($userID), true);
    $getDescription = $decodedDescription['description'];
    $decodedDescription['description'] = $description;
    $encodeDescription = json_encode($decodedDescription);
    $getName = getUserName($userID);
    if (empty($userName)) {
        echo json_encode(array('errormsg' => 'true', 'errmsg' => 'Channel name should not be empty'));
        exitAction('');
    }
    if ($getName == $userName && $getDescription == $description) {
        echo json_encode(array('errormsg' => 'false', 'errmsg' => ''));
        exitAction('');
    }
    if (!empty($description) && $getDescription != $description) {
        updateImageDetails($encodeDescription, $userID);
    }
    if (!empty($userName) && $getName != $userName) {
        $nameChecking = checkUserName($userName, $userID);
        if (empty($nameChecking)) {
            updateUserName($userName, $userID);
        } else {
            echo json_encode(array('errormsg' => 'true', 'errmsg' => 'User Name Already Exist'));
            exitAction('');
        }
    }
    echo json_encode(array('errormsg' => 'false', 'errmsg' => 'Content Saved'));
    exitAction('');
}
Esempio n. 3
0
$email = filter_input(INPUT_POST, 'email');
$message = filter_input(INPUT_POST, 'message');
$secret = filter_input(INPUT_POST, 'secret');
$to = '*****@*****.**';
$message = 'От ' . $user_name . ' сообщение : ' . $message;
$headers = 'Content-type: text; charset="utf-8"' . "\r\n" . 'From: ' . $user_name . '<' . $email . '>';
function checkEmail($email)
{
    return preg_match('/\\w[0-9a-zA-Z]+@[0-9a-zA-Z]+\\.[a-zA-Z]{2,3}/', $email);
}
function checkUserName($user_name)
{
    return preg_match('/[a-zA-Zа-яА-ЯёЁ_]+/', $user_name);
}
try {
    if (empty($user_name) || !checkUserName($user_name)) {
        throw new Exception('Не указано (Не верно указано) имя' . $user_name);
    }
    if (!checkEmail($email)) {
        throw new Exception('Неверный адрес эл.почты', 1);
    }
    if ($secret != $_SESSION['secret']) {
        throw new Exception('Неверно введено число');
    }
    //        if(!mail($to,$subject,$message,$headers)){
    //            throw new Exception('Упс. Почту не удалось отправить');
    //        }
    $_SESSION['message'] = 'Соощение успешно оправлено';
} catch (Exception $exc) {
    $_SESSION['message'] = $exc->getMessage();
}
Esempio n. 4
0
 function validate($username)
 {
     global $metin;
     if (strlen($username) >= 5) {
         //usleep(250000);
         if (checkUserName($username)) {
             $msg = $metin[411];
         }
     }
     return $msg;
 }
Esempio n. 5
0
 public function userLogin()
 {
     if ($this->get_user_id()) {
         response_code('1');
     }
     $username = checkUserName($this->input->post('username'), '1004');
     $password = check_empty($this->input->post('password'), FALSE, '1003');
     // $remember = check_empty(trimall(strip_tags($this->input->post('remember',TRUE))),FALSE,'1003');自动登录 1:是、0:否
     $passlen = strlen($password);
     if ($passlen < 6 || $passlen > 16) {
         response_code('1003');
     }
     $user = $this->model->get_user_auth_by_mobile($username, TRUE);
     if (!$user) {
         response_code('1004');
     }
     //密码错误
     if (md5(md5($password) . $user['salt']) != $user['user_pass']) {
         response_code('1004');
     }
     $user_info = $this->model->get_user_detail($user['user_id']);
     //待修正
     //商户登录需要同步inn信息至session
     if ($user['role'] == 'innholder') {
         $inn = $this->model->get_user_inn($user['user_id']);
         if (!empty($inn['inn_id'])) {
             $user_info['inn_id'] = $inn['inn_id'];
         }
     }
     if (!$this->user_login($user_info)) {
         response_code('1005');
     }
     response_code('1');
 }
Esempio n. 6
0
<?php

$action = $_POST['action'];
switch ($action) {
    case 'login':
        checkUserName();
        break;
    case 'logout':
        logout();
        break;
    case 'myMovies':
        getMyMovies();
        break;
    case 'notMyMovies':
        notMyMovies();
        break;
    case 'addComment':
        addComment();
        break;
    case 'watch':
        watch();
        break;
    case 'addGenre':
        addGenre();
        break;
    case 'getGenre':
        getGenre();
        break;
    case 'addMovie':
        addMovie();
        break;
<?php

/**
 * Created by PhpStorm.
 * User: manesh
 * Date: 12/16/15
 * Time: 7:33 PM
 */
include "header.php";
$name = $_POST['name'];
$contactNo = $_POST['contactNo'];
$password = $_POST['password'];
$repeatPassword = $_POST['repeatPassword'];
$password = md5($_POST['password']);
$repeatPassword = md5($_POST['repeatPassword']);
if (checkUserName($name) == 1) {
    print '<script>alert("User name is already taken!");</script>';
    // prompts user
    print '<script>window.location.assign("passengerSignUpForm.php");</script>';
    // redirects to the login page
} else {
    if (checkContactNo($contactNo) == 1) {
        print '<script>alert("Contact number already given by another!");</script>';
        // prompts user
        print '<script>window.location.assign("passengerSignUpForm.php");</script>';
        // redirects to the login page
    } else {
        if ($password != $repeatPassword) {
            print '<script>alert("Passwords do not match!");</script>';
            // prompts user
            print '<script>window.location.assign("passengerSignUpForm.php");</script>';
Esempio n. 8
0
                $db->rollback();
                $db->close();
                exit;
            }
            $return = array('user_id' => $res2[0]['user_id'], 'access_token' => $token);
            echo getJsonResponse(0, 'success', $token);
            $db->commit();
            $db->close();
        } else {
            echo getJsonResponse(2, 'post数据有误', null);
            $db->close();
            exit;
        }
    } else {
        if (isset($_POST['username'])) {
            if (checkUserName($db, $_POST['username'])) {
                echo getJsonResponse(3, '用户名存在', null);
                $db->close();
                exit;
            } else {
                echo getJsonResponse(0, "success", null);
                $db->close();
                exit;
            }
        } else {
            echo getJsonResponse(2, 'post数据有误', null);
            $db->close();
            exit;
        }
    }
} else {
Esempio n. 9
0
             header('Location: index.php');
         } else {
             //user entered false details
             $error = "Your information is incorrect!";
         }
     }
     include 'views/logIn.php';
 } else {
     if ($action == 'reg') {
         //loads the registration page
         $error = "";
         if (isset($_POST['action'])) {
             $regEmail = $_POST['regEmail'];
             $regUserName = $_POST['regUserName'];
             $regPassword = $_POST['regPassword'];
             $currentUser = checkUserName($userName);
             if ($currentUser == 0) {
                 //There is no account with desired userName
                 addUser($regUserName, $regPassword, $regEmail);
                 $_SESSION['loggedIn'] = true;
                 $_SESSION['user'] = $regUserName;
                 header('Location: index.php');
             } else {
                 $error = "That user name is already in use please choose another.";
             }
         }
         include 'views/register.php';
     } else {
         if ($action == 'logOut') {
             //loads the logout page and logs the user out
             include 'views/logout.php';
Esempio n. 10
0
 */
include "header.php";
$id = $_POST['id'];
$name = $_POST['name'];
$contactNo = $_POST['contactNo'];
$nic = $_POST['nic'];
$password = $_POST['password'];
$repeatPassword = $_POST['repeatPassword'];
$password = md5($_POST['password']);
$repeatPassword = md5($_POST['repeatPassword']);
$vehicleNo = $_POST['vehicleNo'];
$vehicleType = $_POST['vehicleType'];
$maxPassengers = $_POST['maxPassengers'];
$startLat = $_POST['startLat'];
$startLong = $_POST['startLong'];
if (checkUserName($id) == 1) {
    print '<script>alert("Driver ID is already taken!");</script>';
    // prompts user
    print '<script>window.location.assign("driverSignUpForm.php");</script>';
    // redirects to the login page
} else {
    if ($password != $repeatPassword) {
        print '<script>alert("Passwords do not match!");</script>';
        // prompts user
        print '<script>window.location.assign("driverSignUpForm.php");</script>';
        // redirects to the login page
    } else {
        $insertQueryDriver = "INSERT INTO `driver` (`driver_id`, `password`, `name`, `contact_no`, `nic_no`, `availability`, `longitude`, `lattitude`) VALUES ('{$id}', '{$password}', '{$name}', '{$contactNo}', '{$nic}', '1', '{$startLong}', '{$startLat}')";
        $resultDriver = mysql_query($insertQueryDriver);
        $insertQueryTaxi = "INSERT INTO `taxi` (`reg_no`, `type`, `max_passengers`, `driver_id`) VALUES ('{$vehicleNo}', '{$vehicleType}', '{$maxPassengers}', '{$id}')";
        $resultTaxi = mysql_query($insertQueryTaxi);
Esempio n. 11
0
user.php?action=index')">Back</a>
				<button type="submit" class="btn btn-success" onclick="user_store()">Save</button>
			</div>
			<div class="col-md-4">

			</div>
		</div>

<?php 
} elseif (isset($_GET['action']) && $_GET['action'] == 'store') {
    $res = array();
    $res['result'] = false;
    if ($_GET['user_name'] == '' || !isset($_GET['user_name']) || empty($_GET['user_name'])) {
        $res['user_name'] = "username can't empty";
    } elseif (isset($_GET['user_name']) && !empty($_GET['user_name'])) {
        $user_name = checkUserName($_GET['user_name']);
        if ($user_name != 1) {
            $res['user_name'] = $user_name;
        }
    }
    if (count($res) > 1) {
        echo json_encode($res);
    } else {
        $sql = "INSERT INTO demo_user SET user_name='" . $_GET['user_name'] . "' ";
        $result = mysql_query($sql);
        if ($result) {
            $res['result'] = true;
            $res['reload'] = "user.php?action=index";
        } else {
            $res['server'] = "Error insert data!";
        }
Esempio n. 12
0
     $playerID = $_SESSION['id'];
     deleteUser($playerID);
     deleteSolved($playerID);
     $login_error = 'Thank you for playing. Your account has been deleted.';
     include 'view/login.php';
 } else {
     if ($action == 'options') {
         include 'view/userOptions.php';
     } else {
         if ($action == 'update_splash') {
             include 'view/updateUser.php';
         } else {
             if ($action == 'update_user') {
                 $playerName = filter_input(INPUT_POST, 'username');
                 $playerPassword = filter_input(INPUT_POST, 'password');
                 $value = checkUserName($playerName);
                 if ($value[0] == 1) {
                     $update_error = 'Username is already in use. Please try another name.';
                     include 'view/updateUser.php';
                 } else {
                     $playerID = $_SESSION['id'];
                     updateUser($playerID, $playerName, $playerPassword);
                     $update_message = 'User details updated successfully.';
                     include 'view/userOptions.php';
                 }
             } else {
                 if ($action == 'home') {
                     include 'view/loginSplash.php';
                 } else {
                     if ($action == '1') {
                         $_SESSION['puzzleID'] = 1;
Esempio n. 13
0
 /**
  * 注册用户
  **/
 public function userregpost()
 {
     $username = checkUserName($this->input->post('username'), '1002');
     $identifycode = check_empty($this->input->post('identifycode'), FALSE, '5002');
     $password = check_empty($this->input->post('password'), FALSE, '1003');
     $passlen = strlen($password);
     if ($passlen < 6 || $passlen > 16) {
         response_code('1003');
     }
     /*	$user_mobile = $this->get_current_data('check_mobile');
     		if($user_mobile != $username)
     		{
     			response_code('5002');
     		}*/
     $user_mobile = $username;
     $mobile_cache = $this->model->check_mobile_send($user_mobile);
     //缓存取数据
     if (!$mobile_cache) {
         response_code('5012');
     }
     if ($identifycode != $mobile_cache['mobile_identify']) {
         response_code('5002');
     }
     $user = array('password' => $password, 'mobile' => $user_mobile);
     $user['salt'] = getRandChar(4);
     $user_id = $this->model->reg_user($user);
     if ($user_id) {
         $this->model->delete_mobile_identify($user_mobile);
         /*$session = array(
         			'user_id' => $user_id,
         			'user_name' => $user_mobile,
         			'nick_name' => '手机用户',
         		);
         		$this->set_current_data($session);*/
         //帮助用户登录
         $user['user_id'] = $user_id;
         $token = $this->create_token($user);
         response_json('1', array('token' => $token));
     }
     response_code('4000');
 }