public function changeprofile() { if (!isset($_SESSION[APP_SES . 'id']) || $_SESSION[APP_SES . 'id'] == 0) { gotoUrl('/?route=/users/users'); exit; } if (!isset($_GET['id']) || $_GET['id'] == 0) { $this->loadView(SLASH . 'users' . SLASH . 'invalid_profile'); exit; } $this->setTitle('Update Profile'); $this->loadModel(SLASH . 'users' . SLASH . 'user'); $user = new User(); $user->load($_GET['id']); if (isset($_POST['changedetails'])) { if (isset($_POST['email']) && !empty($_POST['email'])) { if ($user->email_exists()) { $this->setTitle('Update Profile'); $this->loadView(SLASH . 'users' . SLASH . 'email_already_exists'); exit; } $user->setMember('email', $_POST['email']); } if ($_SESSION[APP_SES . 'id'] != $profile['id'] && isset($_POST['user_type'])) { $user->setMember('user_type', $_POST['user_type']); } $user->setMember('fname', $_POST['fname']); $user->setMember('lname', $_POST['lname']); $user->save(); setMessage('User profile has been updated.'); gotoUrl('/?route=/users/users&m=pagelist'); exit; } else { $data['profile'] = $user->getMembers(); $this->setTitle('Update Profile'); $this->loadView(SLASH . 'users' . SLASH . 'change_profile', TRUE, $data); } }
/** * @return bool Whether the email is valid or not. */ private function email_is_valid() { // get the email so I don't have to type a long variable name each time $email = $this->email; $regex_to_match = "/^([\\w-]+(?:\\.[\\w-]+)*)@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)\$/i"; if ($email === "") { return false; } elseif (!preg_match($regex_to_match, $email)) { // if the regex doesn't match, return false return false; } else { // check if the email exists $email_exists = User::email_exists($email); return !$email_exists; } }
require_once "header.php"; if ($session->is_logged_in()) { header("location: index.php?negative"); } $pathinfo = pathinfo($_SERVER["PHP_SELF"]); $basename = $pathinfo["basename"]; $currentFile = str_replace(".php", "", $basename); if (isset($_POST['registration_submit'])) { $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { if (isset($_POST['username']) && isset($_POST['password']) && $_POST['username'] != "" && $_POST['password'] != "") { $username_exists = User::username_exists($_POST['username']); $email_exists = false; if (isset($_POST['email']) && $_POST['email'] != "") { $email_exists = User::email_exists($_POST['email']); } if ($username_exists) { $sound = "negative"; $message .= "Sorry, the username: <i><b>" . $_POST['username'] . '</b></i> is already taken. Please choose a different one.<br />'; } if ($email_exists) { $sound = "negative"; $message .= "Sorry, the email: <i><b>" . $_POST['email'] . '</b></i> is already registered.'; } if ($message == "") { $user = new User(); $user->username = $_POST['username']; $user->password = $_POST['password']; $user->email = $_POST['email']; $user->create();
<?php require_once "../includes/initialize.php"; $ja = array(); if (isset($_POST['email'])) { $email = $db->escape_value($_POST['email']); if (User::email_exists($email)) { $r = $db->query("UPDATE users SET subscribed = 0 WHERE email = '{$email}' LIMIT 1"); if ($db->affected_rows() == 1) { $ja['outcome'] = "ok"; $ja['msg'] = $email; echo json_encode($ja); } else { $ja['outcome'] = "bad"; $ja['msg'] = $email . " nie byl zapisany do listy mailingowej"; echo json_encode($ja); } // end affected rows } else { $ja['outcome'] = "bad"; $ja['msg'] = $email . " nie ma takiego adresu w naszej bazie!"; echo json_encode($ja); } // end email exists } else { $ja['outcome'] = "bad"; $ja['msg'] = "Nie otrzymalem adresu email!"; echo json_encode($ja); } // end isset email
<?php require_once "initialize.php"; $ja = array("email" => "valid", "password" => "valid", "logged" => "false"); if (isset($_POST['email']) && isset($_POST['password'])) { $email = trim($db->escape_value($_POST['email'])); $password = trim($db->escape_value($_POST['password'])); $found_user = User::authenticate($email, $password); if ($found_user) { // login user if he was found in database and password is correct $session->login($found_user); $ja['logged'] = "true"; } else { // if the $found_user is false (not found) we check if the user exists in database $email_exists = User::email_exists($email); if ($email_exists) { // if user exists it means the password was wrong and we can display msg in jQuery if ($email_exists->active == 1) { $ja["password"] = "******"; } else { $ja["email"] = "inactive"; } } else { // if the user does not exist we set the user to invalid so we can use it in jQuery $ja["email"] = "invalid"; } } } else { // if there was no $_POST (ie. entering logowanie.php in browser) $session->is_logged_in() ? $session->logout() : false; }
<?php $success = false; $errors = array(); require 'includes/initialize.php'; if (isset($_POST['email'])) { if (User::email_exists($_POST['email'])) { array_push($errors, 'Email already registered.'); } else { if (strlen($_POST['pwd']) <= 6) { array_push($errors, 'Password length should be greater than 6 characters.'); } else { $user = User::instantiate($_POST); if ($user->create()) { $success = true; } } } } echo '{'; echo "\"success\":"; if ($success) { echo "true"; } else { echo "false"; } echo ","; echo "\"errors\":{"; $i = 0; foreach ($errors as $error) { if ($i != 0) {
<?php require_once "../../includes/initialize.php"; $config = array(); $config['appId'] = APP_ID; $config['secret'] = APP_SECRET; $facebook = new Facebook($config); $fb_user = $facebook->api('/me', 'GET'); if (User::get_by_oauthid($fb_user['id']) != null) { header("location: ../../registration.php?fbtaken=Facebook Username: "******"<br/>Facebook ID: " . $fb_user['id']); } else { $username_exists = User::username_exists($fb_user['username']); $email_exists = false; if (isset($fb_user['email']) && $fb_user['email'] != "") { $email_exists = User::email_exists($fb_user['email']); } if ($username_exists) { $message .= "Sorry, the username: <i><b>" . $fb_user['username'] . '</b></i> is already taken. Please choose a different one.<br />'; } if ($email_exists) { $message .= "Sorry, the email: <i><b>" . $fb_user['email'] . '</b></i> is already registered.'; } if ($message == "") { $generatePassword = generatePassword(); $user = new User(); $user->username = $fb_user['username']; $user->password = $generatePassword; $user->email = $fb_user['email']; $user->name = $fb_user['name']; $user->volume = 4; $user->control = 4;
$user->top_score = $_GET["top_score"]; $user->volume = $_GET["volume"]; $user->control = $_GET["control"]; $user->language = $_GET["language"]; if (isset($_GET["name"]) && $_GET["name"] != "") { $user->name = $_GET["name"]; } else { $user->name = "Kelly"; } $username_exists = false; $email_exists = false; if (User::username_exists($user->username)) { $username_exists = true; } if (isset($_GET["email"])) { if (User::email_exists($_GET["email"])) { $email_exists = true; } else { $user->email = $_GET["email"]; } } else { $user->email = ""; } if ($email_exists == true && $username_exists == true) { echo "username_and_email_exists"; } else { if ($email_exists == true) { echo "email_exists"; } else { if ($username_exists == true) { echo "username_exists";