Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         modules
6
 * @author          Christian Sommer
7
 * @author          WebsiteBaker Project
8
 * @copyright       2004-2009, Ryan Djurovich
9
 * @copyright       2009-2011, Website Baker Org. e.V.
10
 * @link			http://www.websitebaker2.org/
11
 * @license         http://www.gnu.org/licenses/gpl.html
12
 * @platform        WebsiteBaker 2.8.x
13
 * @requirements    PHP 5.2.2 and higher
14
 * @version         $Id: manual_install.php 1374 2011-01-10 12:21:47Z Luisehahne $
15
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/modules/manual_install.php $
16
 * @lastmodified    $Date: 2011-01-10 13:21:47 +0100 (Mon, 10 Jan 2011) $
17
 *
18
 */
19

    
20
/**
21
 * check if there is anything to do
22
 */
23

    
24
if (!(isset($_POST['action']) && in_array($_POST['action'], array('install', 'upgrade', 'uninstall')))) { die(header('Location: index.php?advanced')); }
25
if (!(isset($_POST['file']) && $_POST['file'] != '' && (strpos($_POST['file'], '..') === false))){  die(header('Location: index.php?advanced'));  }
26

    
27
/**
28
 * check if user has permissions to access this file
29
 */
30
// include WB configuration file and WB admin class
31
require_once('../../config.php');
32
require_once('../../framework/class.admin.php');
33

    
34
// check user permissions for admintools (redirect users with wrong permissions)
35
$admin = new admin('Admintools', 'admintools', false, false);
36
if ($admin->get_permission('admintools') == false) { die(header('Location: ../../index.php')); }
37

    
38
// check if the referer URL if available
39
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 
40
	(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : '');
41

    
42
// if referer is set, check if script was invoked from "admin/modules/index.php"
43
$required_url = ADMIN_URL . '/modules/index.php';
44
if ($referer != '' && (!(strpos($referer, $required_url) !== false || strpos($referer, $required_url) !== false))) 
45
{ die(header('Location: ../../index.php')); }
46

    
47
// include WB functions file
48
require_once(WB_PATH . '/framework/functions.php');
49

    
50
// load WB language file
51
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php');
52

    
53
// create Admin object with admin header
54
$admin = new admin('Addons', '', true, false);
55
$js_back = ADMIN_URL . '/modules/index.php?advanced';
56

    
57
/**
58
 * Manually execute the specified module file (install.php, upgrade.php or uninstall.php)
59
 */
60
// check if specified module folder exists
61
$mod_path = WB_PATH . '/modules/' . basename(WB_PATH . '/' . $_POST['file']);
62

    
63
// let the old variablename if module use it
64
$module_dir = $mod_path;
65
if (!file_exists($mod_path . '/' . $_POST['action'] . '.php'))
66
{
67
    $admin->print_error($TEXT['NOT_FOUND'].': <tt>"'.htmlentities(basename($mod_path)).'/'.$_POST['action'].'.php"</tt> ', $js_back);
68
}
69

    
70
// include modules install.php script
71
require($mod_path . '/' . $_POST['action'] . '.php');
72

    
73
// load module info into database and output status message
74
load_module($mod_path, false);
75
$msg = $TEXT['EXECUTE'] . ': <tt>"' . htmlentities(basename($mod_path)) . '/' . $_POST['action'] . '.php"</tt>';
76

    
77
switch ($_POST['action'])
78
{
79
	case 'install':
80
		$admin->print_success($msg, $js_back);
81
		break;
82

    
83
	case 'upgrade':
84
		upgrade_module(basename($mod_path), false);
85
		$admin->print_success($msg, $js_back);
86
		break;
87
	
88
	case 'uninstall':
89
		$admin->print_success($msg, $js_back);
90
		break;
91
}
92

    
93
?>
(4-4/5)