$this->miConfigurador->fabricaConexiones->setRecursoDB('principal'); $this->lenguaje = $lenguaje; $this->miSql = $sql; } function procesarFormulario() { // Aquí va la lógica de procesamiento // Al final se ejecuta la redirección la cual pasará el control a otra página $conexion = "estructura"; $esteRecursoDB = $this->miConfigurador->fabricaConexiones->getRecursoDB($conexion); $cadenaSql = $this->miSql->getCadenaSql('registrar', $_REQUEST); $resultado = $esteRecursoDB->ejecutarAcceso($cadenaSql, "insertar"); if ($resultado) { redireccion::redireccionar('inserto'); exit; } else { redireccion::redireccionar('noInserto'); exit; } } function resetForm() { foreach ($_REQUEST as $clave => $valor) { if ($clave != 'pagina' && $clave != 'development' && $clave != 'jquery' && $clave != 'tiempo') { unset($_REQUEST[$clave]); } } } } $miProcesador = new Registrar($this->lenguaje, $this->sql); $resultado = $miProcesador->procesarFormulario();
$tempUser['oauth_id'] = $fb_user['id']; $tempUser['email'] = isset($fb_user['email']) ? $fb_user['email'] : null; $tempUser['first_name'] = $fb_user['first_name']; $tempUser['middle_name'] = isset($fb_user['middle_name']) ? $fb_user['middle_name'] : null; $tempUser['last_name'] = isset($fb_user['last_name']) ? $fb_user['last_name'] : null; $tempUser['gender'] = $fb_user['gender'] == 'male' ? 1 : 0; if (isset($fb_user['location'])) { $tempUser['location'] = $fb_user['location']->name; $_SESSION['location_received'] = true; } else { $_SESSION['location_received'] = false; } // Register the user data into temporary table // This record will later be moved to the main table after additional information has been obtained // Get HTML form to obtain additional information $registrar = new Registrar($db); if ($registrar->registerTempUser($tempUser)) { require DOCUMENT_ROOT . 'includes/html/login/add_reg_info.php'; } else { echo "<html><body><h3>Unexpected error</h3></body></html>"; } // Facebook would know what happens at this point. :P exit; } } else { // Facebook user is not authenticated - request authentication header("Location: " . $facebook->getLoginURL()); exit; } } header("Location: " . SITE_URL);
header("Location: {$redirect_uri}"); exit; } // Google user is logging in for the first time // Register the user $tempUser = array(); $tempUser['oauth_type'] = OAUTH_GOOGLE; $tempUser['oauth_id'] = $gUser['id']; $tempUser['email'] = $gUser['email']; $tempUser['first_name'] = $gUser['givenName']; $tempUser['last_name'] = isset($gUser['familyName']) ? $gUser['familyName'] : ''; $tempUser['gender'] = $gUser['gender'] == 'male' ? 1 : 0; // Google OAuth doesn't provide with location $_SESSION['location_received'] = false; // Register the user data into temporary table - // This data will later be moved to the main table after additional information has been obtained // Get HTML form to obtain additional information $registrar = new Registrar($db); if ($registrar->registerTempUser($tempUser)) { $registrar->getHTML(); } else { echo "<html><body><h3>Unexpected error</h3></body></html>"; } exit; } } else { header("Location: " . $google->getLoginURL()); exit; } header("Location: " . SITE_URL); exit;
// PASSWORD <<<< /* ----- VALIDATION */ if (sizeof($error) == 0) { // No validation errors. Can continue. $user = array(); $user['username'] = $db->escape($username); $user['email'] = $db->escape($email); $user['password'] = sha1($password); $user['first_name'] = $db->escape($name); $user['gender'] = $gender == 'male' ? 1 : 0; $user['institute'] = $db->escape($institute); $user['location'] = $db->escape($location); $user['registered_in'] = date("Y-m-d H:i:s", time()); $user['verified'] = 0; // Register the user $registrar = new Registrar($db); $user_id = $registrar->registerUser($user); if ($user_id) { // Registration successfull - Send the email verification link if ($registrar->sendVerificationEmail($user_id, $email)) { $result = array('success' => true); } else { $result = array('success' => false, 'error' => 'Unexpected error!'); } header('Content-Type: application/json'); echo json_encode($result); exit; } } else { $result = array('success' => false, 'error' => implode("<br/>", $error)); header('Content-Type: application/json');
$db->delete('users_temp'); unset($_SESSION['registration_pending']); unset($_SESSION['temp_user_id']); // Now that the registration is complete, log in the user $loginHelper = new LoginHelper(); $loginHelper->Login($id, $user['oauth_type'], $user['oauth_id']); exit; // END OF SCRIPT // } } else { $registrar = new Registrar($db); echo $registrar->getHTML($error); // Get error HTML var_dump($error); exit; } } /* No any data POSTed but registration is pending - show Additional Information page */ if (isset($_SESSION['registration_pending'])) { require_once DOCUMENT_ROOT . 'classes/Registrar.php'; require_once DOCUMENT_ROOT . 'config/db.php'; $registrar = new Registrar($db); echo $registrar->getHTML(); exit; } /* No data is POSTed and no registration is pending - Redirect to login page */ if (isset($_SERVER['HTTP_REFERER'])) { $_SESSION['redirect_uri'] = $_SERVER['HTTP_REFERER']; } header(SITE_URL . 'login/'); exit;
session_start(); require $_SERVER['DOCUMENT_ROOT'] . '/ts2/config/consts.php'; require_once DOCUMENT_ROOT . 'classes/Response.php'; $response = new Response(); if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['spoof_proof']) && $_POST['spoof_proof'] == $_SESSION['spoof_proof']) { require_once DOCUMENT_ROOT . 'classes/Registrar.php'; require_once DOCUMENT_ROOT . 'classes/LoginHelper.php'; require_once DOCUMENT_ROOT . 'config/db.php'; if (isset($_POST['email'])) { // Email provided - Make and email a reset link to the user $email = $db->escape($_POST['email']); $db->where('email', $email)->where('oauth_type', 0); $user = $db->getOne('users', 'id, email'); if ($db->count > 0) { // Email record exist - Send reset email $registrar = new Registrar($db); if ($registrar->sendResetEmail($user['id'], $user['email'])) { $response->success(); } else { $response->error('Unexpected error: ERR_SND_RESET_EMAIL'); } } else { // Email record doesn't exist $response->error('No such email record exist in our database.'); } } elseif (isset($_POST['new_password']) && isset($_SESSION['reset_verified']) && isset($_SESSION['reset_id'])) { $user_id = $_SESSION['reset_id']; $password = sha1($db->escape($_POST['new_password'])); $user = array(); $user['password'] = $password; $user['auth_code'] = '';
$user['institute'] = $institute; if (isset($location)) { $user['location'] = $location; } if (isset($email)) { $user['email'] = $email; } if (isset($_POST['gender'])) { $user['gender'] = $_POST['gender'] == 'male' ? 1 : 0; } $user['registered_in'] = date("Y-m-d H:i:s", time()); if ($user['oauth_type'] != OAUTH_TWITTER) { $user['verified'] = 1; } // Add user's record to the database $registrar = new Registrar($db); $id = $registrar->registerUser($user); if ($id) { // Delete tempUser record and unset temporary session variables $db->where('id', $_SESSION['temp_user_id']); $db->delete('users_temp'); unset($_SESSION['registration_pending']); unset($_SESSION['temp_user_id']); unset($_SESSION['spoof_proof']); /* If email has been manually provided, it needs to be verified. */ if (isset($email)) { $registrar->sendVerificationEmail($id, $user['email']); // Show verification page link $result = array('success' => true, 'verify' => true); header('Content-Type: application/json'); echo json_encode($result);
} // Validación de telefono 1 if (!preg_match("/^[9|6][0-9]{8}\$/", $telefono1)) { header('Location: ../signup.html?mensaje=campoErroneo'); exit; } // Validación de telefono 2 if ($telefono2 !== "") { if (!preg_match("/^[9|6][0-9]{8}\$/", $telefono2)) { header('Location: ../signup.html?mensaje=campoErroneo'); exit; } } //Se define el array de campos a introducir en la basa de datos $campos = array("login" => $login, "pass" => $password, "dni" => $dni, "nombre" => $nombre, "apellidos" => $apellidos, "email" => $email, "direccion" => $direccion, "telefono1" => $telefono1, "telefono2" => $telefono2); if ($registro->load($mensaje, $campos, "clientes", "guardar")) { // Éxito en el insert. Se devuelve a la página Thanks $ses = new Session(); $ses->startSession(); $_SESSION['login'] = $login; header('Location: ../thanksRegistro.html'); exit; } else { //Error al introducir un nuevo usuario header('Location: ../signup.html?mensaje=errorUsuario'); exit; } } } $start = new Registrar(); $start->registro();