Project

General

Profile

1 1386 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         modules
6 1529 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7 1386 Luisehahne
 * @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$
13 1457 Luisehahne
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15 1386 Luisehahne
 *
16
 */
17
18
// Include the config file
19
require('../../config.php');
20
require_once(WB_PATH .'/framework/functions.php');
21
require_once(WB_PATH.'/framework/class.admin.php');
22
// No print admin header
23
$admin = new admin('Addons', 'modules_view', false);
24 1457 Luisehahne
if( !$admin->checkFTAN() )
25
{
26 1467 Luisehahne
	$admin->print_header();
27 1457 Luisehahne
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
28
}
29
// After check print the header
30
$admin->print_header();
31 1386 Luisehahne
32
// Get module name
33
if(!isset($_POST['file']) OR $_POST['file'] == "")
34
{
35
	header("Location: index.php");
36
	exit(0);
37
}
38
else
39
{
40 1494 Luisehahne
	$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']);  // fix secunia 2010-92-1
41 1386 Luisehahne
}
42
43
// Check if the module exists
44
if(!file_exists(WB_PATH.'/modules/'.$file)) {
45
	header("Location: index.php");
46
	exit(0);
47
}
48
49 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
50
$ThemePath = realpath(WB_PATH.$admin->correct_theme_source('modules_details.htt'));
51
// Create new template object
52
$template = new Template($ThemePath);
53
// $template->debug = true;
54 1386 Luisehahne
$template->set_file('page', 'modules_details.htt');
55
$template->set_block('page', 'main_block', 'main');
56
57
// Insert values
58
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND directory = '$file'");
59
if($result->numRows() > 0) {
60
	$module = $result->fetchRow();
61
}
62
63
// check if a module description exists for the displayed backend language
64
$tool_description = false;
65
if(function_exists('file_get_contents') && file_exists(WB_PATH.'/modules/'.$file.'/languages/'.LANGUAGE .'.php')) {
66
	// read contents of the module language file into string
67
	$data = @file_get_contents(WB_PATH .'/modules/' .$file .'/languages/' .LANGUAGE .'.php');
68
	// use regular expressions to fetch the content of the variable from the string
69
	$tool_description = get_variable_content('module_description', $data, false, false);
70
	// replace optional placeholder {WB_URL} with value stored in config.php
71
	if($tool_description !== false && strlen(trim($tool_description)) != 0) {
72
		$tool_description = str_replace('{WB_URL}', WB_URL, $tool_description);
73
	} else {
74
		$tool_description = false;
75
	}
76
}
77
if($tool_description !== false) {
78
	// Override the module-description with correct desription in users language
79
	$module['description'] = $tool_description;
80
}
81
82
$template->set_var(array(
83
								'NAME' => $module['name'],
84
								'AUTHOR' => $module['author'],
85
								'DESCRIPTION' => $module['description'],
86
								'VERSION' => $module['version'],
87
								'DESIGNED_FOR' => $module['platform'],
88
								'ADMIN_URL' => ADMIN_URL,
89
								'WB_URL' => WB_URL,
90
								'THEME_URL' => THEME_URL
91
								)
92
						);
93
94
switch ($module['function']) {
95
	case NULL:
96
		$type_name = $TEXT['UNKNOWN'];
97
		break;
98
	case 'page':
99
		$type_name = $TEXT['PAGE'];
100
		break;
101
	case 'wysiwyg':
102
		$type_name = $TEXT['WYSIWYG_EDITOR'];
103
		break;
104
	case 'tool':
105
		$type_name = $TEXT['ADMINISTRATION_TOOL'];
106
		break;
107
	case 'admin':
108
		$type_name = $TEXT['ADMIN'];
109
		break;
110
	case 'administration':
111
		$type_name = $TEXT['ADMINISTRATION'];
112
		break;
113
	case 'snippet':
114
		$type_name = $TEXT['CODE_SNIPPET'];
115
		break;
116
	default:
117
		$type_name = $TEXT['UNKNOWN'];
118
}
119
$template->set_var('TYPE', $type_name);
120
121
// Insert language headings
122
$template->set_var(array(
123
								'HEADING_MODULE_DETAILS' => $HEADING['MODULE_DETAILS']
124
								)
125
						);
126
// Insert language text and messages
127
$template->set_var(array(
128
								'TEXT_NAME' => $TEXT['NAME'],
129
								'TEXT_TYPE' => $TEXT['TYPE'],
130
								'TEXT_AUTHOR' => $TEXT['AUTHOR'],
131
								'TEXT_VERSION' => $TEXT['VERSION'],
132
								'TEXT_DESIGNED_FOR' => $TEXT['DESIGNED_FOR'],
133
								'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
134
								'TEXT_BACK' => $TEXT['BACK']
135
								)
136
						);
137
138
// Parse module object
139
$template->parse('main', 'main_block', false);
140
$template->pparse('output', 'page');
141
142
// Print admin footer
143
$admin->print_footer();