示例#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);
 }
示例#2
0
文件: index.php 项目: D4rk4/Kusaba-z
 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);
 }
示例#3
0
文件: upload.php 项目: D4rk4/Kusaba-z
 public function checkFields($postData)
 {
     if (!$postData['is_reply']) {
         if (empty($postData['files'][0])) {
             kxFunc::showError(_gettext('A file is required for a new thread.'));
         }
     } else {
         if (!$this->postClass->checkEmpty($postData)) {
             kxFunc::showError(_gettext('An image, or message, is required for a reply.'));
         }
     }
 }
示例#4
0
文件: text.php 项目: D4rk4/Kusaba-z
 public function checkFields($postData)
 {
     if ($postData['is_reply']) {
         if (!$postClass->checkEmpty($postData)) {
             kxFunc::showError(_gettext('A message is required for a reply.'));
         }
     } else {
         $result = $this->db->select("posts")->countQuery()->condition("post_board", $this->board->board_id)->condition("post_deleted", 0)->condition("post_subject", substr($postData['subject'], 0, 74))->condition("post_parent", 0)->execute()->fetchField();
         if ($result > 0) {
             kxFunc::showError(_gettext('Duplicate thread subject'), _gettext('Text boards may have only one thread with a unique subject. Please pick another.'));
         }
     }
 }
示例#5
0
文件: oekaki.php 项目: D4rk4/Kusaba-z
 public function checkFields($postData)
 {
     if (!$postData['is_reply']) {
         if (empty($postData['files'][0]) && !$postData['is_oekaki'] && (!isset($this->request['nofile']) && $this->board->board_enable_no_file == 1 || $this->board->board_enable_no_file)) {
             kxFunc::showError(_gettext('A file is required for a new thread.'));
         }
     } else {
         if (!$postData['is_oekaki'] && !$this->postClass->checkEmpty($postData)) {
             kxFunc::showError(_gettext('An image, or message, is required for a reply.'));
         }
     }
     if (isset($this->request['nofile']) && $this->board->board_enable_no_file == 1) {
         if (!$this->postClass->checkNoFile) {
             kxFunc::showError('A message is required to post without a file.');
         }
     }
 }
示例#6
0
文件: board.php 项目: D4rk4/Kusaba-z
 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;
 }
示例#7
0
文件: parse.php 项目: D4rk4/Kusaba-z
 public function doDynamicPostLink($matches)
 {
     $return = $matches[0];
     $postids = kxFunc::getQuoteIds($matches[1]);
     if (count($postids) > 0) {
         $realid = $this->parentid;
         if ($realid === 0) {
             if ($this->id > 0) {
                 $realid = $this->id;
             }
         }
         if ($realid !== '') {
             $return = '<a href="' . kxEnv::Get('kx:paths:boards:folder') . 'read.php';
             if (kxEnv::Get('kx:display:traditionalread')) {
                 $return .= '/' . $thread_board_return . '/' . $realid . '/' . $matches[1];
             } else {
                 $return .= '?b=' . $thread_board_return . '&t=' . $realid . '&p=' . $matches[1];
             }
             $return .= '">' . $matches[0] . '</a>';
         }
     }
     return $return;
 }
示例#8
0
文件: image.php 项目: D4rk4/Kusaba-z
 public function checkFields($postData)
 {
     if (!$postData['is_reply']) {
         if (($this->board->board_upload_type == 1 || $this->board->board_upload_type == 2) && !empty($this->board->board_embeds_allowed)) {
             if ($this->postClass->checkEmbed($postData)) {
                 kxFunc::showError(_gettext('Please enter an embed ID.'));
             }
         }
         if (empty($postData['files'][0]) && (!isset($this->request['nofile']) && $this->board->board_enable_no_file == 1 || $this->board->board_enable_no_file == 0)) {
             if ($this->board->board_upload_type != 0 && empty($this->request['embed']) || $this->board->board_upload_type == 0) {
                 kxFunc::showError(_gettext('A file is required for a new thread. If embedding is allowed, either a file or embed ID is required.'));
             }
         }
     } else {
         if (!$this->postClass->checkEmpty($postData)) {
             kxFunc::showError(_gettext('An image, or message, is required for a reply.'));
         }
     }
     if (isset($this->request['nofile']) && $this->board->board_enable_no_file == 1) {
         if (!$this->postClass->checkNoFile) {
             kxFunc::showError('A message is required to post without a file.');
         }
     }
 }
示例#9
0
文件: post.php 项目: D4rk4/Kusaba-z
 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);
     }
 }
示例#10
0
 /**
  * Format the provided input into a reflink, which follows the Japanese locale if it is set.
  */
 public function formatReflink($post_board, $post_thread_start_id, $post_id, $locale = 'en')
 {
     $return = '	';
     $reflink_noquote = '<a href="' . kxEnv::Get('kx:paths:boards:folder') . $post_board . '/res/' . $post_thread_start_id . '.html#' . $post_id . '" onclick="return highlight(\'' . $post_id . '\');">';
     $reflink_quote = '<a href="' . kxEnv::Get('kx:paths:boards:folder') . $post_board . '/res/' . $post_thread_start_id . '.html#i' . $post_id . '" onclick="return insert(\'>>' . $post_id . '\\n\');">';
     if ($locale == 'ja') {
         $return .= $reflink_quote . kxFunc::formatJapaneseNumbers($post_id) . '</a>' . $reflink_noquote . '?</a>';
     } else {
         $return .= $reflink_noquote . 'No.&nbsp;' . '</a>' . $reflink_quote . $post_id . '</a>';
     }
     return $return . "\n";
 }
示例#11
0
文件: filter.php 项目: D4rk4/Kusaba-z
 public function showFilters()
 {
     $this->twigData['filters'] = $this->db->select("filter")->fields("filter")->execute()->fetchAll();
     $this->twigData['sections'] = kxFunc::fullBoardList();
     kxTemplate::output('manage/filter', $this->twigData);
 }
示例#12
0
文件: login.php 项目: D4rk4/Kusaba-z
 public function loginValidate()
 {
     // Remove old login attempts
     $this->db->delete("loginattempts")->condition("attempt_time", time() - 1200, "<")->execute();
     // Are we locked out still?
     $results = $this->db->select("loginattempts")->fields("loginattempts", array("attempt_ip"))->condition("attempt_ip", $_SERVER['REMOTE_ADDR'])->execute()->fetchAll();
     if (count($results) > 5) {
         kxFunc::showError(_gettext('System lockout'), _gettext('Sorry, because of your numerous failed logins, you have been locked out from logging in for 20 minutes. Please wait and then try again.'));
     } else {
         // Find users with the username supplied to us
         $results = $this->db->select("staff")->fields("staff", array("user_id", "user_name", "user_password", "user_salt"))->condition("user_name", $this->request['username'])->execute()->fetchAll();
         if (count($results) > 0) {
             if (md5($this->request['password'] . $results[0]->user_salt) == $results[0]->user_password) {
                 // Let's make our session
                 $session_id = md5(uniqid(microtime()));
                 $this->request['sid'] = $session_id;
                 // Delete any sessions that already exist for this user
                 $this->db->delete("manage_sessions")->condition("session_staff_id", $results[0]->user_id)->execute();
                 // Insert our new values
                 $this->db->insert("manage_sessions")->fields(array('session_id' => $session_id, 'session_ip' => $_SERVER['REMOTE_ADDR'], 'session_staff_id' => $results[0]->user_id, 'session_location' => "index", 'session_log_in_time' => time(), 'session_last_action' => time(), 'session_url' => ""))->execute();
                 // Set the cookies so ajax functions will load
                 $this->SetModerationCookies();
                 //$this->environment->get('kx:classes:core:logging:id')->manageLog(_gettext('Logged in'), 1);
                 // Let's figure out where we need to go
                 $whereto = "";
                 // Unfiltered on purpose
                 if ($_POST['qstring']) {
                     $whereto = stripslashes($_POST['qstring']);
                     $whereto = str_replace(kxEnv::Get('kx:paths:script:path'), "", $whereto);
                     $whereto = str_ireplace("?manage.php", "", $whereto);
                     $whereto = ltrim($whereto, '?');
                     $whereto = preg_replace("/sid=(\\w){32}/", "", $whereto);
                     $whereto = str_replace(array('old_&', 'old_&amp;'), "", $whereto);
                     $whereto = str_replace("module=login", "", $whereto);
                     $whereto = str_replace("do=login-validate", "", $whereto);
                     $whereto = str_replace('&amp;', '&', $whereto);
                     $whereto = preg_replace("/&{1,}/", "&", $whereto);
                 }
                 $url = kxEnv::Get('kx:paths:script:path') . kxEnv::Get('kx:paths:script:folder') . '/manage.php?sid=' . $session_id . '&' . $whereto;
                 if (!empty($_COOKIE['use_frames'])) {
                     $twigData['url'] = $url;
                     kxTemplate::output("manage/frames", $twigData);
                 } else {
                     kxFunc::doRedirect($url, true);
                 }
                 exit;
             } else {
                 $this->db->insert("loginattempts")->fields(array('attempt_name' => $this->request['username'], 'attempt_ip' => $_SERVER['REMOTE_ADDR'], 'attempt_time' => time()))->execute();
                 $this->showForm(_gettext('Incorrect username/password.'));
             }
         } else {
             $this->db->insert("loginattempts")->fields(array('attempt_name' => $this->request['username'], 'attempt_ip' => $_SERVER['REMOTE_ADDR'], 'attempt_time' => time()))->execute();
             $this->showForm(_gettext('Incorrect username/password.'));
         }
     }
 }
示例#13
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;
 }
示例#14
0
 /**
  * Rebuild a cache using defined $CACHE settings in it's extensions file
  *
  * @param  string  Cache path
  * @param  string  Application
  * @return  @e void
  */
 public static function rebuildCache($path, $app = '')
 {
     $app = kxFunc::alphaNum($app);
     $caches = array();
     if ($app) {
         if ($app == 'base') {
             $caches = self::_implodeConfig(kxEnv::fetchCoreConfig('cache'));
         } else {
             if (isset(kxEnv::$applications[$app]) && !kxFunc::isAppEnabled($app)) {
                 return;
             }
             $caches = self::_implodeConfig(kxEnv::fetchAppConfig($app, 'cache'));
         }
     } else {
         $caches = self::_implodeConfig(kxEnv::fetchCoreConfig('cache'));
         foreach (array_keys($kxEnv::$applications) as $appName) {
             $appCache = self::_implodeConfig(kxEnv::fetchAppConfig($appName, 'cache'));
             if (is_array($appCache)) {
                 $caches = array_merge($caches, $appCache);
             }
         }
     }
     if (isset($caches[$path])) {
         $recacheFile = $caches[$path]['recache_file'];
         if ($recacheFile && is_file($recacheFile)) {
             // If the recache function is in the modules directory, check if we're using a module extender for this module
             if (strpos($recacheFile, '/modules') !== FALSE) {
                 $className = kxFunc::loadModule($recacheFile, $caches[$key]['recache_class']);
             } elseif ($app) {
                 $className = kxFunc::loadHelper($recacheFile, $caches[$key]['recache_class'], $app == 'global' ? 'core' : $app);
             }
             if (!$className) {
                 $className = $caches[$key]['recache_class'];
             }
             $recache = new $className(kxEnv::getInstance());
             if (method_exists($recache, 'makeRegistryShortcuts')) {
                 $recache->makeRegistryShortcuts(kxEnv::getInstance());
             }
             $recache->{$caches}[$path]['recache_function']();
         }
     }
 }
示例#15
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;
         }
     }
 }
示例#16
0
 public function makePost($postData, $post, $files, $ip, $stickied, $locked, $board)
 {
     $timeStamp = time();
     $id = $this->db->insert("posts")->fields(array('post_parent' => $postData['thread_info']['parent'], 'post_board' => $board->board_id, 'post_name' => $post['name'], 'post_tripcode' => $post['tripcode'], 'post_email' => $post['email'], 'post_subject' => $post['subject'], 'post_message' => $post['message'], 'post_password' => $postData['post_fields']['postpassword'], 'post_timestamp' => $timeStamp, 'post_bumped' => $timeStamp, 'post_ip' => kxFunc::encryptMD5($ip, kxEnv::Get('kx:misc:randomseed')), 'post_ip_md5' => md5($ip), 'post_authority' => $postData['user_authority_display'], 'post_tag' => isset($post['tag']) ? $post['tag'] : '', 'post_stickied' => $stickied, 'post_locked' => $locked))->execute();
     if (!$id || kxEnv::Get('kx:db:type') == 'sqlite') {
         // Non-mysql installs don't return the insert ID after insertion, we need to manually get it.
         $id = $this->db->select("posts")->fields("posts", array("post_id"))->condition("post_board", $board->board_id)->condition("post_timestamp", $timeStamp)->condition("post_ip_md5", md5($ip))->range(0, 1)->execute()->fetchField();
     }
     if ($id == 1 && $board->board_start > 1) {
         $this->db->update("posts")->fields(array("id" => $board->board_start))->condition("post_board", $board->board_id)->execute();
         $id = $board->board_start;
     }
     if (!empty($files)) {
         foreach ($files as $file) {
             $this->db->insert("post_files")->fields(array('file_post' => $id, 'file_board' => $board->board_id, 'file_md5' => $file['file_md5'], 'file_name' => $file['file_name'], 'file_type' => substr($file['file_type'], 1), 'file_original' => mb_convert_encoding($file['original_file_name'], 'ASCII', 'UTF-8'), 'file_size' => $file['file_size'], 'file_size_formatted' => $file['file_size'], 'file_image_width' => $file['image_w'], 'file_image_height' => $file['image_h'], 'file_thumb_width' => $file['thumb_w'], 'file_thumb_height' => $file['thumb_h']))->execute();
         }
     } else {
         $this->db->insert("post_files")->fields(array('file_post' => $id, 'file_board' => $board->board_id, 'file_md5' => '', 'file_name' => '', 'file_type' => '', 'file_original' => '', 'file_size' => 0, 'file_size_formatted' => '', 'file_image_width' => 0, 'file_image_height' => 0, 'file_thumb_width' => 0, 'file_thumb_height' => 0))->execute();
     }
     return $id;
 }
示例#17
0
 /**
  * Generate the postbox area
  *
  * @param integer $replythread The ID of the thread being replied to.  0 if not replying
  * @param string $postboxnotice The postbox notice
  * @return string The generated postbox
  */
 public function postBox($replythread = 0)
 {
     if (kxEnv::Get('kx:extras:blotter')) {
         $this->twigData['blotter'] = kxFunc::getBlotter();
         $this->twigData['blotter_updated'] = kxFunc::getBlotterLastUpdated();
     }
 }
示例#18
0
 /**
  * Calls checkRules for each ruleset
  *
  * @access public
  */
 public static function check()
 {
     try {
         foreach (self::$rules as $key => $value) {
             self::_checkRules($key, $value);
         }
     } catch (kxException $kxE) {
         kxFunc::showError($kxE->getMessage());
     }
     self::$values = array();
     self::$rules = array();
 }
示例#19
0
 /**
  * Clean up input data
  *
  * @access	public
  * @param	string		Input
  * @return	string		Cleaned Input
  */
 public static function cleanInputVal($txt)
 {
     if (empty($txt)) {
         return "";
     }
     $txt = kxFunc::strip_magic($txt);
     $search = array("&#032;", "\r\n", "\n\r", "\r", "&", "<!--", "-->", "<", ">", "\n", '"', "<script", "\$", "!", "'");
     $replace = array(" ", "\n", "\n", "\n", "&amp;", "&#60;&#33;--", "--&#62;", "&lt;", "&gt;", "<br />", "&quot;", "&#60;script", "&#036;", "&#33;", "&#39;");
     $txt = str_replace($search, $replace, $txt);
     $txt = preg_replace("/&amp;#([0-9]+);/s", "&#\\1;", $txt);
     $txt = preg_replace("/&#(\\d+?)([^\\d;])/i", "&#\\1;\\2", $txt);
     return $txt;
 }
示例#20
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']);
         }
     }
 }
示例#21
0
文件: bans.php 项目: D4rk4/Kusaba-z
 private function _addBan()
 {
     // TODO: Complete this
     $this->twigData['sections'] = kxFunc::fullBoardList();
     kxTemplate::output('manage/bans_add', $this->twigData);
 }