Project

General

Profile

1
<?php
2
/**
3
 * $Id: manual_install.php 938 2009-02-19 19:13:24Z doc $
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.2.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['action']) && in_array($_POST['action'], array('install', 'upgrade', 'uninstall')))) die(header('Location: index.php?advanced'));
40
if (!(isset($_POST['file']) && $_POST['file'] != '' && (strpos($_POST['file'], '..') === false))) die(header('Location: index.php?advanced'));
41

    
42
/**
43
 * check if user has permissions to access this file
44
 */
45
// include WB configuration file and WB admin class
46
require_once('../../config.php');
47
require_once('../../framework/class.admin.php');
48

    
49
// check user permissions for admintools (redirect users with wrong permissions)
50
$admin = new admin('Admintools', 'admintools', false, false);
51
if ($admin->get_permission('admintools') == false) die(header('Location: ../../index.php'));
52

    
53
// check if the referer URL if available
54
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 
55
	(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : '');
56

    
57
// if referer is set, check if script was invoked from "admin/modules/index.php"
58
$required_url = ADMIN_URL . '/modules/index.php';
59
if ($referer != '' && (!(strpos($referer, $required_url) !== false || strpos($referer, $required_url) !== false))) 
60
	die(header('Location: ../../index.php'));
61

    
62
// include WB functions file
63
require_once(WB_PATH . '/framework/functions.php');
64

    
65
// load WB language file
66
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php');
67

    
68
// create Admin object with admin header
69
$admin = new admin('Addons', '', true, false);
70
$js_back = ADMIN_URL . '/modules/index.php?advanced';
71

    
72
/**
73
 * Manually execute the specified module file (install.php, upgrade.php or uninstall.php)
74
 */
75
// check if specified module folder exists
76
$mod_path = WB_PATH . '/modules/' . basename(WB_PATH . '/' . $_POST['file']);
77
if (!file_exists($mod_path . '/' . $_POST['action'] . '.php')) $admin->print_error($TEXT['NOT_FOUND'] . ': <tt>"' . htmlentities(basename($mod_path)) . '/' . $_POST['action'] . '.php"</tt> ', $js_back);
78

    
79
// include modules install.php script
80
require($mod_path . '/' . $_POST['action'] . '.php');
81

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

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

    
91
	case 'upgrade':
92
		$admin->print_success($msg, $js_back);
93
		break;
94
	
95
	case 'uninstall':
96
		$admin->print_success($msg, $js_back);
97
		break;
98
}
99

    
100
?>
(4-4/5)