-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.php
57 lines (45 loc) · 1.51 KB
/
cli.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
#!/usr/bin/php
<?php
ini_set('display_errors', '0');
error_reporting(E_ALL | E_STRICT);
//show errors only on localhost
if (isset($_SERVER['REMOTE_ADDR']) || !isset($_SERVER['argc']) || $_SERVER['argc'] < 2) {
header('HTTP/1.1 403 Forbidden');
exit;
}
define('QF_CLI', true);
define('QF_DEBUG', true);
ini_set('display_errors', '1');
ini_set('log_errors', '1');
define('QF_BASEPATH', dirname(__FILE__).'/');
try {
require_once(QF_BASEPATH.'data/config.php');
require_once(QF_BASEPATH.'data/tasks.php');
require_once(QF_BASEPATH.'lib/qfAutoload.php');
require_once(QF_BASEPATH.'lib/functions.php');
$autoloader = new qfAutoload();
spl_autoload_register(array($autoloader, 'autoload'));
$config = new qfConfig($qf_config);
$autoloader->setPaths($config->autoload_paths);
$qf = new qfCore($config); // or new qfCoreI18n($config); to add i18n-capability to getUrl/redirectRoute methods
//i18n
//$language = isset($_GET['language']) ? $_GET['language'] : '';
//$qf->i18n = new qfI18n($qf, $language);
//$qf->t = $qf->i18n->get();
//database
//$qf->qfDB = new qfDB($qf);
//$qf->db = $qf->db->get();
$cli = new qfCli($qf);
$taskData = $cli->parseArgs($argv);
if ($taskData) {
if ($output = $cli->callTask($taskData['module'], $taskData['task'], $taskData['parameter'])) {
echo $output;
} else {
'[no output]'."\n";
}
} else {
'[invalid task]'."\n";
}
} catch (Exception $e) {
echo $e;
}