Skip to content

Commit e90846a

Browse files
VINADES.,JSCvuthao
VINADES.,JSC
authored andcommitted
Fix CSRF for module siteinfo
1 parent 4e67cc8 commit e90846a

File tree

2 files changed

+34
-33
lines changed

2 files changed

+34
-33
lines changed

admin/siteinfo/logs_del.php

+31-30
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,44 @@
77
* @License GNU/GPL version 2 or any later version
88
* @Createdate 11-10-2010 14:43
99
*/
10-
11-
if (! defined('NV_IS_FILE_SITEINFO')) {
10+
if (!defined('NV_IS_FILE_SITEINFO')) {
1211
die('Stop!!!');
1312
}
1413

1514
// Delete all log
16-
if ($nv_Request->get_title('logempty', 'post', '') == md5('siteinfo_' . NV_CHECK_SESSION . '_' . $admin_info['userid'])) {
17-
if ($db->query('TRUNCATE TABLE ' . $db_config['prefix'] . '_logs')) {
18-
$nv_Cache->delMod($module_name);
19-
nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['log_empty_log'], 'All', $admin_info['userid']);
20-
die('OK');
21-
} else {
22-
die($lang_module['log_del_error']);
15+
if ($nv_Request->get_title('checksess', 'post') == md5('siteinfo_' . NV_CHECK_SESSION . '_' . $admin_info['userid'])) {
16+
$logempty = $nv_Request->get_int('logempty', 'post,get', 0);
17+
if ($logempty) {
18+
if ($db->query('TRUNCATE TABLE ' . $db_config['prefix'] . '_logs')) {
19+
$nv_Cache->delMod($module_name);
20+
nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['log_empty_log'], 'All', $admin_info['userid']);
21+
die('OK');
22+
} else {
23+
die($lang_module['log_del_error']);
24+
}
2325
}
24-
}
2526

26-
$id = $nv_Request->get_int('id', 'post,get', 0);
27-
$contents = 'NO_' . $lang_module['log_del_error'];
28-
$number_del = 0;
29-
if ($id > 0) {
30-
if ($db->exec('DELETE FROM ' . $db_config['prefix'] . '_logs WHERE id=' . $id)) {
31-
$contents = 'OK_' . $lang_module['log_del_ok'];
32-
++$number_del;
33-
}
34-
} else {
35-
$listall = $nv_Request->get_string('listall', 'post,get');
36-
$array_id = explode(',', $listall);
37-
$array_id = array_map('intval', $array_id);
38-
foreach ($array_id as $id) {
39-
if ($id > 0) {
40-
$db->query('DELETE FROM ' . $db_config['prefix'] . '_logs WHERE id=' . $id);
41-
++$number_del;
27+
$id = $nv_Request->get_int('id', 'post,get', 0);
28+
$contents = 'NO_' . $lang_module['log_del_error'];
29+
$number_del = 0;
30+
if ($id > 0) {
31+
if ($db->exec('DELETE FROM ' . $db_config['prefix'] . '_logs WHERE id=' . $id)) {
32+
$contents = 'OK_' . $lang_module['log_del_ok'];
33+
++ $number_del;
4234
}
35+
} else {
36+
$listall = $nv_Request->get_string('listall', 'post,get');
37+
$array_id = explode(',', $listall);
38+
$array_id = array_map('intval', $array_id);
39+
foreach ($array_id as $id) {
40+
if ($id > 0) {
41+
$db->query('DELETE FROM ' . $db_config['prefix'] . '_logs WHERE id=' . $id);
42+
++ $number_del;
43+
}
44+
}
45+
$contents = 'OK_' . $lang_module['log_del_ok'];
4346
}
44-
$contents = 'OK_' . $lang_module['log_del_ok'];
45-
}
46-
47-
nv_insert_logs(NV_LANG_DATA, $module_name, $lang_global['delete'] . ' ' . $lang_module['logs_title'], $number_del, $admin_info['userid']);
4847

48+
nv_insert_logs(NV_LANG_DATA, $module_name, $lang_global['delete'] . ' ' . $lang_module['logs_title'], $number_del, $admin_info['userid']);
49+
}
4950
nv_htmlOutput($contents);

themes/admin_default/js/siteinfo.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ $(document).ready(function(){
9393
$.ajax({
9494
type : 'POST',
9595
url : CFG.url_del,
96-
data : 'listall=' + listall,
96+
data : 'listall=' + listall + '&checksess=' + CFG.checksess,
9797
success : function(data) {
9898
var s = data.split('_');
9999
if (s[0] == 'OK') {
@@ -111,7 +111,7 @@ $(document).ready(function(){
111111
$.ajax({
112112
type : 'POST',
113113
url : href,
114-
data : '',
114+
data : 'checksess=' + CFG.checksess,
115115
success : function(data) {
116116
var s = data.split('_');
117117
if (s[0] == 'OK') {
@@ -129,7 +129,7 @@ $(document).ready(function(){
129129
$.ajax({
130130
type : 'POST',
131131
url : script_name,
132-
data : nv_name_variable + "=" + nv_module_name + "&" + nv_fc_variable + "=logs_del&logempty=" + CFG.checksess,
132+
data : nv_name_variable + "=" + nv_module_name + "&" + nv_fc_variable + "=logs_del&logempty=1&checksess=" + CFG.checksess,
133133
success : function(data) {
134134
if (data == 'OK') {
135135
window.location = script_name + "?" + nv_name_variable + "=" + nv_module_name + "&" + nv_fc_variable + "=logs";

0 commit comments

Comments
 (0)