Пример #1
0
 public static function display(array $vars = array(), $dirTpl = null)
 {
     $path = Conf::get('app.path') . '/src/Views/Twig_Tpl/Mails/Matrices';
     $tplObj = new Tpl($path);
     $dirTpl = $dirTpl === null ? self::DEFAULT_FILE_TPL : $dirTpl;
     return $tplObj->addVars($vars)->getTpl($dirTpl);
 }
Пример #2
0
 /**
  * Retrieve route used
  *
  * @return array
  */
 private static function matchRoute()
 {
     $routing = Conf::get('route');
     $routeUri = self::getRouteUri();
     $routes = array();
     foreach ($routing as $routeName => $routeTest) {
         $routeNameFormatted = substr($routeName, 0, 32);
         $routes[] = '^(?<' . $routeNameFormatted . '>' . $routeTest['pattern'] . ')$';
         self::$allRoutes[$routeNameFormatted] = $routeTest;
     }
     $testPattern = '#' . implode('|', $routes) . '#';
     preg_match($testPattern, $routeUri, $argv);
     array_shift($argv);
     $isFound = false;
     $results = array_filter($argv, function ($value, $key) use(&$isFound) {
         $resultFilter = is_string($key) && $value != '';
         if (!$isFound && $resultFilter) {
             $isFound = true;
         } elseif ($isFound && $resultFilter) {
             $isFound = false;
         }
         return $isFound ? true : $resultFilter;
     }, ARRAY_FILTER_USE_BOTH);
     return $results;
 }
Пример #3
0
 protected static function addConfToResponse()
 {
     self::$response['app'] = Conf::get('app');
     self::$response['routeInfo'] = Conf::get('routeInfo');
     self::$response['session'] = Session::getAll();
     self::$response['server'] = Server::getAll();
 }
Пример #4
0
 /**
  * @param mixed $entity
  * @param string $message
  * @param null $begin
  * @param null $var
  */
 public static function log($entity = null, $message = null, $begin = null, $var = null)
 {
     $conf = Conf::get('logger_helper');
     self::add($message);
     $message = self::createErrorMessage($entity, $conf['level'], $message, $begin, $var);
     Logger::log($message, $conf['level'], $conf['file'], false);
 }
Пример #5
0
 /**
  * @param $msg
  * @param string $type
  */
 public static function save($msg, $type = self::LOG)
 {
     $confErrors = Conf::get('errors');
     $confApp = Conf::get('app');
     $file = $confApp['root'] . $confApp['path'] . '/' . $confErrors['path'] . '/' . $confErrors['filename'] . '.' . $type;
     Logger::log($msg, Logger::CRITICAL, $file, false);
 }
Пример #6
0
 /**
  * Forms constructor.
  * @param string $nameForm
  * @param string $type
  * @param string|null $dirForm
  */
 public function __construct($nameForm, $type = self::TYPE_POST, $dirForm = null)
 {
     $this->nameForm = $nameForm;
     $this->type = $type;
     $app = Conf::get('app');
     $this->dirForm = $app['root'] . $app['path'] . ($dirForm === null ? self::FORMS_PATH : $dirForm);
     $this->loadFormConf();
 }
Пример #7
0
 protected function getDefaultTemplate()
 {
     $routeInfos = Conf::get('routeInfo');
     $class = explode('\\', $routeInfos['class']);
     $directory = end($class);
     $file = $routeInfos['method'];
     return "{$directory}/{$file}.twig";
 }
Пример #8
0
 /**
  * Mails constructor.
  * @param string $type
  */
 public function __construct($type = 'txt')
 {
     $this->type = $type;
     $conf = Conf::get('emails');
     var_dump($conf);
     ini_set("SMTP", $conf['smtp']);
     ini_set("smtp_port", $conf['smtp_port']);
     ini_set("sendmail_from", $conf['emails']['webmaster']);
 }
Пример #9
0
 public function mails()
 {
     var_dump(Conf::getAll());
     $destinataire = '*****@*****.**';
     $sujet = 'test';
     $message = array(array('test' => 'Nouveau titre'), 'main');
     $headers = array('ADS', Conf::get('emails.emails.webmaster'));
     Mails::init('html')->sendMail($destinataire, $sujet, $message, $headers);
     echo 'message sent';
 }
Пример #10
0
 /**
  * @param string|null $file
  * @return bool
  */
 private static function fileExists($file = null)
 {
     if ($file === null) {
         $file = Conf::get('app.root') . Conf::get('logger.file');
     }
     if (!is_dir(dirname($file))) {
         mkdir(dirname($file), 0777, true);
     }
     if (!file_exists($file)) {
         touch($file);
         chmod($file, 0777);
     }
     return file_exists($file) && is_writable($file);
 }
Пример #11
0
 protected static function display()
 {
     $responseType = Conf::get('routeInfo.response');
     switch ($responseType) {
         case Conf::CLI:
             $response = '';
             break;
         case Conf::GUI:
             $response = \Hyla\Templates\Tpl::display(self::$response, Conf::get('app.path') . "/src/Views/Twig_Tpl");
             break;
         case 'JSON':
             $response = json_encode(self::$response);
             break;
         default:
             throw new \Exception("'{$responseType}' is not a correct type");
     }
     echo $response;
 }
Пример #12
0
 public static function init(array $data = null)
 {
     $type = Conf::get('translate.type');
     switch ($type) {
         case self::DB:
             //self::$traduction = DictionnaireModel::init()->getValues();
             break;
         case self::XML:
             break;
         case self::INI:
             break;
         case self::JSON:
             break;
         case self::NO_TRANSLATE:
             //var_dump('test');
             break;
     }
 }
Пример #13
0
 public static function init(array $data = null)
 {
     $pathToGeoloc = __DIR__ . '/../lib/GeoIp/';
     if (empty($_SERVER['GEOIP_COUNTRY_CODE'])) {
         include $pathToGeoloc . 'geoipcity.inc';
         include $pathToGeoloc . 'geoipregionvars.php';
         $giCity = geoip_open($pathToGeoloc . 'GeoLiteCity.dat', GEOIP_STANDARD);
         $ip = $_SERVER['SERVER_ADDR'];
         $pattern = '/^192\\.168/';
         if (preg_match($pattern, $ip) == 1) {
             $ip = Conf::get('environment.ip_local');
         }
         $record = geoip_record_by_addr($giCity, $ip);
         $_SERVER['GEOIP_COUNTRY_CODE'] = $record->country_code;
         $_SERVER['GEOIP_COUNTRY_NAME'] = $record->country_name;
         $_SERVER['GEOIP_REGION'] = $record->region;
         $_SERVER['GEOIP_CITY'] = $record->city;
         $_SERVER['GEOIP_DMA_CODE'] = $record->dma_code === null ? 0 : $record->dma_code;
         $_SERVER['GEOIP_AREA_CODE'] = $record->area_code === null ? 0 : $record->area_code;
         $_SERVER['GEOIP_LATITUDE'] = $record->latitude;
         $_SERVER['GEOIP_LONGITUDE'] = $record->longitude;
     }
 }
Пример #14
0
 /**
  * @param $date
  * @param $errno
  * @param $errType
  * @param $errMsg
  * @param $file
  * @param $line
  * @param $vars
  * @param null $stackTrace
  * @return string
  */
 public static function display($date, $errno, $errType, $errMsg, $file, $line, $vars, $stackTrace = null)
 {
     $conf = Conf::get('errors');
     $err = '<pre style="border:1px solid #aaa; border-radius:5px; background:#eee; padding: 15px;">';
     $err .= "<b><span style='color:blue;'>[</span>" . $date . "<span style='color:blue;'>]</span> <span style='color:red;'>" . $errno . '.' . $errType . "</span> :</b>\n";
     $err .= '<b style="color:green">' . $errMsg . "</b>\n";
     $err .= 'in <b style="color:blue">' . $file . '</b> on line <b style="color:blue">' . $line . "</b>\n";
     if ($conf['level'] == self::ERR_VARS) {
         $complementaryInformations = self::linearizeVar($vars, false);
         $err .= "<b>Informations Vars</b> : \n{$complementaryInformations}\n";
     } elseif ($conf['level'] == self::ERR_TRACES) {
         $stackTrace = $stackTrace === null ? implode("\n", self::getStackTrace(true)) : self::linearizeVar($stackTrace, true);
         $err .= "<b>StackTrace</b> : \n{$stackTrace}\n";
     } elseif ($conf['level'] == self::ERR_ALL) {
         $complementaryInformations = self::linearizeVar($vars, false);
         $err .= "<b>Informations Vars</b> : \n{$complementaryInformations}\n";
         $stackTrace = $stackTrace === null ? implode("\n", self::getStackTrace(true)) : self::linearizeVar($stackTrace, true);
         $err .= "<b>StackTrace</b> : \n{$stackTrace}\n";
     } else {
         $err .= "\n";
     }
     $err .= '</pre>';
     return $err;
 }
Пример #15
0
<?php

use Hyla\Config\Conf;
use Hyla\FrontController\FrontController;
use Hyla\ErrorHandler\ErrorHandler;
require_once __DIR__ . '/../src/core/Autoloader/autoloader.php';
try {
    Conf::init();
    FrontController::launch();
} catch (Exception $e) {
    ErrorHandler::handleException($e);
}
Пример #16
0
<?php

require_once __DIR__ . '/../../lib/ClassLoader/Psr4ClassLoader.php';
use Symfony\Component\ClassLoader\Psr4ClassLoader as ClassLoader;
use Hyla\Config\Conf;
$loader = new ClassLoader();
$loader->addPrefix('Hyla', dirname(__DIR__));
$loader->addPrefix('Hyla', dirname(dirname(dirname(__DIR__))) . '/test/core');
$loader->addPrefix('HylaComponents', dirname(dirname(__DIR__)) . '/components');
$loader->addPrefix('HylaPlugins', dirname(dirname(__DIR__)) . '/plugins');
$loader->register();
Conf::initApp();
$app = Conf::get('app');
if (!empty($app)) {
    $loader->addPrefix($app['name'], Conf::$rootDir . $app['path'] . '/src');
}
Пример #17
0
 /**
  * redirect url
  */
 private static function redirectURL()
 {
     $user_errors = array(E_ERROR, E_WARNING, E_PARSE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
     if (in_array(self::$errno, $user_errors)) {
         header('HTTP/1.0 500 Internal Server Error', true, 500);
         $err500 = Conf::get('app.root') . Conf::get('app.path') . '/' . Conf::get('redirection.path') . '/' . Conf::get('redirection.500');
         if (file_exists($err500)) {
             echo file_get_contents($err500);
         }
         exit;
     }
 }
Пример #18
0
 /**
  * @param array|null $config
  * @return array|mixed
  * @throws \Exception
  */
 protected function getConfig(array $config = null)
 {
     if ($config === null) {
         $config = Conf::get('db');
     }
     if (empty($config['dbname']) || empty($config['server']) || empty($config['username']) || empty($config['password'])) {
         throw new \Exception('db config dismiss');
     }
     if (empty($config['charset'])) {
         $config['charset'] = 'UTF8';
     }
     if (empty($config['port'])) {
         $config['port'] = '3306';
     }
     return $config;
 }