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)); } }
private function Init($query, $parameters = "") { try { $this->sQuery = $this->prepare($query); $this->bindMore($parameters); if (!empty($this->parameters)) { foreach ($this->parameters as $param => $value) { $type = self::PARAM_STR; switch ($value[1]) { case is_int($value[1]): $type = self::PARAM_INT; break; case is_bool($value[1]): $type = self::PARAM_BOOL; break; case is_null($value[1]): $type = self::PARAM_NULL; break; } $this->sQuery->bindValue($value[0], $value[1], $type); } } $this->sQuery->execute(); } catch (\PDOException $err) { $errorInfo = sprintf('%s: %s in %s on line %s.', 'Database Error', $err, $err->getFile(), $err->getLine()); Debug::dump($errorInfo); } $this->parameters = array(); }
public static function load($path, $class) { try { $_path = str_replace("\\", "/", $path); if (file_exists(PATH_ROOT . "/app" . $_path . ".php")) { require_once PATH_ROOT . "/app" . $_path . ".php"; return new $class(); } else { return new \stdClass(); } } catch (\Error $err) { $errorInfo = sprintf('%s: %s in %s on line %s.', 'Error', $err, $err->getFile(), $err->getLine()); Debug::dump($errorInfo); } }
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 __construct($connectionData) { $connection = NULL; if (!isset($connectionData["charset"])) { $connectionData["charset"] = "utf8"; } $params = array(); if ($connectionData["type"] == "mysql") { $params = array(self::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . $connectionData["charset"]); } else { $params = array(); } try { switch ($connectionData["type"]) { case 'sqlsrv': $hostname = $connectionData["type"] . ":Server=" . $connectionData["host"] . ";"; break; case 'mysql': $hostname = $connectionData["type"] . ":host=" . $connectionData["host"] . ";dbname=" . $connectionData["dbname"]; break; case 'firebird': $params = array(self::FB_ATTR_TIMESTAMP_FORMAT, "%d-%m-%Y", self::FB_ATTR_DATE_FORMAT, "%d-%m-%Y"); $hostname = $connectionData["type"] . ":dbname=" . $connectionData["host"] . $connectionData["dbname"] . ";charset=UTF8"; break; default: $hostname = $connectionData["type"] . ":host=" . $connectionData["host"] . ";dbname=" . $connectionData["dbname"]; break; } parent::__construct($hostname, $connectionData['user'], trim($connectionData['password']), $params); $this->setAttribute(self::ATTR_ERRMODE, self::ERRMODE_EXCEPTION); $this->setAttribute(self::ATTR_EMULATE_PREPARES, false); } catch (\PDOException $err) { $errorInfo = sprintf('%s: %s in %s on line %s.', 'Database Error', $err, $err->getFile(), $err->getLine()); Debug::dump($errorInfo); } }
public function log($data) { Debug::log($data); }