/
save_settings.php
99 lines (87 loc) · 2.91 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
<?php
/**
* CMS module: Download Gallery 3
* Copyright and more information see file info.php
**/
require_once '../../config.php';
$dlgmodname = str_replace(str_replace('\\','/',WB_PATH).'/modules/','',str_replace('\\','/',dirname(__FILE__)));
// Include WB admin wrapper script
$update_when_modified = true; // Tells script to update when this page was last updated
require WB_PATH.'/modules/admin.php';
include_once WB_PATH.'/modules/'.$dlgmodname.'/functions.php';
// This code removes any php tags and adds slashes
$friendly = array('<', '>', '?php');
$raw = array('<', '>', '');
// STEP 1: Retrieve settings from POST vars
if (isset($_POST['use_dir']) && in_array($_POST['use_dir'],array('Y','N'))) {
$use_dir = $_POST['use_dir'];
} else {
$use_dir = 'N';
}
if (isset($_POST['offer_download']) && in_array($_POST['offer_download'],array('Y','N'))) {
$offer_download = $_POST['offer_download'];
} else {
$offer_download = 'N';
}
if (isset($_POST['file_size_decimals']) && is_numeric($_POST['file_size_decimals'])) {
$file_size_decimals = $_POST['file_size_decimals'];
} else {
$file_size_decimals = '0';
}
if (isset($_POST['files_per_page']) && is_numeric($_POST['files_per_page'])) {
$files_per_page = $_POST['files_per_page'];
} else {
$files_per_page = '0';
}
if (isset($_POST['file_size_round']) && is_numeric($_POST['file_size_round'])) {
$file_size_roundup = $_POST['file_size_round'];
} else {
$file_size_roundup = '0';
}
if (isset($_POST['search_filter']) && in_array($_POST['search_filter'],array('Y','N'))) {
$search_filter = $_POST['search_filter'];
} else {
$search_filter = 'N';
}
if (isset($_POST['ordering']) && is_numeric($_POST['ordering'])) {
$ordering = $_POST['ordering'];
} else {
$ordering = 0;
}
$tpldirs = dlg_gettpldirs();
if(isset($_POST['template_dir']) && in_array($_POST['template_dir'],$tpldirs)) {
$tpldir = $_POST['template_dir'];
} else {
$tpldir = 'tableview';
}
$use_default_css = 'Y';
if(!isset($_POST['use_default_css'])) {
$use_default_css = 'N';
}
// Update settings
/*['ordering']
0 - ascending position
1 - descending position
2 - ascending title
3 - descending title
*/
$query = "UPDATE `".TABLE_PREFIX.$tablename."_settings` SET
`files_per_page` = '$files_per_page',
`file_size_roundup` = '$file_size_roundup',
`file_size_decimals` = '$file_size_decimals',
`ordering` = '$ordering',
`search_filter` = '$search_filter',
`tpldir` = '$tpldir',
`tplcss` = '$use_default_css',
`use_dir` = '$use_dir',
`offer_download` ='$offer_download'
WHERE `section_id` = '$section_id' AND `page_id` = '$page_id'";
$database->query($query);
// handle database error
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();