private function _getMenu($savetofile = false, $option = false) { //$twigData['boardpath'] = getCLBoardPath(); $twigData['styles'] = explode(':', kxEnv::Get('kx:css:menustyles')); if ($savetofile) { $file = 'menu.html'; } else { $file = 'menu.php'; } $twigData['file'] = $file; $sections = array(); $boardsExist = $this->db->select("boards")->fields("boards")->countQuery()->execute()->fetchField(); if ($boardsExist) { $sections = $this->db->select("sections")->fields("sections")->orderBy("section_order")->execute()->fetchAll(); $results = $this->db->select("boards")->fields("boards", array("board_order", "board_name", "board_desc", "board_locked", "board_trial", "board_popular"))->where("section = ?")->orderBy("board_order")->orderBy("board_name")->build(); foreach ($sections as $key => $section) { $results->execute(array($section['id'])); $boards = $results->fetchAll(); $sections[$key]['boards'] = $boards; } } $twigData['boards'] = $sections; if ($savetofile) { file_put_contents(KX_ROOT . '/menu.html', kxTemplate::get('menu', $twigData)); return true; } else { return kxTemplate::get('menu', $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 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_&'), "", $whereto); $whereto = str_replace("module=login", "", $whereto); $whereto = str_replace("do=login-validate", "", $whereto); $whereto = str_replace('&', '&', $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.')); } } }
public function exec(kxEnv $environment) { if (isset($this->request['p'])) { switch ($this->request['p']) { case 'faq': $type = 1; break; case 'rules': $type = 2; break; } } else { $this->request['p'] = ''; $type = 0; } $this->twigData['styles'] = explode(':', kxEnv::Get('kx:css:menustyles')); $entries = $this->db->select("front")->fields("front")->condition("entry_type", $type); if ($this->request['p'] != '') { $entries->orderBy("entry_order", "ASC"); } else { $entries->orderBy("entry_time", "DESC"); if (!isset($this->request['view'])) { $entries->range(0, 1); } } $this->twigData['entries'] = $entries->execute()->fetchAll(); $sections = $this->db->select("sections")->fields("sections")->orderBy("section_order")->execute()->fetchAll(); $boards = $this->db->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(); } $this->twigData['sections'] = $sections; // Get recent images $images = $this->db->select("post_files"); $images->innerJoin("posts", "", "post_id = file_post AND post_board = file_board"); $images = $images->fields("post_files", array("file_name", "file_type", "file_board", "file_thumb_width", "file_thumb_height"))->fields("posts", array("post_id", "post_parent"))->condition("file_name", "", "!=")->orderBy("post_timestamp", "DESC")->range(0, 3)->execute()->fetchAll(); $i = 0; if (count($images) > 0) { $results = $this->db->select('boards')->fields('boards', array('board_name'))->where('board_id = ?')->range(0, 1)->build(); while ($i < count($images)) { $results->execute(array($images[$i]->board_id)); $board = $results->fetchAll(); $images[$i]->boardname = $board[0]->board_name; $i++; } } $this->twigData['images'] = $images; kxTemplate::output("index", $this->twigData); }
/** * Allows adding, editing, and deleting of staff members */ private function _show() { $twigData = array(); if ($_GET['act'] == 'add' && $_POST) { // Adds a new staff member kxForm::addRule('username', 'required')->addRule('pwd1', 'required')->addRule('pwd1', 'value', true, $this->request['pwd2'])->addRule('type', 'numeric')->check(); $results = $this->db->select("staff")->fields("staff")->condition("user_name", $this->request['username'])->countQuery()->execute()->fetchField(); if ($results == 0) { $salt = substr(md5(time() . kxEnv::Get('kx:misc:randomseed')), -rand(3, 6)); //$this->_createSalt(); TODO: Decide hashing algorithm, replace current $this->db->insert("staff")->fields(array('user_name' => $this->request['username'], 'user_password' => md5($this->request['pwd1'] . $salt), 'user_salt' => $salt, 'user_type' => intval($this->request['type']), 'user_add_time' => time()))->execute(); $twigData['notice_type'] = 'success'; $twigData['notice'] = _gettext('User added successfully'); } else { // User with that username already exists $twigData['notice_type'] = 'error'; $twigData['notice'] = _gettext('A user with that username already exists'); } } elseif ($_GET['act'] == 'edit') { // Edits a user's information kxForm::addRule('id', 'numeric')->check(); $user = $this->db->select("staff")->fields("staff", array("user_id", "user_name", "user_salt", "user_type"))->condition("user_id", $this->request['id'])->execute()->fetch(); if ($_POST) { kxForm::addRule('pwd1', 'value', true, $this->request['pwd2'])->addRule('type', 'numeric')->check(); $values = array('user_type' => $this->request['type']); if (!empty($this->request['pwd1'])) { $values['user_password'] = md5($this->request['pwd1'] . $user['user_salt']); } $this->db->update("staff")->fields($values)->condition("user_id", $this->request['id'])->execute(); $twigData['notice_type'] = 'success'; $twigData['notice'] = _gettext('User info updated!'); } $twigData['user'] = $user; } elseif ($_GET['act'] == 'del') { // Deletes a user kxForm::addRule('id', 'numeric')->check(); $user_exists = $this->db->select("staff")->condition("user_id", $this->request['id'])->countQuery()->execute()->fetchField(); if ($user_exists) { $this->db->delete("staff")->condition("user_id", $this->request['id'])->execute(); $twigData['notice_type'] = 'success'; $twigData['notice'] = _gettext('User successfully deleted!'); } else { $twigData['notice_type'] = 'error'; $twigData['notice'] = _gettext('A user with that ID does not exist'); } } $staff = $this->db->select("staff")->fields("staff")->orderBy("user_type")->orderBy("user_add_time")->execute()->fetchAll(); $twigData['staffmembers'] = $staff; kxTemplate::output("manage/staff_show", $twigData); }
public function execute($params = array()) { return parent::execute($params); if (kxEnv::Get('kx:misc:debug')) { $errorinfo = parent::errorInfo(); echo "<pre>(" . KU_DBTYPE . ") " . self::getSQL($params); echo "\nError (" . $errorinfo[0] . ") " . $errorinfo[2] . "\n\n</pre>"; } }
/** * 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. ' . '</a>' . $reflink_quote . $post_id . '</a>'; } return $return . "\n"; }
/** * Do execute method * * @access protected * @param object kxCmd reference * @return void */ protected function exec(kxEnv $environment) { @header("Location: " . kxEnv::Get('kx:paths:main:path') . kxEnv::Get('kx:paths:main:folder')); }
/** * Get started */ private function init() { if (self::$initiated !== TRUE) { //--------------------------------------------------------------------------------- // Are we using a caching engine? // Check in the following order (most ideal to least): // WinCache, APC, Memcache, Xcache, eaccelerator (yuck), disk cache (double yuck) //--------------------------------------------------------------------------------- // Wincache if (function_exists('wincache_ucache_info') && kxEnv::Get('kx:cache:wincache')) { require KX_LIB . '/kxCache/cacheInterface.php'; require KX_LIB . '/kxCache/cacheWincache.php'; self::$cacheLib = new cacheWincache(kxEnv::Get('kx:paths:main:path')); } else { if (function_exists('apc_cache_info') && kxEnv::Get('kx:cache:apc')) { require KX_LIB . '/kxCache/engines/cacheInterface.php'; require KX_LIB . '/kxCache/engines/cacheApc.php'; self::$cacheLib = new classCacheApc(kxEnv::Get('kx:paths:main:path')); } else { if (function_exists('memcache_connect') && kxEnv::Get('kx:cache:memcache:enabled')) { require KX_LIB . '/kxCache/engines/cacheInterface.php'; require KX_LIB . '/kxCache/engines/cacheMemcache.php'; self::$cacheLib = new classCacheMemcache(kxEnv::Get('kx:paths:main:path'), kxEnv::Get('kx:cache:memcache')); } else { if (function_exists('xcache_info') && kxEnv::Get('kx:cache:xcache')) { require KX_LIB . '/kxCache/engines/cacheInterface.php'; require KX_LIB . '/kxCache/engines/cacheXcache.php'; require IPS_KERNEL_PATH . 'classCacheXcache.php'; /*noLibHook*/ self::$cacheLib = new classCacheXcache(kxEnv::Get('kx:paths:main:path')); } else { if (function_exists('eaccelerator_put') && kxEnv::Get('kx:cache:eaccelerator')) { require KX_LIB . '/kxCache/engines/cacheInterface.php'; require KX_LIB . '/kxCache/engines/cacheEaccelerator.php'; self::$cacheLib = new classCacheEaccelerator(kxEnv::Get('kx:paths:main:path')); } else { if (kxEnv::Get('kx:cache:diskcache')) { require KX_LIB . '/kxCache/engines/cacheInterface.php'; require KX_LIB . '/kxCache/engines/cacheDisk.php'; self::$cacheLib = new classCacheDiskcache(kxEnv::Get('kx:paths:main:path')); } } } } } } if (is_object(self::$cacheLib) && self::$cacheLib->fail) { // Failsafe in case the cache library somehow manages to load despite not having it installed? self::$cacheLib = NULL; } $caches = array(); for ($i = 0; $i < 2; $i++) { if ($i == 0) { // Load the global cache $cacheData = kxEnv::fetchCoreConfig('cache'); $caches = self::_implodeConfig($cacheData); $loads = kxEnv::fetchCoreConfig('cachetoload'); } else { // Load the cache for this app $cacheData = kxEnv::fetchAppConfig(KX_CURRENT_APP, 'cache'); $caches = self::_implodeConfig($cacheData); $loads = kxEnv::fetchAppConfig(KX_CURRENT_APP, 'cachetoload'); } if (is_array($caches)) { foreach ($caches as $path => $info) { if (!IN_MANAGE && !empty($info['manage'])) { continue; } if ($info['force_load']) { $loadCaches[$path] = $path; } } if (count($loads)) { foreach (array_keys($loads) as $path) { $loadCaches[$path] = $path; } } } } // Let's do it self::_loadCaches($loadCaches); } self::$initiated = TRUE; }
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); } }
public static function UpdateHtaccess() { $htaccess_contents = file_get_contents(KX_BOARD . '.htaccess'); $htaccess_contents_preserve = substr($htaccess_contents, 0, strpos($htaccess_contents, '## !KU_BANS:') + 12) . "\n"; $htaccess_contents_bans_iplist = ''; $results = $kx_db->GetAll("SELECT `ip` FROM `" . kxEnv::Get('kx:db:prefix') . "banlist` WHERE `allowread` = 0 AND `type` = 0 AND (`expired` = 1) ORDER BY `ip` ASC"); if (count($results) > 0) { $htaccess_contents_bans_iplist .= 'RewriteCond %{REMOTE_ADDR} ('; foreach ($results as $line) { $htaccess_contents_bans_iplist .= str_replace('.', '\\.', md5_decrypt($line['ip'], kxEnv::Get('kx:misc:randomseed'))) . '|'; } $htaccess_contents_bans_iplist = substr($htaccess_contents_bans_iplist, 0, -1); $htaccess_contents_bans_iplist .= ')$' . "\n"; } if ($htaccess_contents_bans_iplist != '') { $htaccess_contents_bans_start = "<IfModule mod_rewrite.c>\nRewriteEngine On\n"; $htaccess_contents_bans_end = "RewriteRule !^(banned.php|youarebanned.jpg|favicon.ico|css/site_futaba.css)\$ " . kxEnv::Get('kx:paths:boards:folder') . "banned.php [L]\n</IfModule>"; } else { $htaccess_contents_bans_start = ''; $htaccess_contents_bans_end = ''; } $htaccess_contents_new = $htaccess_contents_preserve . $htaccess_contents_bans_start . $htaccess_contents_bans_iplist . $htaccess_contents_bans_end; file_put_contents(KX_BOARD . '.htaccess', $htaccess_contents_new); }
/** * 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(); } }
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; }
/** * gettext: Looks up message in current domain * faketext: same */ function _gettext($message) { global $faketext; //Ugly hack, if our locale is english, remove $faketext so strings don't get translated if (kxEnv::Get('kx:misc:locale') == 'en' && !empty($faketext)) { unset($faketext); } return !empty($faketext[$message]) ? $faketext[$message] : $message; }
public function wordFilter(&$buffer) { $filters = kxEnv::Get("cache:filters:wordfilters"); foreach ($filters as $filter) { if ((!$filter->filter_boards || in_array($this->environment->get("kx:classes:board:id"), unserialize($filter->filter_boards))) && (!$filter->filter_regex && kxMb::stripos($buffer, $filter->filter_word) !== false) || $filter->filter_regex && preg_match($filter->filter_word, $buffer)) { $buffer = $filter->filter_regex == 1 ? preg_replace($filter->filter_word, $filter->filter_replace, $buffer) : str_ireplace($filter->filter_word, $filter->filter_replace, $buffer); } } }