Пример #1
0
/**
 * @author  ryan <*****@*****.**>
 */
function _init()
{
    $config = $GLOBALS['config'];
    Sdb::setConfig($config['db']);
    // login
    $GLOBALS['user'] = $user = User::loggingUser();
    // but the var here should be long such as $logging_user
    if ($user === false) {
        $has_login = false;
    } else {
        $has_login = true;
    }
    $GLOBALS['has_login'] = $has_login;
    // login check
    $controller = $GLOBALS['controller'];
    if (in_array($controller, $config['login_page']) && !$has_login) {
        redirect("login?back={$controller}/{$target}");
    }
    $GLOBALS['nav'] = $navs = build_nav($config['navs']['admin']);
    $page['description'] = $config['description'];
    $page['keywords'] = $config['keywords'];
}
Пример #2
0
<?php

require 'lib.php';
// functions for test
Sdb::setConfig($config['db']);
// clear side effects for all
// unset all session
foreach ($_SESSION as $key => $value) {
    unset($_SESSION[$key]);
}
if (isset($_GET['u'])) {
    redirect();
}
require_once CORE_ROOT . 'BasicModel.php';
// clear db entries that was insert by test
include 'clear_db.php';
$all_pass = true;
begin_test();
test(1, 1, 'test for 1 === 1');
begin_test();
$username = '******';
$password = '******';
$realname = '小池';
$phone = '13711231212';
$email = '*****@*****.**';
$info = compact('username', 'password', 'realname', 'phone', 'email');
$customer = Customer::create($info);
test(1, 1, array('name' => 'register Customer, db'));
begin_test();
test(User::check($username, $password), true, array('name' => 'User::check($username, $password)'));
begin_test();