Project

General

Profile

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

    
18
/**
19
 * check if there is anything to do
20
 */
21

    
22
/**
23
 * check if user has permissions to access this file
24
 */
25
// include WB configuration file and WB admin class
26
require_once('../../config.php');
27
require_once('../../framework/class.admin.php');
28

    
29
// check user permissions for admintools (redirect users with wrong permissions)
30
$admin = new admin('Admintools', 'admintools', false, false);
31

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

    
35
$js_back = ADMIN_URL . '/modules/index.php?advanced';
36
if( !$admin->checkFTAN() )
37
{
38
	$admin->print_header();
39
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back);
40
}
41

    
42
if ($admin->get_permission('admintools') == false) { die(header('Location: ../../index.php')); }
43

    
44
// check if the referer URL if available
45
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 
46
	(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : '');
47

    
48
// if referer is set, check if script was invoked from "admin/modules/index.php"
49
$required_url = ADMIN_URL . '/modules/index.php';
50
if ($referer != '' && (!(strpos($referer, $required_url) !== false || strpos($referer, $required_url) !== false))) 
51
{ die(header('Location: ../../index.php')); }
52

    
53
// include WB functions file
54
require_once(WB_PATH . '/framework/functions.php');
55

    
56
// load WB language file
57
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php');
58

    
59
// create Admin object with admin header
60
$admin = new admin('Addons', '', true, false);
61

    
62
/**
63
 * Manually execute the specified module file (install.php, upgrade.php or uninstall.php)
64
 */
65
// check if specified module folder exists
66
$mod_path = WB_PATH . '/modules/' . basename(WB_PATH . '/' . $_POST['file']);
67

    
68
// let the old variablename if module use it
69
$module_dir = $mod_path;
70
if (!file_exists($mod_path . '/' . $_POST['action'] . '.php'))
71
{
72
	$admin->print_header();
73
    $admin->print_error($TEXT['NOT_FOUND'].': <tt>"'.htmlentities(basename($mod_path)).'/'.$_POST['action'].'.php"</tt> ', $js_back);
74
}
75

    
76
// include modules install.php script
77
require($mod_path . '/' . $_POST['action'] . '.php');
78

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

    
83
switch ($_POST['action'])
84
{
85
	case 'install':
86
		// $admin->print_header();
87
		$admin->print_success($msg, $js_back);
88
		break;
89

    
90
	case 'upgrade':
91
		upgrade_module(basename($mod_path), false);
92
		// $admin->print_header();
93
		$admin->print_success($msg, $js_back);
94
		break;
95
	
96
	case 'uninstall':
97
		// $admin->print_header();
98
		$admin->print_success($msg, $js_back);
99
		break;
100
}
101

    
(4-4/5)