if (empty($_POST['username']) || empty($_POST['database']) || empty($_POST['host']) || empty($_POST['action'])) { die(generateJson("please make sure you fill all the boxes", 0, "")); } else { if ($_POST['action'] == "dbcheck") { if (checkConnection()) { if (saveDatabaseDetails()) { exit(generateJson("✅ Conncetion to the Database is established.<br>Please wait while we set up the database...", 1, "install_tables", true)); } else { die(generateJson("✖ Setting can't be saved! Make sure you have write permission", 0, "")); } } else { die(generateJson("✖ please make sure username, password, database is valid!", 0, "")); } } elseif ($_POST['action'] == "install_tbl") { //ok, everything seems to be fine, it is time to install the tables if (installTables()) { exit(generateJson("✅ Database Tables successfully created.<br>Please wait while we add some initial data...", 1, "install_data", true)); } else { die(generateJson("❌ Oops, something went wrong.", 0, "")); } } elseif ($_POST['action'] == "install_data") { if (installData()) { exit(generateJson("✅ Initial data successfully added", 1, "install_finished", true)); } else { die(generateJson("❌ Can not enter any data!", 0, "")); } } } } else { die(generateJson("❌ please make sure you fill all the boxes", 0, "")); }
/** * setupDatabase * * @return void */ function setupDatabase() { if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['email'])) { displayStepFive("<p class=\"error\">" . T_('You forgot a required field. Please fill out all required fields.') . "</p>"); return; } include_once 'inc/config_inc.php'; include_once 'inc/install_inc.php'; include_once 'inc/utils.php'; include_once 'inc/thirdparty/phpass/PasswordHash.php'; // Hash the pw $hasher = new PasswordHash(8, FALSE); $password = $hasher->HashPassword($_POST['password']); $connection = mysql_connect($cfg_mysql_host, $cfg_mysql_user, $cfg_mysql_pass); if (!$connection) { die("<h1>Connection Error [" . __FILE__ . __LINE__ . "]</h1>" . mysql_error()); } mysql_select_db($cfg_mysql_db) or die("<h1>Error</h1><p><b>Database could not be found!</b></p>" . mysql_error()); $fname = mysql_real_escape_string($_POST['fname']); $lname = mysql_real_escape_string($_POST['lname']); $email = mysql_real_escape_string($_POST['email']); $bYear = (int) $_POST['year']; $bMonth = (int) $_POST['month']; $bMonth = str_pad($bMonth, 2, "0", STR_PAD_LEFT); $bDay = (int) $_POST['day']; $bDay = str_pad($bDay, 2, "0", STR_PAD_LEFT); $username = mysql_real_escape_string($_POST['username']); installUsers($fname, $lname, $email, $bYear, $bMonth, $bDay, $username, $password); installCategory(); installCalendar(); installTables(); echo ' <div id="install"> <h1>' . T_('Hooray! Yippie!') . '</h1> <p>' . sprintf(T_('%s has been installed successfully.'), 'Family Connections') . '</p> <p><a href="index.php">' . sprintf(T_('Please continue to the homepage to login and begin using %s.'), 'Family Connections') . '</a><p> </div>'; }
<?php require_once 'config/main.conf'; require_once 'config/examples.php'; echo "<p><a href='http://" . $_SERVER['SERVER_NAME'] . "/fnx_journals/articles/'>System was installed. Go?</a></p>\n"; $dbh = installDB($hostname, $db, $root, $root_password, $username, $password); installTables($dbh); /** *Add example users **/ for ($i = 0; $i < count($exampleUsers); $i++) { addExampleUser($dbh, $exampleUsers[$i]); } /** *Add exapmle articles **/ for ($i = 0; $i < count($exampleArticles); $i++) { addExampleArticle($dbh, $exampleArticles[$i]['article'], $exampleArticles[$i]['category'], $exampleArticles[$i]['tags'], $exampleArticles[$i]['author']); } /** *Install script`s db and user **/ function installDB($hostname, $db, $root, $root_password, $username, $password) { try { $dbh = new PDO("mysql:host={$hostname}", $root, $root_password); $dbh->exec("\n \t CREATE DATABASE IF NOT EXISTS {$db};\n \t CREATE USER '{$username}'@'{$hostname}' IDENTIFIED BY '{$password}';\n GRANT ALL ON `{$db}`.* TO '{$username}'@'{$hostname}';\n FLUSH PRIVILEGES;") or die(print_r($dbh->errorInfo(), true)); } catch (PDOException $e) { die("DB ERROR: " . $e->getMessage()); } /**