forked from changi67/tiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.php
118 lines (99 loc) · 4.33 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/php
<?php
// (c) Copyright 2002-2013 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(array('--site'))) {
$_SERVER['TIKI_VIRTUAL'] = $site;
}
$local_php = TikiInit::getCredentialsFile();
$console = new Tiki\Command\Application;
$console->add(new Tiki\Command\ConfigureCommand);
if (is_file($local_php) || TikiInit::getEnvironmentCredentials()) {
require 'db/tiki-db.php';
$console->add(new Tiki\Command\InstallCommand);
$console->add(new Tiki\Command\UpdateCommand);
} else {
$console->add(new Tiki\Command\UnavailableCommand('database:install'));
$console->add(new Tiki\Command\UnavailableCommand('database:update'));
}
$installer = $installer = new Installer;
$isInstalled = $installer->isInstalled();
if ($isInstalled) {
require_once 'tiki-setup.php';
$console->add(new Tiki\Command\CacheClearCommand);
$console->add(new Tiki\Command\BackupDBCommand);
$console->add(new Tiki\Command\BackupFilesCommand);
} else {
$console->add(new Tiki\Command\UnavailableCommand('cache:clear'));
$console->add(new Tiki\Command\UnavailableCommand('database:backup'));
$console->add(new Tiki\Command\UnavailableCommand('backup:files'));
}
if ($isInstalled && ! $installer->requiresUpdate()) {
require_once 'tiki-setup.php';
$console->add(new Tiki\Command\IndexRebuildCommand);
$console->add(new Tiki\Command\IndexOptimizeCommand);
$console->add(new Tiki\Command\IndexCatchUpCommand);
$console->add(new Tiki\Command\ProfileForgetCommand);
$console->add(new Tiki\Command\ProfileInstallCommand);
$console->add(new Tiki\Command\ProfileExport\Init);
} else {
$console->add(new Tiki\Command\UnavailableCommand('index:rebuild'));
$console->add(new Tiki\Command\UnavailableCommand('index:optimize'));
$console->add(new Tiki\Command\UnavailableCommand('index:catch-up'));
$console->add(new Tiki\Command\UnavailableCommand('profile:forget'));
$console->add(new Tiki\Command\UnavailableCommand('profile:apply'));
$console->add(new Tiki\Command\UnavailableCommand('profile:export:init'));
}
if (file_exists('profiles/info.ini')) {
$console->add(new Tiki\Command\ProfileExport\ActivityRuleSet);
$console->add(new Tiki\Command\ProfileExport\ActivityStreamRule);
$console->add(new Tiki\Command\ProfileExport\Article);
$console->add(new Tiki\Command\ProfileExport\ArticleTopic);
$console->add(new Tiki\Command\ProfileExport\ArticleType);
$console->add(new Tiki\Command\ProfileExport\AllModules);
$console->add(new Tiki\Command\ProfileExport\Category);
$console->add(new Tiki\Command\ProfileExport\FileGallery);
$console->add(new Tiki\Command\ProfileExport\Forum);
$console->add(new Tiki\Command\ProfileExport\IncludeProfile);
$console->add(new Tiki\Command\ProfileExport\Menu);
$console->add(new Tiki\Command\ProfileExport\Module);
$console->add(new Tiki\Command\ProfileExport\Preference);
$console->add(new Tiki\Command\ProfileExport\RatingConfig);
$console->add(new Tiki\Command\ProfileExport\RatingConfigSet);
$console->add(new Tiki\Command\ProfileExport\RecentChanges);
$console->add(new Tiki\Command\ProfileExport\Rss);
$console->add(new Tiki\Command\ProfileExport\Tracker);
$console->add(new Tiki\Command\ProfileExport\TrackerField);
$console->add(new Tiki\Command\ProfileExport\WikiPage);
$console->add(new Tiki\Command\ProfileExport\Finalize);
}
if (is_file('db/redact/local.php') && ($site == 'redact') ) {
$console->add(new Tiki\Command\RedactDBCommand);
} else {
$console->add(new Tiki\Command\UnavailableCommand('database:redact'));
}
$console->run();