Exemplo n.º 1
0
function registration()
{
    require_once "mysql.inc.php";
    if (isset($_POST["submit"])) {
        $eingabeVorname = $_POST["vorname"];
        $eingabeNachname = $_POST["nachname"];
        $eingabeBenutzername = $_POST["benutzername"];
        $eingabeEmail = $_POST["email"];
        $eingabePassword = $_POST["password"];
        $passwordmd5 = md5($eingabePassword);
        $eingabePasswordTest = $_POST["passwordTest"];
        $passwordTestmd5 = md5($eingabePasswordTest);
        $eingabeGeburtstag = $_POST["geburtstag"];
        $eingabeWohnort = $_POST["wohnort"];
        $eingabeHochschule = $_POST["hochschule"];
        $eingabeStudienrichtung = $_POST["studienrichtung"];
        if (countUser($eingabeBenutzername) == 0 && $eingabeBenutzername != NULL) {
            if ($passwordmd5 == $passwordTestmd5) {
                if ($eingabeEmail != NULL) {
                    insertUser($eingabeVorname, $eingabeNachname, $eingabeBenutzername, $eingabeEmail, $passwordmd5, $eingabeGeburtstag, $eingabeWohnort, $eingabeHochschule, $eingabeStudienrichtung);
                    echo "Willkommen {$eingabeVorname} {$eingabeNachname}, Sie wurden erfolgreich registriert";
                    $_SESSION["sessionLogin"] = $eingabeBenutzername;
                } else {
                    echo "FEHLER: Keine Email Adresse eingegeben";
                }
            } else {
                echo "FEHLER: Die eingegebenen Passwörter unterscheiden sich.";
            }
        } else {
            echo "FEHLER: Der Benutzer existiert bereits (oder es wurde kein Benutzername eingegeben).";
        }
    }
}
Exemplo n.º 2
0
function register()
{
    // Xu ly dang ki thanh vien moi
    if (isset($_POST['ok'])) {
        if ($_POST['username'] == "") {
            $error = "Chưa nhập username";
        } else {
            if ($_POST['password'] == "") {
                $error = "Chưa nhập mật khẩu";
            } else {
                if ($_POST['re-password'] == "") {
                    $error = "Chưa nhập lại mật khẩu";
                } else {
                    if ($_POST['fullname'] == "") {
                        $error = "Chưa nhập họ tên";
                    } else {
                        if ($_POST['password'] != $_POST['re-password']) {
                            $error = "Xác thực mật khẩu không đúng";
                        } else {
                            insertUser($_POST['username'], $_POST['password'], $_POST['fullname'], $_POST['year'], $_POST['info']);
                            // Chuyen sang trang login
                            redirect("?controller=user&action=login");
                        }
                    }
                }
            }
        }
    }
    include "view/user/register.php";
}
Exemplo n.º 3
0
function createAccount()
{
    if (!isset($_POST['name']) || !isset($_POST['pass'])) {
        http_response_code(HTTP_BAD_REQUEST);
        echo 'name and pass parameters required';
        return;
    }
    $hash = password_hash($_POST['pass'], PASSWORD_DEFAULT);
    $userid = insertUser($_POST['name'], $hash);
    if ($userid > 0) {
        setSessionUser($userid, $_POST['name']);
    }
}
Exemplo n.º 4
0
function parseURI()
{
    parse_str($_SERVER['QUERY_STRING'], $params);
    $ustreamUID = $params['ustreamUID'] ? $params['ustreamUID'] : NULL;
    $longitude = $params['longitude'] ? $params['longitude'] : NULL;
    $latitude = $params['latitude'] ? $params['latitude'] : NULL;
    $event = $params['event'] ? $params['event'] : NULL;
    echo "uid: " . $ustreamUID . " latitude: " . $latitude . " longitude: " . $longitude . " event: " . $event . "<br/>";
    if ($ustreamUID && $longitude && $latitude && $event) {
        if (findUser($ustreamUID)) {
            updateUser($ustreamUID, $longitude, $latitude, $event);
        } else {
            insertUser($ustreamUID);
            updateUser($ustreamUID, $longitude, $latitude, $event);
        }
    }
}
Exemplo n.º 5
0
function addUser($userName, $passwordHash, $role)
{
    $dbInfo = getDbForUserIdGeneration();
    $link = $dbInfo ? connect($dbInfo) : null;
    if (!$link || !\database\beginTransaction($link)) {
        return 0;
    }
    $userId = \database\getNextUserId($link);
    if (!$userId) {
        \database\rollbackTransaction($link);
        return 0;
    }
    $existingId = getUserIdByName($userName);
    if ($existingId) {
        \database\rollbackTransaction($link);
        return 0;
    }
    if (!insertUser($userId, $userName, $passwordHash, $role)) {
        \database\rollbackTransaction($link);
        return 0;
    }
    return \database\commitTransaction($link) ? $userId : 0;
}
function processCSVFile($filename = '', $delimiter = ',')
{
    if (!file_exists($filename) || !is_readable($filename)) {
        return FALSE;
    }
    if (($handle = fopen($filename, 'r')) !== FALSE) {
        while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
            $rowData = array();
            $rowData[] = $row[0];
            //name
            $rowData[] = $row[1];
            //last name
            $rowData[] = strtolower(substr(trim($row[0]), 0, 1) . trim($row[1]));
            //user_id
            $random_password = wp_generate_password($length = 8, $include_standard_special_chars = false);
            $rowData[] = $random_password;
            //password
            $rowData[] = $row[2];
            //email
            insertUser($rowData);
        }
        fclose($handle);
    }
}
Exemplo n.º 7
0
if (!function_exists('mysqli_connect')) {
    fancyDie("MySQL library is not installed");
}
$link = @mysqli_connect(TINYIB_DBHOST, TINYIB_DBUSERNAME, TINYIB_DBPASSWORD);
if (!$link) {
    fancyDie("Could not connect to database: " . (is_object($link) ? mysqli_error($link) : (($link_error = mysqli_connect_error()) ? $link_error : '(unknown error)')));
}
$db_selected = @mysqli_query($link, "USE " . constant('TINYIB_DBNAME'));
if (!$db_selected) {
    fancyDie("Could not select database: " . (is_object($link) ? mysqli_error($link) : (($link_error = mysqli_connect_error()) ? $link_error : '(unknown error')));
}
mysqli_query($link, "SET NAMES 'utf8'");
// Create the users table if it does not exist, as well as a default user
if (mysqli_num_rows(mysqli_query($link, "SHOW TABLES LIKE '" . TINYIB_DBUSERS . "'")) == 0) {
    mysqli_query($link, $users_sql);
    insertUser(array('name' => 'admin', 'password' => password_hash(TINYIB_DEFAULTPASS, PASSWORD_BCRYPT), 'admin' => 1));
}
// Create the posts table if it does not exist
if (mysqli_num_rows(mysqli_query($link, "SHOW TABLES LIKE '" . TINYIB_DBPOSTS . "'")) == 0) {
    mysqli_query($link, $posts_sql);
}
// Create the bans table if it does not exist
if (mysqli_num_rows(mysqli_query($link, "SHOW TABLES LIKE '" . TINYIB_DBBANS . "'")) == 0) {
    mysqli_query($link, $bans_sql);
}
# User Functions
function insertUser($user)
{
    global $link;
    mysqli_query($link, "INSERT INTO `" . TINYIB_DBUSERS . "` (`name`, `password`, `admin`) VALUES ('" . mysqli_real_escape_string($link, $user['name']) . "', '" . mysqli_real_escape_string($link, $user['password']) . "', " . boolval($user['admin']) . ")");
    return mysqli_insert_id($link);
Exemplo n.º 8
0
    $resultado = updateMiPerfil($mysqli, $_POST["uId"], $_POST["uName"], $_POST["uPass"], $_POST["uNombre"], $_POST["uApellidos"], $_POST["uDireccion"], $_POST["uEmail"], $_POST["uTelefono"], $_POST["uBio"]);
    echo 'USUARIO ACTUALIZADO -->' . $resultado;
    //print_r($_POST);
}
//DELETE
if (isset($_POST["userId"]) && isset($_POST["act"]) && $_POST["act"] === 'DELETE') {
    $resultado = deleteUser($mysqli, $_POST["userId"]);
    //devolvemos un mensaje de borrado correcto
    echo 'USUARIO ' . $_POST["userId"] . ' BORRADO';
}
if (isset($_POST["act"]) && $_POST["act"] === 'UPDATE' && isset($_POST["uId"]) && isset($_POST["uPass"]) && isset($_POST["uName"])) {
    $resultado = updateUser($mysqli, $_POST["uName"], $_POST["uPass"], $_POST["uId"]);
    echo 'USUARIO ACTUALIZADO -->' . $resultado;
}
if (isset($_POST["act"]) && $_POST["act"] === 'INSERT' && isset($_POST["uPass"]) && isset($_POST["uName"])) {
    $resultado = insertUser($mysqli, $_POST["uName"], $_POST["uPass"]);
    echo 'USUARIO INSERTADO -->' . $resultado;
}
//updateUser2 de casa
/*
    if(isset($_POST["email"]) && ($_POST["email"] !=="") && isset($_POST["bio"]) && ($_POST["bio"] !=="") && isset($_POST["usuario"]) && ($_POST["usuario"] !=="") && isset($_POST["password"]) && ($_POST["password"] !=="")){
          
      $resultado = updateUser2($mysqli,$_POST["usuario"],$_POST["password"],$_POST["email"],$_POST["bio"],$_SESSION['userId']);
}
*/
//nueva funcion update2
if (isset($_POST["act"]) && $_POST["act"] === 'UPDATE2' && isset($_POST["uId"]) && isset($_POST["uPass"]) && isset($_POST["uName"]) && isset($_POST["uEmail"]) && isset($_POST["uBio"])) {
    $resultado = updateUser2($mysqli, $_POST["uName"], $_POST["uPass"], $_POST["uEmail"], $_POST["uBio"], $_POST["uId"]);
    echo 'USUARIO ACTUALIZADO -->' . $resultado;
    //print_r($_POST);
}
Exemplo n.º 9
0
function registerUser($username, $password)
{
    global $salt;
    $hash = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($salt), $password, MCRYPT_MODE_CBC, md5(md5($salt))));
    insertUser($username, $hash);
}
Exemplo n.º 10
0
                 } else {
                     $error[] = "Sorry, there was an error uploading your file.";
                 }
             }
         }
     }
     if (!empty($adimg) && !empty($pictures)) {
         $pictures .= ',' . $adimg;
     }
     if (!empty($adimg) && empty($pictures)) {
         $pictures .= $adimg;
     }
     $update = "update lam_user_profile set pictures = '{$pictures}' where id = {$LastID}";
     $query = db_query($update);
 } else {
     $newid = insertUser($username, $deviceid);
     $query = sprintf("INSERT INTO lam_user_profile SET " . $field . ",\n                                            userid          =   '%d',\n\t\t\t\t\t\t\t\t\t\t\tpictures\t\t=\t'%s',\n\t\t\t\t\t\t\t\t\t\t\tinsert_date\t\t=\t'%s',\n\t\t\t\t\t\t\t\t\t\t\tstatus\t\t\t=\t'%s'\n\t\t\t", $newid, $name, $title, $rate, $profile_type, $sex, $sexuality, $height, $location, $figure, $languages, $interests, $food, $drinks, $dress_style, $occupation, $description, $pictures, $date, $status);
     $LastID = db_query_lastID($query);
     for ($i = 0; $i < 6; $i++) {
         if (!empty($_FILES["UploadImage"]["name"][$i])) {
             $target_dir = "../upload/";
             $uploadOk = 1;
             $target_temp = $target_dir . basename($_FILES["UploadImage"]["name"][$i]);
             $imageFileType = pathinfo($target_temp, PATHINFO_EXTENSION);
             $imagename = $LastID . "lamansion" . $i . "." . $imageFileType;
             $target_file = $target_dir . $imagename;
             // Check if image file is a actual image or fake image
             if (isset($_POST["submit_profile"])) {
                 $check = getimagesize($_FILES["UploadImage"]["tmp_name"][$i]);
                 if ($check !== false) {
                 } else {
Exemplo n.º 11
0
function createUser($userType, $email, $password, $confirmPassword, $firstname, $lastname)
{
    $return = returnValue();
    // check for empty fields
    if (empty($firstname) || empty($lastname)) {
        $return->value = false;
        $return->msg = "Firstname or lastname is empty";
        return $return;
    }
    //Whitelist name/surname fields
    if (!cleanInput($firstname)) {
        $return->value = false;
        $return->msg = "Invalid First Name";
        return $return;
    }
    if (!cleanInput($lastname)) {
        $return->value = false;
        $return->msg = "Invalid Last Name";
        return $return;
    }
    // check password meets complexity requirement
    if (!checkPasswordComplexity($password)) {
        $return->value = false;
        $return->msg = "Password must be between 8-20 chars, have upper and lower case, as well as digit";
        return $return;
    }
    // validate email format
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $return->value = false;
        $return->msg = "Invalid email format";
        return $return;
    }
    // check if usertype is among valid values
    if ($userType !== "E" && $userType !== "C") {
        $return->value = false;
        $return->msg = "Invalid user type";
        return $return;
    }
    // check if passwords match
    if ($password !== $confirmPassword) {
        $return->value = false;
        $return->msg = "Passwords do not match";
        return $return;
    }
    $password = hash('sha256', $password);
    getDBCredentials('R');
    $insert = insertUser($userType, $email, $password, $firstname, $lastname);
    // check if db operation failed
    if (!$insert) {
        $return->value = false;
        $return->msg = "DB insert operation failed";
        return $return;
    }
    $return->value = true;
    $return->msg = "Registration successful";
    return $return;
}
Exemplo n.º 12
0
                $query = "Select * from users where phone_no =" . $_POST['phone3'] . "";
                $result = mysqli_query($db, $query);
                $user[] = mysqli_affected_rows($db);
                $query = "Select * from teams where name ='" . $_POST['team'] . "'";
                $result = mysqli_query($db, $query);
                $team = mysqli_affected_rows($db);
                if ($user[0] > 0 || $user[1] > 0 || $user[2] > 0) {
                    $errors[] = "<p>Entered user already exists.</p>";
                }
                if ($team > 0) {
                    $errors[] = "<p>Entered team name already exists.</p>";
                }
                if (count($errors) == 0) {
                    insertUser($db, 1);
                    insertUser($db, 2);
                    insertUser($db, 3);
                    insertTeam($db);
                }
            } else {
                $errors[] = "<p>Enter unique phone numbers for each team member</p>";
            }
        }
    }
}
?>

<article id="main">
				<header>
					<h2>Register your team</h2>
				</header>
				<section class="wrapper style5" id="r_page">
Exemplo n.º 13
0
    return $req;
}
function insertUser($password, $name, $surname, $dateofbirth, $gender, $adress, $town, $country, $mail, $telnumber, $pseudo)
{
    $req = connexion()->prepare("INSERT INTO users ( password, name, surname, datebirth, gender, adress, town, country, mail, telnumber,pseudo) VALUES ( :password, :name, :surname, :datebirth, :gender, :adress, :town, :country, :mail, :telnumber,:pseudo)");
    $req->bindParam(':password', $password);
    $req->bindParam(':name', $name);
    $req->bindParam(':surname', $surname);
    $req->bindParam(':datebirth', $dateofbirth);
    $req->bindParam(':gender', $gender);
    $req->bindParam(':adress', $adress);
    $req->bindParam(':town', $town);
    $req->bindParam(':country', $country);
    $req->bindParam(':mail', $mail);
    $req->bindParam(':telnumber', $telnumber);
    $req->bindParam(':pseudo', $pseudo);
    $req->execute();
}
function removeUser($userId)
{
    $req = connexion()->prepare('DELETE * FROM users WHERE userId = ?');
    $req->execute(array($userId));
}
function removeMessage($idmessage)
{
    $req = connexion()->prepare('DELETE * FROM message WHERE idmessage = ?');
    $req->execute(array($idmessage));
}
//if($_POST['nom'] && $_POST['prenom'] && $_POST['date'] && $_POST['sex'] && $_POST['address'] && $_POST['ville'] && $_POST['pays'] && $_POST['pseudo'] && $_POST['pass'] && $_POST['mail'])
insertUser($_POST['pass'], $_POST['nom'], $_POST['prenom'], $_POST['date'], $_POST['sex'], $_POST['address'], $_POST['ville'], $_POST['pays'], $_POST['mail'], $_POST['number'], $_POST['pseudo']);
header('Location: ../view/index.php');
Exemplo n.º 14
0
    $captcha = '';
    if (isset($_POST['g-recaptcha-response'])) {
        $captcha = $_POST['g-recaptcha-response'];
    }
    if (!$captcha) {
        echo '<h2>Please check the the captcha form.</h2>';
        exit;
    }
    $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6Ld3rg8TAAAAADLoleP1CehvC4L7M2Bj87F2z5Jv&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']);
    $decoded_response = json_decode($response, true);
    if ($decoded_response["success"] == FALSE) {
        echo '<script language="javascript">
                                alert("You are Spammer ! Get the F%%k out");
                                window.location="' . SERVER . '";
                              </script>';
    } elseif (!checkUserEmail($email)) {
        insertUser($fname, $lname, $email, $contact, $pass);
        $_SESSION['user'] = $email;
        $row = getUserID($email);
        $_SESSION['id'] = $row['s_id'];
        echo '<script language="javascript">
                                alert("Successfully Registered !!");
                                window.location="' . SERVER . '";
                              </script>';
    } else {
        echo '<script language="javascript">
                                alert("Email Already Inserted !! Sign Up Failed");
                                window.location="' . SERVER . '/signup";
                              </script>';
    }
}
Exemplo n.º 15
0
<?php

if (isset($_POST['collection'])) {
    if ($_POST['collection'] == 'users') {
        switch ($_POST['action']) {
            case 'new':
                insertUser($_POST);
                break;
            case 'list':
                listUsers();
                break;
            case 'edit':
                editUser($_POST);
                break;
            case 'delete':
                deleteUser($_POST['mongoid']);
                break;
            case 'login':
                checkLogin($_POST);
                break;
        }
    }
}
class DataBase
{
    static function getDB()
    {
        $connection = new MongoClient("mongodb://82.223.133.87:20002");
        // connect to a remote host at a given port
        $db = $connection->iWonder;
        return $db;
Exemplo n.º 16
0
<?php

$servername = "localhost";
$username = "******";
$password = "******";
$debtAccount = $_GET['debtID'];
$conn = mysql_connect($servername, $username, $password);
$userName = $_POST['username'];
$email = $_POST['email'];
if (!$conn) {
    die('Could not connect:' . mysql_error());
} else {
    insertUser($userName, $email);
}
// check if
function insertUser($username, $email)
{
    $userID = uniqid();
    //
    // if (!mysql_select_db('BudgetBuddy', $conn)) {
    //     echo 'Could not select database';
    //     exit;
    // }
    $result = mysql_query("SELECT * FROM BudgetBuddy.Users WHERE userId='" . $userID . "'");
    if (!$result) {
        print "error";
        die(mysql_error());
    } else {
        $numRows = mysql_num_rows($result);
        if ($numRows == 0) {
            print "Rows: " . $numRows . " Username" . $username . "userID " . $userID;
Exemplo n.º 17
0
<?php

$connection = mysqli_connect("localhost", "e47wong", "Fall2014", "e47wong") or die("Error " . mysqli_error($link));
//This switch determines which function will be performed based on what parameters are passed in.
if (isset($_POST['json_data']) && !empty($_POST['json_data'])) {
    insertUser(json_decode($_POST['json_data']));
} else {
    if (isset($_GET['phone']) && !empty($_GET['phone'])) {
        //run update User
        updateUser($_GET['p'], $_GET['phone']);
    } else {
        $return = array();
        $return = searchUser($_GET['p']);
        //Retrieve result, encode the array and echo the string back to the application layer.
        echo json_encode($return);
    }
}
/*Function stores Facebook credentials into the MySQL db.
Input  - $fbInfo, a variable for an array decoded from JSON input.
Output - returns nothing. */
function insertUser($fbInfo)
{
    global $connection;
    //Check if there already exists a user with the same Facebook userID.
    $test = "SELECT COUNT(*) FROM `User` WHERE fBLink = '{$fbInfo->profile}'";
    $res = $connection->query($test);
    $row = $res->fetch_row();
    //If the result is 0, proceed with inserting the new user into the MySQL database.
    if ($row[0] == 0) {
        $sql = "INSERT INTO `User`(`firstName`, `lastName`, `fBLink`) VALUES ('{$fbInfo->fbFirstName}', '{$fbInfo->fbLastName}', '{$fbInfo->profile}')";
        $result = $connection->query($sql);
Exemplo n.º 18
0

                <?php 
if (isset($_GET["action"])) {
    switch ($_GET["action"]) {
        case "createUser":
            editUser($mysqli, 0);
            break;
        case "editUser":
            editUser($mysqli, $_GET["id"]);
            break;
        case "updateUser":
            updateUser($mysqli);
            break;
        case "insertUser":
            insertUser($mysqli);
            break;
        case "deleteUser":
            deleteUser($mysqli);
            break;
        case "unsetUsername":
            unset($_SESSION['username']);
            unset($_SESSION['password']);
            unset($_SESSION['admin']);
            header("location: index.php");
            break;
    }
}
showAllUsers($mysqli);
?>
                    
Exemplo n.º 19
0
    $mail = $name . "_" . $lastName . "@mailinator.com";
    $user = "******";
    mysql_query($user) or die("Error in query: {$user}. " . mysql_error());
    $userinfo = "INSERT INTO userinfo (FK_users, dateOfBirth, gender, maritalSt, studies, InstitutionName, currentLocation, religion, photo)\r\n    VALUE ({$id}, '{$dateOfBirth}','{$gender}','{$maritalSt}','{$studies}','{$institution}','{$location}','{$religion}', '{$photo}');";
    mysql_query($userinfo) or die("Error in query: {$userinfo}. " . mysql_error());
}
insertUser(1, 'Daniel', 'Gimenez', 'dg', 1, '14-11-1940', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08');
insertUser(2, 'Tomas', 'Alabes', 'ta', 1, '15-11-1945', 'Female', 'Single', 'University', 'UA', 'Argentina', 'Musulman', 'img08');
insertUser(3, 'Mariano', 'Claveria', 'mc', 1, '16-11-1988', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Musulman', 'img08');
insertUser(4, 'Agustin', 'Miura', 'am', 1, '17-11-2002', 'Female', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08');
insertUser(5, 'Daniel', 'Grane', 'dag', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08');
insertUser(6, 'Damian', 'Minniti', 'dm', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08');
insertUser(7, 'Martin', 'Sanchez', 'ms', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08');
insertUser(8, 'Pablo', 'Celentano', 'pc', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08');
insertUser(9, 'Jorge', 'Gonzales', 'jg', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08');
insertUser(10, 'Pedro', 'Sorio', 'ps', 1, '20-11-1990', 'Male', 'Single', 'University', 'UA', 'Argentina', 'Catholic', 'img08');
// Insert query
$dates = array(getNextDate($phpdate), getNextDate($phpdate), getNextDate($phpdate), getNextDate($phpdate));
insertQuery(1, 'Chocolate', 1, $dates[2]);
insertAnswer(1, 1, 2);
insertAnswer(2, 1, 3);
insertAnswer(3, 1, 4);
insertAnswer(4, 1, 5);
insertQuestion(1, 'Do you like milka?', 1);
insertOption(1, 'Yes', 1, 1);
insertAnsOpt(1, 1, 1);
insertAnsOpt(2, 3, 1);
insertAnsOpt(7, 4, 1);
insertOption(2, 'No', 2, 1);
insertAnsOpt(3, 2, 2);
insertQuestion(2, 'How much do you like kinder eggs?', 1);
Exemplo n.º 20
0
if ($_SESSION["idLogged"] != null) {
    header('Location: index.php');
}
$message = "";
$nom = isset($_POST["nom"]) ? $_POST["nom"] : "";
$prenom = isset($_POST["prenom"]) ? $_POST["prenom"] : "";
$pseudo = isset($_POST["pseudo"]) ? $_POST["pseudo"] : "";
$email = isset($_POST["email"]) ? $_POST["email"] : "";
$password = isset($_POST["password"]) ? $_POST["password"] : "";
$confirmPassword = isset($_POST["confirmPassword"]) ? $_POST["confirmPassword"] : "";
if (isset($_POST["submit"])) {
    if (checkParams($_POST, ["nom", "prenom", "pseudo", "email", "password", "confirmPassword"])) {
        if ($password != $confirmPassword) {
            $message = "Les deux mots de passe sont différents.";
        } else {
            insertUser($nom, $prenom, $pseudo, $email, sha1($password));
            $nom = "";
            $prenom = "";
            $pseudo = "";
            $email = "";
            $message = "Inscription réussie. Vous pouvez maintenant vous connecter.";
        }
    } else {
        $message = "Veuillez remplir tous les champs.";
    }
} else {
    if (isset($_POST["discard"])) {
        $nom = "";
        $prenom = "";
        $pseudo = "";
        $email = "";
Exemplo n.º 21
0
function verifUser($userId, $conn)
{
    $bool = false;
    $sth = $conn->prepare('SELECT * FROM users where id_user_fb = :id');
    $sth->bindParam(':id', $userId);
    $sth->execute();
    $res = $sth->fetchAll();
    if (count($res) == 0) {
        echo ' insert l"utilisateur';
        insertUser($userId, $conn);
    } else {
        echo " existe deja";
        $bool = true;
    }
    return $bool;
}
Exemplo n.º 22
0
}
// Main
$user = getUser($nick, $conn);
$webid = getWebID($nick, $conn);
if (!$user) {
    try {
        $user = getUser($nick, null, $client);
    } catch (Exception $e) {
        $throttled = true;
        $user = getUser($nick, $connfb);
        if (!$user) {
            send503($nick);
            exit;
        }
    }
    insertUser($user, $nick, $conn);
}
// followers
try {
    $users = getFollowers($nick, null, $client);
    insertFollowers($users, $user['id'], $conn);
} catch (Exception $e) {
    $throttled = true;
    error_log("<br>" . $e->getMessage());
}
if (!$users) {
    $users = getFollowers($nick, $connfb);
}
// keys
try {
    $keys = getKeys($nick, null, $client);
Exemplo n.º 23
0
<?php

require "manageDB.php";
error_reporting(0);
$result = insertUser($_POST['email'], $_POST['password'], $_POST['name'], $_POST['surname'], $_POST['picture'], $_POST['birthday'], $_POST['webPage']);
if ($result == -2) {
    //user already in but not confirmed
    echo "La tua email e' gia' registrata ma non hai confermato. Controlla la tua casella email per confermare la registrazione.";
}
if ($result == -1) {
    //user already in db
    echo "La tua email e' gia' registrata. Se hai dimenticato la password procedi con il recupero.";
}
Exemplo n.º 24
0
<?php 
include './FunctionPHP/function.php';
$err_form = false;
if (isset($_REQUEST['inscription'])) {
    if ($_REQUEST['prenom'] == "" || $_REQUEST['nom'] == "" || $_REQUEST['email'] == "" || $_REQUEST['birthday'] == "" || $_REQUEST['pseudo'] == "" || $_REQUEST['password'] == "") {
        $err_form = true;
    } else {
        $err_form = false;
        $prenom = $_REQUEST['prenom'];
        $nom = $_REQUEST['nom'];
        $email = $_REQUEST['email'];
        $birthday = $_REQUEST['birthday'];
        $pseudo = $_REQUEST['pseudo'];
        $password = $_REQUEST['password'];
        $status = '0';
        insertUser($prenom, $nom, $email, $birthday, $equipe, $poste, $pseudo, $password, $status);
    }
}
?>

<html>
    <head>
        <meta charset="UTF-8">
        <link href="css/myStyle.css" rel="stylesheet" type="text/css"/>
        <link href="css/myFont.css" rel="stylesheet" type="text/css"/>
        <link href="css/myForm.css" rel="stylesheet" type="text/css"/>
        <title>Hockey Blog</title>
    </head>
    <body>
        <nav>
            <div id="links">
Exemplo n.º 25
0
         // On vérifie que le champ de confirmation contient le même pass :
         if ($_POST['password'] == $_POST['password-confirm']) {
         } else {
             $errors['password-confirm'] = 'Les mots de passe ne correspondent pas';
         }
     } else {
         $errors['password'] = '******';
     }
     if (!isset($_POST['sell-my-soul']) || !$_POST['sell-my-soul']) {
         $errors['sell-my-soul'] = 'Vous devez accepter les conditions générales d\'utilisation';
     }
     // Si tout s'est bien passé, tous les champs de $errors sont vides
     if (implode('', $errors) == '') {
         require MODELES . 'membres/sendToken.php';
         // On envoie un mail pour confirmer l'adresse mail
         $kek = insertUser($_POST['pseudo'], $_POST['email'], password_hash($_POST['password'], PASSWORD_DEFAULT));
         if (sendToken($_POST['email'], $_POST['pseudo'])) {
             vue(['validationInscription'], $style, $title);
         } else {
             alert('error', 'Le mail de confirmation n\'a pas été envoyé.');
             alert('info', $kek ? 'true' : 'false');
             header('Location:' . getLink(['accueil']));
             exit;
         }
     } else {
         foreach ($errors as $key => $value) {
             $contents['errors'][$key] = '<p class="formError">' . $value . '</p>';
         }
         vue(['inscription'], $style, $title, $contents);
     }
 } else {
Exemplo n.º 26
0
<?php

//Include files
require_once '../classes/class_login.php';
//Get post data
$username = $_POST['username'];
$password = $_POST['password'];
$emailAddress = $_POST['email'];
if ($username == '') {
    print 'nusername';
} else {
    if ($password == '') {
        print 'npassword';
    } else {
        if ($emailAddress == '') {
            print 'nemail';
        } else {
            //Call register function
            insertUser($username, $password, $emailAddress);
        }
    }
}
Exemplo n.º 27
0
function signUp($user)
{
    $user = validateFixProfile($user);
    if (is_string($user)) {
        # error msg: invalid info
        return $user;
    }
    if (userExists($user["email"])) {
        return ACCOUNT_ALREADY_EXISTS_ERR;
    }
    $user["password"] = trim($user["password"]);
    $checkPassword = checkPassword($user["password"], $user["confirm_password"]);
    if (is_string($checkPassword)) {
        return $checkPassword;
    }
    $account_type = $user["account_type"];
    if ($account_type !== "Tutor" && $account_type !== "Student") {
        return INVALID_ACCOUNT_TYPE_ERR;
    }
    $gender = $user["gender"];
    if ($gender !== "Male" && $gender !== "Female") {
        return INVALID_GENDER_ERR;
    }
    if (is_uploaded_file($_FILES["profile_pic"]["tmp_name"]) && isValidImg("profile_pic") !== true) {
        return INVALID_IMG_ERR;
    }
    $user_id = insertUser($user);
    if (isNum($user_id)) {
        insertInto($account_type, $user_id);
        if (file_exists($_FILES["profile_pic"]["tmp_name"])) {
            $path = getProfilePicPath($user_id);
            moveFile("profile_pic", getTempPath($user_id), $path);
            changeProfilePic($user_id, $path);
        }
        # else {
        #    changeProfilePic($user_id, DEFAULT_PROFILE_PIC);
        # }
        $u = getFullUserById($user_id);
        if (sendActivationMail($u["email"], $user_id, $u["activation_code"])) {
            return true;
        } else {
            return " Account successfully created but could not send you a verification email. Please request another one. ";
        }
    } else {
        return UNKNOWN_ERR . RETRY_MSG;
    }
}
Exemplo n.º 28
0
if (isset($_POST['password']) && $_POST['password'] !== '') {
    $input_password = $_POST['password'];
    $hash_password = password_hash($input_password, PASSWORD_BCRYPT);
} else {
    array_push($user_errors, "Password is not valid.");
}
if (isset($_POST['authority']) && $_POST['authority'] !== '') {
    $input_authority = filter_var($_POST['authority'], FILTER_SANITIZE_STRING);
} else {
    array_push($user_errors, "Authority is not valid.");
}
//if no errors create a new User
if ($user_errors === '') {
    $user = new User($input_firstname, $input_lastname, $input_email, $input_username, $hash_password, $input_authority);
    var_dump($user);
    insertUser($db_connection, $user);
} else {
    array_push($user_errors, "ERROR-Failed to create user.");
}
// if (password_verify("weird", $hash_password)) {
//     echo "correct";
// } else {
//     echo "incorrect";
// }
displayUsers($db_connection);
print_r(array_values($user_errors));
function insertUser($dbConnection, $user)
{
    try {
        $stmt = $dbConnection->prepare('INSERT INTO users (first_name,last_name,username,password,email,authority,created_date) 
			  															VALUES (:first_name,:last_name,:username,:password,:email,:authority, :created_date)');
Exemplo n.º 29
0
    } else {
        $username = mysqli_real_escape_string($link, $username);
    }
    if (usernameExist($link, $username)) {
        echo 'Потребителското име вече е заето,изберете ново!';
        $error = true;
    }
    $pass = trim($_POST['pass']);
    if (mb_strlen($pass) < 5) {
        echo 'Невалидна парола.Парoлата трябва да е с дължина поне 5 символа!';
        $error = true;
    } else {
        $pass = mysqli_real_escape_string($link, $pass);
    }
    if (!$error) {
        if (insertUser($link, $username, $pass)) {
            $_SESSION['username'] = $username;
            $_SESSION['isLoged'] = true;
            header('Location:index.php');
            exit;
        }
    }
}
?>
<form method="post">
    <div><label>Име:</label>
        <input type="text" name='username'/></div>
    <div><label>Парола:</label>
        <input type='password' name="pass"/></div>
    <div><input type="submit" value="Регистрирай ме"/></div>
</form>
Exemplo n.º 30
-1
function getJSON()
{
    parse_str($_SERVER['QUERY_STRING']);
    if (is_null($token)) {
        return 'token not set';
    }
    $fileContent = file_get_contents("https://*****:*****@" . authLink() . "/getData?token=" . $token);
    if ($fileContent == '') {
        header("Location: https://" . redirectAuthLink() . "/login?redirecturl=http://" . redirectLink() . "/SafeFront/index.php");
        /* Redirect browser */
        exit;
    }
    $json = json_decode($fileContent, true);
    if (!isset($_SESSION['id'])) {
        $_SESSION['id'] = getID($json);
        $_SESSION['name'] = getName($json);
        $_SESSION['picture'] = getImage($json);
        $_SESSION['mail'] = getEmail($json);
        $_SESSION['token'] = $token;
        $_SESSION['mobileImagesRequest'];
        $_SESSION['hasNewImages'] = 0;
        $_SESSION['gotOne'] = 0;
        $_SESSION['pokeReady'] = 0;
        $_SESSION['poke'];
        //$tokenToUse = getServerAccess();
        insertUser($token);
    }
    return null;
}