1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category modules
|
5
|
* @package news
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2004-2009, Ryan Djurovich
|
8
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9
|
* @link http://www.websitebaker2.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.x
|
12
|
* @requirements PHP 5.2.2 and higher
|
13
|
* @version $Id: submit_comment.php 1395 2011-01-17 19:15:06Z FrankH $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/news/submit_comment.php $
|
15
|
* @lastmodified $Date: 2011-01-17 20:15:06 +0100 (Mon, 17 Jan 2011) $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
// Include config file
|
20
|
require('../../config.php');
|
21
|
|
22
|
/*overwrite php.ini on Apache servers for valid SESSION ID Separator
|
23
|
if(function_exists('ini_set')) {
|
24
|
ini_set('arg_separator.output', '&');
|
25
|
}
|
26
|
*/
|
27
|
require_once(WB_PATH.'/framework/class.wb.php');
|
28
|
$wb = new wb;
|
29
|
/* */
|
30
|
|
31
|
if (!$wb->checkFTAN())
|
32
|
{
|
33
|
$wb->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], WB_URL);
|
34
|
exit();
|
35
|
}
|
36
|
|
37
|
// Check if we should show the form or add a comment
|
38
|
if(isset($_GET['page_id']) AND is_numeric($_GET['page_id'])
|
39
|
AND isset($_GET['section_id']) AND is_numeric($_GET['section_id'])
|
40
|
AND isset($_GET['post_id']) AND is_numeric($_GET['post_id'])
|
41
|
AND ( ( ENABLED_ASP AND isset($_POST['comment_'.date('W')]) AND $_POST['comment_'.date('W')] != '')
|
42
|
OR ( !ENABLED_ASP AND isset($_POST['comment']) AND $_POST['comment'] != '' ) ) )
|
43
|
{
|
44
|
|
45
|
if(ENABLED_ASP){
|
46
|
$comment = $_POST['comment_'.date('W')];
|
47
|
}
|
48
|
else
|
49
|
{
|
50
|
$comment = $_POST['comment'];
|
51
|
}
|
52
|
|
53
|
$comment = $wb->add_slashes(strip_tags($comment));
|
54
|
$title = $wb->add_slashes(strip_tags($_POST['title']));
|
55
|
// do not allow droplets in user input!
|
56
|
$title = str_replace(array("[[", "]]"), array("[[", "]]"), $title);
|
57
|
$comment = str_replace(array("[[", "]]"), array("[[", "]]"), $comment);
|
58
|
$page_id = $_GET['page_id'];
|
59
|
$section_id = $_GET['section_id'];
|
60
|
$post_id = $_GET['post_id'];
|
61
|
|
62
|
// Check captcha
|
63
|
$query_settings = $database->query("SELECT use_captcha FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
|
64
|
if( !$query_settings->numRows())
|
65
|
{
|
66
|
header("Location: ".WB_URL.PAGES_DIRECTORY."");
|
67
|
exit( 0 );
|
68
|
}
|
69
|
else
|
70
|
{
|
71
|
$settings = $query_settings->fetchRow();
|
72
|
$t=time();
|
73
|
|
74
|
// Advanced Spam Protection
|
75
|
if(ENABLED_ASP AND ( ($_SESSION['session_started']+ASP_SESSION_MIN_AGE > $t) // session too young
|
76
|
OR (!isset($_SESSION['comes_from_view']))// user doesn't come from view.php
|
77
|
OR (!isset($_SESSION['comes_from_view_time']) OR $_SESSION['comes_from_view_time'] > $t-ASP_VIEW_MIN_AGE) // user is too fast
|
78
|
OR (!isset($_SESSION['submitted_when']) OR !isset($_POST['submitted_when'])) // faked form
|
79
|
OR ($_SESSION['submitted_when'] != $_POST['submitted_when']) // faked form
|
80
|
OR ($_SESSION['submitted_when'] > $t-ASP_INPUT_MIN_AGE && !isset($_SESSION['captcha_retry_news'])) // user too fast
|
81
|
OR ($_SESSION['submitted_when'] < $t-43200) // form older than 12h
|
82
|
OR ($_POST['email'] OR $_POST['url'] OR $_POST['homepage'] OR $_POST['comment']) /* honeypot-fields */ ) )
|
83
|
{
|
84
|
header("Location: ".WB_URL.PAGES_DIRECTORY."");
|
85
|
exit( 0 );
|
86
|
}
|
87
|
|
88
|
if(ENABLED_ASP)
|
89
|
{
|
90
|
if(isset($_SESSION['captcha_retry_news']))
|
91
|
{
|
92
|
unset($_SESSION['captcha_retry_news']);
|
93
|
}
|
94
|
}
|
95
|
|
96
|
if($settings['use_captcha'])
|
97
|
{
|
98
|
if(isset($_POST['captcha']) AND $_POST['captcha'] != '')
|
99
|
{
|
100
|
// Check for a mismatch
|
101
|
if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR $_POST['captcha'] != $_SESSION['captcha'])
|
102
|
{
|
103
|
$_SESSION['captcha_error'] = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'];
|
104
|
$_SESSION['comment_title'] = $title;
|
105
|
$_SESSION['comment_body'] = $comment;
|
106
|
header("Location: ".WB_URL."/modules/news/comment.php?post_id=".$post_id."§ion_id=".$section_id."" );
|
107
|
exit( 0 );
|
108
|
}
|
109
|
}
|
110
|
else
|
111
|
{
|
112
|
$_SESSION['captcha_error'] = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'];
|
113
|
$_SESSION['comment_title'] = $title;
|
114
|
$_SESSION['comment_body'] = $comment;
|
115
|
header("Location: ".WB_URL."/modules/news/comment.php?post_id=".$post_id."§ion_id=".$section_id."" );
|
116
|
exit( 0 );
|
117
|
}
|
118
|
}
|
119
|
}
|
120
|
|
121
|
if(isset($_SESSION['captcha'])) { unset($_SESSION['captcha']); }
|
122
|
|
123
|
if(ENABLED_ASP)
|
124
|
{
|
125
|
unset($_SESSION['comes_from_view']);
|
126
|
unset($_SESSION['comes_from_view_time']);
|
127
|
unset($_SESSION['submitted_when']);
|
128
|
}
|
129
|
|
130
|
// Insert the comment into db
|
131
|
$commented_when = time();
|
132
|
if($wb->is_authenticated() == true)
|
133
|
{
|
134
|
$commented_by = $wb->get_user_id();
|
135
|
}
|
136
|
else
|
137
|
{
|
138
|
$commented_by = '';
|
139
|
}
|
140
|
|
141
|
$query = $database->query("INSERT INTO ".TABLE_PREFIX."mod_news_comments (section_id,page_id,post_id,title,comment,commented_when,commented_by) VALUES ('$section_id','$page_id','$post_id','$title','$comment','$commented_when','$commented_by')");
|
142
|
// Get page link
|
143
|
$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
|
144
|
$page = $query_page->fetchRow();
|
145
|
header('Location: '.$wb->page_link($page['link']).'?post_id='.$post_id.'' );
|
146
|
exit( 0 );
|
147
|
}
|
148
|
else
|
149
|
{
|
150
|
if( isset($_GET['post_id']) AND is_numeric($_GET['post_id'])
|
151
|
AND isset($_GET['section_id']) AND is_numeric($_GET['section_id']) )
|
152
|
{
|
153
|
header("Location: ".WB_URL."/modules/news/comment.php?post_id=".($_GET['post_id'])."§ion_id=".($_GET['section_id'])."" ) ;
|
154
|
exit( 0 );
|
155
|
}
|
156
|
else
|
157
|
{
|
158
|
header("Location: ".WB_URL.PAGES_DIRECTORY."");
|
159
|
exit( 0 );
|
160
|
}
|
161
|
}
|
162
|
|
163
|
?>
|