1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package addons
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2004-2009, Ryan Djurovich
|
8
|
* @copyright 2009-2010, Website Baker Org. e.V.
|
9
|
* @link http://www.websitebaker2.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.x
|
12
|
* @requirements PHP 4.3.4 and higher
|
13
|
* @version $Id: reload.php 1289 2010-02-10 15:13:21Z kweitzel $
|
14
|
* @filesource $HeadURL: $
|
15
|
* @lastmodified $Date: $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
/**
|
20
|
* check if there is anything to do
|
21
|
*/
|
22
|
$post_check = array('reload_modules', 'reload_templates', 'reload_languages');
|
23
|
foreach ($post_check as $index => $key) {
|
24
|
if (!isset($_POST[$key])) unset($post_check[$index]);
|
25
|
}
|
26
|
if (count($post_check) == 0) die(header('Location: index.php?advanced'));
|
27
|
|
28
|
/**
|
29
|
* check if user has permissions to access this file
|
30
|
*/
|
31
|
// include WB configuration file and WB admin class
|
32
|
require_once('../../config.php');
|
33
|
require_once('../../framework/class.admin.php');
|
34
|
|
35
|
// check user permissions for admintools (redirect users with wrong permissions)
|
36
|
$admin = new admin('Admintools', 'admintools', false, false);
|
37
|
if ($admin->get_permission('admintools') == false) die(header('Location: ../../index.php'));
|
38
|
|
39
|
// check if the referer URL if available
|
40
|
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] :
|
41
|
(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : '');
|
42
|
|
43
|
// if referer is set, check if script was invoked from "admin/modules/index.php"
|
44
|
$required_url = ADMIN_URL . '/addons/index.php';
|
45
|
if ($referer != '' && (!(strpos($referer, $required_url) !== false || strpos($referer, $required_url) !== false)))
|
46
|
die(header('Location: ../../index.php'));
|
47
|
|
48
|
// include WB functions file
|
49
|
require_once(WB_PATH . '/framework/functions.php');
|
50
|
|
51
|
// load WB language file
|
52
|
require_once(WB_PATH . '/languages/' . LANGUAGE .'.php');
|
53
|
|
54
|
// create Admin object with admin header
|
55
|
$admin = new admin('Addons', '', true, false);
|
56
|
$js_back = ADMIN_URL . '/addons/index.php?advanced';
|
57
|
|
58
|
/**
|
59
|
* Reload all specified Addons
|
60
|
*/
|
61
|
$msg = array();
|
62
|
$table = TABLE_PREFIX . 'addons';
|
63
|
|
64
|
foreach ($post_check as $key) {
|
65
|
switch ($key) {
|
66
|
case 'reload_modules':
|
67
|
if ($handle = opendir(WB_PATH . '/modules')) {
|
68
|
// delete modules from database
|
69
|
$sql = "DELETE FROM `$table` WHERE `type` = 'module'";
|
70
|
$database->query($sql);
|
71
|
|
72
|
// loop over all modules
|
73
|
while(false !== ($file = readdir($handle))) {
|
74
|
if ($file != '' && substr($file, 0, 1) != '.' && $file != 'admin.php' && $file != 'index.php') {
|
75
|
load_module(WB_PATH . '/modules/' . $file);
|
76
|
}
|
77
|
}
|
78
|
closedir($handle);
|
79
|
// add success message
|
80
|
$msg[] = $MESSAGE['ADDON']['MODULES_RELOADED'];
|
81
|
|
82
|
} else {
|
83
|
// provide error message and stop
|
84
|
$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back);
|
85
|
}
|
86
|
break;
|
87
|
|
88
|
case 'reload_templates':
|
89
|
if ($handle = opendir(WB_PATH . '/templates')) {
|
90
|
// delete templates from database
|
91
|
$sql = "DELETE FROM `$table` WHERE `type` = 'template'";
|
92
|
$database->query($sql);
|
93
|
|
94
|
// loop over all templates
|
95
|
while(false !== ($file = readdir($handle))) {
|
96
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
|
97
|
load_template(WB_PATH . '/templates/' . $file);
|
98
|
}
|
99
|
}
|
100
|
closedir($handle);
|
101
|
// add success message
|
102
|
$msg[] = $MESSAGE['ADDON']['TEMPLATES_RELOADED'];
|
103
|
|
104
|
} else {
|
105
|
// provide error message and stop
|
106
|
$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back);
|
107
|
}
|
108
|
break;
|
109
|
|
110
|
case 'reload_languages':
|
111
|
if ($handle = opendir(WB_PATH . '/languages/')) {
|
112
|
// delete languages from database
|
113
|
$sql = "DELETE FROM `$table` WHERE `type` = 'language'";
|
114
|
$database->query($sql);
|
115
|
|
116
|
// loop over all languages
|
117
|
while(false !== ($file = readdir($handle))) {
|
118
|
if ($file != '' && substr($file, 0, 1) != '.' && $file != 'index.php') {
|
119
|
load_language(WB_PATH . '/languages/' . $file);
|
120
|
}
|
121
|
}
|
122
|
closedir($handle);
|
123
|
// add success message
|
124
|
$msg[] = $MESSAGE['ADDON']['LANGUAGES_RELOADED'];
|
125
|
|
126
|
} else {
|
127
|
// provide error message and stop
|
128
|
$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back);
|
129
|
}
|
130
|
break;
|
131
|
}
|
132
|
}
|
133
|
|
134
|
// output success message
|
135
|
$admin->print_success(implode($msg, '<br />'), $js_back);
|
136
|
$admin->print_footer();
|
137
|
|
138
|
?>
|