Ejemplo n.º 1
0
 /**
  * Chargement du fichier SQL pour la lecture du fichier
  * @param $sqlfile
  * @throws Exception
  * @return array|bool
  */
 protected function load_sql_file($sqlfile)
 {
     if (!file_exists($sqlfile)) {
         throw new Exception("Error : Not File exist .sql");
     } else {
         $db_structure = preg_split("/;\\s*[\r\n]+/", file_get_contents($sqlfile));
         if ($db_structure != null) {
             $tables = $db_structure;
             return $tables;
         } else {
             magixcjquery_debug_magixfire::magixFireError('Error : SQL File is empty: ' . $sqlfile);
             return false;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @access private
  * @param $dir
  */
 private function cacheDir($dir)
 {
     $makefile = new magixcjquery_files_makefiles();
     $pathDir = $this->pathCacheDir($dir);
     if (file_exists($pathDir)) {
         $scandir = $makefile->scanDir($pathDir, array('.htaccess', '.gitignore'));
         $clean = '';
         if ($scandir != null) {
             foreach ($scandir as $file) {
                 $clean .= $makefile->removeFile($pathDir, $file);
             }
         }
     } else {
         $magixfire = new magixcjquery_debug_magixfire();
         $magixfire->magixFireError(new Exception('Error: var is not exist'));
     }
 }
Ejemplo n.º 3
0
 /**
  * @access private
  * Vérification de la session pour accèder à l'administration
  * @param bool $debug
  */
 private function authSession($debug = false)
 {
     //Language model init class
     $language = new backend_model_language();
     $language->run();
     $token = isset($_SESSION['mc_auth_token']) ? $_SESSION['mc_auth_token'] : magixglobal_model_cryptrsa::tokenId();
     $tokentools = $this->hashPassCreate($token);
     backend_controller_template::assign('hashpass', $tokentools);
     if (isset($this->email_admin) and isset($this->passwd_admin) and isset($this->hashtoken)) {
         if (strcasecmp($this->hashtoken, $tokentools) == 0) {
             if ($debug == true) {
                 $firebug = new magixcjquery_debug_magixfire();
                 $firebug->magixFireGroup('tokentest');
                 if ($this->hashtoken) {
                     if (strcasecmp($this->hashtoken, $tokentools) == 0) {
                         $firebug->magixFireLog('session compatible');
                     } else {
                         $firebug->magixFireError('session incompatible');
                     }
                 }
                 $firebug->magixFireLog($_SESSION);
                 $firebug->magixFireGroupEnd();
             }
             $auth_exist = parent::s_auth_exist($this->email_admin, $this->passwd_admin);
             if (count($auth_exist['id_admin']) == true) {
                 $session = new backend_model_sessions();
                 $lang = new backend_model_language();
                 $string = $_SERVER['HTTP_USER_AGENT'];
                 $string .= 'SHIFLETT';
                 /* Add any other data that is consistent */
                 $fingerprint = md5($string);
                 //Fermeture de la première session, ses données sont sauvegardées.
                 session_write_close();
                 $this->start_session();
                 $data = parent::s_data_session($auth_exist['keyuniqid_admin']);
                 if (!isset($_SESSION['email_admin']) and !isset($_SESSION['keyuniqid_admin'])) {
                     $lang = new backend_model_language();
                     $session->openSession($data['id_admin'], session_regenerate_id(true), $data['keyuniqid_admin']);
                     //session_regenerate_id(true);
                     $_SESSION['id_admin'] = $data['id_admin'];
                     $_SESSION['email_admin'] = $data['email_admin'];
                     $_SESSION['keyuniqid_admin'] = $data['keyuniqid_admin'];
                     $_SESSION['adminLanguage'] = $lang->run();
                     if ($debug == true) {
                         $firebug = new magixcjquery_debug_magixfire();
                         $firebug->magixFireGroup('adminsession');
                         $firebug->magixFireDump('User session', $_SESSION);
                         $firebug->magixFireGroupEnd();
                     }
                     magixglobal_model_redirect::backend_redirect_login(false);
                 } else {
                     $session->openSession($data['id_admin'], null, $data['keyuniqid_admin']);
                     $_SESSION['id_admin'] = $data['id_admin'];
                     $_SESSION['email_admin'] = $data['email_admin'];
                     $_SESSION['keyuniqid_admin'] = $data['keyuniqid_admin'];
                     $_SESSION['adminLanguage'] = $lang->run();
                     if ($debug == true) {
                         $firebug = new magixcjquery_debug_magixfire();
                         $firebug->magixFireGroup('adminsession');
                         $firebug->magixFireDump('User session', $_SESSION);
                         $firebug->magixFireGroupEnd();
                     }
                     magixglobal_model_redirect::backend_redirect_login(false);
                 }
             } else {
                 $this->message->getNotify('error_login', array('method' => 'fetch', 'assignFetch' => 'login_message'));
             }
         } else {
             $this->message->getNotify('error_hash', array('method' => 'fetch', 'assignFetch' => 'login_message'));
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Initialise le système de LOG du CMS
  * @param string $str
  * @param void $e (paramètre Exception)
  */
 public static function magixlog($str, $e)
 {
     //Systeme de log + firephp
     $log = magixcjquery_error_log::getLog();
     $log->logfile = M_TMP_DIR;
     $log->write($str . $e->getMessage(), __FILE__, $e->getLine());
     magixcjquery_debug_magixfire::magixFireError($e);
 }
Ejemplo n.º 5
0
 /**
  * Création du fichier de configuration
  * @throws Exception
  */
 private function create_config_file()
 {
     if (isset($this->M_DBHOST) && isset($this->M_DBUSER) && isset($this->M_DBPASSWORD) && isset($this->M_DBNAME)) {
         if (!is_writable(dirname(self::$configfile))) {
             throw new Exception(sprintf('Cannot write %s file.', self::$configfile));
         }
         self::config_file_exist();
         try {
             # Creates config.php file
             $full_conf = file_get_contents(self::$config_in);
             $writeconst = new magixcjquery_files_makefiles();
             /**
              * create constante define in config file
              */
             $writeconst->writeConstValue('M_DBDRIVER', $this->M_DBDRIVER, $full_conf);
             $writeconst->writeConstValue('M_DBHOST', $this->M_DBHOST, $full_conf);
             $writeconst->writeConstValue('M_DBUSER', $this->M_DBUSER, $full_conf);
             $writeconst->writeConstValue('M_DBPASSWORD', $this->M_DBPASSWORD, $full_conf);
             $writeconst->writeConstValue('M_DBNAME', $this->M_DBNAME, $full_conf);
             switch ($this->M_LOG) {
                 case 'debug':
                     $writeconst->writeConstValue('M_LOG', $this->M_LOG, $full_conf);
                     break;
                 case 'log':
                     $writeconst->writeConstValue('M_LOG', $this->M_LOG, $full_conf);
                     break;
                 case 'false':
                     $writeconst->writeConstValue('M_LOG', $this->M_LOG, $full_conf, false);
             }
             $writeconst->writeConstValue('M_TMP_DIR', magixglobal_model_system::base_path() . 'var' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'errors.log', $full_conf);
             $writeconst->writeConstValue('M_FIREPHP', $this->M_FIREPHP, $full_conf, false);
             $fp = fopen(self::$configfile, 'wb');
             if ($fp === false) {
                 throw new Exception(sprintf('Cannot write %s file.', self::$configfile));
             }
             fwrite($fp, $full_conf);
             fclose($fp);
             //chmod(self::$configfile, 0666);
             app_model_smarty::getInstance()->display('config/request/success_add.tpl');
         } catch (Exception $e) {
             magixcjquery_debug_magixfire::magixFireError($e);
         }
     }
 }