blob: 43621f30806ba06811f0eee7bea65cc505d2bccb (
plain)
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
119
120
121
122
123
124
125
126
127
128
129
|
<?php
/**
*
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
define('IN_PHPBB', 1);
define('ANONYMOUS', 1);
$phpEx = substr(strrchr(__FILE__, '.'), 1);
$phpbb_root_path = __DIR__.'/../';
include($phpbb_root_path . 'common.'.$phpEx);
function usage()
{
echo "Usage: extensions.php COMMAND [OPTION]...\n";
echo "Console extension manager.\n";
echo "\n";
echo "list:\n";
echo " Lists all extensions in the database and the filesystem.\n";
echo "\n";
echo "enable NAME:\n";
echo " Enables the specified extension.\n";
echo "\n";
echo "disable NAME:\n";
echo " Disables the specified extension.\n";
echo "\n";
echo "purge NAME:\n";
echo " Purges the specified extension.\n";
exit(2);
}
function list_extensions()
{
global $phpbb_extension_manager;
$phpbb_extension_manager->load_extensions();
$all = array_keys($phpbb_extension_manager->all_available());
if (empty($all))
{
echo "There were no extensions found.\n";
exit(3);
}
echo "Enabled:\n";
$enabled = array_keys($phpbb_extension_manager->all_enabled());
print_extensions($enabled);
echo "\n";
echo "Disabled:\n";
$disabled = array_keys($phpbb_extension_manager->all_disabled());
print_extensions($disabled);
echo "\n";
echo "Available:\n";
$purged = array_diff($all, $enabled, $disabled);
print_extensions($purged);
}
function print_extensions($exts)
{
foreach ($exts as $ext)
{
echo "- $ext\n";
}
}
function enable_extension($name)
{
global $phpbb_extension_manager;
$phpbb_extension_manager->enable($name);
}
function disable_extension($name)
{
global $phpbb_extension_manager;
$phpbb_extension_manager->disable($name);
}
function purge_extension($name)
{
global $phpbb_extension_manager;
$phpbb_extension_manager->purge($name);
}
function validate_argument_count($count)
{
global $argv;
if (count($argv) <= $count)
{
usage();
}
}
validate_argument_count(1);
$action = $argv[1];
switch ($action)
{
case 'list':
list_extensions();
break;
case 'enable':
validate_argument_count(2);
enable_extension($argv[2]);
break;
case 'disable':
validate_argument_count(2);
disable_extension($argv[2]);
break;
case 'purge':
validate_argument_count(2);
purge_extension($argv[2]);
break;
default:
usage();
}
|