} else { $klasse_zulaessige_eingabe = TRUE; } // Ãœberprüfung ob alles eingegeben wurde. if (strlen($vname) == 0 or strlen($nname) == 0 or $klasse_zulaessige_eingabe == FALSE or strlen($nick) == 0 or strlen($mail) == 0 or strlen($pw1) == 0 or strlen($pw2) == 0) { $user_infos[] = "<h4 style='color:red;'>Sie haben nicht alle Felder ausgefüllt!</h4>"; } // Prüfung ob zwei mal das selbe PW eingegeben wurde. if ($pw1 !== $pw2) { "<h4 style='color:red;'>Sie haben nicht zweimal das selbe Passwort eingegeben!</h4>"; } // speichern bei korrekter Eingabe if (count($user_infos) == 0) { $u = new User(); $u->setLogin($nick); $u->setPasswd($pw1); $u->setAktiv(TRUE); $u->setEmail($mail); $u->setGeburtstag($bday); $u->save(); if ($typ == 1) { //Schueler $s = new Schueler(); $s->setVorname($vname); $s->setNachname($nname); $s->setKlasse_id($klasse[0]); $s->setUser_id($u->getId()); $s->setAktiv(TRUE); $s->save(); } elseif ($typ == 2) { //Lehrer
public function executeSignup($request) { // check invite id $this->invite = InvitePeer::getFromField(InvitePeer::ID, $request->getParameter('invite_id')); if (!$this->invite) { $this->invite = InvitePeer::getFromField(InvitePeer::ID, $this->getUser()->getInviteId()); } if ($request->isMethod('post')) { $this->form = new SignupForm(); // process signup $this->form->bind($request->getParameter('signup')); if ($this->form->isValid()) { $user = new User(); $profile = new Profile(); $email = new Email(); $tag = new Tag(); // setup profile $profile->setFirstName($this->form->getValue('first_name')); $profile->setLastName($this->form->getValue('last_name')); // set prefered language $current_language = LanguagePeer::retrieveByCulture($this->getUser()->getCulture()); if (!$current_language) { $current_language = LanguagePeer::getDefaultLanguage(); } $profile->setLanguage($current_language); // set email $email->setEmail($this->form->getValue('email')); $email->setIsConfirmed(false); $email->setIsPrimary(true); $email->setConfirmCode($email->generateConfirmCode()); $email->setType(ContactPeer::TP_PERSONAL); // setup new user $user->setPasswd($this->form->getValue('password')); // add profile and contact to user $user->addProfile($profile); $user->addEmail($email); if ($this->invite) { $user->setUserRelatedByInvitedBy($this->invite->getUser()); // add jotags to bookmark if ($this->invite->getInviteTagsJoinTag()) { foreach ($this->invite->getInviteTagsJoinTag() as $tagbm) { // add to bookmark $b = new Bookmark(); $b->setTag($tagbm->getTag()); $user->addBookmark($b); } } // delete invite from db $this->invite->delete(); // add initial credit to the user $user->setCredits(OptionPeer::retrieveOption('BONUS_INVITE_CREDIT')); } else { $user->setCredits(OptionPeer::retrieveOption('BONUS_INIT_CREDIT')); } // save $user->save(); $this->getUser()->clearInviteId(); // generate JOTAG. We must do it after save because we use ID in the algorithm $tag->setJotag($user->generateRandomJOTAG()); $tag->setIsPrimary(true); $tag->setStatus(TagPeer::ST_NEW); $tag->setBadge(BadgePeer::getDefaultBadge()); $tag->setUser($user); // link primary email to tag $tm = new TagEmail(); $tm->setEmail($email); $tag->addTagEmail($tm); // save new tag $tag->save(); // send confirmation email Mailer::sendEmail($email->getEmail(), 'signupConfirmation', array('user' => $user, 'email' => $email), $user->getPreferedLanguage()); $this->setMessage("SIGNUP", "SUCCESS", array($email->getEmail())); if (!$this->isWebserviceCall()) { $this->redirect('@homepage'); } } } else { $first = $last = $email = ""; if ($this->invite) { // pre-populate first/last name, if available from invite $first = $this->invite->getFirstName(); $last = $this->invite->getLastName(); $email = $this->invite->getEmail(); } $this->form = new SignupForm(array('first_name' => $first, 'last_name' => $last, 'email' => $email)); // set invite id, if available $this->getUser()->setInviteId($this->invite ? $this->invite->getId() : null); } }
<?php session_start(); include_once "connection/DbConnection.php"; include_once "class/LoginDAO.php"; include "class/User.php"; if (isset($_REQUEST['submit'])) { extract($_REQUEST); $user = new User(); $user->setEmail($_POST['email']); $user->setPasswd($_POST['password']); $signin = new LoginDAO(); $login = $signin->check_login($user->getEmail(), $user->getPasswd()); if ($login === 1) { //Registration Success header("location:adminPage.php"); } if ($login === 2) { //Registration Success header("location:ouroffer.php"); } if ($login === 0) { //Registration Failed $response = '<h3 style="color:indianred">Pogresan email ili sifra! <br />Možda Vam korisnik nije aktivan, proverite da li imate email za potvrdu registracije!</h3>'; header("location:header.php?response={$response}"); } }
<?php if (isset($_REQUEST["action"])) { switch ($_REQUEST["action"]) { case "action_user_login": global $uzivatel; global $message; //kontrola vstup udajov $uzivatel = new User(); $uzivatel->setEmail(test_input($_REQUEST["email"])); $uzivatel->setPasswd(test_input($_REQUEST["passwd"])); //vytvorenie uzovatela if ($uzivatel->is_registered()) { $_SESSION["user"] = $uzivatel->getId(); $uzivatel->loadFromDatabase($_SESSION["user"]); //natiahnutie ostatnzch udajov o uzivatelovi $organizacia = new Organizacia(); $organizacia->loadFromDatabase($uzivatel->getIdOrganizacie()); //kontrola na prechod na novy rok = resetovanie ciselnikov dokumentov if ($organizacia->kontrolaPrechoduRoku()) { $organizacia->setAktualnyRokDokumentov(); //nastavi aktualnz rok dokumentov $organizacia->resetujCiselnikyDokumentov(); //prenesei ymenu do databazy $organizacia->updateInDatabase(); $message->add("System presiel na novy rok! Boli resetovane ciselniky dokumentov."); } $page->redirect(); //po uspesnom prihlaseni redirekneme, aby sa nam nacitali udaje o uzivatelovi } else { $message->add("uzivatel nieje registrovany");
} else { //Prüfung ob zwei mal das selbe PW eingegeben wurde. if ($pw1 == $pw2) { $pwcomplete = $pw1; /*echo "Typ: "; echo $typ; echo "<br>"; echo "Klassen: "; echo "<pre>"; echo print_r ($klasse); echo "</pre>"; echo "Vorname: "; echo $vname; echo "<br>"; echo "Nachname: "; echo $nname; echo "<br>"; echo "Nickname: "; echo $nick; echo "<br>"; echo "Geburtstag: "; echo $bday; echo "<br>"; echo "E-Mail: "; echo $mail; echo "<br>"; echo "Passwort: "; echo $pwcomplete; echo "<br>"; echo "Status: "; echo $status; echo "<br>";*/ $u = new User(); $u->setLogin($nick); $u->setPasswd($pwcomplete); $u->setAktiv(TRUE); $u->setEmail($mail); $u->setGeburtstag($bday); $u->save(); if ($typ == 1) { //Schueler $s = new Schueler(); $s->setVorname($vname); $s->setNachname($nname); $s->setKlasse_id($klasse[0]); $s->setUser_id($u->getId()); $s->setAktiv(TRUE); $s->save(); } elseif ($typ == 2) { //Lehrer
public function getAllAsObject($restriction = '') { $sql = "SELECT *\n\t\t\t\tFROM user\n\t\t\t\tWHERE 1=1"; $sql .= $restriction . ";"; try { $result = mysql_query($sql); if (!$result) { throw new MysqlException(); } $users = array(); while ($row = mysql_fetch_assoc($result)) { $u = new User(); $u->setId($row['user_id']); $u->setLogin($row['login']); $u->setPasswd($row['passwd']); $u->setAktiv($row['aktiv']); $u->setEmail($row['email']); $u->setGeburtstag($row['geburtstag']); $users[$u->getId()] = $u; } } catch (MysqlException $e) { Html::showAll($e); } return $users; }
/** * Action to register * * When called via GET, it shows the register form. * When called via POST, it tries to add the user * to the database. * * The expected HTTP parameters are: * <ul> * <li>login: The username (via HTTP POST)</li> * <li>passwd: The password (via HTTP POST)</li> * </ul> * * The views are: * <ul> * <li>users/register: If this action is reached via HTTP GET (via include)</li> * <li>users/login: If login succeds (via redirect)</li> * <li>users/register: If validation fails (via include). Includes these view variables:</li> * <ul> * <li>user: The current User instance, empty or being added * (but not validated)</li> * <li>errors: Array including validation errors</li> * </ul> * </ul> * * @return void */ public function register() { $user = new User(); if (isset($_POST["login"])) { // reaching via HTTP Post... $user = new User(); if ($_POST["tipo"] == "Jurado popular") { $user->setLogin($_POST["login"]); $user->setPasswd($_POST["passwd"]); $user->setDni($_POST["dni"]); $user->setName($_POST["name"]); $user->setApellidos($_POST["apellidos"]); $user->setMail($_POST["mail"]); $user->setTelefono($_POST["telefono"]); $user->settipo($_POST["tipo"]); } else { if ($_POST["tipo"] == "Establecimiento") { $user = new Establecimiento(); $user->setLogin($_POST["login"]); $user->setPasswd($_POST["passwd"]); $user->setCif($_POST["cif"]); $user->setNombre($_POST["nombreEstablecimiento"]); $user->setDireccion($_POST["direccion"]); $user->setHorario($_POST["horario"]); $user->setPaginaWeb($_POST["paginaWeb"]); $user->setTelefono($_POST["telefono"]); $user->settipo($_POST["tipo"]); } } try { $user->checkIsValidForRegister(); // if it fails, ValidationException // check if user exists in the database if (!$this->userMapper->usernameExists($_POST["login"])) { // save the User object into the database $this->userMapper->save($user); // POST-REDIRECT-GET // Everything OK, we will redirect the user to the list of posts // We want to see a message after redirection, so we establish // a "flash" message (which is simply a Session variable) to be // get in the view after redirection. $this->view->setFlash("Username " . $user->getLogin() . " successfully added. Please login now"); // perform the redirection. More or less: // header("Location: index.php?controller=users&action=login") // die(); $this->view->redirect("users", "login"); } else { $errors = array(); $errors["login"] = "******"; $this->view->setVariable("errors", $errors); } } catch (ValidationException $ex) { // Get the errors array inside the exepction... $errors = $ex->getErrors(); // And put it to the view as "errors" variable $this->view->setVariable("errors", $errors); } } // Put the User object visible to the view $this->view->setVariable("user", $user); // render the view (/view/users/register.php) $this->view->render("users", "register"); }