/** * Check if an authentication request exists and * attempt authentication if it does * @return bool $success */ public function checkAuthentication() { if (isset($this->_authenticatedPerson)) { return true; } // resolve AuthRequest from PostContainer if (static::$requestContainer) { if (isset($_REQUEST[static::$requestContainer])) { $requestData =& $_REQUEST[static::$requestContainer]; } else { $requestData = array(); } } else { $requestData =& $_POST; } // check for authentication request if (isset($requestData['username']) && isset($requestData['password'])) { $this->_authenticatedPerson = $this->attemptAuthentication($requestData['username'], $requestData['password']); if ($this->_authenticatedPerson) { // redirect if original request was GET if ($requestData['returnMethod'] != 'POST' && $_SERVER['REQUEST_METHOD'] != 'GET') { Site::redirect($_SERVER['REQUEST_URI']); } return true; } else { $this->respondLoginPrompt(new PasswordAuthenticationFailedException(_('The username or password you entered was incorrect.'))); return false; } } return false; }
public function action_delete() { $cm = new ClientManager(DB::get_instance()); $clt = $cm->get($this->req->id); $this->site->ajouter_message("ok"); $cm->delete($clt); $this->site->ajouter_message($clt->getMail() . " supprimé!"); Site::redirect("admClient"); }
public static function Logout() { if (self::$me != null) { setcookie(MODLOGIN_LOGIN, '', 0, '/'); setcookie(MODLOGIN_PASSWORD, '', 0, '/'); Site::redirect(WEBDIR); exit; } }
public static function getRecordByHandle($handle) { $Record = parent::getRecordByHandle($handle); // redirect to correct handler if ($Record && !is_a($Record, static::$recordClass)) { $url = $Record->getURL(); if ($rest = static::getPath()) { $url .= '/' . implode('/', $rest); } \Site::redirect($url); } return $Record; }
public function action_validcom() { $com['idClient'] = $this->session->session_ouverte()->getIdClient(); $modm = new ModeleManager(DB::get_instance()); $mod = $modm->getByName($this->req->name); $com['idModele'] = $mod->getIdModele(); $com['contenu'] = $this->req->com; $com['note'] = $this->req->note - 1; $com['dateCom'] = date('Y-m-d', time() + 7200); $commentaire = new Commentaire($com); $comm = new CommentaireManager(DB::get_instance()); $comm->add($commentaire); Site::redirect("car", "index&name=" . $this->req->name); }
public function action_index() { if ($this->session->ouverte()) { $user = $this->session->session_ouverte(); //echo var_dump($user); $f = new Form("?module=clientmanage&action=valide", "form"); //Creation du formulaire $f->add_text("Email", "Email", "Email")->set_value($user->getMail()); $f->add_text("Mdp", "Mdp", "Mot de passe")->set_value($user->getMdp()); $f->add_text("rue", "rue", "Rue")->set_value($user->getRue()); $f->add_text("cp", "cp", "Code Postal")->set_value($user->getCodePostal()); $f->add_text("ville", "ville", "Ville")->set_value($user->getVille()); $f->add_submit("Valider", "Valider")->set_value("Valider"); $this->tpl->assign("form", $f); } else { $this->site->ajouter_message("Vous n'êtes pas connecté(e)"); Site::redirect("index"); } }
public static function redirectViewRecord(ActiveRecord $Record, $path = array(), $permanent = false) { if (is_array($path)) { $path = implode('/', $path); } if (!($url = $Record->getURL())) { if (!($classPath = static::getClassPath($Record))) { return RequestHandler::throwError('No route to record viewer'); } $url = '/' . $classPath . '/' . $Record->getHandle(); } if ($path) { $url .= '/' . ltrim($path, '/'); } if ($permanent) { Site::redirectPermanent($url); } else { Site::redirect($url); } }
public function action_validelogadm() { if ($this->req->log and $this->req->mdp) { if ($this->req->log != 'admin') { $f = $this->session->formlogadm; $f->populate(); $this->session->formlogadm = $f; $this->site->ajouter_message("Login ou mot de passe incorrect"); Site::redirect('login', 'logadmin'); } else { $am = new AdminManager(DB::get_instance()); $adm = $am->connexion($this->req->mdp); if ($adm) { $this->session->ouvrir('admin'); $this->site->ajouter_message("Bienvenue Admin"); unset($this->session->formlogadm); Site::redirect('admSpace'); } else { $f = $this->session->formlogadm; $f->populate(); $this->session->formlogadm = $f; $this->site->ajouter_message("Login ou mot de passe incorrect"); Site::redirect('login', 'logadmin'); } } } else { $this->site->ajouter_message("Login ou mot de passe non renseigné"); Site::redirect("login", "logadm"); } }
public static function handleViewRequest() { $GLOBALS['Session']->requireAuthentication(); return Site::redirect($GLOBALS['Session']->Person->getURL()); }
public function action_validePhoto() { $extensions = array("png", "jpg", "jpeg", "bmp", "PNG", "JPG", "JPEG", "BMP"); $taille_max = 100000; $dossier = "images/"; $fichier = uniqid(); $extension = explode('.', $_FILES['photo']['name']); $extension = strtolower($extension[count($extension) - 1]); if (!in_array($extension, $extensions)) { $error[] = "mauvaise extension"; } /*$taille = getimagesize($_FILES['photo']['tmp_name']); $larg=300; $reduc=($larg*100)/$taille[0]; $haut=($taille[1]*$reduc)/100; if($extension!="jpg") $function=imagecreatefrom.$extension; else $function=imagecreatefrom.jpeg; $image=imagecreatetruecolor($larg,$haut); imagecopyresampled($image, $function($_FILES['photo']['tmp_name']), 0, 0, 0, 0, $larg, $haut, $taille[0],$taille[1]); imagepng($image,$dossier.$fichier.".png",9);*/ move_uploaded_file($_FILES['photo']['tmp_name'], $dossier . $fichier . ".jpg"); if (isset($error[0])) { $f = $this->session->formPh; $f->populate(); $this->tpl->assign("f_addph", $f); foreach ($error as $err) { $this->site->ajouter_message("-" . $err); } } else { $img['idImage'] = $fichier; $img['idModele'] = $this->req->id; $image = new Image($img); $imgM = new ImageManager(DB::get_instance()); $imgM->add($image); $this->site->ajouter_message("upload réussi"); //il faudra penser à redimensionner la photo Site::redirect("admMarque"); } }
public static function redirect($path, $get = false, $hash = false) { Site::redirect($path, $get, $hash); }
public function action_ajax() { // Pour afficher les voitures quand on clique sur un modèle if ($this->req->id) { $vm = new VoitureManager(DB::get_instance()); $liste = $vm->listing($this->req->id); $i = 0; $tab = array(); foreach ($liste as $car) { $tab[$i]['idVoiture'] = $car->getIdVoiture(); $tab[$i]['annee'] = $car->getAnnee(); $tab[$i]['km'] = $car->getKm(); $tab[$i]['description'] = $car->getDescription(); $i = $i + 1; } echo json_encode($tab); exit; } else { Site::redirect('index'); } }
/** * {@inheritdoc} */ public function redirect($url, $data = array()) { Site::redirect($url, $data); }
<?php Site::$debug = true; // set to true for extended query logging Site::$production = true; // set to true for heavy file caching #Site::$autoPull = false; Site::$permittedOrigins = '*'; Site::$skipSessionPaths[] = 'api.php'; Site::$skipSessionPaths[] = 'test-api/cachable.php'; Site::$skipSessionPaths[] = 'test-api/status.php'; if (Gatekeeper\Gatekeeper::$apiHostname && !empty($_SERVER['HTTP_HOST']) && (is_string(Gatekeeper\Gatekeeper::$apiHostname) && $_SERVER['HTTP_HOST'] == Gatekeeper\Gatekeeper::$apiHostname || is_array(Gatekeeper\Gatekeeper::$apiHostname) && in_array($_SERVER['HTTP_HOST'], Gatekeeper\Gatekeeper::$apiHostname))) { Site::$onInitialized = function () { if (empty(Site::$pathStack[0]) && Gatekeeper\Gatekeeper::$portalHostname) { Site::redirect('http://' . Gatekeeper\Gatekeeper::$portalHostname); } array_unshift(Site::$pathStack, 'api'); array_unshift(Site::$requestPath, 'api'); }; }
public function action_index() { Site::redirect("loc"); // La page d'accueil est la page de location }
<?php Site::redirect('/site-admin/index');
$text .= " //Exclusion\n"; $text .= " public static \$exclusion = array();\n\n"; $text .= " //References\n"; $text .= " public static \$references = array({$references});\n"; $text .= " public static \$referenced = array({$referenced});\n\n"; $text .= " //Functions\n\n"; $text .= " }\n"; $text .= "?>"; $monfichier = fopen("classes/{$name}.class.php", 'w+'); fseek($monfichier, 0); // On remet le curseur au début du fichier fputs($monfichier, $text); // On écrit le nouveau nombre de pages vues fclose($monfichier); //echo "<textarea style='width:500px;height:500px;'>$text</textarea>"; Site::redirect(WEBDIR . "manageClasses"); exit; } else { echo "WARNING: verifier ordonnancement des references et des referenced pour les multi liaisons d'une table sur une autre"; $rs = DB::SqlToArray("SELECT table_name FROM information_schema.tables WHERE table_schema = '" . DB_BASE . "'"); echo "<meta http-equiv='content-type' content='text/html; charset=utf-8' />"; echo "Classes: <br />"; foreach ($rs as $r) { $r = $r['table_name']; $r = str_replace(DBPRE, "", $r); if (file_exists("classes/" . $r . ".class.php")) { echo "<span color='green'>{$r}</span><br />"; } else { echo "<span color='red'>{$r}</span> - <a href='" . WEBDIR . "manageClasses/create/{$r}'>Créer la classe</a><br />"; } }
protected static function _forceTrailingSlash() { // if there is no path component in the stack, then there was no trailing slash if (static::peekPath() === false && !empty(Site::$requestPath[0])) { Site::$requestPath[] = ''; Site::redirect(Site::$requestPath); } }
public function action_valide() { $flag = false; if ($this->req->dateloc and $this->req->daterendu) { $locm = $this->req->datelocm; $loch = $this->req->dateloch; $rendum = $this->req->daterendum; $renduh = $this->req->daterenduh; //$this->site->ajouter_message($this->req->dateloc ."h ". $this->req->dateloch."_".$this->req->datelocm ."____".$this->req->daterendu ."h ". $this->req->daterenduh."_".$this->req->daterendum); if ($this->req->dateloc > $this->req->daterendu) { $this->site->ajouter_message("loc> rendu"); } else { if ($this->req->dateloc == $this->req->daterendu) { if ($loch + 6 > $renduh) { $this->site->ajouter_message("loc = rendu mais hloc>hrendu car durée minimal d'une location =6heure"); $flag = true; } else { if ($loch == $renduh) { $this->site->ajouter_message("Durée minimal d'une location = 6heures"); $flag = true; } } } } //On récupère les locations de la voiture concerné pour vérifié que les date voulu par l'utilisateur sont libre. $lm = new LocationManager(DB::get_instance()); $info = $lm->infoLoc($this->req->id); //dateloc et daterendu sont les date rentrer par l'utilisateur $dateloc = $this->req->dateloc . " " . $this->req->dateloch . ":" . $this->req->datelocm . ":00"; $daterendu = $this->req->daterendu . " " . $this->req->daterenduh . ":" . $this->req->daterendum . ":00"; $dateloc = new DateTime($dateloc); $dateloc = $dateloc->format('YmdHis'); $daterendu = new DateTime($daterendu); $daterendu = $daterendu->format('YmdHis'); foreach ($info as $i) { // date à tester : $start = $i->getDateLoc(); $stop = $i->getDateRendu(); $now = date('Y-m-d H:i:s', time() + 3600); //Date actuelle. //$tmp2=explode(" ",$l->getDateRendu()); // $finloc=$l->getDateRendu(); // $debloc =$l->getDateLoc(); // on transforme les date en objet datetime. format YYYYMMDDHHMMSS ( 2009-10-10 10:00:00 donnera 20091010100000). //start et stop sont les date de debut/fin des différent location enregistrer en DB $start = new DateTime($start); $start = $start->format('YmdHis'); $stop = new DateTime($stop); $stop = $stop->format('YmdHis'); $now = new DateTime($now); $now = $now->format('YmdHis'); /* $debloc = new DateTime($debloc); $debloc = $debloc->format('YmdHis'); $finloc = new DateTime($finloc); $finloc = $finloc->format('YmdHis'); */ if ($start <= $dateloc && $stop >= $dateloc || ($dateloc <= $now || $daterendu <= $now) || $start <= $daterendu && $stop >= $daterendu) { $flag = true; } } //location pas encore completement au point if (!$flag) { $user = $this->session->user; $l['dateLoc'] = $this->req->dateloc . " " . $loch . ":" . $locm . ":00"; $l['dateRendu'] = $this->req->daterendu . " " . $renduh . ":" . $rendum . ":00"; $l['prixLoc'] = "75000"; //prix arbitraire temporaire $l['idVoiture'] = $this->req->id; $l['idClient'] = $user->getIdClient(); $loc = new Location($l); $lm->add($loc); $this->site->ajouter_message("Location enregistrée!"); Site::redirect("index"); } else { $this->site->ajouter_message("Vos dates de location ne sont pas valide."); } } else { $this->site->ajouter_message("date loc ou date rendu non renseigné"); } Site::redirect("loc", "rent&id=" . $this->req->id); }
public function action_valide() { /** --- Test la conformitude de tous les champs du formulaires coté serveur --- **/ // --- Champs nom --- // if ($this->req->nom == "") { $errors[] = "Le nom n'est pas rempli"; } else { if (!preg_match(self::EMPTY_REG, $this->req->nom)) { $errors[] = "Le nom est mal renseigné"; } } if (strlen($this->req->nom) >= self::NAME_LENGTH) { $errors[] = "La taille du nom doit être inférieur à " . self::NAME_LENGTH . " caractères"; } if (preg_match(self::NUM_REG, $this->req->nom)) { $errors[] = "Le nom ne doit pas contenir de chiffre"; } // --- Champs prénom --- // if ($this->req->prenom == "") { $errors[] = "Le prenom n'est pas rempli"; } else { if (!preg_match(self::EMPTY_REG, $this->req->prenom)) { $errors[] = "Le prénom est mal renseigné"; } } if (strlen($this->req->prenom) >= self::NAME_LENGTH) { $errors[] = "La taille du prénom doit être inférieur à " . self::NAME_LENGTH . " caractères"; } if (preg_match(self::NUM_REG, $this->req->prenom)) { $errors[] = "Le prénom ne doit pas contenir de chiffre"; } // --- Champs rue --- // if (strlen($this->req->rue) >= self::STREET_LENGTH) { $errors[] = "La taille de la rue doit être inférieur à " . self::STREET_LENGTH . " caractères"; } if (!preg_match(self::STREET_REG, $this->req->rue)) { $errors[] = "Le format du champs rue est: Numéro de rue(nombres) nom de la rue(caractères)"; } // --- Champs Code postal --- // if (!preg_match(self::CP_REG1, $this->req->cp) or preg_match(self::CP_REG2, $this->req->cp)) { $errors[] = "Format du code postal incorrect. Contien 5 chiffres de 01000 à 99999"; } // --- Test si mail déja existant --- (mail => login) // $cm = new ClientManager(DB::get_instance()); if ($cm->chercherParMail($this->req->mail)) { $errors[] = "Mail existant"; } if (!filter_var($this->req->mail, FILTER_VALIDATE_EMAIL)) { $errors[] = "Le mail n'est pas conforme"; } // --- Champs mdp ---// if (strlen($this->req->mdp) < self::MIN_MDP) { $errors[] = "Le mot de passe est trop petit"; } else { if (strlen($this->req->mdp) > self::MAX_MDP) { $errors[] = "Le mot de passe est trop grand"; } } // --- Champs confirmation --- // if ($this->req->mdp != $this->req->mdp2) { $errors[] = "La confirmation ne correspond pas au mot de passe"; } // --- Vérification CAPTCHA --- // if ($this->req->hide && $this->req->cap) { $cap = $this->req->hide; $cap = substr($cap, 2, 3); echo var_dump($cap); if ($cap != $this->req->cap) { $errors[] = "Le captcha n'est pas bon"; } } // -- Si on trouve des erreurs on les affiche en haut du formulaire -- // if (isset($errors[0])) { $f = $this->session->formIns; $f->populate(); $this->session->formIns = $f; foreach ($errors as $err) { $this->site->ajouter_message("-" . $err); } Site::redirect("inscription"); } else { $clt['nom'] = $this->req->nom; $clt['prenom'] = $this->req->prenom; $clt['rue'] = $this->req->rue; $clt['codePostal'] = $this->req->cp; $clt['ville'] = $this->req->ville; $clt['vip'] = 0; $clt['dateInscription'] = date('Y-m-d', time() + 7200); //+7200 Pour mettre en GMT+2 $clt['mail'] = $this->req->mail; $clt['mdp'] = $this->req->mdp; $clt['validate'] = 0; $client = new Client($clt); $cm->add($client); $client2 = $cm->connexion($clt['mail'], $clt['mdp']); // On supprime maintenant la variable contenant les entrées de l'utilisateur sur le form inscription. unset($this->session->formIns); // --On envoie le mail avec la vérif-- if ($client2) { $subject = "Loca-Rent : Bienvenue chère client."; $to = $clt['mail']; $code = md5($clt['prenom'] . $clt['nom'] . time()); $vm = new VerifManager(DB::get_instance()); $ver['codeVerif'] = $code; $ver['idClient'] = $client2->getIdClient(); //echo var_dump($client->getIdClient()); $verif = new Verif($ver); $vm->add($verif); $securelink = 'http://localhost/projet_BD-WEB/github_bd_web/?module=inscription&action=verif&id=' . urlencode($client2->getIdClient()) . '&code=' . urlencode($code); $msg = "<h2>LOCA-RENT</h2><br /><p>Bienvenue chez Loca-Rent,</p> pour continuer votre inscription merci de cliquez sur le lien ci-dessus<br /><a href=" . $securelink . ">" . $securelink . "</a>"; // Dans le cas où nos lignes comportent plus de 70 caractères, nous les coupons en utilisant wordwrap() //$msg = wordwrap($msg, 70, "\r\n"); // Pour envoyer un mail HTML, l'en-tête Content-type doit être défini $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; // En-têtes additionnels $headers .= 'To: ' . $clt['prenom'] . ' ' . $clt['nom'] . ' <' . $clt['mail'] . '>' . "\r\n"; $headers .= 'From: Loca-Rent <*****@*****.**>' . "\r\n"; mail($to, $subject, $msg, $headers); $this->site->ajouter_message("inscription reussie!{$code}"); Site::redirect("index"); } $this->site->ajouter_message("inscription pas reussie!\$"); Site::redirect("index"); } }
public function load_content() { //vérifie si un paramètre de module est passé, sinon : défaut $module = $this->req->module != '' ? $this->req->module : 'index'; //vérifie si une action est requise, sinon : index $action = $this->req->action != '' ? $this->req->action : 'index'; /* require("modules/Login/login.module.php"); $bloc_login=new Login(); $bloc_login->set_variables($this->config); $bloc_login->init(); $this->tpl->assign('bloc_login',$this->tpl->fetch("login.tpl")); */ $this->tpl->assign('titre', 'Titre par défaut'); $this->tpl->assign('module', $module); $this->tpl->assign('action', $action); //inclue le module en question if (!class_exists($module)) { if (file_exists("modules/{$module}/{$module}.module.php")) { require "modules/{$module}/{$module}.module.php"; } else { throw new Exception("Module inconnu : {$module}"); } } //============= exécute le module ================================================================================ //c'est ici qu'il faudrait vérifier la gestion des droits d'accès au module et à l'action demandée //================================================================================================================ $mod = substr($module, 0, 3); if ($mod == "adm") { if ($this->session->ouverte()) { if ($this->session->user == 'admin') { $m = new $module(); } else { $this->site->ajouter_message("pas admin! mais {$this->session->user->getMail()}"); Site::redirect('index'); exit; } } else { $this->site->ajouter_message("Vous n'êtes pas connecté"); Site::redirect('login', 'logadmin'); exit; } } else { $m = new $module(); } if ($this->session->ouverte()) { if ($this->session->user == 'admin') { $this->tpl->assign("login", $this->session->user); } else { $this->tpl->assign("login", $this->session->user->getMail()); } //Assigne la valeur de $login dans main.tpl } //nom du template à appeler, par défaut $m->set_tpl_name("{$module}" . "-{$action}"); //nom de la fonction à appeler $action = "action_{$action}"; //variables outils $m->set_variables($this->config); $m->init(); if (method_exists($module, $action)) { $m->{$action}(); } else { throw new Exception("Action inconnue : {$module}::{$action}"); } $res = $this->tpl->fetch("file:modules/{$module}/tpl/" . $m->get_tpl_name() . ".tpl"); $this->tpl->assign('bloc_contenu', $res); $this->tpl->assign('messages', $this->site->liste_messages()); }
<?php $redirectTo = Site::$requestPath; $redirectTo[0] = 'people'; Site::redirect($redirectTo);
<?php Site::redirect('/site-admin/table-manager');
<?php if (strtolower(Site::get_page()) == 'index') { Site::redirect(WEBDIR); exit; } if (Site::get_page() != '' && is_file('controller/' . Site::get_page() . '.php')) { include 'controller/' . Site::get_page() . '.php'; } else { if (Site::get_page() == '') { include 'controller/index.php'; } else { include 'pages/404.php'; } } if (Manager::isInstancied()) { if (Manager::getInstance()->shouldEditDataBase()) { Manager::getInstance()->EditDataBase(); } } Site::doIfRedirect(); if (Site::is_view_defined()) { //Inclure le header, sauf si la requête est AJAX if (!(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')) { header('Content-type:text/html; charset=utf-8'); ?> <html lang="fr"> <head> <!-- Meta -->
<?php Site::redirect('/checkin/*top-members');
static function goToNextUrl() { Site::redirect($_SESSION['next_url']); unset($_SESSION['next_url']); exit; }