This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
59 lines (46 loc) · 2.33 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace AutomaticWordpress;
use Exception;
define('ABS', __DIR__);
require implode(DIRECTORY_SEPARATOR, [ABS, 'autoload.php']);
try {
$startExecutionTime = microtime(true);
$console = new Console($argv ?? null);
if (!$console->isConsole()) {
echo '<pre>';
echo 'The script cannot be called by the browser yet';
exit;
}
Console::echo(' ', [Console::BG_BLACK, Console::COLOR_LIGHT_BLUE], false);
Console::echo(' ', [Console::COLOR_BLACK, Console::BG_LIGHT_BLUE], false);
Console::echo('', [Console::BG_DEFAULT]);
Console::echo(' Automatic ', [Console::BG_BLACK, Console::COLOR_LIGHT_BLUE], false);
Console::echo(' Wordpress ', [Console::COLOR_BLACK, Console::BG_LIGHT_BLUE], false);
Console::echo('', [Console::BG_DEFAULT]);
Console::echo(' ', [Console::BG_BLACK, Console::COLOR_LIGHT_BLUE], false);
Console::echo(' ', [Console::COLOR_BLACK, Console::BG_LIGHT_BLUE], false);
Console::echo('', [Console::BG_DEFAULT]);
Console::centerEcho('Wordpress installation initialization', 50, Console::TEXT_REVERSE);
$profiles = new Profiles(implode(DIRECTORY_SEPARATOR, [ABS, 'profiles.ini']));
$profile = $profiles->getProfile($console->getFlag('profile'));
if (is_null($profile)) {
$profile = Profile::createEmpty();
}
if ($console->hasFlag('lang')) {
$profile->setLang($console->getFlag('lang'));
}
$installationName = $console->getLocation();
$configuration = new Configuration(implode(DIRECTORY_SEPARATOR, [ABS, '.env']));
$database = new Database($configuration);
$wordpress = new Wordpress($database, $configuration);
if (!$wordpress->install($installationName, $profile)) {
throw new Exception('Cannot install wordpress', 20);
} else {
throw new Exception('Wordpress has been installed successfully', 0);
}
} catch (Exception $exception) {
Console::centerEcho($exception->getMessage(), 50, Console::TEXT_REVERSE, false);
Console::echo('', Console::TEXT_NORMAL);
Console::centerEcho('Total execution time: '.round(microtime(true) - $startExecutionTime, 2).' s', 50, [Console::COLOR_BLACK, Console::BG_LIGHT_BLUE], false);
Console::echo('', Console::BG_DEFAULT);
}