forked from osTicket/osTicket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.php
executable file
·81 lines (60 loc) · 2.28 KB
/
manage.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
#!/usr/bin/env php
<?php
/*********************************************************************
manage.php
CLI (command line interface) for osTicket management. Use
php manage.php --help
for detailed and updated getting started information.
Jared Hancock <[email protected]>
Copyright (c) 2006-2015 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require_once 'bootstrap.php';
// Make sure the script is executed via CLI
if (!osTicket::is_cli())
die("Management only supported from command-line\n");
require_once CLI_DIR . 'cli.inc.php';
class Manager extends Module {
var $prologue =
"Manage one or more osTicket installations";
var $arguments = array(
'action' => "Action to be managed"
);
var $usage = '$script action [options] [arguments]';
var $autohelp = false;
function showHelp() {
foreach (glob(CLI_DIR.'modules/*.php') as $script)
include_once $script;
global $registered_modules;
$this->epilog =
"Currently available modules follow. Use 'manage.php <module>
--help' for usage regarding each respective module:";
parent::showHelp();
echo "\n";
ksort($registered_modules);
$width = max(array_map('strlen', array_keys($registered_modules)));
foreach ($registered_modules as $name=>$mod)
echo str_pad($name, $width + 2) . $mod->prologue . "\n";
}
function run($args, $options) {
if ($options['help'] && !$args['action'])
$this->showHelp();
else {
$action = $args['action'];
global $argv;
foreach ($argv as $idx=>$val)
if ($val == $action)
unset($argv[$idx]);
require_once CLI_DIR . "modules/{$args['action']}.php";
if (($module = Module::getInstance($action)))
return $module->_run($args['action']);
$this->stderr->write("Unknown action given\n");
$this->showHelp();
}
}
}
$manager = new Manager();
$manager->_run(basename(__file__), false);