<?php
    
// WPCAMFG - WordPress: Comments Awaiting Moderation Feed v0.1
    // Copyright (C) 2008 Kai 'Oswald' Seidler, osw@ldism.de, GPL-licensed
    // Please feel free to use, spread, copy, and modify this software according to the GPL.

    
$password="";

    
// You shouldn't need to change anything below this line

    
header('Content-type: text/xml; charset=utf-8'true);

    
$base_url=(strtolower($_SERVER['HTTPS']) == 'on' 'https://' 'http://').$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI']);

    echo 
'<?xml version="1.0" encoding="utf-8"?>';
    echo 
'<!-- generator="WPCAMFG/0.1" -->';
    echo 
'<rss version="0.92"><channel><title>Blog Comments Awaiting Moderation</title>';
    echo 
'<link>'.$base_url.'</link>';
    echo 
'<description>Blog Comments Awaiting Moderation at '.$base_url.'</description>';

    if(
$password=="")
    {
        echo 
'<item><title>Please set a password in your wpcamfg.php!</title>';
        echo 
'<description>You need to set a password in your wpcamfg.php file to protect your blog information against unwanted access.</description>';
        echo 
'</item></channel></rss>';
        exit;
    }

    if(
$password!=$_SERVER['QUERY_STRING'])
    {
        echo 
'<item><title>Wrong password!</title>';
        echo 
'<description>The given password doesn\'t match the password stated in your wpcamfg.php file.</description>';
        echo 
'</item></channel></rss>';
        exit;
    }

    include(
"wp-config.php");

    
$results $wpdb->get_results("SELECT comment_ID,comment_author_email, comment_author, comment_content FROM $wpdb->comments WHERE comment_approved = '0'");
    foreach ( 
$results as $row 
    {
        echo 
"<item>";

        echo 
"<title>".$row->comment_author_email." (".$row->comment_author.")</title>";

        echo 
"<description><![CDATA[";
        echo 
htmlspecialchars($row->comment_content);
        echo 
"]]></description>";

        
$link=$base_url."wp-admin/comment.php?action=editcomment&c=".$row->comment_ID;
        echo 
"<link><![CDATA[$link]]></link>";

        echo 
"</item>";
    }

    echo 
'</channel>';
    echo 
'</rss>';
?>