示例#1
0
/**
 * Reset CodeIgniter instance
 */
function reset_instance()
{
    // Reset loaded classes
    load_class('', '', NULL, TRUE);
    is_loaded('', TRUE);
    // Reset config functions
    reset_config();
    // Close db connection
    $CI =& get_instance();
    if (isset($CI->db)) {
        if ($CI->db->dsn !== 'sqlite::memory:' && $CI->db->database !== ':memory:') {
            $CI->db->close();
            $CI->db = null;
        } else {
            // Don't close if SQLite in-memory database
            // If we close it, all tables and stored data will be gone
            load_class_instance('db', $CI->db);
        }
    }
    // Load core classes
    $BM =& load_class('Benchmark', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('BM', $BM);
    $EXT =& load_class('Hooks', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('EXT', $EXT);
    $CFG =& load_class('Config', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('CFG', $CFG);
    $UNI =& load_class('URI', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('UNI', $UNI);
    //	$URI =& load_class('Utf8', 'core');
    //	CIPHPUnitTestSuperGlobal::set_Global('URI', $URI);
    $RTR =& load_class('Router', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('RTR', $RTR);
    $OUT =& load_class('Output', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('OUT', $OUT);
    $SEC =& load_class('Security', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('SEC', $SEC);
    $IN =& load_class('Input', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('IN', $IN);
    $LANG =& load_class('Lang', 'core');
    CIPHPUnitTestSuperGlobal::set_Global('LANG', $LANG);
    CIPHPUnitTest::loadLoader();
    // Remove CodeIgniter instance
    $CI = new CIPHPUnitTestNullCodeIgniter();
}
示例#2
0
function create_user($username, $password)
{
    global $conf_base_path, $conf_nodes, $conf_c9_group, $conf_defaults_path, $users;
    global $is_storage_node, $is_control_node, $is_svn_node, $storage_node_addr;
    $forbidden_usernames = array('root', 'daemon', 'bin', 'sys', 'sync', 'games', 'man', 'lp', 'mail', 'news', 'uucp', 'proxy', 'www-data', 'backup', 'list', 'irc', 'gnats', 'nobody', 'libuuid', 'syslog', 'messagebus', 'landscape', 'sshd', 'c9test', 'c9');
    if (in_array($username, $forbidden_usernames)) {
        debug_log("forbidden username {$username}");
        print "ERROR: username {$username} not allowed\n";
        return;
    }
    $userdata = setup_paths($username);
    if ($is_control_node) {
        debug_log("create_user {$username}");
    }
    // Create user on storage node
    if ($is_storage_node) {
        exec("useradd -d " . $userdata['home'] . " -g {$conf_c9_group} -k {$conf_defaults_path}/home -m " . $userdata['esa']);
        // For some reason files copied from default home aren't owned by user :(
        exec("chown -R " . $userdata['esa'] . ":{$conf_c9_group} " . $userdata['home']);
    } else {
        if ($is_control_node) {
            run_on($storage_node_addr, "{$conf_base_path}/bin/webidectl add-user " . $userdata['esa'] . " " . escapeshellarg($password));
        }
        exec("useradd -d " . $userdata['home'] . " -g {$conf_c9_group} " . $userdata['esa']);
    }
    // If this is control node, create user on other nodes
    if ($is_control_node) {
        foreach ($conf_nodes as $node) {
            if (!in_array("control", $node['type']) && !in_array("compute", $node['type']) && !in_array("svn", $node['type'])) {
                continue;
            }
            if (!is_local($node['address']) && !in_array("control", $node['type'])) {
                run_on($node['address'], "{$conf_base_path}/bin/webidectl add-user " . $userdata['esa'] . " " . escapeshellarg($password));
            }
        }
    }
    // If this is svn node, create repo
    if ($is_svn_node) {
        user_create_svn_workspace($username);
    }
    // Copy defaults
    if ($is_storage_node && $is_control_node) {
        reset_config($username);
    } else {
        if ($is_control_node) {
            run_on($storage_node_addr, "{$conf_base_path}/bin/webidectl reset-config " . $userdata['esa']);
        }
    }
    // Add default files to SVN
    if ($is_svn_node) {
        run_as($username, "cd " . $userdata['workspace'] . "; svn add *; svn ci -m import .");
    }
    // Init git on storage node and fix
    if ($is_storage_node && $is_control_node) {
        git_init($username);
    } else {
        if ($is_control_node) {
            run_on($storage_node_addr, "{$conf_base_path}/bin/webidectl git-init " . $userdata['esa']);
        }
    }
    // Fix c9 link
    if ($is_control_node) {
        run_as($username, "cd " . $userdata['home'] . "; ln -s {$conf_base_path}/c9fork fork");
    }
    $users[$username] = array();
    $users[$username]['status'] = "inactive";
    write_files();
}
示例#3
0
文件: config.php 项目: jechiy/xiu-cms
$config['S_DB_PREFIX'] = '';
$config['S_ROOT'] = '';
$config['S_TPL_PATH'] = 'templates/default/';
$config['S_LANG'] = 'zh-cn';
$config['S_URL_PREFIX'] = '?/';
$config['S_URL_SUFFIX'] = 'index.html';
$config['S_URL_REWRITE'] = 0;
$config['S_HALF_STATIC'] = 0;
$config['S_SHAM_STATIC'] = 0;
$config['S_PURE_STATIC'] = 0;
$config['S_SESSION'] = 1;
$config['S_FLASH'] = 0;
$config['S_MULTILINGUAL'] = 0;
$config['S_BROWSER'] = 'pc';
$config['S_SERVER_URL'] = 'http://data.sinsiu.com/';
reset_config();
function reset_config()
{
    global $config, $re_config;
    $root = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));
    if ($root != '/' && $root != '') {
        $root .= '/';
    }
    $re_config['S_ROOT'] = $root;
    include 'include/browser.class.php';
    $obj = new browser();
    $re_config['S_BROWSER'] = $obj->check_browser();
    foreach ($re_config as $key => $value) {
        $config[$key] = $value;
    }
    foreach ($config as $key => $value) {