1 |
4
|
ryan
|
<?php
|
2 |
|
|
|
3 |
40
|
stefan
|
// $Id$
|
4 |
4
|
ryan
|
|
5 |
|
|
/*
|
6 |
|
|
|
7 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
|
|
Copyright (C) 2004-2005, Ryan Djurovich
|
9 |
|
|
|
10 |
|
|
Website Baker is free software; you can redistribute it and/or modify
|
11 |
|
|
it under the terms of the GNU General Public License as published by
|
12 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
(at your option) any later version.
|
14 |
|
|
|
15 |
|
|
Website Baker is distributed in the hope that it will be useful,
|
16 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
GNU General Public License for more details.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License
|
21 |
|
|
along with Website Baker; if not, write to the Free Software
|
22 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23 |
|
|
|
24 |
|
|
*/
|
25 |
|
|
|
26 |
|
|
// Include config file
|
27 |
|
|
require('../../config.php');
|
28 |
|
|
|
29 |
250
|
ryan
|
require_once(WB_PATH.'/framework/class.wb.php');
|
30 |
|
|
$wb = new wb;
|
31 |
|
|
|
32 |
4
|
ryan
|
// 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']) AND isset($_POST['comment']) AND $_POST['comment'] != '') {
|
34 |
|
|
|
35 |
250
|
ryan
|
// Check captcha
|
36 |
|
|
if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */
|
37 |
|
|
if(isset($_POST['captcha']) AND $_POST['captcha'] != ''){
|
38 |
|
|
// Check for a mismatch
|
39 |
|
|
if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR $_POST['captcha'] != $_SESSION['captcha']) {
|
40 |
|
|
$_SESSION['captcha_error'] = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'];
|
41 |
|
|
$_SESSION['comment_title'] = $_POST['title'];
|
42 |
|
|
$_SESSION['comment_body'] = $_POST['comment'];
|
43 |
|
|
exit(header('Location: '.WB_URL.'/modules/news/comment.php?id='.$_GET['post_id']));
|
44 |
|
|
}
|
45 |
|
|
} else {
|
46 |
|
|
$_SESSION['captcha_error'] = $MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'];
|
47 |
|
|
$_SESSION['comment_title'] = $_POST['title'];
|
48 |
|
|
$_SESSION['comment_body'] = $_POST['comment'];
|
49 |
|
|
exit(header('Location: '.WB_URL.'/modules/news/comment.php?id='.$_GET['post_id']));
|
50 |
|
|
}
|
51 |
|
|
}
|
52 |
|
|
if(isset($_SESSION['catpcha'])) { unset($_SESSION['captcha']); }
|
53 |
|
|
|
54 |
4
|
ryan
|
// Insert the comment into db
|
55 |
|
|
$page_id = $_GET['page_id'];
|
56 |
|
|
$section_id = $_GET['section_id'];
|
57 |
|
|
$post_id = $_GET['post_id'];
|
58 |
242
|
stefan
|
$title = $wb->add_slashes(strip_tags($_POST['title']));
|
59 |
|
|
$comment = $wb->add_slashes(strip_tags($_POST['comment']));
|
60 |
4
|
ryan
|
$commented_when = mktime();
|
61 |
242
|
stefan
|
if($wb->is_authenticated() == true) {
|
62 |
|
|
$commented_by = $wb->get_user_id();
|
63 |
4
|
ryan
|
} else {
|
64 |
|
|
$commented_by = '';
|
65 |
|
|
}
|
66 |
|
|
$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')");
|
67 |
|
|
// Get page link
|
68 |
|
|
$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
|
69 |
|
|
$page = $query_page->fetchRow();
|
70 |
242
|
stefan
|
header('Location: '.$wb->page_link($page['link']).'?id='.$post_id);
|
71 |
4
|
ryan
|
|
72 |
|
|
} else {
|
73 |
|
|
header('Location: '.WB_URL.'/pages/');
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
?>
|