public function exec(kxEnv $environment) { $dbsize = 0; switch ($this->db->driver()) { case 'mysql': $twigData['dbtype'] = 'MySQL'; $results = $this->db->query("SHOW TABLE STATUS"); foreach ($results as $line) { $dbsize += $line->data_length + $line->index_length; } break; case 'pgsql': $twigData['dbtype'] = 'PostgreSQL'; $results = $this->db->query("SELECT pg_database_size('" . substr(kxEnv::get("kx:db:dsn"), strpos(kxEnv::get("kx:db:dsn"), "dbname=") + 7, strlen(kxEnv::get("kx:db:dsn"))) . "')"); foreach ($results as $line) { $dbsize += $line->pg_database_size; } break; case 'sqlite': $twigData['dbtype'] = 'SQLite'; $dbsize = filesize(substr(kxEnv::get("kx:db:dsn"), strpos(kxEnv::get("kx:db:dsn"), "sqlite:") + 7, strlen(kxEnv::get("kx:db:dsn")))); break; default: $twigData['dbtype'] = $this->db->driver(); } $twigData['dbsize'] = kxFunc::convertBytes($dbsize); $twigData['dbversion'] = substr($this->db->version(), 0, strrpos($this->db->version(), '-') !== FALSE ? strrpos($this->db->version(), '-') : strlen($this->db->version())); $twigData['stats']['numboards'] = $this->db->select("boards")->countQuery()->execute()->fetchField(); $twigData['stats']['totalposts'] = $this->db->select("posts")->countQuery()->execute()->fetchField(); $twigData['stats']['edahaversion'] = kxEnv::get("cache:version"); kxTemplate::output("manage/index", $twigData); }
public static function init($template_dir = null, $compiled_dir = null, $cache_dir = null) { if (self::$instance == null) { //echo "<p>init() called!</p>"; if ($template_dir != null) { self::$template_dir = $template_dir; } else { self::$template_dir = KX_ROOT . kxEnv::get("kx:templates:dir"); } $loader = new Twig_Loader_Filesystem(self::$template_dir); if ($cache_dir == null) { $cache_dir = KX_ROOT . kxEnv::get("kx:templates:cachedir"); } self::$instance = new Twig_Environment($loader, array('cache' => $cache_dir, 'auto_reload' => true, 'debug' => true)); // Load our extensions self::$instance->addExtension(new Twig_Extensions_Extension_I18n()); self::$instance->addExtension(new Twig_Extensions_Extension_kxEnv()); self::$instance->addExtension(new Twig_Extensions_Extension_DateFormat()); self::$instance->addExtension(new Twig_Extensions_Extension_Text()); self::$instance->addExtension(new Twig_Extensions_Extension_Round()); self::$instance->addExtension(new Twig_Extensions_Extension_Strip()); self::$instance->addExtension(new Twig_Extensions_Extension_Debug()); self::$instance->addExtension(new Twig_Extensions_Extension_PHP()); // Supply Twig with our GET/POST variables self::$data['_get'] = $_GET; self::$data['_post'] = $_POST; // Supply Twig with the default locale self::$data['locale'] = kxEnv::Get('kx:misc:locale'); // Are we in manage? Load up the manage wrapper if (IN_MANAGE) { self::$data['current_app'] = ""; if (KX_CURRENT_APP == "core") { // Load up some variables for tabbing/menu purposes if (isset(kxEnv::$request['app'])) { self::$data['current_app'] = kxEnv::$request['app']; } } else { if (KX_CURRENT_APP == "board") { if (kxEnv::$current_module == "posts") { self::$data['current_app'] = "posts"; } else { self::$data['current_app'] = "board"; } } } $baseurl = kxEnv::Get('kx:paths:main:path') . '/manage.php?sid=' . (isset(kxEnv::$request['sid']) ? kxEnv::$request['sid'] : '') . '&'; self::$data['base_url'] = $baseurl; // Get our manage username if (isset(kxEnv::$request['sid'])) { $result = kxDB::getinstance()->select('staff', 'stf')->fields('stf', array('user_name')); $result->innerJoin("manage_sessions", "ms", "ms.session_staff_id = stf.user_id"); self::assign('name', $result->condition('session_id', kxEnv::$request['sid'])->execute()->fetchField()); } } // else { // die('Not IN_MANAGE!'); //} } }
public function doStaticPostLink($matches) { $result = $this->db->select("posts")->fields("posts", array("post_parent"))->condition("post_board", $this->board->board_id)->condition("post_id", $matches[1])->execute()->fetchField(); if ($result === 0) { $realID = $matches[1]; } elseif (empty($result)) { return $matches[0]; } else { $realID = $result; } return '<a href="' . kxEnv::get('kx:paths:boards:folder') . $this->board->board_name . '/res/' . $realID . '.html#' . $matches[1] . '" id="ref">' . $matches[0] . '</a>' . $lastchar; }
public static function initialize($environment, $configdir) { if (self::$instance instanceof self) { return; } $configuration = array(); // Load config foreach (self::getConfigFiles($configdir) as $configfile) { $configuration = array_merge_recursive(array_reduce(array_intersect_key(self::loadConfigFile($configfile), array_flip(array('all', $environment))), array('self', 'mergeWrapper')), $configuration); } // Set our instance, load kxConfig self::$instance = new self($environment, new kxConfig($configuration)); // Add any classes we want added to the autoloader. foreach (kxEnv::get('kx:autoload:load') as $repo => $opts) { kxEnv::set(sprintf('kx:autoload:repository:%s:id', $repo), kxAutoload::registerRepository(sprintf('%s/%s/%s', KX_ROOT, 'application/lib', $opts['path']), array('prefix' => $opts['prefix']))); } // Set up our input, remove any magic quotes if (is_array($_POST) and !empty($_POST)) { foreach ($_POST as $BUTTER => $TOAST) { // Skip arrays if (!is_array($TOAST)) { $_POST[$BUTTER] = kxFunc::strip_magic($TOAST); } } } // Clean up all of our input (cookies, get/post requests, etc) kxFunc::cleanInput($_GET); kxFunc::cleanInput($_POST); kxFunc::cleanInput($_COOKIE); kxFunc::cleanInput($_REQUEST); //Okay NOW let's parse our input $input = kxFunc::parseInput($_GET, array()); // Allow $_POST to overwrite $_GET self::$request = kxFunc::parseInput($_POST, $input) + self::$request; // Grab our app $_application = preg_replace("/[^a-zA-Z0-9\\-\\_]/", "", isset($_REQUEST['app']) && trim($_REQUEST['app']) ? $_REQUEST['app'] : "core"); // Make sure we get (hopefully) a string if (is_array($_application)) { $_application = array_shift($_application); } define('KX_CURRENT_APP', $_application); kxEnv::$current_application = KX_CURRENT_APP; kxEnv::$current_module = isset(self::$request['module']) ? self::$request['module'] : ''; kxEnv::$current_section = isset(self::$request['section']) ? self::$request['section'] : ''; // Cleanup kxEnv::$current_module = kxFunc::alphaNum(kxEnv::$current_module); kxEnv::$current_section = kxFunc::alphaNum(kxEnv::$current_section); // Load the cache self::$cache = kxCache::instance(); }
public function parseData(&$message) { $message = trim($message); $this->cutWord($message, kxEnv::get('kx:limits:linelength') / 15); //var_dump($message); $message = htmlspecialchars($message, ENT_QUOTES, kxEnv::get('kx:charset')); if (kxEnv::Get('kx:posts:makelinks')) { $this->makeClickable($message); } $this->clickableQuote($message); $this->coloredQuote($message); $this->bbCode($message); $this->wordFilter($message); $this->checkNotEmpty($message); return $message; }
public function kxEnvFilter($string) { return kxEnv::get('kx:' . $string); }
public static final function openConnection($driver_options) { $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; try { $pdo = new PDO_(kxEnv::get('kx:db:dsn', 'mysql:dbname=kusabax;host=localhost'), kxEnv::get('kx:db:username', 'kusabax'), kxEnv::get('kx:db:password', 'kusabax'), $driver_options); } catch (PDOException $e) { throw new kxPDOException($e->getMessage()); } return $pdo; }
/** * mb_stripos wrapper * * @param string Input haystack * @param string Input needle * @param integer D * @return string Parsed string * @since 2.0 */ public static function stripos($haystack, $needle, $offset = 0) { if (function_exists('mb_stripos')) { $encodings = mb_list_encodings(); if (count($encodings) && in_array(strtolower(kxEnv::get("kx:charset")), $encodings)) { return mb_stripos($haystack, $needle, $offset, strtoupper(kxEnv::get("kx:charset"))); } } if (!self::seemsUtf8($haystack)) { if (strtoupper(kxEnv::get("kx:charset")) == "UTF-8") { return stripos($haystack, $needle, $offset); } else { $text = convertCharset($haystack, kxEnv::get("kx:charset"), "UTF-8"); } } if (!self::seemsUtf8($needle)) { if (strtoupper(kxEnv::get("kx:charset")) == "UTF-8") { return stripos($haystack, $needle, $offset); } else { $text = convertCharset($needle, kxEnv::get("kx:charset"), "UTF-8"); } } if (self::checkMultibyte($haystack)) { $haystack = self::strtoupper($haystack); $needle = self::strtoupper($needle); return self::strpos($haystack, $needle, $offset); } return stripos($haystack, $needle, $offset); }
private function _filetypes() { // Retrieve filetypes from cache $this->twigData['filetypes'] = kxEnv::get('cache:attachments:filetypes'); kxTemplate::output("manage/filetypes", $this->twigData); }