예제 #1
0
/**
 * main 
 * 
 * @return void
 */
function main()
{
    displayHeader();
    if (isset($_POST['submit1'])) {
        displayStepTwo();
    } elseif (isset($_POST['submit2'])) {
        displayStepThree();
    } elseif (isset($_POST['submit3'])) {
        displayStepFour();
    } elseif (isset($_POST['submit4'])) {
        displayStepFive();
    } elseif (isset($_POST['submit5'])) {
        setupDatabase();
    } elseif (file_exists('inc/config_inc.php')) {
        displayAlreadyInstalled();
        displayStepOne();
        displayFooter();
        return;
    } else {
        displayStepOne();
    }
}
예제 #2
0
function setupDatabase($task)
{
    $db = array();
    $db['driver'] = $task->askAndValidate('What type of database will you be using? (mysql, pgsql, sqlite)', new sfValidatorString(), array('style' => 'QUESTION_LARGE'));
    $db['username'] = null;
    $db['password'] = null;
    if ($db['driver'] == 'sqlite') {
        $db['path'] = $task->askAndValidate('Enter the path to your sqlite database:', new sfValidatorString(), array('style' => 'QUESTION_LARGE'));
        $db['dsn'] = 'sqlite:///' . $db['path'];
    } else {
        $db['host'] = $task->askAndValidate('Enter the host of your database:', new sfValidatorString(), array('style' => 'QUESTION_LARGE'));
        $db['name'] = $task->askAndValidate('Enter the name of your database:', new sfValidatorString(), array('style' => 'QUESTION_LARGE'));
        $db['username'] = $task->askAndValidate('Enter your database username:'******'style' => 'QUESTION_LARGE'));
        $db['password'] = $task->askAndValidate('Enter your database password:'******'required' => false)), array('style' => 'QUESTION_LARGE'));
        $db['dsn'] = $db['driver'] . '://' . $db['username'] . ':' . $db['password'] . '@' . $db['host'] . '/' . $db['name'];
    }
    $task->logSection('sympal', sprintf('...testing connection dsn "%s"', $db['dsn']));
    try {
        $conn = Doctrine_Manager::getInstance()->openConnection($db['dsn'], 'test', false);
        $conn->setOption('username', $db['username']);
        $conn->setOption('password', $db['password']);
        try {
            $conn->createDatabase();
        } catch (Exception $e) {
        }
        $conn->connect();
        $task->logSection('sympal', '...connection credentials valid');
    } catch (Exception $e) {
        $task->logBlock('Connection credentials invalid! Try again! ' . $e->getMessage(), 'ERROR_LARGE');
        return setupDatabase($task);
    }
    return $db;
}
예제 #3
0
파일: setup.php 프로젝트: Beasta/Wicker
    echo W . "Database username:\t\t";
    $data["database"]["username"] = input();
    echo W . "Database password:\t\t";
    $data["database"]["password"] = input();
    echo W . "Attempting to connect to MySQL Server...\n";
    $database = connectToDatabase();
    if ($database == true) {
        echo "Are these settings ok?\t\t";
        if (!in_array(strtolower(input()), array("yes", "y"))) {
            $database = false;
        }
    }
} while ($database == false);
echo W . "=====" . C . " Database Setup " . W . "=====\n";
// if true, ask if you want to import tables else ask if you want to create database and import tables.
setupDatabase();
// Webserver user
echo W . "\n=====" . C . " Webserver User " . W . "=====\n";
$webserver = false;
do {
    echo W . "Webserver User:\t\t\t";
    $data["webserver"]["user"] = input();
    echo W . "Are these settings ok?\t\t";
    if (!in_array(strtolower(input()), array("yes", "y"))) {
        $webserver = false;
    } else {
        $webserver = true;
    }
} while ($webserver == false);
// Wireless
echo W . "\n=====" . C . " Wireless " . W . "=====\n";