public function actionView($productId) { $categories = array(); $categories = Platform::getPlatformList(); $product = Products::getProductById($productId); $productId = $product['id']; $platform = Platform::getPlatformById($product['platform_id']); $comments = Comment::getCommentsByProductId($productId); //COMMENTS if (isset($_POST['submit'])) { $userComment = $_POST['message']; $errors = false; if (!Comment::validateMessage($userComment)) { $errors[] = "Введите собщение"; } if (User::isGuest()) { $userName = $_POST['name']; $userEmail = $_POST['email']; if (!User::validateUsername($userName)) { $errors[] = "Неверное имя"; } if (!User::validateEmail($userEmail)) { $errors[] = "Неверный Email"; } $userId = false; } else { $userId = User::validateLogged(); $user = User::getUserById($userId); $userName = $user['name']; } Comment::addComment($userComment, $userId, $userName, $productId); } require_once ROOT . '/views/product/view.php'; return true; }
function doRegister() { $name = $_REQUEST['name']; $email = $_REQUEST['email']; $password = $_REQUEST['password']; $password_again = $_REQUEST['password_again']; $user = new User($this->dbconn); if (!$user->validateName($name) or !$user->validateEmail($email) or !$user->validatePassword($password, $password_again)) { $error_data = 1; } if (!isset($error_data)) { $this->dbconn->debug = true; $user->name = $name; $user->email = $email; $user->password = $password; if ($user->save()) { $_SESSION['user_id'] = $user->id; header('Location: index.php'); exit; } else { $this->showErrors(); $this->register(); } } else { $this->showErrors(); $this->register(); } }
public function actionLogin() { $result = false; $password = ''; $email = ''; if (isset($_POST['submit'])) { $password = $_POST['password']; $email = $_POST['email']; $errors = false; if (!User::validateEmail($email)) { $errors[] = "Неккоректный email"; } if (!User::validatePassword($password)) { $errors[] = "Пароль должен быть больше 3 символов"; } $userId = User::validateUserData($email, $password); if ($userId == false) { $errors[] = "Некорректные данные для входа на сайт"; } else { User::auth($userId); header("Location: /cabinet/"); } } require_once ROOT . '/views/user/login.php'; return true; }
public function actionContact() { $userEmail = ''; $userText = ''; $subject = ''; $result = false; if (isset($_POST['submit'])) { $userEmail = $_POST['email']; $userText = $_POST['message']; $subject = $_POST['subject']; $errors = false; if (!User::validateEmail($userEmail)) { $errors[] = "Неправильный Email"; } if ($errors == false) { $adminEmail = "*****@*****.**"; $message = "Текст: " . $userText . " от " . $userEmail; $result = mail($adminEmail, $subject, $message); $result = true; } } require_once ROOT . '/views/site/contact.php'; return true; }
$user->getUserData($_GET['id']); if (isset($_GET['name'])) { $userName = $_GET['name']; $email = $_GET['email']; } else { $userName = $user->getUserName(); $email = $user->getUserEmail(); } $id = $_GET['id']; if (isset($_GET['Ivesti']) && $_GET['Ivesti'] == 'Įvesti') { $validation = 1; if (!$user->validateName($_GET['name'])) { echo "Neteisingai įvestas vardas, galimos tik raidės<br>"; $validation = 0; } if (!$user->validateEmail($_GET['email'])) { echo "Neteisingai įvestas email <br>"; $validation = 0; } if ($validation) { $user->changeUser($_GET['name'], $_GET['email'], $_GET['id']); echo "Vartotojas sekmingai įvestas"; } } include "./inputForm.php"; } else { echo $user->createUsersList($_GET['sort']); } echo "<a href='' onClick='history.go(0)'>Atnaujinti</a> | <a href='index.php'>Grįžti</a><br>"; } else { /**
/** * Verifies the account data present in the session * @param boolean $silent If true, no messages are created. * Defaults to false * @return boolean True if the account data is complete * and valid, false otherwise */ static function verify_account($silent = false) { global $_ARRAYLANG; //\DBG::log("Verify account"); $status = true; //\DBG::log("POST: ". var_export($_POST, true)); if (isset($_POST) && !self::verifySessionAddress()) { if ($silent) { return false; } $status = \Message::error($_ARRAYLANG['TXT_FILL_OUT_ALL_REQUIRED_FIELDS']); } // Registered Customers are okay now if (self::$objCustomer) { return $status; } if (\Cx\Core\Setting\Controller\Setting::getValue('register', 'Shop') == ShopLibrary::REGISTER_MANDATORY || \Cx\Core\Setting\Controller\Setting::getValue('register', 'Shop') == ShopLibrary::REGISTER_OPTIONAL && empty($_SESSION['shop']['dont_register'])) { if (isset($_SESSION['shop']['password']) && !\User::isValidPassword($_SESSION['shop']['password'])) { if ($silent) { return false; } global $objInit; $objInit->loadLanguageData('Access'); $status = \Message::error(\Cx\Core_Modules\Access\Controller\AccessLib::getPasswordInfo()); } } else { // User is not trying to register, so she doesn't need a password. // Mind that this is necessary in order to avoid passwords filled // in automatically by the browser, which may be wrong, or // invalid, or both. $_SESSION['shop']['password'] = NULL; } if (isset($_SESSION['shop']['email']) && !\FWValidator::isEmail($_SESSION['shop']['email'])) { if ($silent) { return false; } $status = \Message::error($_ARRAYLANG['TXT_INVALID_EMAIL_ADDRESS']); } if (!$status) { return false; } if (isset($_SESSION['shop']['email'])) { // Ignore "unregistered" Customers. These will silently be updated if (Customer::getUnregisteredByEmail($_SESSION['shop']['email'])) { return true; } $objUser = new \User(); $objUser->setUsername($_SESSION['shop']['email']); $objUser->setEmail($_SESSION['shop']['email']); \Message::save(); // This method will set an error message we don't want here // (as soon as it uses the Message class, that is) if (!($objUser->validateUsername() && $objUser->validateEmail())) { //\DBG::log("Shop::verify_account(): Username or e-mail in use"); \Message::restore(); $_POST['email'] = $_SESSION['shop']['email'] = NULL; if ($silent) { return false; } return \Message::error(sprintf($_ARRAYLANG['TXT_EMAIL_USED_BY_OTHER_CUSTOMER'], \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'login') . '?redirect=' . base64_encode(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'account')))) || \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_GOTO_SENDPASS'], \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'sendpass'))); } \Message::restore(); } return $status; }
public static function register() { //If form hasn't been posted, return form... if (!isset($_POST['username'])) { return User::processRegisterForm(); } //Check if form was filled out completely... if ($_POST['username'] == '') { return User::processRegisterForm(User::config('register_no_username_error'), NULL, $_POST['email']); } if ($_POST['email'] == '') { return User::processRegisterForm(User::config('register_no_email_error'), $_POST['username']); } if ($_POST['password'] == '') { return User::processRegisterForm(User::config('register_no_password_error'), $_POST['username'], $_POST['email']); } if ($_POST['passwordConfirm'] == '') { return User::processRegisterForm(User::config('register_no_confirm_password_error'), $_POST['username'], $_POST['email']); } //Check if entered details are valid... if (!User::validateUsername($_POST['username'])) { return User::processRegisterForm(User::config('register_invalid_username_error'), NULL, $_POST['email']); } if (!User::validateEmail($_POST['email'])) { return User::processRegisterForm(User::config('register_invalid_email_error'), $_POST['username']); } if (!User::validatePassword($_POST['password'])) { return User::processRegisterForm(User::config('register_invalid_password_error'), $_POST['username'], $_POST['email']); } //Check if username & email are available... if (!User::availableUsername($_POST['username'])) { return User::processRegisterForm(User::config('register_unavailable_username_error'), NULL, $_POST['email']); } if (!User::availableEmail($_POST['email'])) { return User::processRegisterForm(User::config('register_unavailable_email_error'), $_POST['username']); } //Ensure passwords match... if ($_POST['password'] != $_POST['passwordConfirm']) { return User::processRegisterForm(User::config('register_password_mismatch_error'), $_POST['username'], $_POST['email']); } //Add user to the usersPending table.. User::addPending($_POST['username'], $_POST['password'], $_POST['email']); //Process any onRegister callbacks, passing them, at present, nothing... User::processEventHandlers('onRegister'); return User::config('register_success_template'); }
public function actionOrder() { $platform = array(); $errors = array(); $userName = ''; $userEmail = ''; $userPhone = ''; $userComment = ''; $platform = Platform::getPlatformList(); $result = false; if (isset($_POST['submit'])) { $userName = $_POST['name']; $userEmail = $_POST['email']; $userPhone = $_POST['phone']; $userComment = $_POST['message']; $errors = false; if (!User::validateUsername($userName)) { $errors[] = "Неверное имя"; } if (!User::validateEmail($userEmail)) { $errors[] = "Неверный Email"; } if (!User::validatePhone($userPhone)) { $errors[] = "Неккоректный телефон"; } if ($errors == false) { $productsBasket = Basket::getProducts(); if (User::isGuest()) { $userId = false; } else { $userId = User::validateLogged(); } $result = Order::save($userName, $userEmail, $userPhone, $userComment, $userId, $productsBasket); if ($result) { $adminEmail = "*****@*****.**"; $subject = "Новый заказ"; mail($adminEmail, $subject, $userComment); Basket::clear(); } } else { $productsInBasket = Basket::getProducts(); $productId = array_keys($productsInBasket); $products = Products::getProductsByIdInBasket($productId); $totalPrice = Basket::getTotalPrice($products); $total = array_sum($totalPrice); $totalQuantity = Basket::countItem(); } } else { $productsInbasket = Basket::getProducts(); if ($productsInbasket == false) { header("Loaction: /"); } else { $productId = array_keys($productsInbasket); $products = Products::getProductsByIdInBasket($productId); $totalPrice = Basket::getTotalPrice($products); $totalQuantity = Basket::countItem(); $userName = false; $userEmail = false; $userPhone = false; $userComment = false; if (User::isGuest()) { } else { $userId = User::validateLogged(); $user = User::getUserById($userId); $userName = $user['name']; $userEmail = $user['email']; } } } require_once ROOT . "/views/basket/order.php"; return true; }
<?php /** * Developed by Jay Gaha * http://jaygaha.com.np */ $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if (!isset($_GET['identifier'])) { header('Location: ' . $url); exit; } include "includes/classes/class.user.php"; $user = new User(); $validate = $user->validateEmail($_GET['identifier']); /*$new_member = $user->register_company($_POST); if($new_member){ $_SESSION['message'] = 'Please confirm your email address to complete your registrataion.'; header('Location: ' . $url .'/company_login.php'); exit; } else{ $_SESSION['error'] = 'Something went wrong. Please try again.'; header('Location: ' . $url .'/company_signup.php'); exit; }*/