-
Notifications
You must be signed in to change notification settings - Fork 5
/
modify_adv_settings.php
181 lines (157 loc) · 7.77 KB
/
modify_adv_settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
/**
* WebsiteBaker CMS module: mpForm
* ===============================
* This module allows you to create customised online forms, such as a feedback form with file upload and customizable email notifications. mpForm allows forms over one or more pages, loops of forms, conditionally displayed sections within a single page, and many more things. User input for the same session_id will become a single row in the submitted table. Since Version 1.1.0 many ajax helpers enable you to speed up the process of creating forms with this module. Since 1.2.0 forms can be imported and exported directly in the module.
*
* @category page
* @module mpform
* @version 1.3.36
* @authors Frank Heyne, NorHei(heimsath.org), Christian M. Stefan (Stefek), Martin Hecht (mrbaseman) and others
* @copyright (c) 2009 - 2020, Website Baker Org. e.V.
* @url https://github.com/WebsiteBaker-modules/mpform
* @license GNU General Public License
* @platform 2.8.x
* @requirements php >= 5.3
*
**/
/* This file prints the advanced settings form of the module in the backend.*/
// unset page/section IDs defined via GET before including the admin file (we expect POST here)
unset($_GET['page_id']);
unset($_GET['section_id']);
// manually include the config.php file (defines the required constants)
require('../../config.php');
// $admin_header = false;
// Tells script to update when this page was last updated
$update_when_modified = false;
// show the info banner
$print_info_banner = true;
// Include WB admin wrapper script
require(WB_PATH.'/modules/admin.php');
// include core functions of WB 2.7 to edit the optional module CSS files (frontend.css, backend.css)
@include_once(WB_PATH .'/framework/module.functions.php');
// obtain module directory
$mod_dir = basename(dirname(__FILE__));
require_once(dirname(__FILE__).'/constants.php');
// include the module language file depending on the backend language of the current user
if (!@include(get_module_language_file($mod_dir))) return;
// Get header and footer
$query_content
= $database->query(
"SELECT *"
. " FROM `".TP_MPFORM."settings`"
. " WHERE `section_id` = '$section_id'"
);
$setting = $query_content->fetchRow();
// protect from cross page reading
if (($setting['page_id'] != $page_id)
&& (!(defined('MPFORM_SKIP_ID_CHECK')&&(MPFORM_SKIP_ID_CHECK)))) {
$sUrlToGo = ADMIN_URL."/pages/index.php";
if(headers_sent())
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']
.' (ID_CHECK) '.__FILE__.':'.__LINE__,
$sUrlToGo);
else
header("Location: ". $sUrlToGo);
exit(0);
}
// include template parser class and set template
if (!class_exists('Template') && file_exists(WB_PATH . '/include/phplib/template.inc'))
require_once(WB_PATH . '/include/phplib/template.inc');
$tpl = new Template(dirname(__FILE__) . '/htt/');
// define how to handle unknown variables
// (default:='remove', during development use 'keep' or 'comment')
$tpl->set_unknowns('keep');
// define debug mode (default:=0 (disabled), 1:=variable assignments,
// 2:=calls to get variable, 4:=show internals)
$tpl->debug = 0;
$tpl->set_file('page', 'backend_modify_adv_settings.htt');
$tpl->set_block('page', 'main_block', 'main');
// replace all placeholder {xxx} of the template file with values from language file
foreach($LANG['backend_adv'] as $key => $value) {
$tpl->set_var($key, $value);
}
// obtain display option from the database table
$table = TP_MPFORM.'settings';
$sql = "SELECT *"
. " FROM `$table`"
. " WHERE `section_id` = '$section_id'";
$sql_result = $database->query($sql);
$settings = $sql_result->fetchRow();
if($settings['value_option_separator']=="")
$settings['value_option_separator']=MPFORM_DEFAULT_OPT_SEPARATOR; // fallback
$settings['value_option_separator']=
htmlspecialchars($settings['value_option_separator'],ENT_QUOTES);
// replace all placeholder {xxx} of the template file with values from the db
foreach($settings as $key => $value) {
$tpl->set_var($key, $value);
}
$sCaptchaType = '';
if(class_exists('Settings') && defined('WBCE_VERSION')){
$sCaptchaType = Settings::Get('captcha_type', '');
}
if($sCaptchaType == ''){
$sCaptchaType = $database->get_one(
'SELECT `captcha_type` FROM `'.TABLE_PREFIX.'mod_captcha_control`'
);
}
$sImgSrc = '/include/captcha/captchas/'.$sCaptchaType.'.png';
$sCaptchaImgSrc = (file_exists(WB_PATH.$sImgSrc)) ? WB_URL.$sImgSrc : '';
// replace static template placeholders with values from language file
$tpl->set_var(
array(
// variables from Website Baker framework
'PAGE_ID' => (int) $page_id,
'SECTION_ID' => (int) $section_id,
'MOD_CLASS' => strtolower(basename(dirname(__FILE__))),
'MODULE_URL' => WB_URL . "/modules/mpform",
'FTAN' => method_exists( $admin, 'getFTAN' ) ? $admin->getFTAN() : '',
// variables from global WB language files
'des_use_captcha' => '',
'txt_use_captcha' => $TEXT['CAPTCHA_VERIFICATION'],
'CAPTCHA_TYPE_IMAGE' => $sCaptchaImgSrc != ''
? '<img style="border:1px dotted #ccc; "'
. ' alt="captcha_example"'
. ' id="captcha_example"'
. ' src="'.$sCaptchaImgSrc.'" />'
: '',
'use_captcha_true_checked' => (($settings['use_captcha']==true)
? 'checked="checked"' : ''),
'use_captcha_false_checked' => (($settings['use_captcha']==true)
? '' : 'checked="checked"'),
'des_max_submissions' => '',
'txt_max_submissions' => $TEXT['MAX_SUBMISSIONS_PER_HOUR'],
'txt_stored_submissions' => $TEXT['SUBMISSIONS_STORED_IN_DATABASE'],
'des_upload_files_folder' => '',
'MEDIA_DIRECTORY' => WB_PATH . MEDIA_DIRECTORY,
'des_attach_file' => '',
'attach_file_true_checked' => (($settings['attach_file']==true)
? 'checked="checked"' : ''),
'attach_file_false_checked' =>(($settings['attach_file']==true)
? '' : 'checked="checked"'),
'des_max_file_size_kb' => '',
'des_multiple_files' => '',
'multiple_files_true_checked' => (($settings['multiple_files']==true)
? 'checked="checked"' : ''),
'multiple_files_false_checked' =>(($settings['multiple_files']==true)
? '' : 'checked="checked"'),
'TXT_ENABLED' => $TEXT['ENABLED'],
'TXT_DISABLED' => $TEXT['DISABLED'],
'TXT_SAVE' => $TEXT['SAVE'],
'TXT_CANCEL' => $TEXT['CANCEL'],
// module settings
'MOD_SAVE_URL' => WB_URL
. str_replace("\\","/",
substr(
dirname(__FILE__),
strlen(WB_PATH)
)
)
. '/save_adv_settings.php',
'MOD_CANCEL_URL' => ADMIN_URL.'/pages/modify.php?page_id='.$page_id
)
);
// Parse template objects output
$tpl->parse('main', 'main_block', false);
$tpl->pparse('output', 'page',false, false);
$admin->print_footer();