current_mod = "boost"; require_once("../mod/boost/class/Boost.php"); require_once("../mod/language/class/Language.php"); require_once("../mod/search/class/Search.php"); require_once("../mod/help/class/CLS_help.php"); require_once("../mod/users/class/Users.php"); require_once("../mod/layout/class/Layout.php"); require_once("../mod/controlpanel/class/ControlPanel.php"); require_once("defaultMods.php"); if ($_POST) extract($_POST); /* Fix for those with session auto start enabled */ if (get_cfg_var("session.auto_start") == "1") session_destroy(); $sessionName = md5($core->site_hash . PHPWS_HOME_HTTP); session_name($sessionName); session_start($sessionName); include("allow_setup.php"); if (isset($_POST["check_session"]) && !isset($_SESSION["send_sess"])){ $session_failure = 1; $install_step = null; } if (!isset($_SESSION["OBJ_user"])) $_SESSION["OBJ_user"] = new PHPWS_User; $_SESSION["translate"] = new PHPWS_Language; if ($install_language != "en"){ $_SESSION["translate"]->current_language = $install_language; $_SESSION["translate"]->langActive = 1; $_SESSION["translate"]->quickDict("lang/setup.$install_language.lng"); } else $_SESSION["translate"]->langActive = 0; if (!DB::isError($core->db)) $db_connect = TRUE; else $db_connect = FALSE; if (!isset($_SESSION["password_allowed"])){ if ($dbuser == "your_username" || $dbpass == "your_password" || (isset($install_password) && ( $install_password == "default" || $install_password == ""))) $install_step = NULL; elseif (isset($install_step) && (isset($install_password) && $install_password != $install_pw)) $install_step = NULL; elseif (isset($install_password) && $install_password == $install_pw) $_SESSION["password_allowed"] = 1; } echo " ".$_SESSION["translate"]->it("phpWebSite Core Installation")."

" . $_SESSION["translate"]->it("phpWebSite Version") . " $version - " . $_SESSION["translate"]->it("Installation Utility") . "

"; switch ($install_step){ case "1": if ($_POST["hash"] != $install_hash) exit("You are not authorized to create a user."); if (submitUserInfo()){ $_SESSION["OBJ_user"]->username = $_POST["username"]; $_SESSION["OBJ_user"]->password = md5($_POST["pass1"]); $_SESSION["OBJ_user"]->deity = 1; $_SESSION["OBJ_user"]->admin_switch = 1; $_SESSION['OBJ_user']->email = $_POST['email']; echo $_SESSION["translate"]->it("Your administrative user was successfully created") . ".

"; echo installSecModules($defaultMods); } else { if (isset($GLOBALS["errorMes"])){ echo $GLOBALS["errorMes"]; unset($GLOBALS["errorMes"]); } else echo $_SESSION["translate"]->it("You must create a deity user account that will have administrative rights to this phpWebSite installation") . ".
" . $_SESSION["translate"]->it("Make sure the password is 5 characters or more and not simple to guess") . ".

" . $_SESSION["translate"]->it("Please enter the required information to continue") . ".

"; echo createUserForm(); } break; case "2": if ($core->sqlImport($core->source_dir . "setup/install.sql", 1,1)){ if ($dbversion == "mysql") $core->sqlModifyColumn("cache", "data", "MEDIUMTEXT NOT NULL"); $langCreate = " CREATE TABLE mod_lang_".strtoupper($install_language)." ( phrase_id int unsigned NOT NULL, module varchar(30) NOT NULL default '', phrase text NOT NULL, translation text NOT NULL, PRIMARY KEY (phrase_id), KEY module (module) );"; if (!$core->query($langCreate, TRUE)) echo $_SESSION["translate"]->it("There was a problem creating the default language table") . ".
"; echo "".$_SESSION["translate"]->it("Core tables successfully installed") . "!
"; } else { echo $_SESSION["translate"]->it("There was a problem installing the core tables") . ".
"; echo $_SESSION["translate"]->it("Please check your core and try the installation again") . ".
"; exit(); } echo "

" . $_SESSION["translate"]->it("Building required modules") . "


"; echo PHPWS_Boost::installModuleList($defaultMods); PHPWS_ControlPanel::import("controlpanel"); echo "

" . $_SESSION["translate"]->it("Registering Default Language") . "


"; echo PHPWS_Language::installModuleLanguage($defaultMods); echo "

" . $_SESSION["translate"]->it("Post Installation Procedures") . "


"; echo PHPWS_Boost::postInstall($defaultMods); if (isset($_POST["extraMods"]) && (isset($_POST["secModules"]) && count($_POST["secModules"]))){ echo "

" . $_SESSION["translate"]->it("Building extra modules") . "


"; echo PHPWS_Boost::installModuleList($_POST["secModules"], FALSE, TRUE, TRUE); } PHPWS_BOOST::setVersionInfo("../conf/core_info.php", "insert"); echo PHPWS_Text::link(PHPWS_HOME_HTTP, $_SESSION["translate"]->it("Go to my installation")); $_SESSION["OBJ_user"]->writeUser(); $core->killAllSessions(); break; default: $core->killSession("password_allowed"); if (phpversion() < "4.2.2"){ if ($overrideVersion) echo $_SESSION["translate"]->it("You have chosen to override the version checker") . ". " . $_SESSION["translate"]->it("Be aware that your version of php is NOT supported") . ".
"; else { echo $_SESSION["translate"]->it("Sorry, but you appear to running PHP version") . " ".phpversion().". " . $_SESSION["translate"]->it("phpWebSite requires 4.2.2 or above") . ".
"; $error = 1; } } if ($session_failure){ echo $_SESSION["translate"]->it("phpWebSite failed a session test") . ". " . $_SESSION["translate"]->it("If your PHP installation is not configured to allow sessions, you will not be able to run phpWebSite") . ".
" . $_SESSION["translate"]->it("Please check your session path in your php.ini file and make sure your version of php supports superglobals") . "(" . $_SESSION["translate"]->it("greater than version") . " 4.1.2)
"; $error = 1; } if ($db_connect == FALSE){ echo $_SESSION["translate"]->it("[var1] not found", "$dbname") . ". " . $_SESSION["translate"]->it("You will need to create a database of this name before continuing") . ".
"; $error = 1; } elseif ($db_connect == TRUE) { $table_check = count($core->listTables()); if ($table_check && !isset($login) && !$table_prefix){ echo $_SESSION["translate"]->it("There are tables in this database and you have not set a table prefix") . ".
" . $_SESSION["translate"]->it("Please do so in your config.php file and return") . ".
"; $error = 1; } } if (!$error){ $_SESSION["send_sess"] = 1; echo "
" . PHPWS_Form::formHidden(array("install_step"=>1, "check_session"=>1, "hash"=>$install_hash)) . $_SESSION["translate"]->it("Welcome to the phpWebSite installation utility") . "!
" . $_SESSION["translate"]->it("Please enter your installation password to continue.") . "

" . PHPWS_Form::formPassword("install_password") . " " . PHPWS_Form::formSubmit($_SESSION["translate"]->it("Continue")) . "
"; } break; } echo " "; function createUserForm(){ $core = $GLOBALS["core"]; $content = "\n
\n"; $content .= PHPWS_Form::formHidden(array("hash"=>$GLOBALS["install_hash"], "install_step"=>1, "login"=>1)); $content .= "
" . $_SESSION["translate"]->it("Username") . ":" . PHPWS_Form::formTextField("username", (isset($_POST["username"])) ? $_POST["username"] : NULL) ."
" . $_SESSION["translate"]->it("Password") . ":". PHPWS_Form::formPassword("pass1") . "
" . $_SESSION["translate"]->it("Password Confirmation") . ":" . PHPWS_Form::formPassword("pass2") . "
" . $_SESSION["translate"]->it("Email Address") . ":" . PHPWS_Form::formTextField("email", (isset($_POST['email'])) ? $_POST['email'] : NULL) . "

" . PHPWS_Form::formSubmit($_SESSION["translate"]->it("Continue")) ."
"; return $content; } function submitUserInfo(){ $core = $GLOBALS["core"]; if (!isset($_POST["login"])) return FALSE; if (!PHPWS_Text::isValidInput($_POST["username"])){ $GLOBALS["errorMes"] = "" . $_SESSION["translate"]->it("Bad user name") . ". " . $_SESSION["translate"]->it("Alphanumeric characters only") . ". " . $_SESSION["translate"]->it("No spaces") . ".
"; return FALSE; } elseif(preg_match("/[^a-zA-Z0-9!@_]/", $_POST["pass1"])){ $GLOBALS["errorMes"] = "" . $_SESSION["translate"]->it("Some strange characters in that password") . ".
"; return FALSE; } elseif(strlen($_POST["pass1"]) < 5){ $GLOBALS["errorMes"] = "" . $_SESSION["translate"]->it("Couple of letters missing in that password") . "?
"; return FALSE; } elseif(preg_match("/(pass|password|phpwebsite|qwerty|passwd|asd|admin|fallout)/i", $_POST["pass1"])){ $GLOBALS["errorMes"] = "" . $_SESSION["translate"]->it("No seriously") . ". " . $_SESSION["translate"]->it("Even I guessed that one") .". " . $_SESSION["translate"]->it("Pick a REAL password") . ".
"; return FALSE; } elseif ($_POST["pass1"] != $_POST["pass2"]){ $GLOBALS["errorMes"] = "" . $_SESSION["translate"]->it("Passwords did not match") . ". " . $_SESSION["translate"]->it("Try again") . ".
"; return FALSE; } elseif (!phpws_text::isValidInput($_POST["email"], "email")){ $GLOBALS["errorMes"] = "" . $_SESSION["translate"]->it("You must enter a proper email address") . ". " . $_SESSION["translate"]->it("Try again") . ".
"; return FALSE; } else return TRUE; } function installSecModules($required){ $core = $GLOBALS["core"]; if (!($dir = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR."mod/", 1))) return NULL; foreach ($dir as $mod_dir_name){ $filename = PHPWS_SOURCE_DIR."mod/$mod_dir_name/conf/boost.php"; if (!(file_exists($filename))) continue; include($filename); $mods[$mod_directory] = $mod_pname; } foreach ($required as $modRemove) unset($mods[$modRemove]); $content = "
" . PHPWS_Form::formHidden("install_step", "2") . "\n"; if (count($mods)){ $content .= $_SESSION["translate"]->it("The modules listed below were found with your installation") . ".
" . $_SESSION["translate"]->it("These modules are not essential to the operation of phpWebSite") . ".
" . $_SESSION["translate"]->it("If you wish to add or remove modules later, use the Boost Module in your administration panel") . ".

" . $_SESSION["translate"]->it("Click the checkbox next to the modules you wish to install, then click the Install Selected Modules button") . ".
" . $_SESSION["translate"]->it("If you do not wish to install any extra modules at this time, click the Install Core Only button") . ".

\n"; foreach ($mods as $modDir=>$modName) $content .= PHPWS_Form::formCheckBox("secModules[]", $modDir) . " $modName
\n"; $content .= PHPWS_Form::formButton($_SESSION["translate"]->it("Toggle All"), "toggle", "CheckAll();") . "

"; $content .= PHPWS_Form::formSubmit($_SESSION["translate"]->it("Install Selected Modules"), "extraMods"); } $content .= " " . PHPWS_Form::formSubmit($_SESSION["translate"]->it("Install Core Only")) . "\n
"; return $content; } ?>