Beispiel #1
0
 public function __construct($url)
 {
     $_GET['url'] = $url;
     $_SERVER['SERVER_SOFTWARE'] = '';
     $_SERVER['REQUEST_METHOD'] = 'cli';
     $segments = Request::get();
     $segments = $segments['segments'];
     $_config = Reader::get('app');
     if (isset($_config['timezone'])) {
         date_default_timezone_set($_config['timezone']);
     }
     Debug::path(PATH_LOGS);
     Debug::reporting(DEV_SHOWERRORS);
     Debug::cli(1);
     $path = "";
     if (trim($segments['controller']) == "") {
         $segments['controller'] = "Index";
     }
     if (trim($segments['action']) == "") {
         $segments['action'] = "index";
     }
     if (trim($segments['module']) != "") {
         $path .= "\\{$segments['module']}";
     }
     $path .= "\\Controllers\\{$segments['controller']}";
     $objClass = $this->_loadClass($path, $segments['controller'] . "Controller");
     if (is_callable(array($objClass, $segments['action']))) {
         if (strtolower($segments['action']) != 'index') {
             call_user_func(array($objClass, $segments['action']));
         }
     } else {
         Debug::dump("ERROR :: No es posible lanzar " . implode("->", $segments));
     }
 }
Beispiel #2
0
 public function __construct($dataBase = NULL)
 {
     if (is_null($dataBase)) {
         $dataBase = 'default';
     }
     $_config = Reader::get('bases');
     $base = $_config[$dataBase];
     $base['password'] = Crypt::decrypt($base['password']);
     parent::connect($base);
 }
Beispiel #3
0
 private function __construct()
 {
     $this->data = array();
     $this->params = array();
     $_segments = array('module', 'controller', 'action');
     $this->data['method'] = strtoupper(trim($_SERVER['REQUEST_METHOD']));
     $this->data['content_type'] = 'html';
     if (isset($_SERVER['CONTENT_TYPE'])) {
         $this->data['content_type'] = $_SERVER['CONTENT_TYPE'];
     }
     if (isset($_SERVER['HTTP_REFERER'])) {
         $this->data['previous'] = $_SERVER['HTTP_REFERER'];
     } else {
         $this->data['previous'] = NULL;
     }
     //Soporte para Autorización
     if ($_SERVER['REQUEST_METHOD'] != 'cli') {
         if (function_exists('apache_request_headers')) {
             $headers = apache_request_headers();
         }
         if (function_exists('getallheaders')) {
             $headers = getallheaders();
         }
         if (isset($headers['Authorization'])) {
             $this->data['authorization'] = $headers['Authorization'];
         }
         if (isset($headers['x-access-token'])) {
             $this->data['authorization'] = $headers['x-access-token'];
         }
     }
     if (!isset($_GET['url'])) {
         $_GET['url'] = false;
     }
     $_url = explode('/', $_GET['url']);
     if (!strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
         array_shift($_url);
     }
     $_segmentsTemp = $_segments;
     $_urlTemp = $_url;
     if (array_shift($_segmentsTemp) == "module" && !is_dir(PATH_ROOT . "/app/" . ucwords(array_shift($_urlTemp)))) {
         array_shift($_segments);
     }
     while (count($_segments) > 0) {
         $this->data['segments'][array_shift($_segments)] = ucwords(array_shift($_url));
     }
     if (!isset($this->data['segments']['module'])) {
         $this->data['segments']['module'] = '';
     }
     $this->params = self::procesaParametros($_url);
     $this->data["params"] = $this->params;
     if (array_key_exists('__clearCache', $this->params)) {
         $this->clearCache(PATH_CACHE);
         Reader::restart();
     }
 }
Beispiel #4
0
 protected function __construct()
 {
     $config = Reader::get();
     if (!isset($config['sesion'])) {
         $config['sesion']['type'] = 'DEFAULT';
         $config['sesion']['name'] = 'sfphp';
         $config['sesion']['ssl'] = 0;
         $config['sesion']['inactivity'] = 300;
     }
     $config = $config['sesion'];
     $httponly = true;
     $session_hash = 'sha512';
     if (in_array($session_hash, hash_algos())) {
         ini_set('session.hash_function', $session_hash);
     }
     ini_set('session.hash_bits_per_character', 5);
     ini_set('session.use_only_cookies', 1);
     ini_set('session.gc_maxlifetime', $config['inactivity']);
     $cookieParams = session_get_cookie_params();
     if ($cookieParams["lifetime"] == 0) {
         $cookieParams["lifetime"] = 28800;
     }
     #Se mantiene una sesion activa hasta por 8 horas en el navegador
     session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $config['ssl'], true);
     session_save_path(PATH_SESSION);
     session_name($config['name']);
     session_start();
     $_cookie = isset($_SERVER['HTTP_COOKIE']) ? $_SERVER['HTTP_COOKIE'] : "";
     if (trim($_cookie) == "") {
         $_cookie = $config['name'] . "=" . session_id();
     }
     self::set('sincco\\sfphp\\client\\browser', $_SERVER['HTTP_USER_AGENT']);
     self::set('sincco\\sfphp\\client\\address', $_SERVER['REMOTE_ADDR']);
     if (is_null(self::get('sincco\\sfphp\\client\\token'))) {
         self::set('sincco\\sfphp\\client\\uid', md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . $_cookie));
     } else {
         #if (self::get('sincco\sfphp\client\uid') != md5($_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT'].$_cookie))
         #    throw new \Sincco\Sfphp\Exception('Violacion de seguridad', 403);
     }
     if (is_null(self::get('sincco\\sfphp\\client\\token'))) {
         self::set('sincco\\sfphp\\client\\token', md5(\Sincco\Sfphp\UUID::v4()));
     }
 }
Beispiel #5
0
 public function __construct()
 {
     $_config = Reader::get('app');
     if (isset($_config['timezone'])) {
         date_default_timezone_set($_config['timezone']);
     }
     Debug::path(PATH_LOGS);
     Debug::reporting(DEV_SHOWERRORS);
     Plugger::dispatchGlobal('pre', 'ResolveUrl');
     $path = "";
     $segments = Request::get('segments');
     if (trim($segments['controller']) == "") {
         $segments['controller'] = "Index";
     }
     if (trim($segments['action']) == "") {
         $segments['action'] = "index";
     }
     if (trim($segments['module']) != "") {
         $path .= "\\{$segments['module']}";
     }
     $path .= "\\Controllers\\{$segments['controller']}";
     if (trim($segments['module']) != '') {
         $observer = $segments['module'] . '_' . $segments['controller'] . '_' . $segments['action'];
     } else {
         $observer = $segments['controller'] . '_' . $segments['action'];
     }
     $objClass = ClassLoader::load($path, $segments['controller'] . "Controller");
     if (is_callable(array($objClass, $segments['action']))) {
         Plugger::dispatchAction('pre', $observer);
         call_user_func(array($objClass, $segments['action']));
         Plugger::dispatchAction('post', $observer);
     } else {
         if (DEV_SHOWERRORS) {
             Debug::dump("ERROR :: No es posible lanzar " . implode("->", $segments));
         } else {
             new Response('htmlstatuscode', '404 Not Found');
         }
     }
 }
Beispiel #6
0
 public static function run()
 {
     try {
         Paths::init();
         Reader::get('app');
         if (!defined('DEV_SHOWERRORS')) {
             define('DEV_SHOWERRORS', false);
         }
         if (!defined('APP_KEY')) {
             define('APP_KEY', 'e77393ef-c24b-4ff5-81f7-ed9fa28b4fb8');
         }
         if (!defined('APP_NAME')) {
             define('APP_NAME', 'sfphp');
         }
         Translations::init();
         Session::get();
         new Launcher();
     } catch (\Exception $err) {
         $errorInfo = sprintf('%s: %s in %s on line %s.', 'Error', $err, $err->getFile(), $err->getLine());
         Debug::dump($errorInfo);
     }
 }
Beispiel #7
0
 public function extra_elasticemail($username, $api_key, $from, $test = 0)
 {
     echo 'Registrando elastic email...' . PHP_EOL;
     $config = Reader::get();
     $config['elasticemail']['username'] = $username;
     $config['elasticemail']['api_key'] = $api_key;
     $config['elasticemail']['from'] = $from;
     $config['elasticemail']['test'] = $test;
     Writer::write($config, 'config', 'etc/config/config.xml');
     chmod("./etc/config/config.xml", 0775);
     echo 'OK' . PHP_EOL;
 }