This repository has been archived by the owner on Feb 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
console.php
80 lines (61 loc) · 2.07 KB
/
console.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/php
<?php
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
use Symfony\Component\Console\Input\ArgvInput;
define('TIKI_CONSOLE', 1);
declare(ticks = 1); // how often to check for signals
if (function_exists('pcntl_signal')) {
$exit = function () {
error_reporting(0); // Disable error reporting, misleading backtrace on kill
exit;
};
pcntl_signal(SIGTERM, $exit);
pcntl_signal(SIGHUP, $exit);
pcntl_signal(SIGINT, $exit);
}
if (isset($_SERVER['REQUEST_METHOD'])) {
die('Only available through command-line.');
}
require_once 'tiki-filter-base.php';
require_once 'lib/init/initlib.php';
include_once 'lib/init/tra.php';
require_once 'lib/setup/tikisetup.class.php';
require_once 'lib/setup/twversion.class.php';
$input = new ArgvInput;
if (false !== $site = $input->getParameterOption(['--site'])) {
$_SERVER['TIKI_VIRTUAL'] = $site;
}
$local_php = TikiInit::getCredentialsFile();
if (! is_readable($local_php)) {
die("\033[31mCredentials file local.php not found. See http://doc.tiki.org/Installation for more information.\033[0m\n");
}
if (is_file($local_php) || TikiInit::getEnvironmentCredentials()) {
require_once 'db/tiki-db.php';
}
$installer = $installer = new Installer;
$isInstalled = $installer->isInstalled();
$exceptionToRender = null;
if ($isInstalled) {
$bypass_siteclose_check = true;
try {
require_once 'tiki-setup.php';
} catch (Exception $e) {
$exceptionToRender = $e;
}
if (! $asUser = $input->getParameterOption(['--as-user'])) {
$asUser = 'admin';
}
if (TikiLib::lib('user')->user_exists($asUser)) {
$permissionContext = new Perms_Context($asUser);
}
}
$consoleBuilder = new Tiki\Command\ConsoleApplicationBuilder($site);
$console = $consoleBuilder->create();
if ($exceptionToRender instanceof Exception) {
$console->renderException($exceptionToRender, new \Symfony\Component\Console\Output\ConsoleOutput());
}
$console->run();