1 |
934
|
doc
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* $Id:$
|
4 |
|
|
* Website Baker Manual module installation
|
5 |
|
|
*
|
6 |
|
|
* This file contains the function to invoke the module install or upgrade
|
7 |
|
|
* scripts update the Add-on information from the
|
8 |
|
|
* database with the ones stored in the Add-on files (e.g. info.php or EN.php)
|
9 |
|
|
*
|
10 |
|
|
* LICENSE: GNU Lesser General Public License 3.0
|
11 |
|
|
*
|
12 |
|
|
* @author Christian Sommer
|
13 |
|
|
* @copyright (c) 2009
|
14 |
|
|
* @license http://www.gnu.org/copyleft/lesser.html
|
15 |
|
|
* @version 0.1.0
|
16 |
|
|
* @platform Website Baker 2.7
|
17 |
|
|
*
|
18 |
|
|
* Website Baker Project <http://www.websitebaker.org/>
|
19 |
|
|
* Copyright (C) 2004-2009, Ryan Djurovich
|
20 |
|
|
*
|
21 |
|
|
* Website Baker is free software; you can redistribute it and/or modify
|
22 |
|
|
* it under the terms of the GNU General Public License as published by
|
23 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
24 |
|
|
* (at your option) any later version.
|
25 |
|
|
*
|
26 |
|
|
* Website Baker is distributed in the hope that it will be useful,
|
27 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
28 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
29 |
|
|
* GNU General Public License for more details.
|
30 |
|
|
*
|
31 |
|
|
* You should have received a copy of the GNU General Public License
|
32 |
|
|
* along with Website Baker; if not, write to the Free Software
|
33 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
34 |
|
|
*/
|
35 |
|
|
|
36 |
|
|
/**
|
37 |
|
|
* check if there is anything to do
|
38 |
|
|
*/
|
39 |
|
|
if (!(isset($_POST['file']) && (strpos($_POST['file'], '..') === false))) die(header('Location: index.php'));
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* check if user has permissions to access this file
|
43 |
|
|
*/
|
44 |
|
|
// include WB configuration file and WB admin class
|
45 |
|
|
require_once('../../config.php');
|
46 |
|
|
require_once('../../framework/class.admin.php');
|
47 |
|
|
|
48 |
|
|
// check user permissions for admintools (redirect users with wrong permissions)
|
49 |
|
|
$admin = new admin('Admintools', 'admintools', false, false);
|
50 |
|
|
if ($admin->get_permission('admintools') == false) die(header('Location: ../../index.php'));
|
51 |
|
|
|
52 |
|
|
// check if the referer URL if available
|
53 |
|
|
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] :
|
54 |
|
|
(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : '');
|
55 |
|
|
|
56 |
|
|
// if referer is set, check if script was invoked from "admin/modules/index.php"
|
57 |
|
|
$required_url = ADMIN_URL . '/modules/index.php';
|
58 |
|
|
if ($referer != '' && (!(strpos($referer, $required_url) !== false || strpos($referer, $required_url) !== false)))
|
59 |
|
|
die(header('Location: ../../index.php'));
|
60 |
|
|
|
61 |
|
|
// include WB functions file
|
62 |
|
|
require_once(WB_PATH . '/framework/functions.php');
|
63 |
|
|
|
64 |
|
|
// load WB language file
|
65 |
|
|
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php');
|
66 |
|
|
|
67 |
|
|
// create Admin object with admin header
|
68 |
|
|
$admin = new admin('Addons', '', true, false);
|
69 |
|
|
$js_back = ADMIN_URL . '/modules/index.php';
|
70 |
|
|
|
71 |
|
|
/**
|
72 |
|
|
* Reload all specified Addons
|
73 |
|
|
*/
|
74 |
|
|
// check if specified module folder exists
|
75 |
|
|
$mod_path = WB_PATH . '/modules/' . basename(WB_PATH . '/' . $_POST['file']);
|
76 |
|
|
if (!file_exists($mod_path . '/install.php')) $admin->print_error($MESSAGE['GENERIC']['NOT_INSTALLED'], $js_back);
|
77 |
|
|
|
78 |
|
|
// include modules install.php script
|
79 |
|
|
require($mod_path . '/install.php');
|
80 |
|
|
|
81 |
|
|
// load module info into database and output status message
|
82 |
|
|
load_module($mod_path, false);
|
83 |
|
|
$admin->print_success($MESSAGE['GENERIC']['INSTALLED'], $js_back);
|
84 |
|
|
|
85 |
|
|
?>
|