コード例 #1
0
ファイル: index.php プロジェクト: K-4U/Pr-IP-P2-02
 function parse()
 {
     if ($this->user->isLoggedIn()) {
         header("location: " . baseurl(""));
     } else {
         $_POST = removeHTMLFromPOST($_POST);
         $emailCode = md5($_POST['email'] . date("U"));
         $_POST['emailCode'] = $emailCode;
         if (isset($_POST['saveEmail'])) {
             if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === true) {
                 $_POST['email'] = null;
                 $this->website->assign("emailError", "Ingevulde email was niet valide, ga naar de hoofdpagina en probeer opnieuw te registreren.");
             } else {
                 $emailUsed = $this->db->buildQuery("SELECT email FROM users WHERE email = %s", $_POST['email']);
                 if ($this->db->getHasRows($emailUsed) == 0) {
                     $this->website->assign("email", $_POST['email']);
                     $_SESSION['emailCode'] = $_POST['emailCode'];
                     $this->website->assign("emailVerificationCode", $_POST['emailVerificationCode']);
                     sendMail($_POST['email'], "Uw verificatie code is: " . $emailCode, "Eenmaal andermaal verificatie");
                 } else {
                     $this->website->assign("emailError", "Uw email is al in gebruik genomen.");
                     $emailIsAlreadyUsed = true;
                 }
             }
         }
         $this->addToBreadcrumbs("Home", baseurl(""));
         $this->addToBreadcrumbs("Registratie");
         $this->addToBreadcrumbs("Email Verificatie");
         if ($emailIsAlreadyUsed == false) {
             $this->render("emailVerification", "emailVerification.tpl");
         } else {
             header("location: " . baseurl(""));
         }
     }
 }
コード例 #2
0
ファイル: index.php プロジェクト: K-4U/Pr-IP-P2-02
 function parse()
 {
     if ($this->user->isLoggedIn()) {
         header("location: " . baseurl(""));
     } else {
         $_POST = removeHTMLFromPOST($_POST);
         if (isset($_POST['validateCode'])) {
             if ($_SESSION['emailCode'] == $_POST['emailVerificationCode']) {
                 foreach ($_POST as $key => &$value) {
                     $temp = strip_tags($value);
                     $value = $temp;
                 }
                 //                    $errors = Array();
                 if (isset($_POST['registerInfo'])) {
                     //lets check if every required field is actually filled in correctly
                     if (strlen($_POST['username']) >= 4 && strlen($_POST['username']) <= 12) {
                     } else {
                         $errors['usernameErr'] = "De lengte van uw username voldoet niet aan onze waarden.";
                     }
                     if (!isset($_POST['firstname']) && !isset($_POST['lastname'])) {
                         $errors['nameErr'] = "Vul uw voornaam en achternaam in.";
                     }
                     if (ctype_digit(substr($_POST['postalcode'], 0, 4)) && ctype_alpha(substr($_POST['postalcode'], -2))) {
                     } else {
                         $errors['postalcodeErr'] = "De postcode moet als volgt gegeven zijn, 4 cijfers gevolgd door 2 letters. Bijvoorbeeld: 1234AB.";
                     }
                     if (ctype_digit(substr($_POST['adress_number'], 0, 1))) {
                     } else {
                         $errors['adress_numberErr'] = "De eerste character van uw adress moet een nummer zijn.";
                     }
                     if ($_POST['password'] == $_POST['password2']) {
                         $hashedPassword = hash("sha512", $_POST['password']);
                         $_POST['password'] = $hashedPassword;
                     } else {
                         $errors['passwordErr'] = "De opgegeven wachtwoorden komen niet overeen.";
                     }
                     if ($_POST['securityQuestions'] >= 0) {
                     } else {
                         $errors['securityQuestionsErr'] = "U heeft geen geheime vraag gekozen.";
                     }
                     if (isset($_POST['questionAnswer'])) {
                     } else {
                         $errors['questionAnswerErr'] = "U heeft geen antwoord voor uw geheime vraag opgegeven.";
                     }
                     if (!isset($_POST['birthdate'])) {
                         $errors['birthdate'] = "U heeft geen geboortedatum aangegeven.";
                     }
                     if (!isset($_POST['city'])) {
                         $errors['city'] = "U heeft geen plaatsnaam opgegeven.";
                     }
                     if (!isset($_POST['country'])) {
                         $errors['country'] = "U heeft geen land opgegeven.";
                     }
                     if (isset($_POST['g-recaptcha-response']) && $_POST['g-recaptcha-response']) {
                         $sCaptcha = "6LcL4xITAAAAAHuArX4fZ4eMjr25H2TfLiKq8mNR";
                         $ip = $_SERVER['REMOTE_ADDR'];
                         $captcha = $_POST['g-recaptcha-response'];
                         $resp = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$sCaptcha}&response={$captcha}&remoteip={$ip}");
                         $arr = json_decode($resp, true);
                         if ($arr['success']) {
                             if (!isset($errors)) {
                                 $noErrs = true;
                             }
                         } else {
                             $errors['captchaErr'] = "De reCaptcha is niet door de validatie gekomen.";
                         }
                     }
                 }
                 $birthdate = strtotime($_POST['birthdate']);
                 $_POST['birthdate'] = date("Y-m-d", $birthdate);
                 $infoInsert = array('username' => strip_tags($_POST['username']), 'firstname' => strip_tags($_POST['firstname']), 'lastname' => strip_tags($_POST['lastname']), 'adress_street1' => strip_tags($_POST['adress_street1']), 'adress_number' => strip_tags($_POST['adress_number']), 'postalcode' => strip_tags($_POST['postalcode']), 'birthdate' => strip_tags($_POST['birthdate']), 'password' => strip_tags($_POST['password']), 'security_question' => strip_tags($_POST['securityQuestions']), 'security_answer' => strip_tags($_POST['questionAnswer']), 'city' => strip_tags($_POST['city']), 'country' => strip_tags($_POST['country']), 'email' => strip_tags($_POST['email']));
                 if (strlen($_POST['adress_street2']) >= 1) {
                     $infoInsert['adress_street2'] = strip_tags($_POST['adress_street2']);
                 } else {
                     $_POST['adress_street2'] = NULL;
                 }
                 if (isset($_POST['phonenumber'])) {
                     $phonenumberArray = array('phonenumber' => strip_tags($_POST['phonenumber']), 'username' => strip_tags($_POST['username']));
                 }
                 if ($noErrs) {
                     $this->db->insert("users", $infoInsert);
                     $dbErr = $this->db->getLastError();
                     $this->db->insert("phonenumbers", $phonenumberArray);
                     $dbErr1 = $this->db->getLastError();
                     if (!isset($dbErr) && !isset($dbErr1)) {
                         $this->user->doLogin($_POST['username'], $_POST['password2']);
                         header("location: " . baseurl(""));
                     }
                 }
                 $sqlQuestion = "SELECT id, question FROM security_questions";
                 $questionResult = $this->db->query($sqlQuestion);
                 $questions = array();
                 $questions = $this->db->fetchAllAssoc($questionResult);
                 $this->website->assign("questions", $questions);
                 $this->website->assign("emailVerificationCode", $_POST['emailVerificationCode']);
                 $this->website->assign("previousInfo", $_POST);
                 $this->website->assign("email", $_POST['email']);
                 $this->website->assign("emailCode", $_POST['emailCode']);
                 $this->website->assign("validateCode", $_POST['validateCode']);
                 if (isset($errors)) {
                     $this->website->assign("errors", $errors);
                 }
                 $this->addToBreadcrumbs("Home", baseurl(""));
                 $this->addToBreadcrumbs("Registratie");
                 $this->addToBreadcrumbs("Info");
                 $this->render("info", "register.tpl");
             } else {
                 $wrongCode = "De validatie code komt niet overeen met de gestuurde code, probeer opnieuw te registreren.";
                 $this->website->assign("wrongCode", $wrongCode);
                 $this->addToBreadcrumbs("Home", baseurl(""));
                 $this->addToBreadcrumbs("Registratie");
                 $this->addToBreadcrumbs("Info");
                 $this->render("info", "register.tpl");
             }
         } else {
             header("location: " . baseurl(""));
         }
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: K-4U/Pr-IP-P2-02
 function parse()
 {
     if ($this->user->isSeller()) {
         $_POST = removeHTMLFromPOST($_POST);
         if (isset($_POST['submit'])) {
             if (isset($_POST['title']) && isset($_POST['description']) && isset($_POST['start_bid']) && isset($_POST['location']) && isset($_POST['duration']) && isset($_POST['payment_method'])) {
                 $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
                 $errors = array();
                 if ($check !== false) {
                     //echo "File is an image - " . $check["mime"] . ".";
                     $uploadOk = 1;
                 } else {
                     $errors['imageErr'] = "U moet een afbeelding uploaden.";
                     //echo "File is not an image.";
                     $uploadOk = 0;
                 }
                 if (strlen($_POST['title']) > 4 && strlen($_POST['title']) < 60) {
                 } else {
                     $errors['titleErr'] = "Lengte van titel bestaat niet uit 4 tot 60 tekens.";
                 }
                 if (trim(strlen($_POST['description'])) > 1 && trim(strlen($_POST['description'])) < 4000) {
                 } else {
                     $errors['descriptionErr'] = "Lengte van de beschrijving bestaat niet uit 1 tot 4000 tekens.";
                 }
                 if (number_format($_POST['start_bid'], 2) > 0 && number_format($_POST['start_bid'], 2) < 100000) {
                 } else {
                     $errors['start_bidErr'] = "Vul een startbod in wat minimaal 1 karakter en maximaal 99999,99 is.";
                 }
                 if (trim(strlen($_POST['location'])) > 1 && trim(strlen($_POST['location'])) < 163) {
                 } else {
                     $errors['locationErr'] = "Vul een plaatsnaam in van minimaal 1 en maximaal 163 karakters.";
                 }
                 if ($_POST['duration'] > 0) {
                 } else {
                     $errors['durationErr'] = "Looptijd niet geldig.";
                 }
                 if (!empty($_POST['payment_method'])) {
                 } else {
                     $errors['payment_methodErr'] = "Kies een betaalmethode.";
                 }
                 //var_dump($_POST['start_bid']);
                 //var_dump("fwsbjkfewghkfewu");
                 //var_dump($_POST);
                 $insertArray = array("title" => $_POST['title'], "description" => $_POST['description'], "start_bid" => intval(number_format($_POST['start_bid'], 2)), "city" => $_POST['location'], "country" => 'Nederland', "duration" => intval($_POST['duration']), "payment_method" => $_POST['payment_method'], "payment_instructions" => $_POST['payment_instructions'], "shipment_instructions" => $_POST['shipment_instructions'], "shipment_costs" => intval($_POST['shipment_costs']), "seller" => $this->user->getName());
                 if ($errors) {
                     $this->website->assign("errors", $errors);
                     $this->website->assign("values", $_POST);
                 } else {
                     //var_dump($_FILES);
                     $target_dir = getcwd() . "/upload/";
                     $imageFileType = pathinfo($_FILES['fileToUpload']['name'], PATHINFO_EXTENSION);
                     $target_file = md5(date(U) . $this->user->getName()) . '.' . $imageFileType;
                     //md5
                     $uploadOk = 1;
                     rename($_FILES['fileToUpload']['tmp_name'], $target_dir . $target_file);
                     $this->db->insert("objects", $insertArray);
                     $errors['databaseErr1'] = $this->db->getLastError();
                     $objectId = $this->db->getLastInsertedId();
                     $insertFileNameArray = array("filename" => $target_file, "objectid" => $objectId);
                     $this->db->insert("files", $insertFileNameArray);
                     $errors['databaseErr'] = $this->db->getLastError();
                     //Insert into the category that they chose:
                     $categoryInsertArray = array("object_id" => $objectId, "category_id" => $_POST['category']);
                     $this->db->insert("object_in_category", $categoryInsertArray);
                     $errors['databaseErr2'] = $this->db->getLastError();
                     if (sizeof($errors) > 0) {
                         header("Location: " . baseurl("Kavel/Item/" . $objectId));
                     }
                 }
             }
         }
         $displayName = "Kavel aanbieden";
         if (!$this->user->isLoggedIn()) {
             $this->website->assign("loginError", "U moet ingelogd zijn voordat u een kavel kan aanbieden.");
             $this->render('Login', 'users/login.tpl');
         } else {
             $categoryList = getCategory(array());
             $endCategoryList = array();
             foreach ($categoryList as $category) {
                 $this->parseCategoryList($category, $endCategoryList);
             }
             $this->addToBreadcrumbs("Home", baseurl(""));
             $this->addToBreadcrumbs("Kavel aanbieden");
             $this->website->assign("categoryList", $endCategoryList);
             $this->render($displayName, 'lot/newlot.tpl');
         }
     } else {
         $this->website->assign("error", "U moet een verkopers account aanmaken voordat u een kavel kan aanbieden. <br> Klik <a href=https://veiling.k-4u.nl/Users/CP/SellerRequest>hier</a> om een aacount aan te maken.");
         $this->render("", "error.tpl");
     }
 }