summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-comments.php
blob: f45044dbb6c86a1e9af73aa9d4ac3ef3bd3c5488 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php // Do not delete these lines

/* $Id: wp-comments.php,v 1.3 2004/11/22 11:14:01 donncha Exp $ */

global $wpsmarty;
if ('wp-comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');
$commentstext = '';
$withcomments = true;
if (($withcomments && $wpsmarty->template_exists( "blog-comments.html" ) ) or (is_single())) 
{
    unset( $t );
    if (!empty($post->post_password)) { // if there's a password
        if ($_COOKIE['wp-postpass_'.$cookiehash] != $post->post_password) {  // and it doesn't match the cookie
            ?><p><?php _e("Enter your password to view comments."); ?><p><?php
                return;
        }
    }
    $query = "SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date";
    $comments = $wpdb->get_results( $query );
    if( is_array( $comments ) )
    {
        foreach( $comments as $key => $comment )
        {
            $t[ $key ] = $comment;
            $t[ $key ]->comment_content = stripslashes( $t[ $key ]->comment_content );
        }
    }
    else
    {
        $t = $comments;
    }
    $wpsmarty->assign( "comments", $t);
    $wpsmarty->assign( "comment_author_url", $comment_author_url );
    $wpsmarty->assign( "comment_author", $comment_author );
    $wpsmarty->assign( "comment_author_email", $comment_author_email );
    $wpsmarty->assign( "req", $req );
    $wpsmarty->assign( "redirect_to", htmlspecialchars($_SERVER["REQUEST_URI"]) );
    $wpsmarty->assign( "post", $post );
    $wpsmarty->caching = false;
    if( is_single() == false )
    {
	if( $wpsmarty->template_exists( "blog-comments.html" ) )
	    $commentstext .= $wpsmarty->fetch( "blog-comments.html" );
    }
    else
    {
	$commentstext .= $wpsmarty->fetch( "comments.html" );
    }
    $wpsmarty->caching = true;
}
?>