Index: trackback.module =================================================================== RCS file: /var/www/vhosts/davidherron.com/cvsroot/drupal/modules/trackback/trackback.module,v retrieving revision 1.2 retrieving revision 1.3 diff -u -F^f -r1.2 -r1.3 --- trackback.module 15 Jun 2006 04:48:28 -0000 1.2 +++ trackback.module 20 Jun 2006 03:38:40 -0000 1.3 @@ -1,5 +1,5 @@ url = check_url($_REQUEST['url']); + if ($trackback->url && valid_url($_REQUEST['url'], TRUE)) { + + $error = 0; + + if (true) { + $response = drupal_http_request($trackback->url); + + // Check $response->error to see if the request happened right + // Look in $response->data for our URL + + if ($response->error) { + $error = 1; + $message = t('Could not retrieve requesting page'); + watchdog('trackback', t('Could not retrieve requesting page %url', array('%url' => $trackback->url)), WATCHDOG_NOTICE, l(t('view node'), 'node/'. $node->nid)); + } else { + $node_url = url('node/'. $node->nid, NULL, NULL, TRUE); + $found = stristr($response->data, $node_url); + if ($found === false) { + $error = 1; + $message = t('Page requesting trackback does not refer to '.$node_url); + watchdog('trackback', + t('Page requesting trackback does not refer to %nodeurl, source is %url', + array('%url' => $trackback->url, '%nodeurl' => $node_url + )), + WATCHDOG_NOTICE, l(t('view node'), 'node/'. $node->nid)); + } else { + watchdog('trackback', + t('Page requesting trackback DOES refer to %nodeurl, source is %url -- WILL RECORD TRACKBACK', + array('%url' => $trackback->url, '%nodeurl' => $node_url + )), + WATCHDOG_NOTICE, l(t('view node'), 'node/'. $node->nid) + ); + } + } + } + + if ($error == 0) { + $trackback->trid = db_next_id('{trackback_received}_trid'); + $trackback->nid = $node->nid; + $trackback->created = time(); + $trackback->site = $_SERVER['REMOTE_ADDR']; + $trackback->name = strip_tags(($_REQUEST['blog_name']) ? $_REQUEST['blog_name'] : $trackback->url); + $trackback->subject = strip_tags(($_REQUEST['title']) ? $_REQUEST['title'] : $trackback->url); + // $trackback->url already set above. Though I might say something here since I'm setting the fields + // in the exact same order that they are created in the table's create statement (with this exception). $trackback->excerpt = (strlen($_REQUEST['excerpt'] > 255) ? truncate_utf8($_REQUEST['excerpt'], 252) .'...' : $_REQUEST['excerpt']); + $trackback->status = (variable_get('trackback_moderation', 0) == 0) ? 1 : 0; + //watchdog('trackback', t('trackback: added \'%subject\'', array('%subject' => $trackback->subject)), l(t('view trackback'), 'node/'. $node->nid, NULL, NULL, 'trackback-'. $trackback->trid)); + + watchdog('trackback', t('trackback: added \'%subject\'', array('%subject' => $trackback->subject)), WATCHDOG_NOTICE, l(t('view trackback'), 'node/'. $node->nid .'#trackback-'. $trackback->trid)); + + db_query("INSERT INTO {trackback_received} (trid, nid, created, site, name, subject, url, excerpt, status) VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', '%s', %d)", $trackback->trid, $trackback->nid, $trackback->created, $trackback->site, $trackback->name, $trackback->subject, $trackback->url, $trackback->excerpt, $trackback->status); + + if (function_exists('spam_check') && variable_get('trackback_spam_filter', 1)) { + // trid, subject and body are used by spam_check() + // Put everything we want to check for spam in the trackback body and subject + // Since everything has already been inserted into the database and since the value + // of the $trackback variable's attributes will not be used again in this function, + // we can modify the attributes as we want before passing it on to the spam check. + $trackback->subject = $trackback->subject .' '. $trackback->url; + spam_check($trackback, 'excerpt', 'subject', 'trackback_spam_actions', 'insert'); + } + } + } + else { + $error = 1; + $message = t('Missing TrackBack url.'); + } + + // Generate response + $output = "\n"; + $output .= "\n"; + $output .= ''. $error ."\n"; + $message and $output .= ''. $message ."\n"; + $output .= "\n"; + + return $output; +} + + + + +/*OLD function trackback_receive(&$node) { $trackback = new stdClass(); // Process TrackBack post data. @@ -71,6 +156,7 @@ function trackback_receive(&$node) { return $output; } +END OLD */ function theme_trackbacks($trackbacks) { $output = '
'."\n";