-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtine20.php
executable file
·73 lines (64 loc) · 2.22 KB
/
tine20.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
#!/usr/bin/env php
<?php
/**
* tine cli script
*
* @package Cli
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @author Philipp Schüle <p.schuele@metaways.de>
* @copyright Copyright (c) 2007-2012 Metaways Infosystems GmbH (http://www.metaways.de)
*/
if (php_sapi_name() != 'cli') {
die('Not allowed: wrong sapi name!');
}
require_once 'bootstrap.php';
/**
* options
*/
try {
$opts = new Zend_Console_Getopt(
array(
'help|h' => 'Display this help Message',
'verbose|v' => 'Output messages',
'config|c=s' => 'Path to config.inc.php file',
'dry|d' => "Dry run - don't change anything",
'info|i' => 'Get usage description of method',
'method=s' => 'Method to call [required]',
'username=s' => 'Username',
'password=s' => 'Password',
'passwordfile=s' => 'Name of file that contains password',
));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getMessage() . "\n";
echo $e->getUsageMessage();
exit;
}
if (count($opts->toArray()) === 0 || $opts->h || empty($opts->method)) {
echo $opts->getUsageMessage();
exit;
}
if ($opts->config) {
// add path to config.inc.php to include path
$path = strstr($opts->config, 'config.inc.php') !== false ? dirname($opts->config) : $opts->config;
set_include_path($path . PATH_SEPARATOR . get_include_path());
}
// get username / password if not already set
if (! in_array($opts->method, Tinebase_Server_Cli::getAnonymousMethods($opts->method))) {
if (empty($opts->username)) {
$opts->username = Tinebase_Server_Cli::promptInput('username');
}
if (empty($opts->username)) {
echo "error: username must be given! exiting \n";
exit (1);
}
if (empty($opts->password)) {
if (empty($opts->passwordfile)) {
$opts->password = Tinebase_Server_Cli::promptInput('password', TRUE);
} else {
$opts->password = Tinebase_Server_Cli::getPasswordFromFile($opts->passwordfile);
}
}
}
Tinebase_Core::set('opts', $opts);
Tinebase_Core::dispatchRequest();