Exemple #1
0
 public function getUpdateData($sql)
 {
     $resu = null;
     try {
         $pdo = new \PDO('mysql:host=' . \fbx\Config::getInstance()->getHost() . ';port=' . \fbx\Config::getInstance()->getPort() . ';dbname=' . \fbx\Config::getInstance()->getDbName(), \fbx\Config::getInstance()->getUser(), \fbx\Config::getInstance()->getPwd());
         $resu = $pdo->exec($sql);
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
     unset($pdo);
     return $resu;
 }
Exemple #2
0
//-- definition du serveur
$config = simplexml_load_file("../lib/config.ini");
$_SESSION['IP'] = "{$config->dev->ip}";
$_SESSION['PUBLIC_PATH'] = "{$config->path->public}";
//-- définition de la langue
if (isset($_POST["languages"]) && !isset($_GET["languages"])) {
    $language = $_SESSION["languages"] = $_POST["languages"];
} elseif (isset($_GET["languages"]) && !isset($_POST["languages"])) {
    $language = $_SESSION["languages"] = $_GET["languages"];
} elseif (isset($_SESSION["languages"])) {
    $language = $_SESSION["languages"];
} else {
    $language = $_SESSION["languages"] = "fr_FR";
}
//--Load Config
\fbx\Config::init();
//--Load DBmysql
\fbx\DBmysql::init();
//-- définition du user
if (isset($_POST["login"]) && !isset($_GET["login"])) {
    $_SESSION["loginUsr"] = $_POST["login"];
} elseif (isset($_GET["login"]) && !isset($_POST["login"])) {
    $_SESSION["loginUsr"] = $_GET["login"];
}
\fbx\Fab\Utilisateur::init();
putenv("LC_MESSAGES=" . $language);
setlocale(LC_MESSAGES, $language . ".utf8");
if (function_exists('bindtextdomain') && function_exists('textdomain')) {
    bindtextdomain("messages", APPLICATION_ROOT . "/locale");
    textdomain("messages");
    bind_textdomain_codeset("messages", "UTF-8");
Exemple #3
0
 public function __construct($class_controller, $args_array = null)
 {
     $this->_class = $class_controller;
     $this->_template = "welcome.twig";
     \fbx\Config::init();
     $auth = new Auth();
     $usr = $pwd = $lng = $loginText = $loginPwd = $loginLng = null;
     if (isset($_POST["login"])) {
         $loginTxt = $_POST["login"];
     } else {
         if (isset($_GET["login"])) {
             $loginTxt = $_GET["login"];
         }
     }
     if (isset($_POST["password"])) {
         $loginPwd = $_POST["password"];
     } else {
         if (isset($_GET["password"])) {
             $loginPwd = $_GET["password"];
         }
     }
     if (isset($_POST["languages"])) {
         $loginLng = $_POST["languages"];
     } else {
         if (isset($_GET["languages"])) {
             $loginLng = $_GET["languages"];
         }
     }
     //--- si cookie existe alors on recup value cookie et on le dehash sinon on recup value post
     if (isset($_COOKIE['FBX_SESSID'])) {
         $FBX_SESSID = explode("-+-+-", $_COOKIE['FBX_SESSID']);
         $usr = $FBX_SESSID[0];
         $pwd = $FBX_SESSID[1];
         $pwd = $this->dehashPassword($pwd);
         $lng = $_SESSION['languages'] = $loginLng = $FBX_SESSID[2];
         $_SESSION['IDLANGUE'] = $FBX_SESSID[3];
     } elseif (isset($loginTxt)) {
         $usr = $loginTxt;
         $pwd = $loginPwd;
         $lng = $loginLng;
     }
     if (isset($usr) && $usr != "") {
         $auth->login($usr, $pwd);
     }
     if ($auth->isUserLoggedIn()) {
         \fbx\DBmysql::init();
         //-- identification de l'utilisateur
         if (!Utilisateur::isIdentified()) {
             Utilisateur::init();
         }
         //-- si la coche est "on" alors on instruit cookie valable 5j = 5*24*3600 et on hash le mdp
         $pwd = $this->hashPassword($pwd);
         if (isset($_POST['remember'])) {
             setcookie("FBX_SESSID", "{$usr}-+-+-{$pwd}-+-+-{$lng}-+-+-{$_SESSION['IDLANGUE']}", time() + 5 * 24 * 60 * 60 * 1);
         }
         //-- recuperation du text pour le welcome message
         $chemin_destination = $this->path($_SESSION['FBX_USER_ID']);
         for ($i = 1; $i <= 4; $i++) {
             $fichier = "{$chemin_destination}text{$i}.txt";
             if (file_exists($fichier) == 1) {
                 $txtfile = fopen($fichier, 'r');
                 $_SESSION["TXT"][$i] = fgets($txtfile);
                 fclose($txtfile);
             }
             $image = "{$chemin_destination}image{$i}.png";
             if (file_exists($image) == 1) {
                 $_SESSION["IMG"][$i] = $image;
             } else {
                 $_SESSION["IMG"][$i] = "img/carousel/0/image{$i}.png";
             }
         }
         $this->_data = array("session" => $_SESSION, "OUT" => $_SESSION);
         $class_controller = __NAMESPACE__ . "\\" . $class_controller;
         if (class_exists($class_controller)) {
             $this->_controller = new $class_controller();
             $this->setAction();
             $methodVariable = array($this->_controller, $this->_action);
             if (is_callable($methodVariable, false, $callback_name)) {
                 $this->_controller->{$this->_action}(array_merge($args_array, $_SESSION));
                 $this->_template = $this->_controller->getTemplate();
                 $methodVariable = array($this->_controller, "getData");
                 if (is_callable($methodVariable, false, $callback_name)) {
                     $this->_data = $this->_controller->getData();
                 }
             }
         }
         if ($auth->isUserLoggedIn()) {
             $this->_navbar = "navbar.twig";
         }
     } else {
         $this->_template = "login.twig";
         //-- Envoi du mot de passe si le mot de passe n'a pas déjà été envoyé dans les 5mn précédentes
         if (!isset($_SESSION["MdpEnvoye"])) {
             $send_pwd = 1;
         } else {
             if ($_SESSION["MdpEnvoye"] < time() - 300) {
                 $send_pwd = 1;
             } else {
                 $send_pwd = 0;
             }
         }
         if (isset($_POST['login'])) {
             if ($send_pwd == 1) {
                 $this->_data = array("MdpOublie" => $auth->SendForgottenPassword($args_array));
                 if ($this->_data["MdpOublie"] == "1") {
                     $_SESSION["MdpEnvoye"] = time();
                 }
             } else {
                 $this->_data = array("MdpOublie" => "1");
             }
         } elseif ($send_pwd == 0) {
             $this->_data = array("MdpOublie" => "1");
         }
     }
 }