Project

General

Profile

1
<?php
2

    
3
// $Id: submit_comment.php,v 1.3 2005/03/28 11:58:04 rdjurovich Exp $
4

    
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
// Include admin class
30
require_once(WB_PATH.'/framework/class.admin.php');
31
$admin = new admin('Start', 'start', false, false);
32

    
33
// Include WB functions file
34
if(!defined('FUNCTIONS_CLASS_LOADED')) {
35
	require(WB_PATH.'/framework/functions.php');
36
}
37

    
38
// Check if we should show the form or add a comment
39
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'] != '') {
40
	
41
	// Insert the comment into db
42
	$page_id = $_GET['page_id'];
43
	$section_id = $_GET['section_id'];
44
	$post_id = $_GET['post_id'];
45
	$title = addslashes(strip_tags($_POST['title']));
46
	$comment = addslashes(strip_tags($_POST['comment']));
47
	$commented_when = mktime();
48
	if(isset($admin) AND $admin->is_authenticated() == true) {
49
		$commented_by = $admin->get_user_id();
50
	} else {
51
		$commented_by = '';
52
	}
53
	$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')");
54
	// Get page link
55
	$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
56
	$page = $query_page->fetchRow();
57
	header('Location: '.page_link($page['link']).'?id='.$post_id);
58
	
59
} else {
60
	header('Location: '.WB_URL.'/pages/');
61
}
62

    
63
?>
(25-25/27)