Adding user accounts.
This commit is contained in:
parent
a07ba4020c
commit
188162f0a2
22 changed files with 800 additions and 16 deletions
62
install.php
62
install.php
|
|
@ -1,10 +1,12 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
ini_set('display_errors', 'on');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$dbHost = ask('Enter your MySQL host: ');
|
||||
$dbName = ask('Enter the database name PHPCI should use: ');
|
||||
$dbUser = ask('Enter your MySQL username: ');
|
||||
$dbPass = ask('Enter your MySQL password: ');
|
||||
$dbPass = ask('Enter your MySQL password: ', true);
|
||||
|
||||
$cmd = 'mysql -u' . $dbUser . (!empty($dbPass) ? ' -p' . $dbPass : '') . ' -h' . $dbHost . ' -e "CREATE DATABASE IF NOT EXISTS ' . $dbName . '"';
|
||||
shell_exec($cmd);
|
||||
|
|
@ -19,21 +21,48 @@ b8\Database::setReadServers(array('{$dbHost}'));
|
|||
|
||||
");
|
||||
|
||||
require_once('bootstrap.php');
|
||||
|
||||
$gen = new b8\Database\Generator(b8\Database::getConnection(), 'PHPCI', './PHPCI/Model/Base/');
|
||||
$gen->generate();
|
||||
|
||||
print 'INSTALLING: Composer' . PHP_EOL;
|
||||
file_put_contents('./composerinstaller.php', file_get_contents('https://getcomposer.org/installer'));
|
||||
shell_exec('php ./composerinstaller.php');
|
||||
unlink('./composerinstaller.php');
|
||||
if(!file_exists('./composer.phar'))
|
||||
{
|
||||
print 'INSTALLING: Composer' . PHP_EOL;
|
||||
file_put_contents('./composerinstaller.php', file_get_contents('https://getcomposer.org/installer'));
|
||||
shell_exec('php ./composerinstaller.php');
|
||||
unlink('./composerinstaller.php');
|
||||
}
|
||||
|
||||
print 'RUNNING: Composer' . PHP_EOL;
|
||||
shell_exec('./composer.phar install');
|
||||
|
||||
|
||||
function ask($question)
|
||||
require_once('bootstrap.php');
|
||||
|
||||
$gen = new b8\Database\Generator(b8\Database::getConnection(), 'PHPCI', './PHPCI/Model/Base/');
|
||||
$gen->generate();
|
||||
|
||||
$adminEmail = ask('Enter your email address: ');
|
||||
$adminPass = ask('Enter your desired admin password: ');
|
||||
$adminName = ask('Enter your name: ');
|
||||
|
||||
try
|
||||
{
|
||||
$user = new PHPCI\Model\User();
|
||||
$user->setEmail($adminEmail);
|
||||
$user->setName($adminName);
|
||||
$user->setIsAdmin(1);
|
||||
$user->setHash(password_hash($adminPass, PASSWORD_DEFAULT));
|
||||
|
||||
$store = b8\Store\Factory::getStore('User');
|
||||
$store->save($user);
|
||||
|
||||
print 'User account created!' . PHP_EOL;
|
||||
}
|
||||
catch(Exception $ex)
|
||||
{
|
||||
print 'There was a problem creating your account. :(' . PHP_EOL;
|
||||
print $ex->getMessage();
|
||||
}
|
||||
|
||||
|
||||
function ask($question, $emptyOk = false)
|
||||
{
|
||||
print $question . ' ';
|
||||
|
||||
|
|
@ -42,5 +71,12 @@ function ask($question)
|
|||
$rtn = fgets($fp);
|
||||
fclose($fp);
|
||||
|
||||
return trim($rtn);
|
||||
$rtn = trim($rtn);
|
||||
|
||||
if(!$emptyOk && empty($rtn))
|
||||
{
|
||||
$rtn = ask($question, $emptyOk);
|
||||
}
|
||||
|
||||
return $rtn;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue