Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         modules
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/modules/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
// No print admin header
24
$admin = new admin('Addons', 'modules_view', false);
25

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

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

    
34
// Get module name
35
    $file = '';
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 module 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 module exists
55
if (!file_exists(WB_PATH.'/modules/'.$file)) {
56
    $admin->print_error(' ('.$file.') '.$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('modules_details.htt')));
62
// $template->debug = true;
63
$template->set_file('page', 'modules_details.htt');
64
$template->set_block('page', 'main_block', 'main');
65

    
66

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

    
75
// check if a module description exists for the displayed backend language
76
$tool_description = false;
77
if(function_exists('file_get_contents') && file_exists(WB_PATH.'/modules/'.$file.'/languages/'.LANGUAGE .'.php')) {
78
    // read contents of the module language file into string
79
    $data = @file_get_contents(WB_PATH .'/modules/' .$file .'/languages/' .LANGUAGE .'.php');
80
    // use regular expressions to fetch the content of the variable from the string
81
    $tool_description = get_variable_content('module_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 module-description with correct desription in users language
91
    $module['description'] = $tool_description;
92
}
93

    
94
$template->set_var(array(
95
                      'NAME' => $module['name'],
96
                      'AUTHOR' => $module['author'],
97
                      'DESCRIPTION' => $module['description'],
98
                      'VERSION' => $module['version'],
99
                      'DESIGNED_FOR' => $module['platform'],
100
                      'ADMIN_URL' => ADMIN_URL,
101
                      'WB_URL' => WB_URL,
102
                      'THEME_URL' => THEME_URL
103
                      )
104
                        );
105

    
106
switch ($module['function']) {
107
    case NULL:
108
        $type_name = $TEXT['UNKNOWN'];
109
        break;
110
    case 'page':
111
        $type_name = $TEXT['PAGE'];
112
        break;
113
    case 'wysiwyg':
114
        $type_name = $TEXT['WYSIWYG_EDITOR'];
115
        break;
116
    case 'tool':
117
        $type_name = $TEXT['ADMINISTRATION_TOOL'];
118
        break;
119
    case 'admin':
120
        $type_name = $TEXT['ADMIN'];
121
        break;
122
    case 'administration':
123
        $type_name = $TEXT['ADMINISTRATION'];
124
        break;
125
    case 'snippet':
126
        $type_name = $TEXT['CODE_SNIPPET'];
127
        break;
128
    default:
129
        $type_name = $TEXT['UNKNOWN'];
130
}
131
$template->set_var('TYPE', $type_name);
132

    
133
// Insert language headings
134
$template->set_var(array(
135
                                'HEADING_MODULE_DETAILS' => $HEADING['MODULE_DETAILS']
136
                                )
137
                        );
138
// Insert language text and messages
139
$template->set_var(array(
140
                                'TEXT_NAME' => $TEXT['NAME'],
141
                                'TEXT_TYPE' => $TEXT['TYPE'],
142
                                'TEXT_AUTHOR' => $TEXT['AUTHOR'],
143
                                'TEXT_VERSION' => $TEXT['VERSION'],
144
                                'TEXT_DESIGNED_FOR' => $TEXT['DESIGNED_FOR'],
145
                                'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
146
                                'TEXT_BACK' => $TEXT['BACK']
147
                                )
148
                        );
149

    
150
// Parse module object
151
$template->parse('main', 'main_block', false);
152
$template->pparse('output', 'page');
153

    
154
// Print admin footer
155
$admin->print_footer();
(1-1/5)