-
Notifications
You must be signed in to change notification settings - Fork 4
/
save_settings.php
187 lines (167 loc) · 6.63 KB
/
save_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
181
182
183
184
185
186
187
<?php
/**
*
* @category modules
* @package news_img
* @author WBCE Community
* @copyright 2004-2009, Ryan Djurovich
* @copyright 2009-2010, Website Baker Org. e.V.
* @copyright 2019-, WBCE Community
* @link https://www.wbce.org/
* @license http://www.gnu.org/licenses/gpl.html
* @platform WBCE
*
*/
require_once __DIR__.'/functions.inc.php';
// Include WB admin wrapper script
$update_when_modified = true; // Tells script to update when this page was last updated
$admin_header = false;
require WB_PATH.'/modules/admin.php';
if (!defined('CAT_PATH')) {
if (!$admin->checkFTAN()) {
$admin->print_header();
$admin->print_error(
$MESSAGE['GENERIC_SECURITY_ACCESS']
.' (FTAN) '.__FILE__.':'.__LINE__,
ADMIN_URL.'/pages/index.php'
);
$admin->print_footer();
exit();
} else {
$admin->print_header();
}
}
// change mode
if(isset($_POST['mode']) && in_array($_POST['mode'],array('default','advanced'))) {
$database->query(sprintf(
"UPDATE `%smod_news_img_settings`"
. " SET `mode`='%s' WHERE `section_id`=%d",
TABLE_PREFIX, $_POST['mode'], $section_id
));
if ($database->is_error()) {
$admin->print_error($database->get_error(), ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
} else {
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
}
$admin->print_footer();
exit;
}
// This code removes any <?php tags and adds slashes
$friendly = array('<', '>', '?php');
$raw = array('<', '>', '');
// get current settings
$settings = mod_nwi_settings_get($section_id);
// always there
$header = mod_nwi_escapeString(str_replace($friendly, $raw, $_POST['header']));
$post_loop = mod_nwi_escapeString(str_replace($friendly, $raw, $_POST['post_loop']));
$view_order = intval($_POST['view_order']);
$footer = mod_nwi_escapeString(str_replace($friendly, $raw, $_POST['footer']));
$post_header = mod_nwi_escapeString(str_replace($friendly, $raw, $_POST['post_header']));
$post_content = mod_nwi_escapeString(str_replace($friendly, $raw, $_POST['post_content']));
$post_footer = mod_nwi_escapeString(str_replace($friendly, $raw, $_POST['post_footer']));
$posts_per_page = mod_nwi_escapeString($_POST['posts_per_page']);
$gallery = mod_nwi_escapeString($_POST['gallery']);
$use_second_block = ( (isset($_POST['use_second_block']) && $_POST['use_second_block']=='Y') ? 'Y' : 'N');
$show_settings_only_admins = ( (isset($_POST['show_settings_only_admins']) && $_POST['show_settings_only_admins']=='Y') ? 'Y' : 'N');
// expert mode
if(isset($settings['mode']) && $settings['mode']=='advanced') {
$image_loop = mod_nwi_escapeString(str_replace($friendly, $raw, $_POST['image_loop']));
$gal_img_resize_width = mod_nwi_escapeString($_POST['gal_img_resize_width']);
$gal_img_resize_height = mod_nwi_escapeString($_POST['gal_img_resize_height']);
$gal_img_max_size = intval($_POST['gal_img_max_size'])*1024;
$view = mod_nwi_escapeString($_POST['view']);
$block2 = mod_nwi_escapeString(str_replace($friendly, $raw, $_POST['block2']));
$thumbwidth = mod_nwi_escapeString($_POST['thumb_width']);
$thumbheight = mod_nwi_escapeString($_POST['thumb_height']);
} else {
$image_loop = $settings['image_loop'];
$gal_img_resize_width = $settings['imgmaxwidth'];
$gal_img_resize_height = $settings['imgmaxheight'];
$gal_img_max_size = $settings['imgmaxsize'];
$view = $settings['view'];
$block2 = $settings['block2'];
list($previewwidth,
$previewheight,
$thumbwidth,
$thumbheight
) = mod_nwi_get_sizes($section_id);
}
// if the user chooses a new view, the settings are overwritten by the
// defaults of this view!
if(!empty($view) && $view != $settings['view']) {
include __DIR__.'/views/'.$view.'/config.php';
}
$resize_preview = '';
$crop = 'N';
$width = $_POST['resize_width'];
$height = $_POST['resize_height'];
$thumbsize = "100x100"; // default
$crop = (isset($_POST['crop_preview']) ? $_POST['crop_preview'] : 'N');
if (is_numeric($width) && is_numeric($height)) {
if ($height>0 && $width>0) {
$resize_preview = $width.'x'.$height;
}
}
if (is_numeric($thumbwidth) && is_numeric($thumbheight)) {
if ($thumbheight>0 && $thumbwidth>0) {
$thumbsize = $thumbwidth.'x'.$thumbheight;
}
}
if ($crop=='on') {
$crop = 'Y';
} else {
$crop = 'N';
}
if ($posts_per_page=='') {
$posts_per_page = 0; // unlimited
}
// if the gallery setting changed, load default settings
$query_content = $database->query("SELECT `gallery` FROM `".TABLE_PREFIX."mod_news_img_settings` WHERE `section_id` = '$section_id'");
$fetch_content = $query_content->fetchRow();
if ($fetch_content['gallery'] != $gallery) {
include WB_PATH.'/modules/news_img/js/galleries/'.$gallery.'/settings.php';
}
$gal_img_max_size = intval($gal_img_max_size);
$gal_img_resize_width = intval($gal_img_resize_width);
$gal_img_resize_height = intval($gal_img_resize_height);
// if the "use block 2" setting changed...
if($settings['use_second_block'] != $use_second_block) {
// from on to off: delete content
if($use_second_block == 'N') {
$block2 = '';
}
}
// Update settings
$database->query(
"UPDATE `".TABLE_PREFIX."mod_news_img_settings`"
. " SET"
. " `header` = '$header',"
. " `post_loop` = '$post_loop',"
. " `view_order` = '$view_order',"
. " `footer` = '$footer',"
. " `block2` = '$block2',"
. " `posts_per_page` = '$posts_per_page',"
. " `post_header` = '$post_header',"
. " `post_content` = '$post_content',"
. " `image_loop` = '$image_loop',"
. " `post_footer` = '$post_footer',"
. " `resize_preview` = '$resize_preview',"
. " `crop_preview` = '$crop',"
. " `gallery` = '$gallery',"
. " `imgmaxsize`='$gal_img_max_size',"
. " `imgmaxwidth`='$gal_img_resize_width',"
. " `imgmaxheight`='$gal_img_resize_height',"
. " `imgthumbsize`='$thumbsize',"
. " `use_second_block`='$use_second_block',"
. " `show_settings_only_admins`='$show_settings_only_admins',"
. " `view`='$view'"
. " WHERE `section_id` = '$section_id'"
);
// Check result
if ($database->is_error()) {
$admin->print_error($database->get_error(), ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
} else {
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
}
// Print admin footer
$admin->print_footer();