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)); } }
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); }
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())); } }
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'); } } }
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); } }
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; }