Esempio n. 1
0
$misc = new MiscFunctions();
// Assign some defaults since nothing is configured
$TITLE = "phpDHCPAdmin-0.9.5-beta Setup Wizard";
$STYLE = "../templates/black";
$DESCRIPTION = "I am here to help you import the database structure and setup the application defaults";
$DISCLAIMER = "All rights reserved 2009 ® Jason Gerfen";
$TABLES = array('admin_backup_conf', 'admin_config_algorithm', 'admin_logs', 'admin_sessions', 'auth_groups', 'auth_levels', 'auth_users', 'conf_adapters', 'conf_classes', 'conf_classes_options', 'conf_classes_opts', 'conf_dnssec_opts', 'conf_dns_opts', 'conf_failover', 'conf_global_opts', 'conf_hosts', 'conf_leases', 'conf_leases_properties', 'conf_pools', 'conf_pxe_groups', 'conf_pxe_opts', 'conf_shared_networks', 'conf_subnets', 'conf_traffic');
$REGEX = array('/\\$defined[\'hostname\']\\s\\s\\s\\s=\\s\\"\\";/', '/\\$defined[\'dbhost\']\\s\\s\\s\\s\\s\\s=\\s\\"localhost\\";/', '/\\$defined[\'username\']\\s\\s\\s\\s=\\s\\"\\";/', '/\\$defined[\'password\']\\s\\s\\s\\s=\\s\\"\\";/', '/\\$defined[\'mail\']\\s\\s\\s\\s\\s\\s\\s\\s=\\s\\"\\";/', '/\\$defined[\'virpath\']\\s\\s\\s\\s\\s=\\s\\"\\";/');
// lets process the form
if (!empty($_POST)) {
    // make sure we have a complete form submission
    if (!empty($_POST['mysql_root_user']) && !empty($_POST['mysql_root_passwd']) && !empty($_POST['defined_hostname']) && !empty($_POST['mysql_server_address']) && !empty($_POST['mysql_server_username']) && !empty($_POST['mysql_server_password']) && !empty($_POST['configuration_path']) && !empty($_POST['admin_email'])) {
        // ensure nothing screwy is going on in regards to input
        if ($val->ValidateString($_POST['mysql_root_user']) !== -1 && $val->ValidateParagraph($_POST['mysql_root_passwd']) !== -1 && $val->ValidateDomain($_POST['defined_hostname']) !== -1 && $val->ValidateDomain($_POST['mysql_server_address']) !== -1 && $val->ValidateParagraph($_POST['mysql_server_username']) !== -1 && $val->ValidateParagraph($_POST['mysql_server_password']) !== -1 && $val->ValidateParagraph($_POST['configuration_path']) !== -1 && $val->ValidateEmail($_POST['admin_email']) !== -1) {
            // ensure our root username & password is correct
            $dbconn = $db->dbConnectOnly($_POST['mysql_server_address'], $_POST['mysql_root_user'], $_POST['mysql_root_passwd']);
            echo $db->dbCatchError();
            if ($dbconn === -1) {
                $error = $err->GenerateErrorLink("../help/help.html", "#app_setup", '../templates/images/error.jpg', "Error connecting to the database during initial connection. Wrong username/password combination", NULL, NULL);
            } else {
                // perform our .sql file import (this fails if it exists already)
                $cmd = "mysql -u " . $_POST['mysql_root_user'] . " --password="******" < phpDHCPAdmin.sql";
                `{$cmd}`;
                // create a default user based on the form input
                $dbconn = $db->dbConnect($_POST['mysql_server_address'], $_POST['mysql_root_user'], $_POST['mysql_root_passwd'], 'phpDHCPAdmin');
                if ($dbconn === -1) {
                    $error = $err->GenerateErrorLink("../help/help.html", "#app_setup", '../templates/images/error.jpg', "Error connecting to the database. Wrong username/password combination", NULL, NULL);
                } else {
                    $query = "GRANT SELECT,INSERT,UPDATE,DELETE,INDEX,REFERENCES ON phpDHCPAdmin.* TO '" . $_POST['mysql_server_username'] . "'@'" . $_POST['mysql_server_address'] . "' IDENTIFIED BY '" . $_POST['mysql_server_password'] . "'";
                    if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === -1) {
                        $error = $err->GenerateErrorLink("../help/help.html", "#create_admin_user", '../templates/images/error.jpg', "There was a problem when creating the default user that the phpDHCPAdmin application will use to keep persistant connections to the database", NULL, NULL);