function cs_init($predefined) { @error_reporting(E_ALL | E_STRICT); @set_error_handler("php_error"); @ini_set('short_open_tag', 'off'); @ini_set('arg_separator.output', '&'); @ini_set('session.use_trans_sid', '0'); @ini_set('session.use_cookies', '1'); @ini_set('session.use_only_cookies', '1'); @ini_set('display_errors', 'on'); $phpversion = phpversion(); if (version_compare($phpversion, '5.1', '>=')) { @date_default_timezone_set('Europe/Berlin'); } global $account, $com_lang, $cs_db, $cs_logs, $cs_main, $cs_micro, $cs_template; $cs_micro = explode(' ', microtime()); # starting parsetime $cs_logs = array('php_errors' => '', 'errors' => '', 'sql' => '', 'queries' => 0, 'warnings' => 1, 'dir' => 'uploads/logs'); $cs_main['cellspacing'] = 1; $cs_main['def_lang'] = empty($cs_main['def_lang']) ? 'English' : $cs_main['def_lang']; $cs_main['def_theme'] = empty($cs_main['def_theme']) ? 'base' : $cs_main['def_theme']; $cs_main['xsrf_protection'] = true; $cs_main['zlib'] = true; require_once 'system/core/servervars.php'; $cs_main['ajaxrequest'] = isset($_REQUEST['xhr']) ? true : false; require_once 'system/core/tools.php'; require_once 'system/core/abcode.php'; require_once 'system/core/templates.php'; require_once 'system/core/gd.php'; require_once 'system/core/cachegen.php'; $cs_main['cache_mode'] = 'file'; if (version_compare($phpversion, '5.0', '<')) { require_once 'mods/clansphere/fallback.php'; } if ($cs_main['php_self']['basename'] == 'install.php') { $account = array('users_id' => 0, 'access_clansphere' => 0, 'access_errors' => 2, 'access_install' => 5); } else { file_exists('setup.php') ? require_once 'setup.php' : die(cs_error_internal('setup', '<a href="' . $cs_main['php_self']['dirname'] . 'install.php">Installation</a>')); } if (!in_array($cs_main['cache_mode'], array('file', 'none')) and !extension_loaded($cs_main['cache_mode'])) { $cs_main['cache_mode'] = 'file'; } require_once 'system/cache/' . $cs_main['cache_mode'] . '.php'; if (empty($cs_main['charset'])) { $cs_main['charset'] = 'UTF-8'; die(cs_error_internal(0, 'No charset information found in setup.php')); } # backfall if json extension is not available if (!extension_loaded('json')) { require_once 'system/output/json.php'; } require_once 'system/output/xhtml_10.php'; # add old xhtml functions if needed if (!empty($cs_main['xhtml_old'])) { require_once 'system/output/xhtml_10_old.php'; } if (!empty($predefined['init_sql'])) { require_once 'system/database/' . $cs_db['type'] . '.php'; $cs_db['con'] = cs_sql_connect($cs_db); unset($cs_db['pwd'], $cs_db['user']); $cs_options = cs_sql_option(__FILE__, 'clansphere'); $cs_options['unicode'] = extension_loaded('unicode') ? 1 : 0; if (!isset($cs_options['cache_unicode']) or $cs_options['cache_unicode'] != $cs_options['unicode']) { cs_cache_clear(); } } else { $cs_options = array(); } $cs_main = array_merge($cs_main, $cs_options, $predefined); if (empty($cs_main['def_path'])) { $cs_main['def_path'] = getcwd(); } # process mod and action data $cs_main = cs_content_prepare($cs_main); if (!empty($predefined['init_sql'])) { require_once 'system/core/account.php'; $cs_main['def_theme'] = empty($account['users_theme']) ? $cs_main['def_theme'] : $account['users_theme']; } # determine users language $account['users_lang'] = cs_content_lang(); if (!empty($predefined['init_sql'])) { # check for deprecated runstartup behavior if (!empty($cs_main['runstartup'])) { cs_tasks('system/runstartup'); } # fetch startup files $startup = cs_cache_load('startup'); # fallback to create startup files overview if ($startup == false) { $startup = cs_cache_dirs('mods', $account['users_lang'], 1); } # execute startup files if (is_array($startup)) { foreach ($startup as $mod) { $file = $cs_main['def_path'] . '/mods/' . $mod . '/startup.php'; file_exists($file) ? include_once $file : cs_error($file, 'cs_init - Startup file not found'); } } } # search for possible mod and action errors $cs_main = cs_content_check($cs_main); $cs_main['template'] = empty($cs_main['def_tpl']) ? 'clansphere' : $cs_main['def_tpl']; $cs_template = cs_template_info($cs_main['template']); if (!empty($_GET['template']) and preg_match("=^[_a-z0-9-]+\$=i", $_GET['template'])) { $cs_main['template'] = $_GET['template']; } if (!empty($predefined['init_tpl'])) { if ($cs_main['ajaxrequest'] === true) { echo cs_ajaxwrap(); } else { echo cs_template($cs_micro, $cs_main['tpl_file']); } } }
if (empty($cs_db['type'])) { $error++; $errormsg .= $cs_lang['no_type'] . cs_html_br(1); } if (empty($cs_db['name'])) { $error++; $errormsg .= $cs_lang['no_name'] . cs_html_br(1); } if (!preg_match("=^[a-z0-9]+\$=i", $cs_db['prefix'])) { $error++; $errormsg .= $cs_lang['prefix_err'] . cs_html_br(1); } if (empty($error)) { if (isset($sql_files['' . $cs_db['type'] . '.php'])) { include_once 'system/database/' . $cs_db['type'] . '.php'; $dberr = cs_sql_connect($cs_db, 1); } else { $dberr = 'Extension could not be found'; } } if (!empty($dberr)) { $error++; $errormsg = $cs_lang['db_err'] . ' ' . nl2br($dberr); } if (empty($error)) { $setup_php = "<?php\n\n\$cs_db['hash'] = '" . $cs_db['hash'] . "'; # don't change!\n"; $setup_php .= "\$cs_db['type'] = '" . $cs_db['type'] . "';\n"; $setup_php .= "\$cs_db['subtype'] = '" . $cs_db['subtype'] . "';\n"; $setup_php .= "\$cs_db['place'] = '" . $cs_db['place'] . "';\n"; $setup_php .= "\$cs_db['user'] = '******'user'] . "';\n"; $setup_php .= "\$cs_db['pwd'] = '" . $cs_db['pwd'] . "';\n";
<?php // ClanSphere 2010 - www.clansphere.net // $Id$ # Overwrite global settings by using the following array $cs_main = array('charset' => 'UTF-8', 'def_action' => 'list', 'def_mod' => 'install', 'def_title' => 'ClanSphere Installation', 'def_tpl' => 'install', 'def_parameters' => '', 'def_width' => '100%', 'init_sql' => false, 'init_tpl' => false, 'public' => 1, 'img_path' => 'crystal_project', 'img_ext' => 'png', 'version_name' => '', 'version_date' => '', 'zlib' => false); require_once 'system/core/functions.php'; cs_init($cs_main); if (file_exists('setup.php')) { require 'setup.php'; require 'system/database/' . $cs_db['type'] . '.php'; $cs_db['con'] = cs_sql_connect($cs_db); unset($cs_db['pwd'], $cs_db['user']); } else { global $cs_logs; $cs_logs['save_actions'] = 0; $cs_logs['save_errors'] = 1; } echo cs_template($cs_micro);