Project

General

Profile

1
<?php
2

    
3
// $Id: comment.php 594 2008-01-25 03:49:24Z thorn $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2008, 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
// Check if there is a post id
30
if(!isset($_GET['id']) OR !is_numeric($_GET['id'])) {
31
	header("Location: ".WB_URL.PAGES_DIRECTORY."");
32
	exit(0);
33
}
34
$post_id = $_GET['id'];
35
$section_id = $_GET['sid'];
36

    
37

    
38
// Include database class
39
require_once(WB_PATH.'/framework/class.database.php');
40
$database = new database();
41

    
42
$query_settings = $database->query("SELECT use_captcha FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
43
$use_captcha = $query_settings->fetchRow();
44
if($use_captcha['use_captcha']) {
45
	$_SESSION['captcha'] = '';
46
	for($i = 0; $i < 5; $i++) {
47
		$_SESSION['captcha'] .= rand(0,9);
48
	}
49
}
50

    
51
// Query post for page id
52
$query_post = $database->query("SELECT post_id,title,section_id,page_id FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
53
if($query_post->numRows() == 0) {
54
	header("Location: ".WB_URL.PAGES_DIRECTORY."");
55
	exit(0);
56
} else {
57
	$fetch_post = $query_post->fetchRow();
58
	$page_id = $fetch_post['page_id'];
59
	$section_id = $fetch_post['section_id'];
60
	$post_id = $fetch_post['post_id'];
61
	$post_title = $fetch_post['title'];
62
	define('SECTION_ID', $section_id);
63
	define('POST_ID', $post_id);
64
	define('POST_TITLE', $post_title);
65
	
66
	// don't allow commenting if its disabled, or if post or group is inactive
67
	$table_posts = TABLE_PREFIX."mod_news_posts";
68
	$table_groups = TABLE_PREFIX."mod_news_groups";
69
	$query = $database->query("
70
		SELECT p.post_id
71
		FROM $table_posts AS p LEFT OUTER JOIN $table_groups AS g ON p.group_id = g.group_id
72
		WHERE p.post_id='$post_id' AND p.commenting != 'none' AND p.active = '1' AND ( g.active IS NULL OR g.active = '1' )
73
	");
74
	if($query->numRows() == 0) {
75
		header("Location: ".WB_URL.PAGES_DIRECTORY."");
76
		exit(0);
77
	}
78

    
79
	// Get page details
80
	$query_page = $database->query("SELECT parent,page_title,menu_title,keywords,description,visibility FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
81
	if($query_page->numRows() == 0) {
82
		header("Location: ".WB_URL.PAGES_DIRECTORY."");
83
		exit(0);
84
	} else {
85
		$page = $query_page->fetchRow();
86
		// Required page details
87
		define('PAGE_CONTENT', WB_PATH.'/modules/news/comment_page.php');
88
		// Include index (wrapper) file
89
		require(WB_PATH.'/index.php');
90
	}
91
}
92

    
93

    
94
?>
(5-5/32)