Exemple #1
0
 /**
  * Fetch the cache array
  *
  * @access	public
  * @return	array caches and caches to load
  */
 public function fetchCaches()
 {
     /* Apps and modules */
     $cache = array('version' => array('force_load' => 1, 'recache_file' => kxFunc::getAppDir('core') . '/modules/manage/index/index.php', 'recache_class' => 'manage_core_index_index', 'recache_function' => 'recacheEdahaVersion'), 'addons' => array('app_cache' => array('force_load' => 1, 'recache_file' => kxFunc::getAppDir('core') . '/modules/manage/addons/addons.php', 'recache_class' => 'manage_core_addons_addons', 'recache_function' => 'recacheApplications'), 'app_menu' => array('force_load' => 1, 'recache_file' => kxFunc::getAppDir('core') . '/modules/manage/addons/addons.php', 'recache_class' => 'manage_core_addons_addons', 'recache_function' => 'recacheAppMenu'), 'module_cache' => array('force_load' => 1, 'recache_file' => kxFunc::getAppDir('core') . '/modules/manage/addons/addons.php', 'recache_class' => 'manage_core_addons_addons', 'recache_function' => 'recacheModules'), 'hooks_cache' => array('force_load' => 1, 'recache_file' => kxFunc::getAppDir('core') . '/modules/manage/addons/hooks.php', 'recache_class' => 'manage_core_addons_hooks', 'recache_function' => 'recacheHooks')), 'filters' => array('wordfilters' => array('force_load' => 1, 'recache_file' => kxFunc::getAppDir('core') . '/modules_admin/posts/filter.php', 'recache_class' => 'manage_core_posts_filter', 'recache_function' => 'recacheWordFilters'), 'spamfilters' => array('force_load' => 1, 'recache_file' => kxFunc::getAppDir('core') . '/modules_admin/posts/filter.php', 'recache_class' => 'manage_core_posts_filter', 'recache_function' => 'recacheSpamFilters')));
     $load = array();
     return array('caches' => $cache, 'cachetoload' => $load);
 }
Exemple #2
0
 /**
  * Run requested method
  *
  * @access  public
  * @param  object    Registry object
  * @param  object    Board object
  * @param  int       Thread ID
  * @param  string    Method to run
  * @return  void
  */
 public function exec(kxEnv $environment)
 {
     //-----------------------------------------
     // Setup...
     //-----------------------------------------
     $this->board = $this->db->select("boards")->fields("boards")->condition("board_name", $this->request['board'])->execute()->fetch();
     //-----------------------------------------
     // Get the unique posts for this board
     //-----------------------------------------
     $result = $this->db->select("posts");
     $result->addExpression("COUNT(DISTINCT post_ip_md5)");
     $this->board->board_uniqueposts = $result->condition("post_board", $this->board->board_id)->condition("post_deleted", 0)->execute()->fetchField();
     //-----------------------------------------------
     // Get the the allowed filetypes for this board
     //-----------------------------------------------
     $result = $this->db->select("filetypes", "f")->fields("f", array("type_ext"));
     $result->innerJoin("board_filetypes", "bf", "bf.type_id = f.type_id");
     $result->innerJoin("boards", "b", "b.board_id = bf.type_board_id");
     $this->board->board_filetypes_allowed = $result->condition("type_board_id", $this->board->board_id)->orderBy("type_ext")->execute()->fetchAssoc();
     $this->board->boardlist = array();
     $this->environment->set('kx:classes:board:id', $this->board);
     require_once kxFunc::getAppDir('board') . '/classes/upload.php';
     $this->environment->set('kx:classes:board:upload:id', new upload($environment));
     require_once kxFunc::getAppDir('core') . '/classes/parse.php';
     $this->environment->set('kx:classes:board:parse:id', new parse($environment));
 }
Exemple #3
0
 private function onRegen()
 {
     // Grabing essential data about the board
     $boardType = $this->db->select("boards")->fields("boards", array("board_type"))->condition("board_name", $this->request['board'])->execute()->fetchField();
     // Nope
     if ($boardType === false) {
         $this->errorMessage = sprintf(_gettext("Couldn't find board /%s/."), $this->request['board']);
         return false;
     }
     //Check against our built-in board types.
     if (in_array($boardType, array(0, 1, 2, 3))) {
         $types = array('image', 'text', 'oekaki', 'upload');
         $module_to_load = $types[$boardType];
     } else {
         $result = $this->db->select("modules")->fields("modules", array("module_variables", "module_directory"))->condition("module_application", 1)->execute()->fetchAll();
         foreach ($result as $line) {
             $varibles = unserialize($line->module_variables);
             if (isset($variables['board_type_id']) && $variables['board_type_id'] == $boardType) {
                 $module_to_load = $line->module_directory;
             }
         }
     }
     // Module loading time!
     $moduledir = kxFunc::getAppDir("board") . '/modules/public/' . $module_to_load . '/';
     if (file_exists($moduledir . $module_to_load . '.php')) {
         require_once $moduledir . $module_to_load . '.php';
     }
     // Some routine checks...
     $className = "public_board_" . $module_to_load . "_" . $module_to_load;
     if (class_exists($className)) {
         $module_class = new ReflectionClass($className);
         if ($module_class->isSubClassOf(new ReflectionClass('kxCmd'))) {
             $this->_boardClass = $module_class->newInstance($this->environment);
             $this->_boardClass->execute($this->environment);
         } else {
             $this->errorMessage = sprintf("Couldn't find module %s", $className);
             return false;
         }
     }
     $this->_boardClass->regeneratePages();
     $this->_boardClass->regenerateThreads();
     return true;
 }
Exemple #4
0
 private static function _buildMenu()
 {
     $app = KX_CURRENT_APP;
     if (KX_CURRENT_APP == 'core' && !isset(kxEnv::$request['module']) && !isset(kxEnv::$request['app'])) {
         $modules = array(array('module_file' => 'index'));
     } else {
         $modules = kxDB::getinstance()->select("modules", "", array('fetch' => PDO::FETCH_ASSOC))->fields("modules", array("module_name", "module_file"))->condition("module_application", $app)->condition("module_manage", 1)->orderBy("module_position")->execute()->fetchAll();
     }
     //print_r($modules);
     foreach ($modules as $module) {
         $_file = kxFunc::getAppDir($app) . "/modules/manage/" . $module['module_file'] . '/menu.yml';
         //echo "<p>Getting menu from {$_file}</p>";
         if (file_exists($_file)) {
             if (function_exists("syck_load")) {
                 $menu[$module['module_file']] = syck_load(file_get_contents($_file));
             } else {
                 $menu[$module['module_file']] = spyc_load_file($_file);
             }
             self::assign('menu', $menu);
             self::assign('module', $module['module_file']);
         }
     }
 }
Exemple #5
0
 /**
  * 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;
 }
Exemple #6
0
 /**
  * Loads the configuration for an application
  *
  * @param string App directory
  */
 public static function loadAppConfig($app)
 {
     $CACHE = $LOAD = array();
     if (!isset(self::$_appConfig[$app])) {
         $file = kxFunc::getAppDir($app) . '/appConfig.php';
         if (is_file($file)) {
             require $file;
             self::$_appConfig[$app]['cache'] = $CACHE;
             self::$_appConfig[$app]['cacheload'] = $LOAD;
         }
     }
 }
Exemple #7
0
 public function exec(kxEnv $environment)
 {
     // Before we do anything, let's check if we even have any board info
     if (!$this->request['board']) {
         die;
         kxFunc::doRedirect(kxEnv::Get('kx:paths:main:webpath'));
     }
     // Grabing essential data about the board
     $boardType = $this->db->select("boards")->fields("boards", array("board_type"))->condition("board_name", $this->request['board'])->execute()->fetchField();
     // Uh oh! Someone's being naughty! Silently redirect them to the mainpage if they supply us with a non-existing board.
     if ($boardType === false) {
         kxFunc::doRedirect(kxEnv::Get('kx:paths:main:webpath'));
     }
     //Check against our built-in board types.
     if (in_array($boardType, array(0, 1, 2, 3))) {
         $types = array('image', 'text', 'oekaki', 'upload');
         $module_to_load = $types[$boardType];
     } else {
         $result = $this->db->select("modules")->fields("modules", array("module_variables", "module_directory"))->condition("module_application", 1)->execute()->fetchAll();
         foreach ($result as $line) {
             $varibles = unserialize($line->module_variables);
             if (isset($variables['board_type_id']) && $variables['board_type_id'] == $boardType) {
                 $module_to_load = $line->module_directory;
             }
         }
     }
     // Module loading time!
     $moduledir = kxFunc::getAppDir("board") . '/modules/public/' . $module_to_load . '/';
     if (file_exists($moduledir . $module_to_load . '.php')) {
         require_once $moduledir . $module_to_load . '.php';
     } else {
         kxFunc::doRedirect(kxEnv::Get('kx:paths:main:webpath'));
     }
     // Some routine checks...
     $className = "public_board_" . $module_to_load . "_" . $module_to_load;
     if (class_exists($className)) {
         $module_class = new ReflectionClass($className);
         if ($module_class->isSubClassOf(new ReflectionClass('kxCmd'))) {
             $this->_boardClass = $module_class->newInstance($this->environment);
             $this->_boardClass->execute($this->environment);
         } else {
             kxFunc::doRedirect(kxEnv::Get('kx:paths:main:webpath'));
         }
     } else {
         kxFunc::doRedirect(kxEnv::Get('kx:paths:main:webpath'));
     }
     // Include our posting class
     require_once kxFunc::getAppDir('core') . '/classes/posting.php';
     $this->_postingClass = new posting($this->environment);
     $this->environment->set('kx:classes:board:posting:id', $this->_postingClass);
     // Phew, that's over with. Let's now prepare our post for generation.
     //Are we UTF-8?
     $this->_postingClass->checkUTF8();
     // Is post valid according to our board's spec?
     if ($this->_boardClass->validPost()) {
         $this->db->startTransaction();
         // Do we have files?
         $this->postData['files'] = isset($_FILES['imagefile']) ? $_FILES['imagefile']['name'] : '';
         // Backwards compatability hack for dumpers that don't support multifile uploading
         if ($this->postData['files'] && !is_array($this->postData['files'])) {
             foreach ($_FILES['imagefile'] as $key => $value) {
                 $_FILES['imagefile'][$key] = array($value);
             }
             $this->postData['files'] = array($_FILES['imagefile']['name'][0]);
         }
         $this->postData['is_reply'] = $this->_postingClass->isReply($this->_boardClass->board->board_id);
         $this->_postingClass->checkPostingTime($this->postData['is_reply'], $this->_boardClass->board->board_id);
         $this->_postingClass->checkMessageLength($this->_boardClass->board->max_message_length);
         $this->_postingClass->checkBlacklistedText($this->_boardClass->board->board_id);
         $this->_postingClass->checkCaptcha($this->_boardClass->board, $this->postData);
         $this->_postingClass->checkBannedHash($this->_boardClass->board);
         //How many replies, is the thread locked, etc
         if ($this->postData['is_reply']) {
             $this->postData['thread_info'] = $this->_postingClass->threadInfo($this->_boardClass->board_id, $this->request['replythread']);
         } else {
             $this->postData['thread_info'] = array('replies' => 0, 'locked' => 0, 'parent' => 0);
         }
         // Subject, email, etc fields need special processing
         $this->postData['post_fields'] = $this->_postingClass->parseFields();
         $this->postData['post_fields']['postpassword'] = isset($this->request['postpassword']) ? $this->request['postpassword'] : '';
         $nextid = $this->db->select("posts")->fields("posts", array("post_id"))->condition("post_board", $this->_boardClass->board->board_id)->execute()->fetchField();
         if ($nextid) {
             $this->postData['next_id'] = $nextid + 1;
         } else {
             $this->postData['next_id'] = 1;
         }
         // Are we modposting?
         $this->postData['user_authority'] = $this->_postingClass->userAuthority();
         if (isset($this->request['displaystaffstatus'])) {
             $this->postData['flags'] .= 'D';
         }
         if (isset($this->request['lockonpost'])) {
             $this->postData['flags'] .= 'L';
         }
         if (isset($this->request['stickyonpost'])) {
             $this->postData['flags'] .= 'S';
         }
         if (isset($this->request['rawhtml'])) {
             $this->postData['flags'] .= 'RH';
         }
         if (isset($this->request['usestaffname'])) {
             $this->postData['flags'] .= 'N';
         }
         $this->postData['display_status'] = 0;
         $this->postData['lock_on_post'] = 0;
         $this->postData['sticky_on_post'] = 0;
         // If they are just a normal user, or vip...
         if ($this->postData['user_authority'] == 0 || $this->postData['user_authority'] > 2) {
             // If the thread is locked
             if ($this->postData['thread_info']['locked'] == 1) {
                 // Don't let the user post
                 kxFunc::showError(_gettext('Sorry, this thread is locked and can not be replied to.'));
             }
             $this->postData['thread_info']['message'] = $this->_boardClass->parseData($this->request['message']);
             // Or, if they are a moderator/administrator...
         } else {
             // If they checked the D checkbox, set the variable to tell the script to display their staff status (Admin/Mod) on the post during insertion
             if (isset($this->request['displaystaffstatus'])) {
                 $this->postData['display_status'] = true;
             }
             // If they checked the RH checkbox, set the variable to tell the script to insert the post as-is...
             if (isset($this->request['rawhtml'])) {
                 $this->postData['thread_info']['message'] = $this->request['message'];
                 // Otherwise, parse it as usual...
             } else {
                 $this->postData['thread_info']['message'] = $this->_boardClass->parseData($this->request['message']);
             }
             // If they checked the L checkbox, set the variable to tell the script to lock the post after insertion
             if (isset($this->request['lockonpost'])) {
                 $this->postData['lock_on_post'] = true;
             }
             // If they checked the S checkbox, set the variable to tell the script to sticky the post after insertion
             if (isset($this->request['stickyonpost'])) {
                 $this->postData['sticky_on_post'] = true;
             }
             if (isset($this->request['usestaffname'])) {
                 $_POST['name'] = kxFunc::md5_decrypt($this->request['modpassword'], kxEnv::Get('kx:misc:randomseed'));
                 $post_name = kxFunc::md5_decrypt($this->request['modpassword'], kxEnv::Get('kx:misc:randomseed'));
             }
         }
         //kxFunc::checkBadUnicode($this->postData['post_fields']);
         $this->_boardClass->processPost($this->postData);
         $url = kxEnv::Get("kx:paths:boards:path") . '/' . $this->_boardClass->board->board_name;
         if (!$this->postData['is_reply']) {
             $url .= '/' . kxEnv::Get('kx:pages:first');
         } else {
             $url .= '/res/' . intval($this->request['replythread']) . '.html';
         }
         @header('Location: ' . $url);
     }
 }