close_site.php 1.46 KB
Newer Older
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
<?php

/**
 *
 * @package    mahara
 * @subpackage core
 * @author     Evan Giles
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 * @copyright  (C) 2015 Evan Giles <evan@catalyst-au.net>
 *
 */

define('INTERNAL', 1);
define('ADMIN', 1);
define('CLI', 1);
define('INSTALLER', 1);

require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require(get_config('libroot') . 'cli.php');
require(get_config('libroot') . 'upgrade.php');

$cli = get_cli();

$options = array();
$options['close'] = (object) array(
    'shortoptions' => array('cl', 'c'),
    'description' => get_string('closesite', 'admin'),
);
$options['open'] = (object) array(
    'shortoptions' => array('op', 'o'),
    'description' => get_string('reopensite', 'admin'),
);

$settings = (object) array(
    'info' => get_string('cli_close_site_info', 'admin'),
    'options' => $options,
);
$cli->setup($settings);

$opensite = $cli->get_cli_param('open');
$closesite = $cli->get_cli_param('close');

if ($closesite) {
    set_config('siteclosedbyadmin', 1);
    require_once(get_config('docroot') . 'auth/session.php');
    remove_all_sessions();
    $cli->cli_exit(get_string('cli_close_site_siteclosed', 'admin'));
}
else if ($opensite) {
    set_config('siteclosedbyadmin', 0);
    $cli->cli_exit(get_string('cli_close_site_siteopen', 'admin'));
}

$cli->cli_print_help(true);