Revision 656
Added by thorn almost 17 years ago
submit_comment.php | ||
---|---|---|
30 | 30 |
$wb = new wb; |
31 | 31 |
|
32 | 32 |
// Check if we should show the form or add a comment |
33 |
if(is_numeric($_GET['page_id']) AND is_numeric($_GET['section_id']) AND isset($_GET['post_id']) AND is_numeric($_GET['post_id'])
|
|
34 |
AND ( ENABLED_ASP AND isset($_POST['c0mment_'.date('W')]) AND $_POST['c0mment_'.date('W')] != '') |
|
35 |
OR (!ENABLED_ASP AND isset($_POST['comment']) AND $_POST['comment'] != '')
|
|
33 |
if(isset($_GET['page_id']) AND is_numeric($_GET['page_id']) AND isset($_GET['section_id']) AND is_numeric($_GET['section_id']) AND isset($_GET['post_id']) AND is_numeric($_GET['post_id'])
|
|
34 |
AND (( ENABLED_ASP AND isset($_POST['c0mment_'.date('W')]) AND $_POST['c0mment_'.date('W')] != '')
|
|
35 |
OR (!ENABLED_ASP AND isset($_POST['comment']) AND $_POST['comment'] != ''))
|
|
36 | 36 |
) { |
37 | 37 |
|
38 | 38 |
if(ENABLED_ASP) |
39 | 39 |
$comment = $_POST['c0mment_'.date('W')]; |
40 | 40 |
else |
41 | 41 |
$comment = $_POST['comment']; |
42 |
|
|
42 |
$comment = $wb->add_slashes(strip_tags($comment)); |
|
43 |
$title = $wb->add_slashes(strip_tags($_POST['title'])); |
|
44 |
$page_id = $_GET['page_id']; |
|
45 |
$section_id = $_GET['section_id']; |
|
46 |
$post_id = $_GET['post_id']; |
|
47 |
|
|
43 | 48 |
// Check captcha |
44 |
$query_settings = $database->query("SELECT use_captcha FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '".$_GET['section_id']."'");
|
|
49 |
$query_settings = $database->query("SELECT use_captcha FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
|
|
45 | 50 |
if($query_settings->numRows() == 0) { |
46 | 51 |
exit(header("Location: ".WB_URL.PAGES_DIRECTORY."")); |
47 | 52 |
} else { |
... | ... | |
67 | 72 |
// Check for a mismatch |
68 | 73 |
if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR $_POST['captcha'] != $_SESSION['captcha']) { |
69 | 74 |
$_SESSION['captcha_error'] = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA']; |
70 |
$_SESSION['comment_title'] = $_POST['title'];
|
|
75 |
$_SESSION['comment_title'] = $title;
|
|
71 | 76 |
$_SESSION['comment_body'] = $comment; |
72 |
exit(header('Location: '.WB_URL."/modules/news/comment.php?id={$_GET['post_id']}&sid={$_GET['section_id']}"));
|
|
77 |
exit(header('Location: '.WB_URL."/modules/news/comment.php?id=$post_id&sid=$section_id"));
|
|
73 | 78 |
} |
74 | 79 |
} else { |
75 | 80 |
$_SESSION['captcha_error'] = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA']; |
76 |
$_SESSION['comment_title'] = $_POST['title'];
|
|
81 |
$_SESSION['comment_title'] = $title;
|
|
77 | 82 |
$_SESSION['comment_body'] = $comment; |
78 |
exit(header('Location: '.WB_URL."/modules/news/comment.php?id={$_GET['post_id']}&sid={$_GET['section_id']}"));
|
|
83 |
exit(header('Location: '.WB_URL."/modules/news/comment.php?id=$post_id&sid=$section_id"));
|
|
79 | 84 |
} |
80 | 85 |
} |
81 | 86 |
} |
... | ... | |
87 | 92 |
} |
88 | 93 |
|
89 | 94 |
// Insert the comment into db |
90 |
$page_id = $_GET['page_id']; |
|
91 |
$section_id = $_GET['section_id']; |
|
92 |
$post_id = $_GET['post_id']; |
|
93 |
$title = $wb->add_slashes(strip_tags($_POST['title'])); |
|
94 |
$comment = $wb->add_slashes(strip_tags($comment)); |
|
95 | 95 |
$commented_when = mktime(); |
96 | 96 |
if($wb->is_authenticated() == true) { |
97 | 97 |
$commented_by = $wb->get_user_id(); |
... | ... | |
104 | 104 |
$page = $query_page->fetchRow(); |
105 | 105 |
header('Location: '.$wb->page_link($page['link']).'?id='.$post_id); |
106 | 106 |
} else { |
107 |
header('Location: '.WB_URL."/modules/news/comment.php?id={$_GET['post_id']}&sid={$_GET['section_id']}"); |
|
107 |
if(isset($_GET['post_id']) AND is_numeric($_GET['post_id']) AND isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) |
|
108 |
header('Location: '.WB_URL."/modules/news/comment.php?id={$_GET['post_id']}&sid={$_GET['section_id']}"); |
|
109 |
else |
|
110 |
exit(header("Location: ".WB_URL.PAGES_DIRECTORY."")); |
|
108 | 111 |
} |
109 | 112 |
|
110 | 113 |
?> |
Also available in: Unified diff
Added some missing add_slashes(), get_post_escaped(), and strip_tags() for $_POST, $_GET and $_REQUEST-data. Also for $_SERVER['PHP_SELF'].