public function __construct(kxEnv $environment) { $this->environment = $environment; $this->db = kxDB::getInstance(); $this->request = kxEnv::$request; }
/** * Set a cache * * @param string Cache Key * @param mixed Cache value */ private function _setCache($path, $value) { if ($path) { // First, update the already-loaded cache with the new value $return = kxEnv::getconfig()->setRecursive($path, $value); // Are we using an alt cache engine? // Update it if so if (is_object(self::$cacheLib)) { if (!$value) { $value = "NULL"; } self::$cacheLib->update(implode(':', $path), $value); } // Now update the database // Merge does an update if the key exists, otherwise, it inserts kxDB::getInstance()->merge("cache")->key(array("cache_path" => implode(':', $path)))->fields(array("cache_array" => intval(is_array($value)), "cache_value" => is_array($value) ? serialize($value) : $value, "cache_updated" => time()))->execute(); return $return; } }
/** * Retreive our command * * @access public * @param object kxEnv reference * @return object */ public function getCmd(kxEnv $environment) { $module = kxEnv::$current_module; $section = kxEnv::$current_section; // No module? if (!$module) { if (IN_MANAGE && !isset(kxEnv::$request['app'])) { $module = 'index'; } else { // Get the first module in the DB $module = kxDB::getInstance()->select("modules")->fields("modules", array("module_file"))->condition("module_application", KX_CURRENT_APP)->condition("module_manage", IN_MANAGE)->orderBy("module_position")->execute()->fetchField(); } } $moduledir = kxFunc::getAppDir(KX_CURRENT_APP) . '/modules/' . self::$class_dir . '/' . $module . '/'; // No section? if (!$section) { if (file_exists($moduledir . 'default_section.php')) { $defaultSection = ""; require $moduledir . 'default_section.php'; if ($defaultSection) { $section = $defaultSection; } } } // Are we in manage? if (IN_MANAGE) { // Load the logging class here because we'll probably need it anyway in pretty much any manage function require_once kxFunc::getAppDir('core') . '/classes/logging.php'; $environment->set('kx:classes:core:logging:id', new logging($environment)); $validSession = kxFunc::getManageSession(); if ((!isset($environment::$request['module']) || isset($environment::$request['module']) && $environment::$request['module'] != 'login') && !$validSession) { // Force login if we have an invalid session $environment::$request['module'] = 'login'; kxEnv::$current_module = 'login'; require_once kxFunc::getAppDir('core') . "/modules/manage/login/login.php"; $login = new manage_core_login_login($environment); $login->execute($environment); exit; } } // Ban check ( may as well do it here before we do any further processing) $boardName = ""; if (KX_CURRENT_APP == "core" && $module == "post" && $section == "post") { if (isset($environment->request) && isset($environment->request['board'])) { $boardName = $environment->{$request}['board']; } } kxBans::banCheck($_SERVER['REMOTE_ADDR'], $boardName); $className = self::$class_dir . '_' . KX_CURRENT_APP . '_' . $module . '_' . $section; if (file_exists($moduledir . $section . '.php')) { require_once $moduledir . $section . '.php'; } if (class_exists($className)) { $cmd_class = new ReflectionClass($className); if ($cmd_class->isSubClassOf(self::$baseCmd)) { return $cmd_class->newInstance(); } else { throw new kxException("{$section} in {$module} does not exist!"); } } //If we somehow made it here, let's just use the default command return clone self::$defaultCmd; }
public static function fullBoardList() { $sections = kxDB::getInstance()->select("sections")->fields("sections")->orderBy("section_order")->execute()->fetchAll(); $boards = kxDB::getInstance()->select("boards")->fields("boards", array('board_name', 'board_desc'))->where("board_section = ?")->orderBy("board_order")->build(); // Add boards to an array within their section foreach ($sections as &$section) { $boards->execute(array($section->id)); $section->boards = $boards->fetchAll(); } // Prepend boards with no section $boards->execute(array(0)); return array_merge($boards->fetchAll(), $sections); }