Example #1
0
             //tussenvoegsel mag spatie bevatten
             $docent_afkorting = filter_var(trim($_POST['afkorting']), FILTER_SANITIZE_STRING);
             $emailadres = filter_var(trim($_POST['emailadres']), FILTER_VALIDATE_EMAIL);
             if (!$emailadres) {
                 $_SESSION['message'] = 'Voer een geldig e-mailadres in.';
             } else {
                 $role = 2;
                 // is leraar
                 $account_activated = 0;
                 //account is nog niet geactiveerd, dit wordt pas gedaan als gebruiker eerste keer inlogt.
                 $generated_password = generate_random_password();
                 $wachtwoord = password_hash($generated_password, PASSWORD_BCRYPT);
                 $email_code = md5($voornaam + microtime());
                 $gegevens = ["voornaam" => $voornaam, "tussenvoegsel" => $tussenvoegsel, "achternaam" => $achternaam, "emailadres" => $emailadres, "email_code" => $email_code, "wachtwoord" => $wachtwoord, "account_activated" => $account_activated, "role" => $role, "docent_afkorting" => $docent_afkorting];
                 //checken of email en afkorting uniek zijn
                 if (checkIfUserExists($gegevens["emailadres"]) === FALSE) {
                     //leraar toevoegen
                     addTeacher($gegevens);
                     //wachtwoord mailen naar gebruiker
                     $mail_gegevens = ["emailadres" => $gegevens["emailadres"], "voornaam" => $gegevens["voornaam"], "tussenvoegsel" => $gegevens["tussenvoegsel"], "achternaam" => $gegevens["achternaam"], "wachtwoord" => $generated_password];
                     $mail_content = createTempPasswordMail($mail_gegevens);
                     sendMail($mail_content);
                 } else {
                     //email adres is al in gebruik.
                     $_SESSION['message'] = "Email adres is al in gebruik";
                 }
             }
         }
     }
 } else {
     // voor als een docent bewerkt wordt
         foreach ($gegevens as $values => $keys) {
             $gegevens[$values]["klas"] = $klas;
             $gegevens[$values]["role"] = 1;
             // is leerling
             $gegevens[$values]["account_activated"] = 0;
             //account is nog niet geactiveerd, dit wordt pas gedaan als gebruiker eerste keer inlogt.
             $gegevens[$values]["generated_password"] = generate_random_password();
             $gegevens[$values]["wachtwoord"] = password_hash($gegevens[$values]["generated_password"], PASSWORD_BCRYPT);
             $gegevens[$values]["email_code"] = md5($gegevens[$values]["voornaam"] + microtime());
         }
         //checken of email en student_id uniek zijn
         foreach ($gegevens as $leerling_gegevens) {
             if ($leerling_gegevens['emailadres'] === FALSE) {
                 $false_email = [$leerling_gegevens['emailadres']];
             } else {
                 if (checkIfUserExists($leerling_gegevens['emailadres'], $leerling_gegevens['leerling_id']) === FALSE) {
                     //email adres niet in gebruik, dus gebruiker kan worden toegevoegd.
                     // gegevens inserten
                     addStudent($leerling_gegevens, $leerling_gegevens["emailadres"], $leerling_gegevens["leerling_id"], $leerling_gegevens["klas"]);
                 } else {
                     //email adres in gebruik gebruiker wordt op de hoogte gesteld dat dit email adres bezet is.
                     $_SESSION['message'] = "Email adres " . $leerling_gegevens['emailadres'] . " is al in gebruik";
                 }
             }
         }
     }
 }
 if (isset($_POST["submit_bewerk_leerling"])) {
     if ($_POST['voornaam'] == "" or $_POST['achternaam'] == "" or $_POST['leerling_id'] == "" or $_POST['emailadres'] == "") {
         $_SESSION['message'] = "Je moet alle gegevens invullen!";
     } else {
Example #3
0
function checkLogin($username, $password)
{
    //Clean strings for security
    username == secureStrings($username);
    password == secureStrings($password);
    //Salt password
    $password = saltPassword($password);
    //Check if user exists
    if (checkIfUserExists($username, $password) == 'true') {
        //Check if approved
        if (checkIfApproved($username, $password) == 'true') {
            //Create Session
            createSession($username, $password);
        } else {
            print 'napproved';
        }
    } else {
        print 'Incorrect';
    }
}
Example #4
0
     $upload = importLeerlingenExcelFile($_FILES["excel_leerlingen"]);
     $exceldata = importLeerlingenWithExcel($upload);
     $excelheaders = array_shift($exceldata);
     $leerlingendata = rebuildExcelClassDataArray($exceldata, $excelheaders);
 }
 //******  VIA EXCEL BESTAND KLAS(SEN) MET LEERLINGEN TOEVOEGEN ******//
 if (isset($_POST['submit_excel_data'])) {
     unset($_POST['submit_excel_data']);
     $leerlingendata = rebuildArray($_POST);
     //controleren of klas al bestaat, zo niet: aanmaken
     foreach ($leerlingendata as $leerling) {
         $getKlas = getKlas($leerling["klas"]);
         if ($getKlas == 0) {
             addKlas($leerling);
         }
         if (checkIfUserExists($leerling['emailadres']) === FALSE) {
             $leerling = addStudentCredentials($leerling);
             addStudent($leerling, $leerling["emailadres"], $leerling["leerling_id"], $leerling["klas"]);
         }
     }
 }
 //****************  KLAS TOEVOEGEN ******************//
 if (isset($_POST['submit_add_klas'])) {
     if (isset($_POST['klas'], $_POST['examenjaar'], $_POST['docent_afk'])) {
         //binnenkomende array ombouwen
         unset($_POST['submit_add_klas']);
         $gegevens = rebuildArray($_POST);
         if (!checkArrayForEmptyValues($gegevens)) {
             $_SESSION['message'] = "Je moet alle gegevens invullen!";
         } else {
             //Ingevoerde gegevens door filter halen en trimmen
Example #5
0
/**
 * Add a new user in the database.
 * @return true if the user was added, otherwise false.
 */
function addNewUserInDB($username, $email, $invite_url)
{
    if ($connection = connectDB()) {
        if (!checkIfUserExists($connection, $username)) {
            $userStats = fetchUserStatsFromKid($invite_url);
            if (!strContains($userStats, 'error')) {
                $query = "INSERT INTO users(displayname, rank, referrals, email, invite_url) VALUES (?, ?, ?, ?, ?)";
                $stmt = $connection->stmt_init();
                $stmt->prepare($query);
                $stmt->bind_param("siiss", $username, explode(';', $userStats)[0], explode(';', $userStats)[1], $email, $invite_url);
                $stmt->execute();
                $connection->close();
                return true;
            }
        }
        $connection->close();
    }
    return false;
}
Example #6
0
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
try {
    echo "<html>\n\t\t\t<head>\n\t\t\t\t<title>Video Factory</title>\n\t\t\t\t<link rel='shortcut icon' href='favicon.png' type='img/x-icon'/>\n\t\t\t\t<link rel='stylesheet' type='text/css' href='masterPage/main.css'/>\n\t\t\t</head>\n\t\t\t<body>\n\t\t\t\t<div id='activatePage' class='container'>\n\t\t\t\t\t<div class='col-xs-12 activateContainer'>\n\t\t\t\t\t<p id='activateTitle' class='col-xs-'12>Video Factory</p>\n\t\t\t\t";
    $key = $_GET['key'];
    $sqlconn = new SQLMediator();
    $sqlconn->connect();
    $values = getValuesFromTempTable($key, $sqlconn);
    if (count($values) == 0) {
        echo 'Key not found<br/>';
        echo "<a class='activateLink' href='/'>Return to site</a>";
    } else {
        $userExists = checkIfUserExists($values['Email'], $sqlconn);
        if ($userExists) {
            echo 'User already has an active account<br/>';
            echo "<a class='activateLink' href='/'>Return to site</a>";
        } else {
            addToUserInfoTable($values, $sqlconn);
            deleteValuesFromTempTable($values['Email'], $sqlconn);
            echo 'Account is now active!<br/>';
            echo "<a class='activateLink' href='/'>Return to site</a>";
        }
    }
    $sqlconn->disconnect();
    echo "\t\t</div>\n\t\t\t\t</div>\n\t\t\t</body>\n\t\t</html>";
} catch (Exception $ex) {
    echo GlobalExceptionHandler::writeException($ex);
}
if (isset($_SESSION['gebruiker_id'])) {
    header('Location: ' . BASE_URL . 'dashboard/');
    exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //checken als er gegevens ingevoerd zijn
    if (isset($_POST['user'])) {
        $email = trim($_POST['user']);
        $email = filter_var($email, FILTER_VALIDATE_EMAIL);
        if (!$email) {
            $_SESSION['message'] = 'Voer een geldig e-mailadres in.';
        } else {
            if (!checkIfUserExists($email)) {
                $_SESSION['message'] = 'Email adres niet gevonden.';
            } else {
                $user_data = checkIfUserExists($email);
                $user_id = $user_data['gebruiker_id'];
                $email_code = $user_data['email_code'];
                $url_code = "index.php?id=" . $user_id . "&email_code=" . $email_code;
                $mail_content = passwordResetMail($user_data, $url_code);
                sendMail($mail_content);
                $_SESSION['message-success'] = 'Er is een e-mail verstuurd om uw wachtwoord opnieuw in te stellen.';
            }
        }
    }
}
?>
<!DOCTYPE html>
<html>
	<head>
		<title>Examen Analyse</title>
Example #8
0
function createTables()
{
    //blog title name
    $inputHost = $_POST[form_host];
    //blog is the name of the text field
    $inputUser = $_POST[form_user];
    //blog title name
    $inputPassword = $_POST[form_password];
    //blog is the name of the text field
    $inputDataBase = $_POST[form_database];
    if (!empty($inputHost) && !empty($inputUser) && !empty($inputPassword) && !empty($inputDataBase)) {
        createUsersTable();
        checkIfUserExists('1', 'bfusterg', '904deeaf9fdc44dd75e17954d10f21889ce8669a', 'Beatriz', 'Fuster', '*****@*****.**', 'student');
        checkIfUserExists('2', 'jrtundidor', '1d1f7b626bbd3efa49c7b5ac68a88fdd3d60a7a0', 'Jaime', 'Ruiz', '*****@*****.**', 'student');
        checkIfUserExists('3', 'andreagm', '90fd7547a62150eed1b1354f7814366775784440', 'Andrea', 'Gomez', '*****@*****.**', 'student');
        checkIfUserExists('4', 'jlamber4', '0efa0f43d9f28d92c0ab6b8611c039f29270dfc7', 'Jason', 'Lambert', '*****@*****.**', 'professor');
        checkIfUserExists('5', 'phuang9', '375eeeeccd8f6f249f182b5284710e6338b669a4', 'Peisong', 'Huang', '*****@*****.**', 'professor');
        checkIfUserExists('6', 'carlson', '9753456e0298e686b5eb1d5ef1019a7f31fc44dd', 'Carl', 'Carlson', '*****@*****.**', 'professor');
        checkIfUserExists('7', 'mschray', '9b612414e1804c937d5305eecdfc3a942604db9d', 'Martin', 'Schray', '*****@*****.**', 'professor');
        createSubjectsTable();
        checkIfSubjectExists('1', 'ITMD-555-02', 'Intelligent Device Application', 'E1', '241', 'Peisong Huang', 'Fall');
        checkIfSubjectExists('2', 'ITMD-562-01', 'Web Site Development', 'E1', '104', 'Jason Lambert', 'Fall');
        checkIfSubjectExists('3', 'ITMD-555-01', 'Intelligent Device Application', 'Tech Business Center', 'Idea Shop', 'Martin Schray', 'Fall');
        checkIfSubjectExists('4', 'ITMM-581', 'IT Entrepreneurship', 'E1', '121', 'Carl Carlson', 'Fall');
        createEnrollmentTable();
    }
}
Example #9
0
function checkLogin($username, $password)
{
    //Clean strings for security
    $username = secureStrings($username);
    $password = secureStrings($password);
    //echo $username ;
    //echo $password;
    //Salt password
    $password = saltPassword($password);
    //Check if user exists
    //echo " checkLogin".(boolean)checkIfUserExists($username,$password)."<br>";
    if (checkIfUserExists($username, $password) == 'true') {
        //Check if approved
        if (checkIfApproved($username, $password) == 'true') {
            //Create Session
            createSession($username, $password);
        } else {
            print 'napproved';
        }
    } else {
        print 'Incorrect';
    }
}
Example #10
0
require_once dirname(__FILE__) . '/../PHPMailer/class.phpmailer.php';
require_once dirname(__FILE__) . '/../../masterPage/config.php';
function error_to_exception($code, $message, $file, $line, $context)
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
$email = $_POST['email'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
try {
    $sql = new SQLMediator();
    $sql->connect();
    $userExists = checkIfUserExists($email, $sql);
    if ($userExists) {
        echo 'An account with that email already exits.';
    } else {
        $activationKey = uniqid();
        $table = 'TempUser';
        $queryType = 'Insert';
        $condition = null;
        $types = array('text', 'text', 'text');
        $columns = array('Email', 'Password', 'ActivateKey');
        $values = array($email, $password, $activationKey);
        $args = array('column' => $columns, 'value' => $values, 'type' => $types);
        $xml = createXML($table, $args);
        $res = $sql->query($xml, $queryType, $condition);
        $mail = new PHPMailer(true);
        //New instance, with exceptions enabled
Example #11
0
function GetAllUsersList($mailAdd)
{
    global $connection;
    $response = "<div class='row'>";
    $id = "";
    $email = "";
    $interests = "";
    try {
        if (checkIfUserExists($mailAdd) == "1") {
            $query = "select * from Users";
            $rs = mysql_query($query);
            if (!$rs) {
                $response = "-1";
            } else {
                while ($res = mysql_fetch_array($rs)) {
                    $id = $res["UserID"];
                    $email = $res["UserEmail"];
                    $interests = getInterests($email, $id);
                    $in = explode(" @I ", $interests);
                    $interests = "";
                    foreach ($in as $i) {
                        if ($i == "-" || $i == " " || $i == "" || $i == "-3") {
                        } else {
                            $interests .= $i . ", ";
                        }
                    }
                    $interests = substr($interests, 0, strlen($interests) - 2);
                    if ($interests == "") {
                        $interests = "-1";
                    }
                    if ($res["UserPic"] == "") {
                        $res["UserPic"] = "img/dp.jpg";
                    }
                    // <p class='userLocation'><span>Expertise in: </span> <u>" . $interests . "</u> </p>
                    if ($interests == "-1") {
                        //$response .= "<div class='list-group-item item'><div class='media-left media-top'><img src='" . $res["UserPic"] . "' class='media-object userImage' width='120' height='120' /></div><div class='userItem'><p class='userName'>" . $res["UserName"] . "</p><p class='userReadMore'><a class='readMoreLink' data-id='" . $id . "' data-email='" . $email . "' href='#'>Read More...</a></p></div><button class='btn btn-lg btn-primary btn-block btnConnRequest' data-id='" . $id . "' data-email='" . $email . "' data-profile='" . $res["UserProfile"] . "'>Connect on LinkedIn</button></div>" . " (BR) ";
                        $response .= "<div class='col-lg-6 col-md-6'><div class='thumbnail'><img class='media-object userImage' width='130' height='130' src='" . $res["UserPic"] . "' /><div class='caption'><p class='userName'>" . $res["UserName"] . "</p><p class='userLocation'><span>Expertise in: </span> <u>" . "None" . "</u> </p><p class='userReadMore'><a class='readMoreLink' data-id='" . $id . "' data-email='" . $email . "' href='#'>Read More...</a></p></div><button class='btn btn-lg btn-primary btn-block btnConnRequest' data-id='" . $id . "' data-email='" . $email . "' data-profile='" . $res["UserProfile"] . "'>Connect on LinkedIn</button></div></div>" . " (BR) ";
                    } else {
                        //$response .= "<div class='list-group-item item'><div class='media-left media-top'><img src='" . $res["UserPic"] . "' class='media-object userImage' width='120' height='120' /></div><div class='userItem'><p class='userName'>" . $res["UserName"] . "</p><p class='userLocation'><span>Expertise in: </span> <u>" . $interests . "</u> </p><p class='userReadMore'><a class='readMoreLink' data-id='" . $id . "' data-email='" . $email . "' href='#'>Read More...</a></p></div><button class='btn btn-lg btn-primary btn-block btnConnRequest' data-id='" . $id . "' data-email='" . $email . "' data-profile='" . $res["UserProfile"] . "'>Connect on LinkedIn</button></div>"  . " (BR) ";
                        if (strlen($interests) >= 15) {
                            $interests = substr($interests, 0, 15);
                            $interests .= "...";
                        }
                        $response .= "<div class='col-lg-6 col-md-6'><div class='thumbnail'><img class='media-object userImage' width='130' height='130' src='" . $res["UserPic"] . "' /><div class='caption'><p class='userName'>" . $res["UserName"] . "</p><p class='userLocation'><span>Expertise in: </span> <u>" . $interests . "</u> </p><p class='userReadMore'><a class='readMoreLink' data-id='" . $id . "' data-email='" . $email . "' href='#'>Read More...</a></p></div><button class='btn btn-lg btn-primary btn-block btnConnRequest' data-id='" . $id . "' data-email='" . $email . "' data-profile='" . $res["UserProfile"] . "'>Connect on LinkedIn</button></div></div>" . " (BR) ";
                    }
                }
            }
            $response .= "</div>";
        } else {
            if (checkIfUserExists($mailAdd) == "-1") {
                // user does not exists.
                $response = "-1";
            } else {
                $response = "-2";
            }
        }
        return $response;
    } catch (Exception $e) {
        $response = "-2";
        return $response;
    }
}
function SaveUser($basic, $edu, $exp, $phoneNo, $pic)
{
    $res2 = "";
    $contactJson = json_decode($phoneNo, true);
    $eduJson = json_decode($edu, true);
    $expJson = json_decode($exp, true);
    $picJson = json_decode($pic, true);
    $res = "";
    $res2 = "";
    $email = $basic["emailAddress"];
    $name = $basic["firstName"] . " " . $basic["lastName"];
    $contact = $contactJson["phoneNumber"];
    $date = date("Y-m-d H:i:s");
    $userID = "";
    global $connection;
    try {
        if (checkIfUserExists($email) == "-1") {
            // firstly, check if all the data, that comes from linkedIn exists or not.
            if (!isset($email)) {
                $email = "";
            }
            if (!isset($name)) {
                $name = "";
            }
            if (!isset($picJson)) {
                $picJson = "";
            }
            if (!isset($contact)) {
                $contact = "";
            }
            if (!isset($basic["publicProfileUrl"])) {
                $basic["publicProfileUrl"] = "";
            }
            if (!isset($basic["location"]["name"]) || !isset($basic["location"])) {
                $basic["location"]["name"] = "";
            }
            if (!isset($basic["primaryTwitterAccount"]["providerAccountName"]) || !isset($basic["primaryTwitterAccount"])) {
                $basic["primaryTwitterAccount"]["providerAccountName"] = "";
            }
            //go ahead and insert the user with all the data here.
            if (savePersonalDetails($email, $name, $picJson, $contact, $basic["publicProfileUrl"], $basic["location"]["name"], $basic["primaryTwitterAccount"]["providerAccountName"], "", "", $date) == "1") {
                $res = "1";
                //for saving into the database correctly!
                $userID = getUserID($email);
                if ($userID == "-1") {
                    $res = "-2";
                    echo $res;
                    return;
                }
                //now,save all the education details here.
                if (isset($eduJson)) {
                    foreach ($eduJson as $eduItem) {
                        if (!isset($eduItem["degree"])) {
                            $eduItem["degree"] = "";
                        }
                        if (!isset($eduItem["startDate"]["year"])) {
                            $eduItem["startDate"]["year"] = "";
                        }
                        if (!isset($eduItem["endDate"]["year"])) {
                            $eduItem["endDate"]["year"] = "";
                        }
                        if (!isset($eduItem["fieldOfStudy"])) {
                            $eduItem["fieldOfStudy"] = "";
                        }
                        if (!isset($eduItem["schoolName"])) {
                            $eduItem["schoolName"] = "";
                        }
                        $eduDate = $eduItem["startDate"]["year"] . "-" . $eduItem["endDate"]["year"];
                        if (saveEducation($userID, $eduItem["schoolName"], $eduDate, $eduItem["degree"], $eduItem["fieldOfStudy"], $date) == "1") {
                            $res = "1";
                        } else {
                            $res = "-1";
                        }
                    }
                    //end of foreach loop for education.
                }
                //now, save the Experience listings to the database.
                foreach ($expJson as $expItem) {
                    if (!isset($expItem["company"]["name"])) {
                        $expItem["company"]["name"] = "";
                    }
                    if (!isset($expItem["startDate"]["year"])) {
                        $expItem["startDate"]["year"] = "";
                    }
                    if (!isset($expItem["endDate"]["year"])) {
                        $expItem["endDate"]["year"] = "";
                    }
                    if (!isset($expItem["title"])) {
                        $expItem["title"] = "";
                    }
                    if (!isset($expItem["summary"])) {
                        $expItem["summary"] = "";
                    }
                    if (!isset($expItem["isCurrent"]) && $expItem["isCurrent"] == true) {
                        $expItem["endDate"]["year"] = "current";
                    }
                    $expDate = $expItem["startDate"]["year"] . "-" . $expItem["endDate"]["year"];
                    if (saveExperience($userID, $expItem["company"]["name"], $expDate, $expItem["title"], $expItem["summary"], $date) == "1") {
                        $res2 = "1";
                        // echo $res;
                        // return;
                    } else {
                        $res2 = "-1";
                        // echo $res;
                        // return;
                    }
                }
                //end of foreach loop for experience.
            } else {
                $res = "-1";
                //not saved into the database
            }
        } else {
            if (checkIfUserExists($email) == "1") {
                $res = "2";
            } else {
                //Error in checking if the user already exists or not.
                $res = "Error in checking if the user already exists or not.";
            }
        }
    } catch (Exception $e) {
        $res = "-1";
    }
    echo $res . ", " . $email . ", " . $userID;
}