Exemplo n.º 1
0
 /**
  * Authentification sur la page de login
  * @param $create
  * @param bool $debug
  */
 private function getAuth($create, $debug = false)
 {
     $token = isset($_SESSION['mc_auth_token']) ? $_SESSION['mc_auth_token'] : filter_rsa::tokenID();
     $tokentools = self::hashPassCreate($token);
     $create->assign('hashpass', $tokentools);
     if (isset($this->email_admin) and isset($this->passwd_admin)) {
         $firebug = new debug_firephp();
         if (strcasecmp($this->hashtoken, $tokentools) == 0) {
             if ($debug == true) {
                 $firebug->group('tokentest');
                 if ($this->hashtoken) {
                     if (strcasecmp($this->hashtoken, $tokentools) == 0) {
                         $firebug->log('session compatible');
                     } else {
                         $firebug->error('session incompatible');
                     }
                 }
                 $firebug->log($_SESSION);
                 $firebug->groupEnd();
             }
             $auth_exist = parent::s_auth_exist($this->email_admin, $this->passwd_admin);
             if (count($auth_exist['idadmin']) == true) {
                 $data = parent::s_data_session($auth_exist['keyuniqid_admin']);
                 $session = new http_session();
                 $language = new backend_model_language();
                 $session->start('mc_adminlang');
                 $sessionUtils = new admin_model_sessionUtils();
                 if (!isset($_SESSION['email_admin']) and !isset($_SESSION['keyuniqid_admin'])) {
                     $sessionUtils->openSession($data['idadmin'], session_regenerate_id(true), $data['keyuniqid_admin']);
                     $array_sess = array('id_admin' => $data['idadmin'], 'email_admin' => $data['email_admin'], 'keyuniqid_admin' => $data['keyuniqid_admin'], 'language_admin' => $language->run());
                     $session->run($array_sess, $language->run());
                     if ($debug == true) {
                         $firebug = new debug_firephp();
                         $firebug->group('adminsession');
                         $firebug->dump('User session', $_SESSION);
                         $firebug->log($session->ip());
                         $firebug->groupEnd();
                     }
                     admin_model_redirect::login(false);
                 } else {
                     $sessionUtils->openSession($data['idadmin'], null, $data['keyuniqid_admin']);
                     $array_sess = array('email_admin' => $data['email_admin'], 'keyuniqid_admin' => $data['keyuniqid_admin']);
                     $language = new admin_model_language();
                     $session->run($array_sess, $language->run());
                     if ($debug == true) {
                         $firebug = new debug_firephp();
                         $firebug->group('adminsession');
                         $firebug->dump('User session', $_SESSION);
                         $firebug->log($session->ip());
                         $firebug->groupEnd();
                     }
                     admin_model_redirect::login(false);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Chargement du fichier SQL pour la lecture du fichier
  * @param $sqlfile
  * @throws Exception
  * @return array|bool|string
  */
 private function load_sql_file($sqlfile)
 {
     try {
         $db_structure = "";
         $structureFile = $sqlfile;
         if (!file_exists($structureFile)) {
             throw new Exception("Error : Not File exist .sql");
         } else {
             $db_structure = preg_split("/;\\s*[\r\n]+/", file_get_contents($structureFile));
             if ($db_structure != null) {
                 $tables = $db_structure;
             } else {
                 debug_firephp::error("Error : SQL File is empty");
                 return false;
             }
         }
         return $tables;
     } catch (Exception $e) {
         $logger = new debug_logger(MP_LOG_DIR);
         $logger->log('php', 'error', 'An error has occured : ' . $e->getMessage(), debug_logger::LOG_MONTH);
     }
 }
Exemplo n.º 3
0
 /**
  * Enregistre $row dans le fichier log déterminé à partir des paramètres $type, $name et $archive
  *
  * @param string $type Dossier dans lequel sera enregistré le fichier de log
  * @param string $name Nom du fichier de log
  * @param string $row Texte à ajouter au fichier de log
  * @param string $archive Archive : LOG_VOID, LOG_MONTH ou LOG_YEAR
  *
  * @return bool
  */
 public function log($type, $name, $row, $archive = self::LOG_YEAR)
 {
     /**
      * Instance dateformat
      */
     $date = new date_dateformat();
     # Contrôle des arguments
     if (!isset($type) || empty($name) || empty($row)) {
         trigger_error("Params is not defined", E_USER_WARNING);
         return false;
     }
     $logfile = $this->path($type, $name, $archive);
     if ($logfile === false) {
         trigger_error("Unable to save the log", E_USER_WARNING);
         return false;
     }
     # Ajout de la date et de l'heure au début de la ligne
     $row = $date->dateDefine('d/m/Y H:i:s') . ' ' . $row;
     # Ajout du retour chariot de fin de ligne si il n'y en a pas
     if (!preg_match('#\\n$#', $row)) {
         $row .= "\n";
     }
     $this->write($logfile, $row);
     # Firephp
     $firephp = new debug_firephp();
     if ($firephp instanceof debug_firephp) {
         $firephp->error($row);
     }
 }