Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 71 lines (55 sloc) 2.117 kb
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
<?php

require_once( 'AMP/BaseDB.php');
require_once( 'AMP/Content/Article/Trackback.php');
AMP_config_load('urls' );

if ( !AMP_CONTENT_TRACKBACKS_ENABLED ) {
    print 'Sorry, trackbacks are currently disabled due to abuse.';
    exit;
}


$article_id = 0;
if ( isset( $_GET['id']) && is_numeric( $_GET['id']) && $_GET['id']) {
    $article_id = intval( $_GET['id'] );
}

$headers = apache_request_headers();
if(!isset($headers['Content-Type']) || strpos($headers['Content-Type'], 'application/x-www-form-urlencoded') !== 0) {
  $response = &new ArticleTrackback_Response(1, "Content-Type header must be 'application/x-www-form-urlencoded'");
  print $response->execute( );
  exit;
}

if(!isset($_POST['url'])) {
  $response = &new ArticleTrackback_Response(1, "No URL given");
  print $response->execute( );
  exit;
}

$trackback = &new ArticleTrackback( $dbcon );
$trackback->setDefaults();
$allowed_tags = $trackback->getAllowedTags( );
$trackback_data = array_combine_key( $allowed_tags, $_POST );
$trackback_data['article_id'] = $article_id;
if(isset($headers['charset'])) {
  $trackback_data['charset'] = $headers['charset'];
}
//content-type should be something like "application/x-www-form-urlencoded; charset=utf-8"
$content_type = explode(';', $headers['Content-Type']);
foreach($content_type as $param) {
  if(strpos($param, 'charset=') === 0) {
    $charset = explode('=', $param);
    $trackback_data['charset'] = trim($charset[1]);
  }
}

// no trackback data received, redirect to article display page
if ( !(
       ( isset( $trackback_data['title']) && $trackback_data['title'] )
    && ( isset( $trackback_data['url']) && $trackback_data['url'] )
    && ( isset( $trackback_data['blog_name'] ) && $trackback_data['blog_name'] ) )) {
    if ( $article_id ) ampredirect( AMP_Url_AddVars( AMP_CONTENT_URL_ARTICLE, "id=".$article_id ));
}

if ( $trackback->setPingData( $trackback_data )) {

    //if ( $trackback->validate( )){
    // $trackback->publish( );
    //}

    $trackback->save( );
}

$display = &$trackback->getResponse( );

print $display->execute( );


?>
Something went wrong with that request. Please try again.