Example #1
0
	/**
	 * quickbox::__construct()
	 *
	 * @param array $init Initialization configuration
	 *
	 * Constructor which basically creates quickbox
	 * and readies it for doing things.
	 */
	public function __construct ($init)
	{
		# We need to include initialize the config class because it allows us to get and
		# set configuration variables without using a global
		require $init['quickbox/path'] . '/classes/core/config.class.php';
		config::init($init);
		define(DEBUG, config::get('debug'));
		# Start a database connection
		$this->db = new database();
		try
		{
			$this->db->init();
		} catch (Exception $e)
		{
			trigger_error(text::get('system/fatalError',$e->getMessage()), E_USER_ERROR);
		}
		require $init['quickbox/path'] . '/classes/core/metaclass.class.php';
		metaclass::init($this->db);
		# Put the post and get variables into a private for later use.
		$_POST = $_POST;
		$this->qbGet = $_GET;
		# Start the session, giving it the database connection.
		$this->qbSession = new session($this->db);
		if ($this->qbGet['page'] == 'logout')
		{
			$this->qbSession->logout();
		}
		$this->qbSession->checkCookie();
		if (strlen($_POST['user']) > 0 && $_POST['login'] == 1)
		{
			$this->qbErrors['login'] = $this->qbSession->login($_POST['user'], $_POST['password']);
		}
		$this->qbPage = ($_GET['page'] ? janitor::cleanData($_GET['page']) : 'home');
	}
 /**
  * 初始化获取配置文件
  * @return void
  */
 public function initConfig()
 {
     config::init();
 }
Example #3
0
        }
    }
    /**
     * Get configuration parameter by key
     * @param string $key data-array key
     * @return null
     */
    public static function get($key)
    {
        if (isset(self::$_data[$key])) {
            return self::$_data[$key];
        }
        return null;
    }
}
config::init();
function __autoload($class)
{
    scan(config::get('base_path'), $class);
}
function scan($path = '.', $class)
{
    $ignore = array('.', '..');
    $dh = opendir($path);
    while (false !== ($file = readdir($dh))) {
        if (!in_array($file, $ignore)) {
            if (is_dir($path . DIRECTORY_SEPARATOR . $file)) {
                scan($path . DIRECTORY_SEPARATOR . $file, $class);
            } else {
                if ($file === 'class.' . $class . '.php') {
                    require_once $path . DIRECTORY_SEPARATOR . $file;
Example #4
0
File: txf.php Project: cepharum/txf
 /**
  * Gets called on single instance being selected initially.
  *
  */
 public function onLoad()
 {
     // install class autoloader
     spl_autoload_register(array(get_class($this), 'classAutoloader'));
     // analyse pathnames and prepare context for addressing related resources
     $this->context = new context();
     if (!is_dir($this->context->application->pathname)) {
         throw new \InvalidArgumentException('no such application');
     }
     // declare some constants for improving performance on accessing TXF context
     define('TXF_INSTALL_PATH', $this->context->installationPathname);
     define('TXF_FRAMEWORK_PATH', $this->context->frameworkPathname);
     define('TXF_URL', $this->context->url);
     define('TXF_APPLICATION', $this->context->application->name);
     define('TXF_APPLICATION_PATH', $this->context->application->pathname);
     define('TXF_APPLICATION_URL', $this->context->application->url);
     define('TXF_SCRIPT_PATH', $this->context->application->script);
     define('TXF_SCRIPT_NAME', pathinfo(TXF_SCRIPT_PATH, PATHINFO_FILENAME));
     // prepare URL prefix to use on compiling relative URLs pointing to
     // current application's public root
     define('TXF_RELATIVE_PREFIX', $this->context->application->relativePrefix());
     // start runtime configuration support
     config::init();
     // support configuration option to enable/disable errors displayed in output
     ini_set('display_errors', config::get('php.display_errors', false));
     // enable internal class redirection support
     $this->initializeClassRedirections();
     // open managed session space
     $this->session = session::current();
     /*
      * basically put further initialization below this comment
      */
 }