Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         news
6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2011, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id: comment.php 1538 2011-12-10 15:06:15Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/news/comment.php $
14
 * @lastmodified    $Date: 2011-12-10 16:06:15 +0100 (Sat, 10 Dec 2011) $
15
 *
16
 */
17

    
18
// Include config file
19
require('../../config.php');
20
require_once(WB_PATH.'/framework/class.wb.php');
21
$wb = new wb;
22

    
23
// Check if there is a post id
24
// $post_id = $wb->checkIDKEY('post_id', false, 'GET');
25

    
26
$post_id = (int)$_GET['post_id'];
27
$section_id = (int)$_GET['section_id'];
28

    
29
if (!$post_id OR !isset($_GET['section_id']) OR !is_numeric($_GET['section_id'])) {
30
	$wb->print_error('ABORT::'.$MESSAGE['GENERIC_SECURITY_ACCESS'], WB_URL.PAGES_DIRECTORY );
31
	exit();
32
}
33

    
34
// Query post for page id
35
$query_post = $database->query("SELECT post_id,title,section_id,page_id FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
36
if($query_post->numRows() == 0)
37
{
38
    header("Location: ".WB_URL.PAGES_DIRECTORY."");
39
	exit( 0 );
40
}
41
else
42
{
43
	$fetch_post = $query_post->fetchRow();
44
	$page_id = $fetch_post['page_id'];
45
	$section_id = $fetch_post['section_id'];
46
	$post_id = $fetch_post['post_id'];
47
	$post_title = $fetch_post['title'];
48
	define('SECTION_ID', $section_id);
49
	define('POST_ID', $post_id);
50
	define('POST_TITLE', $post_title);
51

    
52
	// don't allow commenting if its disabled, or if post or group is inactive
53
	$t = time();
54
	$table_posts = TABLE_PREFIX."mod_news_posts";
55
	$table_groups = TABLE_PREFIX."mod_news_groups";
56
	$query = $database->query("
57
		SELECT p.post_id
58
		FROM $table_posts AS p LEFT OUTER JOIN $table_groups AS g ON p.group_id = g.group_id
59
		WHERE p.post_id='$post_id' AND p.commenting != 'none' AND p.active = '1' AND ( g.active IS NULL OR g.active = '1' )
60
		AND (p.published_when = '0' OR p.published_when <= $t) AND (p.published_until = 0 OR p.published_until >= $t)
61
	");
62
	if($query->numRows() == 0)
63
    {
64
		header("Location: ".WB_URL.PAGES_DIRECTORY."");
65
	    exit( 0 );
66
	}
67

    
68
	// don't allow commenting if ASP enabled and user doesn't comes from the right view.php
69
	if(ENABLED_ASP && (!isset($_SESSION['comes_from_view']) OR $_SESSION['comes_from_view']!=POST_ID))
70
    {
71
		header("Location: ".WB_URL.PAGES_DIRECTORY."");
72
	    exit( 0 );
73
	}
74

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