Example #1
0
 protected function loginAsNormalUser()
 {
     $un = 'user-' . uniqid();
     $u = newUser($email = $un . '@example.com', $username = $un, $password = '******');
     $this->login($un, $password);
     $this->user = $u;
     return $u;
 }
Example #2
0
function getUser($email = '*****@*****.**')
{
    if (DB\countRows('users', "email = ?", array($email)) == 0) {
        return newUser($email, 'big-joe-' . time(), 'something');
    } else {
        return User::loadFromEmailAddr($email);
    }
}
Example #3
0
 function testOneEmailAddressMayNotBeAssociatedWithMultipleAccounts()
 {
     newUser($email = '*****@*****.**', $username = '******', $password = '******');
     $this->get('/account/signup');
     $this->submitFormExpectingErrors($this->getForm(), array('username' => 'bigkid', 'email' => '*****@*****.**', 'password1' => 't0pS33cret', 'password2' => 't0pS33cret'));
     $this->assertContains("//div[contains(., 'already have an account')]");
     assertEqual(1, DB\countRows('users', 'email = ?', array('*****@*****.**')));
 }
Example #4
0
 function testUsersOverviewScreen()
 {
     newUser('*****@*****.**', 'some-user', 'abc');
     $u2 = newUser('*****@*****.**', 'other-user', 'def');
     DB\updateByID('users', $u2->id, array('created_at' => new \DateTime('now')));
     newUser('*****@*****.**', 'chris', 'secret!');
     $this->login('chris', 'secret!');
     $this->get('/admin/users/');
 }
function testUpdatePassword()
{
    clearDB();
    $u1 = newUser('*****@*****.**', 'a', 'mysecretpass');
    $u2 = newUser('*****@*****.**', 'b', 'sumthingsecret');
    $u1->updatePassword('newpass');
    $rows = DB\selectAllRows('users');
    assertNotEqual($rows[0]['password'], $rows[1]['password']);
}
    $name = makeStringSafe($name);
    $email = makeStringSafe($email);
    $user_level = makeStringSafe($user_level);
    $password = "";
    if (!getConfigVar("use_ldap")) {
        $password = makeStringSafe(generatePassword(9, 4));
    }
    doQuery("INSERT INTO " . getDBPrefix() . "_users SET username = '******', name = '" . $name . "', password = '******', email = '" . $email . "', user_level = '" . $user_level . "', warnings = '0'");
    $user = mysql_fetch_assoc(doQuery("SELECT user_id FROM " . getDBPrefix() . "_users ORDER BY user_id DESC LIMIT 1"));
    logAddUser(getSessionVariable('user_id'), $user['user_id']);
    return $password;
}
function createUserFromLDAP($username, $password)
{
    $auth_user = $username . "@" . getConfigVar('ldap_domain');
    if ($connect = @ldap_connect(getConfigVar('ldap_server'))) {
        if ($bind = @ldap_bind($connect, $auth_user, $password)) {
            $ldap_dn = "ou=people, dc=radford, dc=EDU";
            $filter = "(sAMAccountName={$username})";
            $result = ldap_search($connect, $ldap_dn, $filter);
Example #7
0
function signUp($db)
{
    if (!empty($_POST['username'])) {
        $myusername = mysqli_real_escape_string($db, $_POST['username']);
        $mypassword = mysqli_real_escape_string($db, $_POST['password']);
        $sql = "SELECT user_id FROM user WHERE username = '******' and password = '******'";
        $result = mysqli_query($db, $sql);
        if (!$result) {
            die('Invalid query: ' . mysqli_error($db));
        }
        $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
        $count = mysqli_num_rows($result);
        if ($count == 1) {
            echo "Sorry you are already a registered user";
            echo "</br></br>This page will redirect in 5 seconds";
            header("refresh:5;url=../views/register-form.php");
        } else {
            newUser($db);
        }
    }
}
Example #8
0
<?php

include './functions/user_logic.php';
include './functions/photo_logic.php';
$ip = get_client_ip();
$nick = $_POST['nick'];
$password = $_POST['password'];
$email = $_POST['email'];
$name = $_POST['name'];
$surname = $_POST['surname'];
$age = $_POST['age'];
$gender = $_POST['gender'];
$avatar = $_FILES['avatar'];
if (newUser($ip, $nick, $password, $email, $name, $surname, $age, $gender)) {
    echo "Usuario registrado.<br/>";
    $path = "data/user.png";
    if (isset($_FILES['avatar'])) {
        if (acceptImage($avatar)) {
            echo "Imagen aceptada.<br/>";
            $path = "data/" . $nick;
            if (!file_exists("../" . $path) and !is_dir("../" . $path)) {
                mkdir("../" . $path, 0777, true);
                // 0777 default for folder, rather than 0755
            }
            $path = $path . "/" . $avatar["name"];
            $error = uploadPhoto($ip, $avatar, $nick, $email, $path, "Fotos de Perfil");
            if ($error != '0') {
                $path = "data/user.png";
                switch ($error) {
                    case '1':
                        echo "No se ha podido crear el álbum de fotos.";
Example #9
0
$con = dataBase();
//Подключение разных языков!!!
if (!isset($_SESSION['lang']) and $_SESSION['lang'] == NULL) {
    $_SESSION['lang'] = "ru";
}
if (isset($_POST['lang'])) {
    $_SESSION['lang'] = $_POST['lang'];
}
$lang = getLang($_SESSION['lang'], $con);
//Конец подключения разных языков!!!
if (isset($_POST['register']) and isset($_POST['login']) and isset($_POST['email']) and isset($_POST['password']) and isset($_POST['repassword'])) {
    $login = $_POST['login'];
    $email = $_POST['email'];
    $pass = $_POST['password'];
    $repass = $_POST['repassword'];
    $newUser = newUser($login, $email, $pass, $repass, $con);
    if ($newUser == "true") {
        header("Location: ../index.php?registration=success");
        exit;
    } else {
        $error = $newUser;
    }
}
?>

<!DOCTYPE html>
<html lang="ru">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    $o->{1} = $first_name;
    $o->{2} = $last_name;
    return $o;
}
class Something
{
    public function __isset($name)
    {
        return $name == 'first_name';
    }
    public function __get($name)
    {
        return new User(4, 'Jack', 'Sparrow');
    }
}
$records = array(newUser(1, 'John', 'Doe'), newUser(2, 'Sally', 'Smith'), newUser(3, 'Jane', 'Jones'), new User(1, 'John', 'Doe'), new User(2, 'Sally', 'Smith'), new User(3, 'Jane', 'Jones'), new Something());
echo "*** Testing array_column() : object property fetching (numeric property names) ***\n";
echo "-- first_name column from recordset --\n";
var_dump(array_column($records, 1));
echo "-- id column from recordset --\n";
var_dump(array_column($records, 0));
echo "-- last_name column from recordset, keyed by value from id column --\n";
var_dump(array_column($records, 2, 0));
echo "-- last_name column from recordset, keyed by value from first_name column --\n";
var_dump(array_column($records, 2, 1));
echo "*** Testing array_column() : object property fetching (string property names) ***\n";
echo "-- first_name column from recordset --\n";
var_dump(array_column($records, 'first_name'));
echo "-- id column from recordset --\n";
var_dump(array_column($records, 'id'));
echo "-- last_name column from recordset, keyed by value from id column --\n";
Example #11
0
<?php

//  $query = $coll->findOne(array('login' => $_POST['login']));
require_once 'seguridad/class.inputfilter.php';
$filtro = new InputFilter();
$_POST = $filtro->process($_POST);
$usuario = $_POST['login'];
$password = $_POST['password'];
///////////////////////////////////////
include_once "config.php";
if (newUser($usuario, $password)) {
    header("Refresh: 0;url=confirmar.php?mensaje=1");
} else {
    header("Refresh: 0;url=confirmar.php?mensaje=2");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Crear usuario</title>
</head>
<body>
	
</body>
</html>
Example #12
0
<?php 
session_start();
//подключение конфигов
include "../include/stack.php";
$con = dataBase();
if (isset($_POST['register']) and isset($_POST['login']) and isset($_POST['email']) and isset($_POST['password']) and isset($_POST['repassword'])) {
    $login = $_POST['login'];
    $email = $_POST['email'];
    $pass = $_POST['password'];
    $repass = $_POST['repassword'];
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $newUser = newUser($login, $email, $pass, $repass, "registration", $firstname, $lastname, "", $con);
    if ($newUser == "true") {
        header("Location: ../index.php?registration=success");
        exit;
    } else {
        $error = $newUser;
    }
}
?>

<!DOCTYPE html>
<html lang="ru">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Cake Group | Регистрация</title>
Example #13
0
        return false;
    }
    $stmnt2->close();
    $stmnt = $conn->prepare("INSERT INTO USERS2(USER_UID,USER_PWDHSH,USER_PWDSALT,USER_FNAME,USER_LNAME, USER_EMAIL, VERIFYED) VALUES(?,?,?,?,?,?,1)");
    $salt = file_get_contents('/dev/urandom', false, null, 0, 64);
    $options = array('salt' => $salt);
    $phash = crypt($password, $salt);
    $stmnt->bind_param('ssssss', $username, $phash, $salt, $fname, $lname, $email);
    $stmnt->execute();
    $stmnt->close();
    $conn->close();
    return true;
}
$fail = false;
session_start();
if (newUser($_POST["USERNAME"], $_POST["PASSWORD"], $_POST["PASSWORD2"], $_POST["FNAME"], $_POST["LNAME"], $_POST["EMAIL"])) {
    echo "True";
    //make folder for every new user
    $dir = "/var/www/html/facePics/" . $_POST["USERNAME"];
    mkdir($dir);
    //make csv file
    $file = $dir . "/csv";
    touch($file);
    $mail = $_POST["EMAIL"];
    $name = $_POST["USERNAME"];
    $subject = "Welcome to the Who R U";
    $message = "141.210.25.46/email.php?USERNAME={$name}";
    $headers = "";
    $from = "-f your@email.here";
    if (mail($mail, $subject, $message)) {
        //		echo "Mail worked";
Example #14
0
    $result = false;
    $params = array('client_id' => $client_id, 'redirect_uri' => $redirect_uri, 'client_secret' => $client_secret, 'code' => $_GET['code']);
    $url = 'https://graph.facebook.com/oauth/access_token';
}
//Для того чтобы распарсить данный ответ, воспользуемся функцией parse_str, а результат (в виде массива) запишем в переменную $tokenInfo:
$tokenInfo = null;
parse_str(file_get_contents($url . '?' . http_build_query($params)), $tokenInfo);
//Получение информации о пользователе
if (count($tokenInfo) > 0 && isset($tokenInfo['access_token'])) {
    $params = array('access_token' => $tokenInfo['access_token']);
    $userInfo = json_decode(file_get_contents('https://graph.facebook.com/me' . '?' . urldecode(http_build_query($params))), true);
    if (isset($userInfo['id'])) {
        $userInfo = $userInfo;
        $result = true;
    }
}
//Показ данных пользователя
if ($result) {
    $login = formChars($userInfo['id']);
    $pass = formChars($userInfo['id']);
    $repass = formChars($userInfo['id']);
    $id = userLogin($login, $pass, $con);
    if ($id == false) {
        newUser($login, "", $pass, $repass, "facebook", $userInfo['name'], "", "http://graph.facebook.com/" . $userInfo['id'] . "/picture?type=large", $con);
    }
    $id = userLogin($login, $pass, $con);
    usersLog($id, "Пользователь успешно авторизовался и вошел в сеть", $con);
    $_SESSION['idUser'] = $id;
    header("Location: ../pages/profile.php");
    exit;
}
		echo participantSearch($_GET['search']);
	}
	
	if(isset($_GET['confirm'])){
		participantConfirm($_GET['confirm']);
	}
	
	if(isset($_GET['participantevent'])){
		echo participantEvents($_GET['participantevent']);
	}
	
	if(isset($_GET['participantinfo'])){
		echo participantInfo($_GET['participantinfo']);
	}
	
	if(isset($_POST['pname'])&&
		isset($_POST['pemail'])&&
		isset($_POST['pclg'])&&
		isset($_POST['pcntct'])&&
		isset($_POST['pstate'])&&
		isset($_POST['pgender'])&&
		isset($_POST['preq'])){
		header("Location: ../details.php?tid=".newUser($_POST['pname'],$_POST['pemail'],$_POST['pclg'],$_POST['pcntct'],$_POST['pstate'],$_POST['pgender'],$_POST['preq']));
	}

	if(isset($_POST['pid']) && isset($_POST['pname']) && isset($_POST['pemail']) && isset($_POST['pclg']) && isset($_POST['pcntct']) && isset($_POST['pstate']) && isset($_POST['preq']) && isset($_POST['pnitc'])){
		echo updateParticipantInfo($_POST['pid'], $_POST['pname'],$_POST['pemail'],$_POST['pclg'],$_POST['pcntct'],$_POST['pstate'],$_POST['preq'],$_POST['pnitc']);
		}
	
?>
Example #16
0
        trigger_error($result->getMessage(), E_USER_ERROR);
    }
    // Find the max cust_id
    $result = $connection->query("SELECT max(cust_id) FROM customer");
    if (DB::isError($result)) {
        trigger_error($result->getMessage(), E_USER_ERROR);
    }
    $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
    // Work out the next available ID
    $cust_id = $row["max(cust_id)"] + 1;
    // Insert the new customer
    $query = "INSERT INTO customer VALUES ({$cust_id}, \n            '{$_SESSION["custFormVars"]["surname"]}', \n            '{$_SESSION["custFormVars"]["firstname"]}',  \n            '{$_SESSION["custFormVars"]["initial"]}', \n            {$_SESSION["custFormVars"]["title_id"]}, \n            '{$_SESSION["custFormVars"]["address"]}', \n            '{$_SESSION["custFormVars"]["city"]}', \n            '{$_SESSION["custFormVars"]["state"]}', \n            '{$_SESSION["custFormVars"]["zipcode"]}', \n            {$_SESSION["custFormVars"]["country_id"]}, \n            '{$_SESSION["custFormVars"]["phone"]}', \n            '{$_SESSION["custFormVars"]["birth_date"]}')";
    $result = $connection->query($query);
    if (DB::isError($result)) {
        trigger_error($result->getMessage(), E_USER_ERROR);
    }
    // Unlock the customer table
    $result = $connection->query("UNLOCK TABLES");
    if (DB::isError($result)) {
        trigger_error($result->getMessage(), E_USER_ERROR);
    }
    // As this was an INSERT, we need to INSERT into the users table too
    newUser($_SESSION["custFormVars"]["loginUsername"], $_SESSION["custFormVars"]["loginPassword"], $cust_id, $connection);
    // Log the user into their new account
    registerLogin($_SESSION["custFormVars"]["loginUsername"]);
}
// Clear the custFormVars so a future form is blank
unset($_SESSION["custFormVars"]);
unset($_SESSION["custErrors"]);
// Now show the customer receipt
header("Location: " . S_CUSTRECEIPT);
Example #17
0
function signUp()
{
    global $db;
    // refer to the global variable 'db'
    $userID = $_POST['user'];
    $userpass = $_POST['pass'];
    if (!empty($userID)) {
        $query = "SELECT * FROM USER WHERE user_id='" . $userID . "' AND hashed_password ='******' LIMIT 1";
        $res = $db->query($query);
        if (!$res) {
            exit("There is a MySQL error, exiting this script");
        }
        if (!($row = mysqli_fetch_row($res))) {
            newUser();
        } else {
            echo "SORRY...YOU ARE ALREADY REGISTERED USER";
        }
    }
}
Example #18
0
}
$answer = "[\"Error. No function executed\"]";
$method = filter_input(INPUT_POST, "method");
if ($method) {
    $id = $mysqli->real_escape_string(filter_input(INPUT_POST, "id"));
    $firstname = $mysqli->real_escape_string(filter_input(INPUT_POST, "firstname"));
    $lastname = $mysqli->real_escape_string(filter_input(INPUT_POST, "lastname"));
    $nickname = $mysqli->real_escape_string(filter_input(INPUT_POST, "nickname"));
    $sex = $mysqli->real_escape_string(filter_input(INPUT_POST, "sex"));
    $birthday = $mysqli->real_escape_string(filter_input(INPUT_POST, "birthday"));
    $lefteye_x = $mysqli->real_escape_string(filter_input(INPUT_POST, "lefteyeX"));
    $lefteye_y = $mysqli->real_escape_string(filter_input(INPUT_POST, "lefteyeY"));
    $righteye_x = $mysqli->real_escape_string(filter_input(INPUT_POST, "righteyeX"));
    $righteye_y = $mysqli->real_escape_string(filter_input(INPUT_POST, "righteyeY"));
    if ($method == "newuser") {
        $answer = newUser($firstname, $lastname, $nickname, $sex, $birthday);
    } elseif ($method == "getallusers") {
        $answer = getAllUsers();
    } elseif ($method == "getuserdata") {
        $answer = getUserData($id);
    } elseif ($method == "updateuser") {
        $answer = updateUser($id, $firstname, $lastname, $nickname, $sex, $birthday);
    } elseif ($method == "deleteuser") {
        $answer = deleteuser($id);
    } elseif ($method == "getuserimageids") {
        $answer = getUserImageIds($id);
    } elseif ($method == "newphoto") {
        $answer = uploadNewPhoto($id);
    } elseif ($method == "deletephoto") {
        $answer = deletePhoto($id);
    } elseif ($method == "updateeyes") {
Example #20
0
function main($usercount, $groupcount, $noticeavg, $subsavg, $joinsavg, $tagmax)
{
    global $config;
    $config['site']['dupelimit'] = -1;
    $n = 0;
    $g = 0;
    // Make users first
    $preuser = min($usercount, 5);
    for ($j = 0; $j < $preuser; $j++) {
        printfv("{$i} Creating user {$n}\n");
        newUser($n);
        $n++;
    }
    $pregroup = min($groupcount, 3);
    for ($k = 0; $k < $pregroup; $k++) {
        printfv("{$i} Creating group {$g}\n");
        newGroup($g, $n);
        $g++;
    }
    // # registrations + # notices + # subs
    $events = $usercount + $groupcount + $usercount * ($noticeavg + $subsavg + $joinsavg);
    $events -= $preuser;
    $events -= $pregroup;
    $ut = $usercount;
    $gt = $ut + $groupcount;
    $nt = $gt + $usercount * $noticeavg;
    $st = $nt + $usercount * $subsavg;
    $jt = $st + $usercount * $joinsavg;
    printfv("{$events} events ({$ut}, {$gt}, {$nt}, {$st}, {$jt})\n");
    for ($i = 0; $i < $events; $i++) {
        $e = rand(0, $events);
        if ($e >= 0 && $e <= $ut) {
            printfv("{$i} Creating user {$n}\n");
            newUser($n);
            $n++;
        } else {
            if ($e > $ut && $e <= $gt) {
                printfv("{$i} Creating group {$g}\n");
                newGroup($g, $n);
                $g++;
            } else {
                if ($e > $gt && $e <= $nt) {
                    printfv("{$i} Making a new notice\n");
                    newNotice($n, $tagmax);
                } else {
                    if ($e > $nt && $e <= $st) {
                        printfv("{$i} Making a new subscription\n");
                        newSub($n);
                    } else {
                        if ($e > $st && $e <= $jt) {
                            printfv("{$i} Making a new group join\n");
                            newJoin($n, $g);
                        } else {
                            printfv("No event for {$i}!");
                        }
                    }
                }
            }
        }
    }
}
Example #21
0
     newArticle();
     break;
 case 'editArticle':
     editArticle();
     break;
 case 'deleteArticle':
     deleteArticle();
     break;
 case 'viewArticle':
     viewArticle();
     break;
 case 'archive':
     archive();
     break;
 case 'newUser':
     newUser();
     break;
 case 'editUser':
     editUser();
     break;
 case 'deleteUser':
     deleteUser();
     break;
 case 'viewUser':
     viewUser();
     break;
 case 'users':
     users();
     break;
 default:
     homepage();
Example #22
0
 * Auteur : Romain Maillard
 * Date   : 28.09.2015
 * But: Création d'un nouvel utilisateur
 */
session_start();
//  Inclusion fichier de fonction.
require_once "include/fonction.php";
//  V?rifie si l'utilisateur est d?j? connect? sinon le redirige vers signin.php.
if (!isConnected()) {
    header('Location: signout.php');
}
if ($_SESSION['role'] != 2) {
    header('Location: index.php');
}
if (isset($_POST['ok'])) {
    if (!newUser($_POST['username'], $_POST['password'], $_POST['passwordretape'], $_POST['role'], $_POST['active'])) {
        echo "<script>alert('Add failed');</script>";
    } else {
        header('Location: admin.php');
    }
}
//  ***************************************************************************
?>
 
<!DOCTYPE html> 
<html lang="fr"> 
    <head> 
        <meta charset="utf-8">         
        <meta http-equiv="X-UA-Compatible" content="IE=edge">         
        <meta name="viewport" content="width=device-width, initial-scale=1">         
        <meta name="description" content="">         
Example #23
0
        $errors['password_confirm'] = "Please confirm password.";
    }
    if ($_POST['password'] != $_POST['password_confirm']) {
        $errors['password'] = "******";
    }
    if (!$email) {
        $errors['email'] = "Not a valid email address.";
    }
}
if (isset($_POST["submit"]) && empty($errors)) {
    $hasher = new PasswordHash(8, FALSE);
    $password = $hasher->HashPassword($_POST['password']);
    $token = md5(uniqid(mt_rand(), true));
    $query = $coll->findOne(array('$or' => array(array('username' => $_POST['username']), array('email' => $_POST['email']))));
    if (empty($query)) {
        newUser($_POST["username"], $password, $_POST["email"], $token);
        cleanMemberSession($_POST["username"], $_POST["remember_me"]);
        sendMail($_POST["email"], "", "register");
        header("Location: members.php");
    } elseif ($query['username'] == $_POST['username']) {
        $errors['username'] = "******";
    } elseif ($query['email'] == $_POST['email']) {
        $errors['email'] = "That email address is already in use.";
    }
}
?>

<html>
<head>
    <title>Simple Register with MongoDB</title>
</head>
Example #24
0
<?php

require_once 'includes/header.php';
$db = Database::obtain();
if (isset($_POST['nickname'], $_POST['email'], $_POST['steamId64'])) {
    $nickname = substr($_POST['nickname'], 0, 80);
    $email = $_POST['email'];
    $steamid = (string) $_POST['steamId64'];
    if (newUser($nickname, $steamid, $email, $_POST['loc'])) {
        echo 'Your account has been successfully created.';
        redirect('index.php', 3);
    }
} else {
    echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>TF2 Matchmaking System</title>
	<link href="theme/style_profile.css" rel="stylesheet" type="text/css" />
	<link href="theme/uniform.default.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div id="background_image"></div>
	<div id="wrapper">
		<div id="header">
			<a href="" id="logo">TF2 Matchmaking System</a>
		</div>
		<div id="content" class="big_panel">
			<ul class="nav_panel">
				<li><a href="index.html">Home</a></li>
				<li class="current"> &raquo; Register</li>
Example #25
0
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, urldecode(http_build_query($params)));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $result = curl_exec($curl);
    curl_close($curl);
    $tokenInfo = json_decode($result, true);
    if (isset($tokenInfo['access_token'])) {
        $params['access_token'] = $tokenInfo['access_token'];
        $userInfo = json_decode(file_get_contents('https://www.googleapis.com/oauth2/v1/userinfo' . '?' . urldecode(http_build_query($params))), true);
        if (isset($userInfo['id'])) {
            $userInfo = $userInfo;
            $result = true;
        }
    }
}
if ($result) {
    $login = formChars($userInfo['id']);
    $pass = formChars($userInfo['id']);
    $repass = formChars($userInfo['id']);
    $id = userLogin($login, $pass, $con);
    if ($id == false) {
        newUser($login, $userInfo['email'], $pass, $repass, "google", $userInfo['name'], "", $userInfo['picture'], $con);
    }
    $id = userLogin($login, $pass, $con);
    usersLog($id, "Пользователь успешно авторизовался и вошел в сеть", $con);
    $_SESSION['idUser'] = $id;
    header("Location: ../pages/profile.php");
    exit;
}
Example #26
0
<?php

include '../../inc/connect.php';
$passLen = 8;
// minimum length for a password
if (!empty($_POST['username'])) {
    $query = $db->query("SELECT user_name FROM user WHERE user_name = '{$_POST['username']}'");
    if ($query->num_rows > 0) {
        echo "UserExists";
    } else {
        if ($_POST['password'] == $_POST['repassword']) {
            if (strlen($_POST['password']) >= $passLen) {
                $user = $_POST['username'];
                $pass = $_POST['password'];
                if (newUser($user, $pass, $db)) {
                    echo "UserCreated";
                } else {
                    echo "UserNotCreated";
                }
            } else {
                echo "PassLen";
            }
        } else {
            echo "PassSame";
        }
    }
} else {
    echo "EmptyField";
}
function newUser($username, $password, $db)
{
Example #27
0
    $token = json_decode(file_get_contents('https://oauth.vk.com/access_token' . '?' . urldecode(http_build_query($params))), true);
    if (isset($token['access_token'])) {
        $params = array('uids' => $token['user_id'], 'fields' => 'uid,first_name,last_name,screen_name,sex,bdate,photo_big', 'access_token' => $token['access_token']);
        $userInfo = json_decode(file_get_contents('https://api.vk.com/method/users.get' . '?' . urldecode(http_build_query($params))), true);
        if (isset($userInfo['response'][0]['uid'])) {
            $userInfo = $userInfo['response'][0];
            $result = true;
        }
    }
    if ($result) {
        $login = formChars($userInfo['uid']);
        $pass = formChars($userInfo['uid']);
        $repass = formChars($userInfo['uid']);
        $id = userLogin($login, $pass, $con);
        if ($id == false) {
            newUser($login, "", $pass, $repass, "vkontakte", $userInfo['first_name'], "", $userInfo['photo_bit'], $con);
        }
        $id = userLogin($login, $pass, $con);
        usersLog($id, "Пользователь успешно авторизовался и вошел в сеть", $con);
        $_SESSION['idUser'] = $id;
        header("Location: ../pages/profile.php");
        exit;
        /*
                echo "Социальный ID пользователя: " . $userInfo['uid'] . '<br />';
                echo "Имя пользователя: " . $userInfo['first_name'] . '<br />';
                echo "Ссылка на профиль пользователя: " . $userInfo['screen_name'] . '<br />';
                echo "Пол пользователя: " . $userInfo['sex'] . '<br />';
                echo "День Рождения: " . $userInfo['bdate'] . '<br />';
                echo '<img src="' . $userInfo['photo_big'] . '" />'; echo "<br />";
*/
    }
Example #28
0
 function testAttemptingToSigninWithIncorrectPassword()
 {
     newUser('*****@*****.**', 'jimmy', 'strawberries');
     $this->get('/account/signin');
     $this->submitFormExpectingErrors($this->getForm(), array('username' => 'jimmy', 'password' => 'incorrect'));
 }
Example #29
0
function main($usercount, $noticeavg, $subsavg, $tagmax)
{
    global $config;
    $config['site']['dupelimit'] = -1;
    $n = 1;
    newUser(0);
    // # registrations + # notices + # subs
    $events = $usercount + $usercount * ($noticeavg + $subsavg);
    for ($i = 0; $i < $events; $i++) {
        $e = rand(0, 1 + $noticeavg + $subsavg);
        if ($e == 0) {
            newUser($n);
            $n++;
        } else {
            if ($e < $noticeavg + 1) {
                newNotice($n, $tagmax);
            } else {
                newSub($n);
            }
        }
    }
}
Example #30
0
	<body>
		
		<!-- contenu de la page -->
		<?php 
session_start();
if (isset($_SESSION['pseudo']) && isset($_SESSION['pass'])) {
    include "template/header.php";
    ?>
		<section>
			<?php 
    if (isset($_POST['username']) && isset($_POST['password']) && $_POST['username'] !== "" && $_POST['password'] !== "") {
        require_once "../scripts/base_connexion.php";
        require_once "../scripts/traitement.php";
        require_once "../scripts/requetes.php";
        //insertion dans la base
        $res = newUser($_POST['username'], $_POST['password'], $base);
        if ($res == -1) {
            echo "<div>Impossible d'ajouter cet utilisateur!</div>";
        } elseif ($res == 0) {
            echo "<div>Cet utilisateur existe déjà...</div>";
        } else {
            echo "<div>Opération d'ajout de l'utilisateur réussie:<br/>\n\t\t\t\t\t\t\t<label>Nom d'utilisateur</label> " . $_POST['username'] . "<br/>\n\t\t\t\t\t\t\t<label>Mot de passe</label>" . $_POST['password'] . "<br/>\n\t\t\t\t\t\t</div>";
        }
    } else {
        ?>
					<form method="post" action="ajouter_utilisateur.php">
						<table>
						<tr>
							<td><label>Nom d'utilisateur</label></td>
							<td><input type="text" name="username" autocomplete="off" placeholder="username" required/></td>
						</tr>