1 |
1392
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category admin
|
5 |
|
|
* @package templates
|
6 |
1529
|
Luisehahne
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7 |
1712
|
Luisehahne
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8 |
1392
|
Luisehahne
|
* @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 |
1392
|
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 |
1457
|
Luisehahne
|
// suppress to print the header, so no new FTAN will be set
|
23 |
|
|
$admin = new admin('Addons', 'templates_view', false);
|
24 |
1392
|
Luisehahne
|
if( !$admin->checkFTAN() )
|
25 |
|
|
{
|
26 |
1467
|
Luisehahne
|
$admin->print_header();
|
27 |
1425
|
Luisehahne
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
|
28 |
1392
|
Luisehahne
|
}
|
29 |
|
|
|
30 |
1712
|
Luisehahne
|
// After check print the header
|
31 |
|
|
$admin->print_header();
|
32 |
1392
|
Luisehahne
|
// Get template name
|
33 |
|
|
if(!isset($_POST['file']) OR $_POST['file'] == "") {
|
34 |
1712
|
Luisehahne
|
$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 |
1392
|
Luisehahne
|
header("Location: index.php");
|
52 |
|
|
exit(0);
|
53 |
|
|
} else {
|
54 |
1494
|
Luisehahne
|
$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']); // fix secunia 2010-92-2
|
55 |
1392
|
Luisehahne
|
}
|
56 |
|
|
|
57 |
|
|
if(!file_exists(WB_PATH.'/templates/'.$file)) {
|
58 |
|
|
header("Location: index.php");
|
59 |
|
|
exit(0);
|
60 |
|
|
}
|
61 |
1712
|
Luisehahne
|
// Check if the template exists
|
62 |
|
|
if(!is_dir(WB_PATH.'/templates/'.$file)) {
|
63 |
|
|
$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']);
|
64 |
|
|
}
|
65 |
|
|
*/
|
66 |
1392
|
Luisehahne
|
|
67 |
|
|
// Print admin header
|
68 |
1712
|
Luisehahne
|
//$admin = new admin('Addons', 'templates_view');
|
69 |
1392
|
Luisehahne
|
|
70 |
1529
|
Luisehahne
|
// Setup template object, parse vars to it, then parse it
|
71 |
|
|
// Create new template object
|
72 |
1625
|
Luisehahne
|
$template = new Template(dirname($admin->correct_theme_source('templates_details.htt')));
|
73 |
1529
|
Luisehahne
|
// $template->debug = true;
|
74 |
1392
|
Luisehahne
|
$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 |
1712
|
Luisehahne
|
}
|
102 |
1392
|
Luisehahne
|
|
103 |
|
|
$template->set_var(array(
|
104 |
1750
|
Luisehahne
|
'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 |
1392
|
Luisehahne
|
|
113 |
1913
|
Luisehahne
|
//$mLang = ModLanguage::getInstance();
|
114 |
|
|
//$mLang->setLanguage(ADMIN_PATH.'/addons/languages/', LANGUAGE, DEFAULT_LANGUAGE);
|
115 |
|
|
$mLang = Translate::getinstance();
|
116 |
|
|
$mLang->enableAddon('admin\addons');
|
117 |
1712
|
Luisehahne
|
|
118 |
|
|
/*-- insert all needed vars from language files ----------------------------------------*/
|
119 |
|
|
$template->set_var($mLang->getLangArray());
|
120 |
|
|
|
121 |
|
|
$template->set_var('TEXT_FUNCTION', ($row['function'] == 'theme' ? $mLang->TEXT_THEME : $mLang->TEXT_TEMPLATE));
|
122 |
1392
|
Luisehahne
|
// Parse template object
|
123 |
|
|
$template->parse('main', 'main_block', false);
|
124 |
|
|
$template->pparse('output', 'page');
|
125 |
|
|
|
126 |
|
|
// Print admin footer
|
127 |
|
|
$admin->print_footer();
|