Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         templates
6
 * @author          WebsiteBaker Project
7
 * @copyright       Ryan Djurovich
8
 * @copyright       WebsiteBaker Org. e.V.
9
 * @link            http://websitebaker.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.3
12
 * @requirements    PHP 5.3.6 and higher
13
 * @version         $Id: details.php 2 2017-07-02 15:14:29Z Manuela $
14
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/admin/templates/details.php $
15
 * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
16
 *
17
 */
18
// Include config file and admin class file
19
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
20
if ( !class_exists('admin', false) ) { require(WB_PATH.'/framework/class.admin.php'); }
21

    
22
require_once(WB_PATH .'/framework/functions.php');
23
// suppress to print the header, so no new FTAN will be set
24
$admin = new admin('Addons', 'templates_view', false);
25

    
26
$js_back = ADMIN_URL.'/templates/index.php';
27

    
28
    if( !$admin->checkFTAN() ){
29
        $admin->print_header();
30
        $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL );
31
    }
32
    $admin->print_header();
33

    
34
    $file = '';
35
// Check if user selected template
36
    if (!isset($_POST['file']) || $_POST['file'] == false) {
37
        $iAddonId = 0;
38
        $admin->print_error( $MESSAGE['GENERIC_FORGOT_OPTIONS'], $js_back );
39
    } else {
40
        $iAddonId = $admin->checkIDKEY('file',0);
41
    }
42
    if ($iAddonId == 0){
43
        $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $js_back );
44
    }
45

    
46
// Get template directory
47
    $sqlAddons = 'SELECT `directory` FROM `'.TABLE_PREFIX.'addons` '
48
               . 'WHERE `addon_id`='.(int)$iAddonId.' '
49
               . ''.'';
50
    if ($file = $database->get_one($sqlAddons)) {
51
        $file = preg_replace('/[^a-z0-9_-]/i', "", $file);  // fix secunia 2010-92-2
52
    }
53

    
54
// Check if the template exists
55
    if (!is_readable(WB_PATH.'/templates/'.$file)) {
56
        $admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED'], $js_back );
57
    }
58

    
59
// Setup template object, parse vars to it, then parse it
60
// Create new template object
61
$template = new Template(dirname($admin->correct_theme_source('templates_details.htt')));
62
// $template->debug = true;
63
$template->set_file('page', 'templates_details.htt');
64
$template->set_block('page', 'main_block', 'main');
65
$template->set_var('FTAN', $admin->getFTAN());
66

    
67
// Insert values
68
    $sqlAddons  = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '
69
                . 'WHERE `type` = \'template\' '
70
                . 'AND `directory` = \''.$file.'\'';
71
    if($result = $database->query($sqlAddons)) {
72
        $row = $result->fetchRow(MYSQLI_ASSOC);
73
    }
74

    
75
// check if a template description exists for the displayed backend language
76
$tool_description = false;
77
if(function_exists('file_get_contents') && file_exists(WB_PATH.'/templates/'.$file.'/languages/'.LANGUAGE .'.php')) {
78
    // read contents of the template language file into string
79
    $data = @file_get_contents(WB_PATH .'/templates/' .$file .'/languages/' .LANGUAGE .'.php');
80
    // use regular expressions to fetch the content of the variable from the string
81
    $tool_description = get_variable_content('template_description', $data, false, false);
82
    // replace optional placeholder {WB_URL} with value stored in config.php
83
    if($tool_description !== false && strlen(trim($tool_description)) != 0) {
84
        $tool_description = str_replace('{WB_URL}', WB_URL, $tool_description);
85
    } else {
86
        $tool_description = false;
87
    }
88
}
89
if($tool_description !== false) {
90
    // Override the template-description with correct desription in users language
91
    $row['description'] = $tool_description;
92
}
93

    
94
$template->set_var(array(
95
                                'NAME' => $row['name'],
96
                                'TYPE' => $row['function'],
97
                                'AUTHOR' => $row['author'],
98
                                'DESCRIPTION' => $row['description'],
99
                                'VERSION' => $row['version'],
100
                                'DESIGNED_FOR' => $row['platform']
101
                                )
102
                        );
103

    
104
// Insert language headings
105
$template->set_var(array(
106
                                'HEADING_TEMPLATE_DETAILS' => $HEADING['TEMPLATE_DETAILS']
107
                                )
108
                        );
109
// Insert language text and messages
110
$template->set_var(array(
111
                                'TEXT_NAME' => $TEXT['NAME'],
112
                                'TEXT_TYPE' => $TEXT['TYPE'],
113
                                'TEXT_AUTHOR' => $TEXT['AUTHOR'],
114
                                'TEXT_VERSION' => $TEXT['VERSION'],
115
                                'TEXT_DESIGNED_FOR' => $TEXT['DESIGNED_FOR'],
116
                                'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
117
                                'TEXT_BACK' => $TEXT['BACK']
118
                                )
119
                        );
120

    
121
// Parse template object
122
$template->parse('main', 'main_block', false);
123
$template->pparse('output', 'page');
124

    
125
// Print admin footer
126
$admin->print_footer();
(1-1/4)