All pastes #744677 Raw Edit

Stuff

public text v1 · immutable
·published 2007-10-21 18:27 UTC
rendered paste body
<?php
require 'config.local.php';

set_include_path(INTRAFACE_PATH_INCLUDE);

require 'k.php';

class tools_ClassLoader extends k_classLoader
{
  static function pear_autoload($classname) {
    $filename = str_replace('_', '/', $classname).'.php';
    if (self::SearchIncludePath($filename)) {
      require_once($filename);
    }
  }
}

spl_autoload_register(Array('tools_ClassLoader', 'pear_autoload'));

class User
{
    private $user;
    private $password;

    function checkRight($right)
    {
        if (!$this->isLoggedIn()) {
            return false;
        }
        return true;
    }

    function login($user, $password)
    {
        $this->user     = $user;
        $this->password = $password;
    }

    function isLoggedIn()
    {
        if ($this->user) {
            return true;
        }
        return false;
    }
}

$application = new Intraface_Tools_Controller_Root();

$application->registry->registerConstructor('errorlist', create_function(
  '$className, $args, $registry',
  'return new Intraface_Tools_ErrorList($args);'
));

$application->registry->registerConstructor('database', create_function(
  '$className, $args, $registry',
  'return MDB2::singleton("mysql://root:@localhost/intraface");'
));

$application->registry->registerConstructor('db_sql', create_function(
  '$className, $args, $registry',
  'return new DB_Sql;'
));

$application->dispatch();