Exemple #1
0
 /**
  * Envoi du message avec la méthode batch send
  * @param string $message
  * @param bool $failures
  * @param bool $log
  * @internal param void $mailer
  * @internal param void $failed
  * @internal param string $logger
  */
 public function batch_send_mail($message, $failures = false, $log = false)
 {
     if (!$this->_mailer->send($message)) {
         debug_firephp::dump("Failures: ", $failures);
     }
     if ($log) {
         $echologger = new Swift_Plugins_Loggers_EchoLogger();
         $this->_mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($echologger));
         debug_firephp::dump("Failures: ", $echologger->dump());
         $logger = new debug_logger(MP_LOG_DIR);
         $logger->log('mail', 'Failures', 'Failures : ' . $echologger->dump(), debug_logger::LOG_VOID);
     }
 }
Exemple #2
0
 /**
  * Envoi une image sur le serveur avec la méthode upload
  * @param files $img
  * @param dir $path
  * @param bool $setOption
  * @param bool|\debug $debug $debug
  * @return null|string|\true
  */
 public static function uploadImg($img, $path, $setOption = false, $debug = false)
 {
     $error = null;
     $makefile = new filesystem_makefile();
     $firebug = new debug_firephp();
     if (is_array($setOption)) {
         if (array_key_exists('maxwidth', $setOption)) {
             $maxwidth = $setOption['maxwidth'];
         } else {
             $maxwidth = 2500;
         }
         if (array_key_exists('maxheight', $setOption)) {
             $maxheight = $setOption['maxheight'];
         } else {
             $maxheight = 2500;
         }
         if (array_key_exists('minheight', $setOption)) {
             $minheight = $setOption['minheight'];
         } else {
             $minheight = 5;
         }
         if (array_key_exists('minwidth', $setOption)) {
             $minwidth = $setOption['minwidth'];
         } else {
             $minwidth = 5;
         }
     } else {
         $maxwidth = 2500;
         $maxheight = 2500;
         $minheight = 5;
         $minwidth = 5;
     }
     /**
      * Envoi de l'image
      */
     if (isset($_FILES[$img])) {
         if ($_FILES[$img]['error'] == UPLOAD_ERR_OK) {
             if (self::imageValid($_FILES[$img]['tmp_name']) === false) {
                 $error .= 'Invalid image format (gif, png, jpeg only)';
             } else {
                 if (!is_readable($_FILES[$img]["tmp_name"])) {
                     //$tmp_img = chmod($_FILES[$img]["tmp_name"],0777);
                     $tmp_img = $makefile->chmod(array($_FILES[$img]["tmp_name"]), 0777);
                 } else {
                     $tmp_img = $_FILES[$img]["tmp_name"];
                 }
                 //if(chmod($_FILES[$img]["tmp_name"],0777)){
                 if (is_uploaded_file($_FILES[$img]["tmp_name"])) {
                     $source = $tmp_img;
                     $cible = component_core_system::basePath() . $path . '/' . http_url::clean($_FILES[$img]["name"]);
                     if (self::imgSizeMax($source, $maxwidth, $maxheight) == false) {
                         $error .= 'Exceeds the maximum size ' . $maxwidth . ' x ' . $maxheight;
                     } elseif (self::imgSizeMin($source, $minwidth, $minheight) == false) {
                         $error .= 'The file is too small: ' . $minwidth . ' x ' . $minheight;
                     } else {
                         if (!move_uploaded_file($source, $cible)) {
                             $error .= 'Error in temporary file';
                         } else {
                             if ($debug != false) {
                                 $firebug->group('Upload image infos');
                                 $firebug->log('Success', 'Status');
                                 $firebug->log($source, 'Source');
                                 $firebug->log($cible, 'Cible');
                                 $firebug->groupEnd();
                             }
                         }
                     }
                 } else {
                     $error .= 'Disk write error';
                 }
                 //}
             }
         } elseif (UPLOAD_ERR_INI_SIZE == true) {
             $error .= 'The file is too large';
         } elseif (UPLOAD_ERR_CANT_WRITE == true) {
             $error .= 'Disk write error';
         } elseif (UPLOAD_ERR_FORM_SIZE == true) {
             $error .= 'The file is too large: maximum size ' . $maxwidth . ' x ' . $maxheight;
         }
     } elseif (UPLOAD_ERR_NO_FILE == true) {
         $error .= 'No file';
     } else {
         $error .= 'Disk write error';
     }
     if ($error != null) {
         $n = $firebug->group('Upload image analyse');
         $n .= $firebug->log($error);
         $n .= $firebug->groupEnd();
     } else {
         $n = NULL;
     }
     return $n;
 }
Exemple #3
0
 /**
  * @access public
  * Check si le domaine est disponible
  * @param $url
  * @param bool $ssl
  * @param bool $debug
  * @internal param string $domain
  * @return bool
  */
 public function isDomainAvailible($url, $ssl = false, $debug = false)
 {
     try {
         if (self::curl_exist()) {
             //check, if a valid url is provided
             if (!filter_var($url, FILTER_VALIDATE_URL)) {
                 return false;
             }
             //initialize curl
             $curlInit = curl_init($url);
             curl_setopt($curlInit, CURLOPT_CONNECTTIMEOUT, 10);
             curl_setopt($curlInit, CURLOPT_HEADER, true);
             curl_setopt($curlInit, CURLOPT_NOBODY, true);
             curl_setopt($curlInit, CURLOPT_RETURNTRANSFER, true);
             if ($ssl) {
                 /*Vérification SSL*/
                 curl_setopt($curlInit, CURLOPT_SSL_VERIFYPEER, false);
             }
             //get answer
             $response = curl_exec($curlInit);
             curl_close($curlInit);
             if ($debug) {
                 $firephp = new debug_firephp();
                 $firephp->log($response);
             }
             if ($response) {
                 return true;
             }
             return false;
         }
     } catch (Exception $e) {
         $logger = new debug_logger(MP_LOG_DIR);
         $logger->log('error', 'php', 'An error has occured : ' . $e->getMessage(), debug_logger::LOG_VOID);
     }
 }
Exemple #4
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);
     }
 }
Exemple #5
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);
     }
 }
Exemple #6
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);
                 }
             }
         }
     }
 }
Exemple #7
0
    throw new Exception('Error load library');
    exit;
}
/**
 * Include phpThumb
 */
/*$phpthumb = __DIR__.'/phpthumb/ThumbLib.inc.php';
if (file_exists($phpthumb)) {
	require ($phpthumb);
}else{
	print 'Error thumbnail Config';
	exit;
}*/
/**
 * Include smarty3
 */
$smarty = __DIR__ . '/smarty3/Smarty.class.php';
if (file_exists($smarty)) {
    require $smarty;
} else {
    print 'Error Smarty Config';
    exit;
}
/**
 * Constante Firephp
 */
if (defined('MP_FIREPHP')) {
    if (MP_FIREPHP) {
        debug_firephp::configErrorHandler();
    }
}
Exemple #8
0
 /**
  * @access public
  * Affiche le debug pour les sessions
  */
 public function debug()
 {
     if (M_FIREPHP) {
         $firebug = new debug_firephp();
         $firebug->group('Magepattern Session');
         //$firebug->magixFireLog($_SESSION);
         $firebug->dump('session run', $_SESSION);
         $firebug->groupEnd();
     } else {
         var_dump($_SESSION);
     }
 }
Exemple #9
0
 /**
  *
  * Retourne
  * @param bool $debug
  */
 public function insight_header($debug = false)
 {
     header('x-insight: inspect');
     if ($debug == true) {
         debug_firephp::log("Headers:", headers_list());
     }
 }
Exemple #10
0
 /**
  * function debug pagination
  *
  * @param void $page
  * @param void $num_pages
  * @param int $limit
  * @param void $getpage
  */
 private function debugPager($page, $num_pages, $limit, $getpage)
 {
     /*debug*/
     if (defined('MP_LOG')) {
         if (MP_LOG == 'debug' and MP_FIREPHP == true) {
             $FirePHPOpt = array('Collapsed' => false, 'Color' => '#FF772F');
             debug_firephp::group('Test pagination', $FirePHPOpt);
             debug_firephp::log($page, 'Page');
             debug_firephp::log($num_pages, 'Page number');
             debug_firephp::log($limit, 'Limit');
             debug_firephp::groupEnd();
             $page = max($getpage, 1);
             debug_firephp::group('Test pagination', $FirePHPOpt);
             debug_firephp::log($page, 'Page');
             debug_firephp::log($num_pages, 'Page number');
             debug_firephp::log($limit, 'Limit');
             debug_firephp::groupEnd();
             $page = min($getpage, $num_pages);
             debug_firephp::group('Test pagination', $FirePHPOpt);
             debug_firephp::log($page, 'Page');
             debug_firephp::log($num_pages, 'Page number');
             debug_firephp::log($limit, 'Limit');
             debug_firephp::groupEnd();
             if ($getpage > $limit || $getpage <= 0) {
                 $page = 1;
             }
             debug_firephp::group('Test pagination', $FirePHPOpt);
             debug_firephp::log($page, 'Page');
             debug_firephp::log($num_pages, 'Page number');
             debug_firephp::log($limit, 'Limit');
             debug_firephp::groupEnd();
         }
     } else {
         print 'Page : ' . $page . '<br />Num_Pages : ' . $num_pages . '<br />Limit : ' . $limit . '##########<br />';
         $page = max($getpage, 1);
         print 'Page : ' . $page . '<br />Num_Pages : ' . $num_pages . '<br />Limit : ' . $limit . '##########<br />';
         $page = min($getpage, $num_pages);
         print 'Page : ' . $page . '<br />Num_Pages : ' . $num_pages . '<br />Limit : ' . $limit . '##########<br />';
         if ($getpage > $limit || $getpage <= 0) {
             $page = 1;
         }
         print 'Page : ' . $page . '<br />Num_Pages : ' . $num_pages . '<br />Limit : ' . $limit . '##########<br />';
     }
 }
Exemple #11
0
 /**
  * Stop Current Unix timestamp with microseconds
  * @access protected
  */
 protected static function timeStop()
 {
     if (self::getIniInstance()) {
         self::$timerEnd = microtime();
     }
 }