/** * * Return logger instance or create new instance * * @return object (PDO) * * @access public * */ public static function getLog() { if (is_null(self::$instancelog)) { self::$instancelog = new magixcjquery_error_log(); } return self::$instancelog; }
/** * filterFiles => filter files with extension * $t = new magixcjquery_files_makefiles(); * var_dump($t->filterFiles('mydir',array('gif','png','jpe?g'))); * or * var_dump($t->filterFiles('mydir','php')); * @param $dir * @param $extension */ public function filterFiles($directory, $extension) { try { $filterfiles = new filterFiles($directory, $extension); $filter = ''; foreach ($filterfiles as $file) { if ($file->isDot() || $file->isDir()) { continue; } $filter[] .= $file; } return $filter; } catch (Exception $e) { if (M_LOG == 'log') { if (M_TMP_DIR != null) { $log = magixcjquery_error_log::getLog(); $log->logfile = $_SERVER['DOCUMENT_ROOT'] . M_TMP_DIR; $log->write('An error has occured', $e->getMessage(), $e->getLine()); exit("Error has filterFiles, view log file"); } else { die('error path tmp dir'); } } elseif (M_LOG == 'debug') { print $e->getMessage() . $e->getLine() . "<br />"; } else { exit("Error has filterFiles, debug with log"); } } }
/** * 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); }
/** * function truncate table * * @param void $table */ public function truncateTable($table, $debugParams) { try { $prepare = $this->prepare('TRUNCATE TABLE ' . $table); $result = $prepare->execute(); $debugParams ? $prepare->debugDumpParams() : ''; $prepare->closeCursor(); } catch (Exception $e) { if (M_LOG == 'log') { if (M_TMP_DIR != null) { $log = magixcjquery_error_log::getLog(); $log->logfile = M_TMP_DIR; $log->write('An error has occured', $e->getMessage(), $e->getLine()); die("Error has database, debug with log"); } else { die('error path tmp dir'); } } elseif (M_LOG == 'debug') { die($e->getMessage() . $e->getLine()); } else { die("Error has database, debug with log"); } } }