public static function getInstance() { if (null === self::$_instance) { $config = CoreConfig::getInstance(); self::$_instance = new self($config->get('dbhost'), $config->get('dbname'), $config->get('dbuser'), $config->get('dbpass')); } return self::$_instance; }
static function removeNonSEF($non_sef) { $non_sef = trim($non_sef, " \t./\\"); $db = CoreDBMysql::getInstance(); $config = CoreConfig::getInstance(); $urls_db_table = $config->get('urls_db_table'); $query = "\n\t\t\tDELETE FROM `{$urls_db_table}` WHERE non_sef = '{$non_sef}'\n\t\t"; $db->setQuery($query)->execute(); }
static function getSEFPath($non_sef) { if (self::$sef_path !== false) { return self::$sef_path; } $db = CoreFactory::getDB(); $config = CoreConfig::getInstance(); $urls_db_table = $config->get('urls_db_table'); $query = "\n\t\t\t\tSELECT sef FROM `{$urls_db_table}` WHERE non_sef = '{$non_sef}'\n\t\t\t"; self::$sef_path = $db->setQuery($query)->getResult(); return self::$sef_path; }
public function __construct($host = '', $dbname = '', $user = '', $pass = '') { if (empty($dbname)) { $config = CoreConfig::getInstance(); $host = $config->get('dbhost'); $dbname = $config->get('dbname'); $user = $config->get('dbuser'); $pass = $config->get('dbpass'); } $this->dbhost = $host; $this->dbname = $dbname; $this->user = $user; $this->pass = $pass; }
include_once CORE_FOLDER . 'config.php'; include_once CORE_FOLDER . 'controller.php'; include_once CORE_FOLDER . 'url.php'; include_once CORE_FOLDER . 'db/mysqli.php'; include_once CORE_FOLDER . 'db/active_record.php'; include_once CORE_FOLDER . 'db/statement.php'; include_once CORE_FOLDER . 'views_loader.php'; include_once CORE_FOLDER . 'models_loader.php'; include_once CORE_FOLDER . 'model.php'; include_once CORE_FOLDER . 'input.php'; include_once CORE_FOLDER . 'route.php'; include_once CORE_FOLDER . 'session.php'; include_once CORE_FOLDER . 'files_upload.php'; $db = CoreFactory::getDB(); //$db->setQuery('SET NAMES "utf8"')->execute(); $config = CoreConfig::getInstance(); $controller = URL::segment(1); if (!$controller) { if (!$config->get('default_controller')) { error('No default controller assigned'); exit; } $controller = $config->get('default_controller'); } $controller = strtolower($controller); $controller_file = APPLICATION_FOLDER . 'controllers/' . $controller . '.php'; if (!file_exists($controller_file)) { error('Controller file does not exist', 404); exit; } include $controller_file;
function getIP() { if ($this->ip_address !== false) { return $this->ip_address; } $config = CoreConfig::getInstance(); if ($config->get('proxy_ips') != '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR')) { $proxies = preg_split('/[\\s,]/', $config->get('proxy_ips'), -1, PREG_SPLIT_NO_EMPTY); $proxies = is_array($proxies) ? $proxies : array($proxies); $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; } elseif ($this->server('REMOTE_ADDR') and $this->server('HTTP_CLIENT_IP')) { $this->ip_address = $_SERVER['HTTP_CLIENT_IP']; } elseif ($this->server('REMOTE_ADDR')) { $this->ip_address = $_SERVER['REMOTE_ADDR']; } elseif ($this->server('HTTP_CLIENT_IP')) { $this->ip_address = $_SERVER['HTTP_CLIENT_IP']; } elseif ($this->server('HTTP_X_FORWARDED_FOR')) { $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; } if ($this->ip_address === false) { $this->ip_address = '0.0.0.0'; return $this->ip_address; } if (strstr($this->ip_address, ',')) { $x = explode(',', $this->ip_address); $this->ip_address = trim(end($x)); } if (!$this->valid_ip($this->ip_address)) { $this->ip_address = '0.0.0.0'; } return $this->ip_address; }