public function __construct($params = null) { if (isset($params['baseurl'])) { $this->_baseUrl = $params['baseurl']; } else { $this->_baseUrl = c::config()->baseUrl->{c::env()}; } }
public function query($query, $args = []) { $stmt = $this->db()->prepare($query); // if we have keyword arguments if (is_object($args)) { throw new Exception('Invalid arguments for query'); } /* if ($args && array_keys($args) !== range(0, count($args) - 1)) { foreach ($args as $key => $value) { switch (gettype($value)) { case 'integer': $type = PDO::PARAM_INT; break; case 'string': $type = PDO::PARAM_STR; break; default: $type = null; break; } $stmt->bindValue(':'.$key, $value, $type); } $args = null; } */ try { $stmt->execute($args); } catch (Exception $e) { if (getenv('DEBUG')) { echo $e->getMessage(); die(c::env()); } throw new Exception((c::env() == 'live' ? '' : $query . "\n" . print_r($args, 1) . "\n") . $e->getMessage()); } return $stmt; }
public function getEnv($d = true) { if (c::user()->debug) { $env = 'dev'; } elseif (c::env() == 'live' || c::env() == 'crondb') { $env = 'live'; } elseif ($d === true) { $env = 'dev'; } else { $env = c::env(); } return $env; }
/** * Filter whitespace to remove unwanted spaces. * * @param string the content to pass * @param array array of config values * filter bool whether or not to run the filter (overwrite object var) * @return string */ private function outputFilter($content, $params) { $env = c::env(); if (!c::config()->templates->{$env}->compress) { return $content; } if (isset($params['filter']) && $params['filter'] || !isset($params['filter']) && $this->_useFilter != false) { $find = ['/^(\\s?)(.*?)(\\s?)$/', '/\\t|\\n|\\r/', '/(\\<\\!\\-\\-)(.*?)\\-\\-\\>/']; $replace = ['\\2', '', '']; return preg_replace($find, $replace, $content); } else { return $content; } }