1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category modules
|
5
|
* @package news
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright WebsiteBaker Org. e.V.
|
8
|
* @link http://websitebaker.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.3
|
11
|
* @requirements PHP 5.3.6 and higher
|
12
|
* @version $Id: comment.php 2 2017-07-02 15:14:29Z Manuela $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/news/comment.php $
|
14
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
// Include config file
|
19
|
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
|
20
|
if ( !class_exists('wb')) { require(WB_PATH.'/framework/class.wb.php'); }
|
21
|
// Create new frontend object
|
22
|
if (!isset($wb) || !($wb instanceof wb)) { $wb = new wb(); }
|
23
|
|
24
|
// Check if there is a post id
|
25
|
// $post_id = $wb->checkIDKEY('post_id', false, 'GET');
|
26
|
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
27
|
$aRequestVars = (isset(${$requestMethod}) ? ${$requestMethod} : null);
|
28
|
$section_id = intval(isset($aRequestVars['section_id'])) ? $aRequestVars['section_id'] : (isset($section_id) ? intval($section_id) : 0);
|
29
|
$post_id = (intval(isset($aRequestVars['post_id'])) ? $aRequestVars['post_id'] : (isset($post_id) ? intval($post_id) : 0));
|
30
|
$position = (isset($aRequestVars['p']) ? $aRequestVars['p'] : '' );
|
31
|
/*
|
32
|
$post_id = (int)$_GET['post_id'];
|
33
|
$section_id = (int)$_GET['section_id'];
|
34
|
$position = 0;
|
35
|
*/
|
36
|
if (!$post_id OR !isset($_GET['section_id']) OR !is_numeric($_GET['section_id'])) {
|
37
|
$_SESSION['message'][] = ('ABORT::'.$MESSAGE['GENERIC_SECURITY_ACCESS'] );
|
38
|
exit();
|
39
|
}
|
40
|
|
41
|
// Query post for page id
|
42
|
$query_post = $database->query("SELECT post_id,title,section_id,page_id FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
|
43
|
if($query_post->numRows() == 0)
|
44
|
{
|
45
|
header("Location: ".WB_URL."/index.php");
|
46
|
exit( 0 );
|
47
|
}
|
48
|
else
|
49
|
{
|
50
|
$fetch_post = $query_post->fetchRow( MYSQLI_ASSOC );
|
51
|
$page_id = $fetch_post['page_id'];
|
52
|
$section_id = $fetch_post['section_id'];
|
53
|
$post_id = $fetch_post['post_id'];
|
54
|
$post_title = $fetch_post['title'];
|
55
|
define('SECTION_ID', $section_id);
|
56
|
define('POST_ID', $post_id);
|
57
|
define('POST_TITLE', $post_title);
|
58
|
|
59
|
// don't allow commenting if its disabled, or if post or group is inactive
|
60
|
$t = time();
|
61
|
$table_posts = TABLE_PREFIX."mod_news_posts";
|
62
|
$table_groups = TABLE_PREFIX."mod_news_groups";
|
63
|
$query = $database->query("
|
64
|
SELECT p.post_id
|
65
|
FROM $table_posts AS p LEFT OUTER JOIN $table_groups AS g ON p.group_id = g.group_id
|
66
|
WHERE p.post_id='$post_id' AND p.commenting != 'none' AND p.active = '1' AND ( g.active IS NULL OR g.active = '1' )
|
67
|
AND (p.published_when = '0' OR p.published_when <= $t) AND (p.published_until = 0 OR p.published_until >= $t)
|
68
|
");
|
69
|
if($query->numRows() == 0)
|
70
|
{
|
71
|
header("Location: ".WB_URL."/index.php");
|
72
|
exit( 0 );
|
73
|
}
|
74
|
|
75
|
// don't allow commenting if ASP enabled and user doesn't comes from the right view.php
|
76
|
if(ENABLED_ASP && (!isset($_SESSION['comes_from_view']) OR $_SESSION['comes_from_view']!=POST_ID))
|
77
|
{
|
78
|
header("Location: ".WB_URL."/index.php");
|
79
|
exit( 0 );
|
80
|
}
|
81
|
|
82
|
// Get page details
|
83
|
$query_page = $database->query("SELECT parent,page_title,menu_title,keywords,description,visibility FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
|
84
|
if($query_page->numRows() == 0)
|
85
|
{
|
86
|
header("Location: ".WB_URL."/index.php");
|
87
|
exit( 0 );
|
88
|
}
|
89
|
else
|
90
|
{
|
91
|
$page = $query_page->fetchRow( MYSQLI_ASSOC );
|
92
|
// Required page details
|
93
|
define('PAGE_CONTENT', WB_PATH.'/modules/news/comment_page.php');
|
94
|
// Include index (wrapper) file
|
95
|
require(WB_PATH.'/index.php');
|
96
|
}
|
97
|
}
|