Repository navigation
Expand file tree
/
Copy pathcli_init.php
More file actions
62 lines (50 loc) · 1.46 KB
/
Copy pathcli_init.php
File metadata and controls
62 lines (50 loc) · 1.46 KB
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
<?php
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
include_once(CLI_ROOT_PATH.'cli_core.php');
include_once(CLI_ROOT_PATH.'cli_command.php');
include_once(PHPWG_ROOT_PATH.'include/config_default.inc.php');
include_once(CLI_ROOT_PATH.'cli_default_config.php');
@include(PHPWG_ROOT_PATH.'local/config/config.inc.php');
if (!$conf['allow_cli'])
{
PwgCommand::error('CLI are disabled');
exit(PwgCommand::ERROR);
}
$cli = new PwgCli();
$cli->trap_interrupt();
$cli->boot();
// Everything below runs at file scope on purpose: common.inc.php and its friends
// create $conf, $user, $page, $template... as globals. Including them from
// inside a method would make them locals of that method, and every core
// function doing "global $conf" would then read null.
$boot_level = $cli->boot_level();
if ('none' === $boot_level)
{
return;
}
$init = $cli->init_minimal();
if ($init === PwgCommand::ERROR)
{
exit(PwgCommand::ERROR);
}
if ('minimal' === $boot_level)
{
$init = $cli->init_db();
if ($init === PwgCommand::ERROR)
{
exit(PwgCommand::ERROR);
}
return;
}
// at this point consider as boot_level as 'full'
$init = $cli->init_piwigo();
if ($init === PwgCommand::ERROR)
{
exit(PwgCommand::ERROR);
}
$cli->prepare_cli_user();
$cli->prepare_cli_logger();
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
// reload config default after full boot
// because common.inc.php erase conf with $conf = array()
include(CLI_ROOT_PATH.'cli_default_config.php');