Beispiel #1
0
 public function recacheFiletypes()
 {
     // Get all the filetypes...
     $recache_filetypes = $this->db->select("filetypes")->fields("filetypes")->orderBy("type_id")->execute()->fetchAll();
     /*echo '<pre>';
       print_r($recache_filetypes);
       echo '</pre>';*/
     // Cache them
     kxEnv::set('cache:attachments:filetypes', $recache_filetypes);
 }
Beispiel #2
0
 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();
 }
Beispiel #3
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;
 }
Beispiel #4
0
<?php

DEFINE('KX_ROOT', realpath(dirname(__FILE__)));
DEFINE('KX_BOARD', KX_ROOT);
DEFINE('KX_SCRIPT', KX_ROOT);
DEFINE('KX_LIB', KX_ROOT . '/application/lib/kx');
// Full path to kx's library files
DEFINE('KUSABA_RUNNING', true);
require_once KX_LIB . "/../Twig/Autoloader.php";
Twig_Autoloader::register();
require_once KX_LIB . '/kxAutoload.class.php';
require_once KX_ROOT . '/application/lib/gettext/gettext.inc.php';
$repository = kxAutoload::registerRepository(KX_LIB, array('prefix' => 'kx'));
// Add the autoloader repository in kx's lib dir, listen only for classes starting with the string 'kx'
kxEnv::initialize('dev', KX_ROOT . '/config');
// Setup the main environment, make it read config files etc, the lots
kxEnv::set('kx:autoload:repository:kx:id', $repository);
// If we want to unload the kx autoloader at some point, store the id here.
// Cleanup global namespace
unset($repository);