PHP Classes

File: bt-trackback.php

Recommend this page to a friend!
  Classes of Michael Dale   Bluetrait   bt-trackback.php   Download  
File: bt-trackback.php
Role: Application script
Content type: text/plain
Description: Trackback Support File
Class: Bluetrait
A multi-user blog system
Author: By
Last change:
Date: 15 years ago
Size: 3,064 bytes
 

Contents

Class file image Download
<?php
/*
    Bluetrait 2.0 Trackback Support
    Michael Dale 2008
*/
include('bt-common.php');

if (
bt_get_config('trackbacks')) {

   
$bt_content_identifier = bt_get_content_identifier();
   
$bt_content_identifier['limit'] = 1;
   
$bt_posts = new bt_posts();
   
$bt_post_array = $bt_posts->get_posts($bt_content_identifier);
   
   
/*
    echo '<pre>';
    print_r($bt_content_identifier);
    echo '</pre>';
    exit;
    */
   
if (count($bt_post_array) == 1 && !$bt_content_identifier['empty']) {
       
//print_r($bt_post_array);
       
$bt_post = $bt_post_array[0];

       
//posted stuff from other blog site
       
$bt_trackback_url = $_POST['url'];
       
$bt_trackback_title = $_POST['title'];
       
$bt_trackback_excerpt = $_POST['excerpt'];
       
$bt_trackback_blog_name = $_POST['blog_name'];

       
$bt_comments = new bt_comments();
       
$bt_spam = new bt_spam();
       
       
$bt_comment_post['comment_body'] = $bt_trackback_excerpt;
       
$bt_comment_post['comment_display_name'] = $bt_trackback_blog_name;
       
$bt_comment_post['comment_website'] = $bt_trackback_url;
       
$bt_comment_post['comment_title'] = $bt_trackback_title;
       
       
$bt_comment_post['user_id'] = 0;
       
$bt_comment_post['comment_email'] = '';
       
$bt_comment_post['comment_allow_contact_form'] = 0;
       
$bt_comment_post['comment_date'] = bt_datetime();
       
$bt_comment_post['comment_date_utc'] = bt_datetime_utc();
       
$bt_comment_post['post_id'] = (int) $bt_post['post_id'];
       
$bt_comment_post['comment_ip_address'] = bt_ip_address();
       
$bt_comment_post['comment_approved'] = 1;
       
$bt_comment_post['comment_type'] = 'trackback';
       
       
//spam filtering happens here
       
$bt_spam->set_comment($bt_comment_post);
       
$bt_processed_comment = $bt_spam->get_comment();
       
//print_r($bt_processed_comment);
        //exit;
       
if ($bt_processed_comment['comment_akismet_spam']) {
           
bt_set_header('Content-Type: text/xml; charset=UTF-8');
           
bt_send_headers();
            echo
'<?xml version="1.0" encoding="iso-8859-1"?'.">\n";
            echo
"<response>\n";
            echo
"<error>1</error>\n";
            echo
"<message>Trackback not accepted as it has been detected as spam.</message>\n";
            echo
"</response>";
        }
        else {
           
//add trackback here
           
$bt_comments->add_comment($bt_processed_comment);
           
bt_set_header('Content-Type: text/xml; charset=UTF-8');
           
bt_send_headers();
            echo
'<?xml version="1.0" encoding="iso-8859-1"?'.">\n";
            echo
"<response>\n";
            echo
"<error>0</error>\n";
            echo
"<message>Trackback accepted.</message>\n";
            echo
"</response>";
        }
    }
    else {
       
bt_set_header('Content-Type: text/xml; charset=UTF-8');
       
bt_send_headers();
        echo
'<?xml version="1.0" encoding="iso-8859-1"?'.">\n";
        echo
"<response>\n";
        echo
"<error>1</error>\n";
        echo
"<message>Post not found.</message>\n";
        echo
"</response>";
    }

}
else {
   
bt_set_header('Content-Type: text/xml; charset=UTF-8');
   
bt_send_headers();
    echo
'<?xml version="1.0" encoding="iso-8859-1"?'.">\n";
    echo
"<response>\n";
    echo
"<error>1</error>\n";
    echo
"<message>Trackbacks Globally Disabled</message>\n";
    echo
"</response>";
}


?>