1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package templates
|
6
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7
|
* @copyright 2009-2012, WebsiteBaker 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: details.php 1712 2012-08-29 11:59:57Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/templates/details.php $
|
14
|
* @lastmodified $Date: 2012-08-29 13:59:57 +0200 (Wed, 29 Aug 2012) $
|
15
|
*
|
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
|
// suppress to print the header, so no new FTAN will be set
|
23
|
$admin = new admin('Addons', 'templates_view', false);
|
24
|
if( !$admin->checkFTAN() )
|
25
|
{
|
26
|
$admin->print_header();
|
27
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
|
28
|
}
|
29
|
|
30
|
// After check print the header
|
31
|
$admin->print_header();
|
32
|
// Get template name
|
33
|
if(!isset($_POST['file']) OR $_POST['file'] == "") {
|
34
|
$admin->print_error($MESSAGE['GENERIC_FORGOT_OPTIONS']);
|
35
|
} else {
|
36
|
$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']); // fix secunia 2010-92-2
|
37
|
}
|
38
|
|
39
|
// Check if the template exists
|
40
|
if(!is_dir(WB_PATH.'/templates/'.$file)) {
|
41
|
$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']);
|
42
|
}
|
43
|
|
44
|
// Check if the template exists
|
45
|
if(!is_readable(WB_PATH.'/templates/'.$file)) {
|
46
|
$admin->print_error($MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES']);
|
47
|
}
|
48
|
|
49
|
/*
|
50
|
if(!isset($_POST['file']) OR $_POST['file'] == "") {
|
51
|
header("Location: index.php");
|
52
|
exit(0);
|
53
|
} else {
|
54
|
$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']); // fix secunia 2010-92-2
|
55
|
}
|
56
|
|
57
|
if(!file_exists(WB_PATH.'/templates/'.$file)) {
|
58
|
header("Location: index.php");
|
59
|
exit(0);
|
60
|
}
|
61
|
// Check if the template exists
|
62
|
if(!is_dir(WB_PATH.'/templates/'.$file)) {
|
63
|
$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']);
|
64
|
}
|
65
|
*/
|
66
|
|
67
|
// Print admin header
|
68
|
//$admin = new admin('Addons', 'templates_view');
|
69
|
|
70
|
// Setup template object, parse vars to it, then parse it
|
71
|
// Create new template object
|
72
|
$template = new Template(dirname($admin->correct_theme_source('templates_details.htt')));
|
73
|
// $template->debug = true;
|
74
|
$template->set_file('page', 'templates_details.htt');
|
75
|
$template->set_block('page', 'main_block', 'main');
|
76
|
$template->set_var('FTAN', $admin->getFTAN());
|
77
|
|
78
|
// Insert values
|
79
|
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template' AND directory = '$file'");
|
80
|
if($result->numRows() > 0) {
|
81
|
$row = $result->fetchRow();
|
82
|
}
|
83
|
|
84
|
// check if a template description exists for the displayed backend language
|
85
|
$tool_description = false;
|
86
|
if(function_exists('file_get_contents') && file_exists(WB_PATH.'/templates/'.$file.'/languages/'.LANGUAGE .'.php')) {
|
87
|
// read contents of the template language file into string
|
88
|
$data = @file_get_contents(WB_PATH .'/templates/' .$file .'/languages/' .LANGUAGE .'.php');
|
89
|
// use regular expressions to fetch the content of the variable from the string
|
90
|
$tool_description = get_variable_content('template_description', $data, false, false);
|
91
|
// replace optional placeholder {WB_URL} with value stored in config.php
|
92
|
if($tool_description !== false && strlen(trim($tool_description)) != 0) {
|
93
|
$tool_description = str_replace('{WB_URL}', WB_URL, $tool_description);
|
94
|
} else {
|
95
|
$tool_description = false;
|
96
|
}
|
97
|
}
|
98
|
if($tool_description !== false) {
|
99
|
// Override the template-description with correct desription in users language
|
100
|
$row['description'] = $tool_description;
|
101
|
}
|
102
|
|
103
|
$template->set_var(array(
|
104
|
'NAME' => $row['name'],
|
105
|
'AUTHOR' => $row['author'],
|
106
|
'DESCRIPTION' => $row['description'],
|
107
|
'VERSION' => $row['version'],
|
108
|
'DESIGNED_FOR' => $row['platform'],
|
109
|
'LICENSE' => $row['license'],
|
110
|
)
|
111
|
);
|
112
|
|
113
|
$mLang = ModLanguage::getInstance();
|
114
|
$mLang->setLanguage(ADMIN_PATH.'/addons/languages/', LANGUAGE, DEFAULT_LANGUAGE);
|
115
|
|
116
|
/*-- insert all needed vars from language files ----------------------------------------*/
|
117
|
$template->set_var($mLang->getLangArray());
|
118
|
|
119
|
$template->set_var('TEXT_FUNCTION', ($row['function'] == 'theme' ? $mLang->TEXT_THEME : $mLang->TEXT_TEMPLATE));
|
120
|
// Parse template object
|
121
|
$template->parse('main', 'main_block', false);
|
122
|
$template->pparse('output', 'page');
|
123
|
|
124
|
// Print admin footer
|
125
|
$admin->print_footer();
|