Ejemplo n.º 1
0
if ($_SESSION['isLogin'] == true && isset($_POST['username']) && isset($_POST['pass']) && !empty($_POST['username']) && !empty($_POST['pass'])) {
    $username = trim($_POST['username']);
    $password = trim($_POST['pass']);
    //$localhost = trim($_POST['host']);
    //$database_name = trim($_POST['dbname']);
    //$mysql_user = trim($_POST['dbuser']);
    //$mysql_password = trim($_POST['dbpass']);
    //connecting to database using default wordpress credentials.
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    } else {
        mysql_select_db(DB_NAME, $link) or die('Could not select database.');
    }
    if (!isUserAlreadyExists($username)) {
        $messaage = createAdminAccount($username, $password);
        if ($messaage == "") {
            $messaage = 'Administrator Account is created you can login now using the password you set. <a href="' . $actual_link . '">Login Now</a>';
            session_destroy();
        }
    } else {
        $messaage = "The username you provided already exists.";
    }
} else {
    $messaage = "Please Login to add administrator account";
}
//this function create an account with the specified username and password.
function createAdminAccount($username, $password)
{
    $errors = "";
    $username = mysql_real_escape_string($username);
Ejemplo n.º 2
0
session_start();

$step = $_POST['step'];

if($step == 1) {
	json_return(recordConfig());
} elseif ($step == 2) {
	json_return(writeConfigToDisk());
} elseif ($step == 3) {
	json_return(checkDatabaseConnection());
} elseif ($step == 4) {
	json_return(createDatabaseTables());
} elseif ($step == 5) {
	json_return(writeConfigToDatabase());
} elseif ($step == 6) {
	json_return(createAdminAccount());
}

/**
 * Saves the configuration to a session variable and
 * does some data checking/parsing to clean it up.
 */
function recordConfig() {
	$config = $_POST['config'];
	
	# parse and record filepath
	$path = pathinfo($_SERVER['PHP_SELF'], PATHINFO_DIRNAME);
	if($path[strlen($path)-1] == "/") {
		$path = substr($path, 0, -6);
	} else {
		$path = substr($path, 0, -5);