Project

General

Profile

« Previous | Next » 

Revision 1425

Added by Dietmar almost 14 years ago

redefined wrong admin backlinks

View differences:

reload.php
1
<?php

2
/**

3
 *

4
 * @category        admin

5
 * @package         addons

6
 * @author          WebsiteBaker Project

7
 * @copyright       2004-2009, Ryan Djurovich

8
 * @copyright       2009-2011, 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 5.2.2 and higher

13
 * @version         $Id$

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
if (!$admin->checkFTAN())
40
{

41
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL);

42
	exit();

43
}

44

  
45
// check if the referer URL if available

46
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 

47
	(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : '');
48

  
49
// if referer is set, check if script was invoked from "admin/modules/index.php"

50
$required_url = ADMIN_URL . '/addons/index.php';
51
if ($referer != '' && (!(strpos($referer, $required_url) !== false || strpos($referer, $required_url) !== false))) 

52
	die(header('Location: ../../index.php'));

53

  
54
// include WB functions file

55
require_once(WB_PATH . '/framework/functions.php');

56

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

59

  
60
// create Admin object with admin header

61
$admin = new admin('Addons', '', true, false);

62
$js_back = ADMIN_URL . '/addons/index.php?advanced';

63

  
64
/**

65
 * Reload all specified Addons

66
 */

67
$msg = array();

68
$table = TABLE_PREFIX . 'addons';

69

  
70
foreach ($post_check as $key) {

71
	switch ($key) {

72
		case 'reload_modules':

73
			if ($handle = opendir(WB_PATH . '/modules')) {

74
				// delete modules from database

75
				$sql = "DELETE FROM `$table` WHERE `type` = 'module'";

76
				$database->query($sql);

77

  
78
				// loop over all modules

79
				while(false !== ($file = readdir($handle))) {

80
					if ($file != '' && substr($file, 0, 1) != '.' && $file != 'admin.php' && $file != 'index.php') {

81
						load_module(WB_PATH . '/modules/' . $file);

82
					}

83
				}

84
				closedir($handle);

85
				// add success message

86
				$msg[] = $MESSAGE['ADDON']['MODULES_RELOADED'];

87

  
88
			} else {

89
				// provide error message and stop

90
				$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back);

91
			}

92
			break;

93
			
94
		case 'reload_templates':

95
			if ($handle = opendir(WB_PATH . '/templates')) {

96
				// delete templates from database

97
				$sql = "DELETE FROM `$table` WHERE `type` = 'template'";

98
				$database->query($sql);

99

  
100
				// loop over all templates

101
				while(false !== ($file = readdir($handle))) {

102
					if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {

103
						load_template(WB_PATH . '/templates/' . $file);

104
					}

105
				}

106
				closedir($handle);

107
				// add success message

108
				$msg[] = $MESSAGE['ADDON']['TEMPLATES_RELOADED'];

109

  
110
			} else {

111
				// provide error message and stop

112
				$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back);

113
			}

114
			break;

115

  
116
		case 'reload_languages':

117
			if ($handle = opendir(WB_PATH . '/languages/')) {

118
				// delete languages from database

119
				$sql = "DELETE FROM `$table` WHERE `type` = 'language'";

120
				$database->query($sql);

121
			
122
				// loop over all languages

123
				while(false !== ($file = readdir($handle))) {

124
					if ($file != '' && substr($file, 0, 1) != '.' && $file != 'index.php') {

125
						load_language(WB_PATH . '/languages/' . $file);

126
					}

127
				}

128
				closedir($handle);

129
				// add success message

130
				$msg[] = $MESSAGE['ADDON']['LANGUAGES_RELOADED'];

131
				
132
			} else {

133
				// provide error message and stop

134
				$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back);

135
			}

136
			break;

137
	}

138
}

139

  
140
// output success message

141
$admin->print_success(implode($msg, '<br />'), $js_back);

142
$admin->print_footer();

143

  
1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         addons
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, 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 5.2.2 and higher
13
 * @version         $Id$
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

  
38
if ($admin->get_permission('admintools') == false) die(header('Location: ../../index.php'));
39

  
40
// check if the referer URL if available
41
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] :
42
	(isset($HTTP_SERVER_VARS['HTTP_REFERER']) ? $HTTP_SERVER_VARS['HTTP_REFERER'] : '');
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
if (!$admin->checkFTAN())
59
{
60
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back);
61
	exit();
62
}
63

  
64
/**
65
 * Reload all specified Addons
66
 */
67
$msg = array();
68
$table = TABLE_PREFIX . 'addons';
69

  
70
foreach ($post_check as $key) {
71
	switch ($key) {
72
		case 'reload_modules':
73
			if ($handle = opendir(WB_PATH . '/modules')) {
74
				// delete modules from database
75
				$sql = "DELETE FROM `$table` WHERE `type` = 'module'";
76
				$database->query($sql);
77

  
78
				// loop over all modules
79
				while(false !== ($file = readdir($handle))) {
80
					if ($file != '' && substr($file, 0, 1) != '.' && $file != 'admin.php' && $file != 'index.php') {
81
						load_module(WB_PATH . '/modules/' . $file);
82
					}
83
				}
84
				closedir($handle);
85
				// add success message
86
				$msg[] = $MESSAGE['ADDON']['MODULES_RELOADED'];
87

  
88
			} else {
89
				// provide error message and stop
90
				$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back);
91
			}
92
			break;
93
			
94
		case 'reload_templates':
95
			if ($handle = opendir(WB_PATH . '/templates')) {
96
				// delete templates from database
97
				$sql = "DELETE FROM `$table` WHERE `type` = 'template'";
98
				$database->query($sql);
99

  
100
				// loop over all templates
101
				while(false !== ($file = readdir($handle))) {
102
					if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
103
						load_template(WB_PATH . '/templates/' . $file);
104
					}
105
				}
106
				closedir($handle);
107
				// add success message
108
				$msg[] = $MESSAGE['ADDON']['TEMPLATES_RELOADED'];
109

  
110
			} else {
111
				// provide error message and stop
112
				$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back);
113
			}
114
			break;
115

  
116
		case 'reload_languages':
117
			if ($handle = opendir(WB_PATH . '/languages/')) {
118
				// delete languages from database
119
				$sql = "DELETE FROM `$table` WHERE `type` = 'language'";
120
				$database->query($sql);
121
			
122
				// loop over all languages
123
				while(false !== ($file = readdir($handle))) {
124
					if ($file != '' && substr($file, 0, 1) != '.' && $file != 'index.php') {
125
						load_language(WB_PATH . '/languages/' . $file);
126
					}
127
				}
128
				closedir($handle);
129
				// add success message
130
				$msg[] = $MESSAGE['ADDON']['LANGUAGES_RELOADED'];
131
				
132
			} else {
133
				// provide error message and stop
134
				$admin->print_error($MESSAGE['ADDON']['ERROR_RELOAD'], $js_back);
135
			}
136
			break;
137
	}
138
}
139

  
140
// output success message
141
$admin->print_success(implode($msg, '<br />'), $js_back);
142
$admin->print_footer();
143

  
144 144
?>

Also available in: Unified diff