| 1 | 
        
            1425
         | 
        
            Luisehahne
         | 
        <?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$
  | 
      
      
        | 13 | 
        
         | 
        
         | 
         * @filesource		$HeadURL$
  | 
      
      
        | 14 | 
        
         | 
        
         | 
         * @lastmodified    $Date$
  | 
      
      
        | 15 | 
        
         | 
        
         | 
         *
  | 
      
      
        | 16 | 
        
         | 
        
         | 
         */
  | 
      
      
        | 17 | 
        
         | 
        
         | 
        
  | 
      
      
        | 18 | 
        
         | 
        
         | 
        // Include config file
  | 
      
      
        | 19 | 
        
         | 
        
         | 
        require('../../config.php');
 | 
      
      
        | 20 | 
        
         | 
        
         | 
        require_once(WB_PATH.'/framework/class.wb.php');
  | 
      
      
        | 21 | 
        
            1844
         | 
        
            Luisehahne
         | 
        if( !(isset($wb) && is_object($wb)) ) { $wb = new wb(); }
 | 
      
      
        | 22 | 
        
            1425
         | 
        
            Luisehahne
         | 
        // Check if there is a post id
  | 
      
      
        | 23 | 
        
         | 
        
         | 
        // $post_id = $wb->checkIDKEY('post_id', false, 'GET');
 | 
      
      
        | 24 | 
        
         | 
        
         | 
        
  | 
      
      
        | 25 | 
        
         | 
        
         | 
        $post_id = (int)$_GET['post_id'];
  | 
      
      
        | 26 | 
        
         | 
        
         | 
        $section_id = (int)$_GET['section_id'];
  | 
      
      
        | 27 | 
        
         | 
        
         | 
        
  | 
      
      
        | 28 | 
        
         | 
        
         | 
        if (!$post_id OR !isset($_GET['section_id']) OR !is_numeric($_GET['section_id'])) {
 | 
      
      
        | 29 | 
        
         | 
        
         | 
        	$wb->print_error('ABORT::'.$MESSAGE['GENERIC_SECURITY_ACCESS'], WB_URL.PAGES_DIRECTORY );
 | 
      
      
        | 30 | 
        
         | 
        
         | 
        	exit();
  | 
      
      
        | 31 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 32 | 
        
         | 
        
         | 
        
  | 
      
      
        | 33 | 
        
         | 
        
         | 
        // Query post for page id
  | 
      
      
        | 34 | 
        
         | 
        
         | 
        $query_post = $database->query("SELECT post_id,title,section_id,page_id FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
 | 
      
      
        | 35 | 
        
         | 
        
         | 
        if($query_post->numRows() == 0)
  | 
      
      
        | 36 | 
        
         | 
        
         | 
        {
 | 
      
      
        | 37 | 
        
         | 
        
         | 
            header("Location: ".WB_URL.PAGES_DIRECTORY."");
 | 
      
      
        | 38 | 
        
         | 
        
         | 
        	exit( 0 );
  | 
      
      
        | 39 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 40 | 
        
         | 
        
         | 
        else
  | 
      
      
        | 41 | 
        
         | 
        
         | 
        {
 | 
      
      
        | 42 | 
        
         | 
        
         | 
        	$fetch_post = $query_post->fetchRow();
  | 
      
      
        | 43 | 
        
         | 
        
         | 
        	$page_id = $fetch_post['page_id'];
  | 
      
      
        | 44 | 
        
         | 
        
         | 
        	$section_id = $fetch_post['section_id'];
  | 
      
      
        | 45 | 
        
         | 
        
         | 
        	$post_id = $fetch_post['post_id'];
  | 
      
      
        | 46 | 
        
         | 
        
         | 
        	$post_title = $fetch_post['title'];
  | 
      
      
        | 47 | 
        
         | 
        
         | 
        	define('SECTION_ID', $section_id);
 | 
      
      
        | 48 | 
        
         | 
        
         | 
        	define('POST_ID', $post_id);
 | 
      
      
        | 49 | 
        
         | 
        
         | 
        	define('POST_TITLE', $post_title);
 | 
      
      
        | 50 | 
        
         | 
        
         | 
        
  | 
      
      
        | 51 | 
        
         | 
        
         | 
        	// don't allow commenting if its disabled, or if post or group is inactive
  | 
      
      
        | 52 | 
        
         | 
        
         | 
        	$t = time();
  | 
      
      
        | 53 | 
        
         | 
        
         | 
        	$table_posts = TABLE_PREFIX."mod_news_posts";
  | 
      
      
        | 54 | 
        
         | 
        
         | 
        	$table_groups = TABLE_PREFIX."mod_news_groups";
  | 
      
      
        | 55 | 
        
         | 
        
         | 
        	$query = $database->query("
 | 
      
      
        | 56 | 
        
         | 
        
         | 
        		SELECT p.post_id
  | 
      
      
        | 57 | 
        
         | 
        
         | 
        		FROM $table_posts AS p LEFT OUTER JOIN $table_groups AS g ON p.group_id = g.group_id
  | 
      
      
        | 58 | 
        
         | 
        
         | 
        		WHERE p.post_id='$post_id' AND p.commenting != 'none' AND p.active = '1' AND ( g.active IS NULL OR g.active = '1' )
  | 
      
      
        | 59 | 
        
         | 
        
         | 
        		AND (p.published_when = '0' OR p.published_when <= $t) AND (p.published_until = 0 OR p.published_until >= $t)
  | 
      
      
        | 60 | 
        
         | 
        
         | 
        	");
  | 
      
      
        | 61 | 
        
         | 
        
         | 
        	if($query->numRows() == 0)
  | 
      
      
        | 62 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 63 | 
        
         | 
        
         | 
        		header("Location: ".WB_URL.PAGES_DIRECTORY."");
 | 
      
      
        | 64 | 
        
         | 
        
         | 
        	    exit( 0 );
  | 
      
      
        | 65 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 66 | 
        
         | 
        
         | 
        
  | 
      
      
        | 67 | 
        
         | 
        
         | 
        	// don't allow commenting if ASP enabled and user doesn't comes from the right view.php
  | 
      
      
        | 68 | 
        
         | 
        
         | 
        	if(ENABLED_ASP && (!isset($_SESSION['comes_from_view']) OR $_SESSION['comes_from_view']!=POST_ID))
  | 
      
      
        | 69 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 70 | 
        
         | 
        
         | 
        		header("Location: ".WB_URL.PAGES_DIRECTORY."");
 | 
      
      
        | 71 | 
        
         | 
        
         | 
        	    exit( 0 );
  | 
      
      
        | 72 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 73 | 
        
         | 
        
         | 
        
  | 
      
      
        | 74 | 
        
         | 
        
         | 
        	// Get page details
  | 
      
      
        | 75 | 
        
         | 
        
         | 
        	$query_page = $database->query("SELECT parent,page_title,menu_title,keywords,description,visibility FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
 | 
      
      
        | 76 | 
        
         | 
        
         | 
        	if($query_page->numRows() == 0)
  | 
      
      
        | 77 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 78 | 
        
         | 
        
         | 
        		header("Location: ".WB_URL.PAGES_DIRECTORY."");
 | 
      
      
        | 79 | 
        
         | 
        
         | 
        	    exit( 0 );
  | 
      
      
        | 80 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 81 | 
        
         | 
        
         | 
            else
  | 
      
      
        | 82 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 83 | 
        
         | 
        
         | 
        		$page = $query_page->fetchRow();
  | 
      
      
        | 84 | 
        
         | 
        
         | 
        		// Required page details
  | 
      
      
        | 85 | 
        
         | 
        
         | 
        		define('PAGE_CONTENT', WB_PATH.'/modules/news/comment_page.php');
 | 
      
      
        | 86 | 
        
         | 
        
         | 
        		// Include index (wrapper) file
  | 
      
      
        | 87 | 
        
         | 
        
         | 
        		require(WB_PATH.'/index.php');
  | 
      
      
        | 88 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 89 | 
        
         | 
        
         | 
        }
  |