Project

General

Profile

1 1392 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         templates
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 1457 Luisehahne
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16 1392 Luisehahne
 *
17
 */
18
19
// Include the config file
20
require('../../config.php');
21
require_once(WB_PATH .'/framework/functions.php');
22
require_once(WB_PATH.'/framework/class.admin.php');
23 1457 Luisehahne
// suppress to print the header, so no new FTAN will be set
24
$admin = new admin('Addons', 'templates_view', false);
25 1392 Luisehahne
if( !$admin->checkFTAN() )
26
{
27 1425 Luisehahne
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
28 1392 Luisehahne
}
29
30
// Get template name
31
if(!isset($_POST['file']) OR $_POST['file'] == "") {
32
	header("Location: index.php");
33
	exit(0);
34
} else {
35
	$file = preg_replace("/\W/", "", $admin->add_slashes($_POST['file']));  // fix secunia 2010-92-2
36
}
37
38
// Check if the template exists
39
if(!file_exists(WB_PATH.'/templates/'.$file)) {
40
	header("Location: index.php");
41
	exit(0);
42
}
43
44
// Print admin header
45
$admin = new admin('Addons', 'templates_view');
46
47
// Setup template object
48
$template = new Template(THEME_PATH.'/templates');
49
$template->set_file('page', 'templates_details.htt');
50
$template->set_block('page', 'main_block', 'main');
51
$template->set_var('FTAN', $admin->getFTAN());
52
53
// Insert values
54
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template' AND directory = '$file'");
55
if($result->numRows() > 0) {
56
	$row = $result->fetchRow();
57
}
58
59
// check if a template description exists for the displayed backend language
60
$tool_description = false;
61
if(function_exists('file_get_contents') && file_exists(WB_PATH.'/templates/'.$file.'/languages/'.LANGUAGE .'.php')) {
62
	// read contents of the template language file into string
63
	$data = @file_get_contents(WB_PATH .'/templates/' .$file .'/languages/' .LANGUAGE .'.php');
64
	// use regular expressions to fetch the content of the variable from the string
65
	$tool_description = get_variable_content('template_description', $data, false, false);
66
	// replace optional placeholder {WB_URL} with value stored in config.php
67
	if($tool_description !== false && strlen(trim($tool_description)) != 0) {
68
		$tool_description = str_replace('{WB_URL}', WB_URL, $tool_description);
69
	} else {
70
		$tool_description = false;
71
	}
72
}
73
if($tool_description !== false) {
74
	// Override the template-description with correct desription in users language
75
	$row['description'] = $tool_description;
76
}
77
78
$template->set_var(array(
79
								'NAME' => $row['name'],
80
								'AUTHOR' => $row['author'],
81
								'DESCRIPTION' => $row['description'],
82
								'VERSION' => $row['version'],
83
								'DESIGNED_FOR' => $row['platform']
84
								)
85
						);
86
87
// Insert language headings
88
$template->set_var(array(
89
								'HEADING_TEMPLATE_DETAILS' => $HEADING['TEMPLATE_DETAILS']
90
								)
91
						);
92
// Insert language text and messages
93
$template->set_var(array(
94
								'TEXT_NAME' => $TEXT['NAME'],
95
								'TEXT_AUTHOR' => $TEXT['AUTHOR'],
96
								'TEXT_VERSION' => $TEXT['VERSION'],
97
								'TEXT_DESIGNED_FOR' => $TEXT['DESIGNED_FOR'],
98
								'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
99
								'TEXT_BACK' => $TEXT['BACK']
100
								)
101
						);
102
103
// Parse template object
104
$template->parse('main', 'main_block', false);
105
$template->pparse('output', 'page');
106
107
// Print admin footer
108
$admin->print_footer();
109
110 4 ryan
?>