", " "); $replace = array(""", "'", "\", """, "'", "<", ">", " "); $text = str_replace($search, $replace, $text); return $text; } function is_function_available($function) { $available = true; if ( ! function_exists( $function ) ) { if ( ! ini_get( $function ) ) { $available = false; } else { $d = ini_get('disable_functions'); $s = ini_get('suhosin.executor.func.blacklist'); if ("$d$s") { $array = preg_split('/,\s*/', "$d,$s"); if ( in_array( $function, $array ) ) { $available = false; } } } } else { $d = ini_get('disable_functions'); $s = ini_get('suhosin.executor.func.blacklist'); if ("$d$s") { $array = preg_split('/,\s*/', "$d,$s"); if (in_array($function, $array)) { $available = false; } } } return $available; } session_start(); if ( !isset($_SESSION['users_lang']) ) $_SESSION['users_lang'] = "English"; if ( isset($_GET['localeset']) ) $_SESSION['users_lang'] = $_GET['localeset']; define("REQUIRED_PHP_VERSION", "5.3"); require_once("includes/helpers.php"); require_once("includes/view.php"); require_once("includes/lang.php"); require_once("includes/html_functions.php"); require_once("includes/functions.php"); ogpLang(); $view = new OGPView(); $view->setCharset(get_lang('lang_charset')); ?>
".get_lang('install_lang')."
"; echo "\n"; for ($i=0;$i < count($locale_files);$i++) { if ($counter != 0 && ($counter % $columns == 0)) echo "\n\n"; echo "\n"; $counter++; } echo "\n
"; if ($locale_files[$i] == $_SESSION['users_lang']) { echo "
  • ".$locale_files[$i]."
  • "; } else { echo "
  • ".$locale_files[$i]."
  • "; } echo "
    \n"; echo "
    ".get_lang('install_welcome')."
    "; echo "

    ".get_lang('file_permission_check').":

    "; $failed = false; echo "\n"; // config.inc.php is checked seperately because we need to check first if the file // exists or not. $value = 'includes/config.inc.php'; if ( !is_file($value) ) { @$control = fopen($value,"w+"); if($control == false){ echo ""; $failed = true; } } else if ( !is_writable($value) ) { echo ""; $failed = true; } else { echo ""; } // Check if the folder "modules/TS3Admin/templates_c" is writable $value = 'modules/TS3Admin/templates_c'; if ( !is_writable($value) ) { echo ""; $failed = true; } else { echo ""; } echo "
    ".$value."". get_lang('create_an_empty_file')."
    ".$value."". get_lang('write_permission_required')."
    ".$value."".get_lang('OK')."
    ".$value."". get_lang('write_permission_required')."
    ".$value."".get_lang('OK')."
    "; echo "

    ".get_lang('php_version_check').":

    \n"; echo ""; echo "
    PHP Version >= ".REQUIRED_PHP_VERSION.""; if ( version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, ">=") ) { echo "".PHP_VERSION.""; } else { echo "".PHP_VERSION.""; $failed = true; } echo "
    "; /* TODO: how to check if pear is enabled or not? */ $properties_to_check = array( array( "name" => "PHP XML-RPC module", "type" => "f", "value" => "xmlrpc_server_create" ), array( "name" => "PHP Curl module", "type" => "f", "value" => "curl_init" ), array( "name" => "PHP XML Reader", "type" => "c", "value" => "XMLReader" ), array( "name" => "PHP JSON Extension", "type" => "f", "value" => "json_decode" ), array( "name" => "PHP Zip Extension", "type" => "c", "value" => "ZipArchive" ), array( "name" => "PHP mbstring Extension", "type" => "x", "value" => "mbstring" ), array( "name" => "PHP MySQLi Extension", "type" => "f", "value" => "mysqli_connect" )); $optional_properties_to_check = array( array( "name" => "PHP BCMath Extension", "type" => "f", "value" => "bcadd" ), ); echo "

    ".get_lang('checking_required_modules').":

    \n"; foreach ( $properties_to_check as $propertie ) { if(preReqInstalled($propertie)){ echo ""; }else{ echo ""; $failed = true; } } echo ""; echo ""; echo ""; echo ""; echo "
    ".$propertie['name']."".get_lang('found')."
    ".$propertie['name']."".get_lang('not_found')."
    Pear XXTEA"; $xxtea_found = false; $pear_found = false; // Lets search for XXTEA pear module from include path. $include_paths = explode(PATH_SEPARATOR, get_include_path()); foreach ( $include_paths as $include_path ) { if ( file_exists( $include_path."/"."Crypt/XXTEA.php") ) $xxtea_found = true; // Pear always includes System.php file that should be found from the include path. if ( file_exists( $include_path."/"."System.php") ) $pear_found = true; } if ( $xxtea_found ) { print_success(get_lang('found')); } else { print_failure(get_lang('not_found')); echo "

    ".get_lang('pear_xxtea_info')."

    "; $failed = true; } echo "
    Pear"; if ( $pear_found ) { print_success(get_lang('found')); } else { print_failure(get_lang('not_found')); $failed = true; } echo "
    file_get_contents()"; if ( is_function_available('file_get_contents') ) { print_success(get_lang('found')); } else { print_failure(get_lang('not_found')); $failed = true; } echo "
    allow_url_fopen=on"; if ( is_function_available('allow_url_fopen') ) { print_success(get_lang('found')); } else { print_failure(get_lang('not_found')); $failed = true; } echo "
    \n"; echo "

    ".get_lang('checking_optional_modules').":

    \n"; foreach ( $optional_properties_to_check as $propertie ) { if(preReqInstalled($propertie)){ echo ""; }else{ echo ""; } } echo "
    ".$propertie['name']."".get_lang('found')."
    ".$propertie['name']."".get_lang('not_found')."
    \n"; if ( $failed ) { echo "

    ".get_lang('refresh')."

    \n"; } else { echo "

    ".get_lang('next')."

    \n"; } echo "\n"; } else if ( $step == "1" ) { echo "
    \n"; if ( is_readable('includes/config.inc.php') ) require_once "includes/config.inc.php"; echo "
    "; echo "\n"; echo ""; echo ""; echo "
    ".get_lang('database_settings')."
    ".get_lang('database_type').":MySQL
    ".get_lang('database_hostname').":
    ".get_lang('database_username').":
    ".get_lang('database_password').":
    ".get_lang('database_name').":
    ".get_lang('database_prefix').":
    \n

    "; echo "

    ".get_lang('back')."

    "; echo "
    \n"; } else if ($step == "2") { echo "
    \n"; if ( isset($_POST['db_host']) ) { $db_host = stripinput($_POST['db_host']); $db_user = stripinput($_POST['db_user']); $db_pass = stripinput($_POST['db_pass']); $db_name = stripinput($_POST['db_name']); $table_prefix = stripinput($_POST['table_prefix']); $db_type = "mysql"; $config = ""; $temp = @fopen("includes/config.inc.php","w"); if (!@fwrite($temp, $config)) { print_failure(get_lang('unable_to_write_config')); echo "

    ".get_lang('back')."

    "; fclose($temp); return; } fclose($temp); } require_once "includes/config.inc.php"; $db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix); $error_text = ""; if ( get_db_error_text($db,$error_text) ) { print_failure($error_text); echo "

    ".get_lang('back')."

    "; return; } $fail = false; // These belong to module manager, but they need to be created before other modules can be "installed". $result = $db->query("DROP TABLE IF EXISTS ".$table_prefix."modules"); $result = $db->query("CREATE TABLE IF NOT EXISTS `".$table_prefix."modules` ( `id` smallint(5) unsigned NOT NULL auto_increment, `title` varchar(100) NOT NULL default '', `folder` varchar(100) NOT NULL default '', `version` varchar(10) NOT NULL default '0', `db_version` int(10) NOT NULL default '0', PRIMARY KEY (`id`), UNIQUE KEY `folder` (`folder`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); $result = $db->query("DROP TABLE IF EXISTS ".$table_prefix."module_menus"); $result = $db->query("CREATE TABLE IF NOT EXISTS `".$table_prefix."module_menus` ( `module_id` int(11) NOT NULL COMMENT 'This references to modules.id', `subpage` varchar(64) NOT NULL default '', `group` varchar(32) NOT NULL, `menu_name` varchar(128) NOT NULL, `pos` INT UNSIGNED NOT NULL, PRIMARY KEY (`module_id`,`subpage`,`group`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); if (!$result) $fail = true; // Install modules. require_once("modules/modulemanager/module_handling.php"); @add_lang_module('modulemanager'); $modules = list_available_modules(); if(in_array('modulemanager', $modules)) { // Install module manager first $fail = $fail || install_module($db, 'modulemanager', FALSE) < 0; } foreach ( $modules as $module ) { if($module == 'modulemanager')//Has already been installed continue; $fail = $fail || install_module($db,$module,FALSE) < 0; } if ( $fail ) { print_failure(get_lang('database_setup_failure')); echo "

    ".get_lang('back')."

    "; echo "

    ".get_lang('unable_to_resolve'). " http://www.opengamepanel.org

    "; return; } print_success(get_lang('config_written')); print_success(get_lang('database_created')); echo "
    \n "; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
    ".get_lang('admin_login_details')."
    "; echo "

    ".get_lang('admin_login_details_info')."

    ".get_lang('username'). ":
    ".get_lang('password'). ":
    ".get_lang('repeat_password'). ":
    ".get_lang('email'). ":
    \n"; echo "

    \n"; echo "

    ".get_lang('back')."

    "; echo "
    \n"; } else if ($step == "3") { echo "
    \n"; require_once "includes/config.inc.php"; $db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix); $error = ""; $username = stripinput($_POST['username']); $password1 = stripinput($_POST['password1']); $password2 = stripinput($_POST['password2']); $email = stripinput($_POST['email']); if (!preg_match("/^[-0-9A-Z_@\s]+$/i", $username)) { print_failure(get_lang('invalid_username')); echo "

    ".get_lang('back')."

    "; return; } // TODO: replace with a constant if (strlen($password1) < 6) { print_failure(get_lang_f('password_too_short', 6)); echo "

    ".get_lang('back')."

    "; return; } if ( $password1 != $password2 ) { print_failure(get_lang('password_mismatch')); echo "

    ".get_lang('back')."

    "; return; } if (!preg_match("/^[-0-9A-Z_\.]{1,50}@([-0-9A-Z_\.]+\.){1,50}([0-9A-Z]){2,4}$/i", $email)) { print_failure(get_lang('invalid_email_address')); echo "

    ".get_lang('back')."

    "; return; } //detect nighly builds, if not its SVN if (file_exists("version.txt")) { $file = "version.txt"; $contents = file($file); $nversion = implode($contents); $nversion2 = substr($nversion ,60); $nversion2 = trim($nversion2); $site_settings = array("title"=>"Open Game Panel", "slogan" => "".get_lang('slogan')."", "ogp_version" => "$nversion2", "version_type" => "SVN", "theme" => "Revolution", "welcome_title" => "1", "welcome_title_message" => "".get_lang('default_welcome_title_message')."", "page_auto_refresh" => "1"); unlink('version.txt'); } else { $site_settings = array("title"=>"Open Game Panel", "slogan" => "".get_lang('slogan')."", "ogp_version" => "0", "version_type" => "SVN", "theme" => "Revolution", "welcome_title" => "1", "welcome_title_message" => "".get_lang('default_welcome_title_message')."", "page_auto_refresh" => "1"); } $result = $db->setSettings($site_settings); $result = $db->addUser($username,$password1,"admin",$email); $result = updateGameConfigsPostInstall(); print_success(get_lang('setup_complete')); echo "

    ".get_lang('remove_install_and_secure_config')."

    "; echo "

    ".get_lang('go_to_panel')."

    "; echo "
    \n"; echo "\n"; } } $view->printView(); ?>