diff -urN drupal-4.4.1/modules/trackback.module drupal4blog/modules/trackback.module
--- drupal-4.4.1/modules/trackback.module	Fri May 14 18:55:43 2004
+++ drupal4blog/modules/trackback.module	Fri May 21 13:28:42 2004
@@ -5,9 +5,23 @@
   switch ($section) {
     case 'admin/system/modules#description':
       return t("Allow for sending and receiving TrackBacks, which is a way for sites to notify another that they have commented on a post.");
+    case 'admin/system/modules/trackback':
+      return t("Trackback can be attached to any node and is treated like comments for all intent and purpose.");
   }
 }
 
+function trackback_settings() {
+    $output = "";
+
+    $array_moderate = array(0 => t("No"), 1 => t("Yes"));
+    $output .= form_radios(t("Display Trackback only after approval"), "trackback_moderation", variable_get("trackback_moderation", 0), $array_moderate, t("If yes, all trackback must be moderated before it can be seen by others."));
+
+    $array_moderate = array(0 => t("No"), 1 => t("Yes"));
+    $output .= form_radios(t("Trackback autodiscovery"), "trackback_autodiscovery", variable_get("trackback_autodiscovery", 1), $array_moderate, t("If yes, any external links will be extracted and the appropriate sites will be sent a Trackback ping. Take note it might slowdown your posting esp. if there is a lot of external links."));
+
+    return $output;
+}
+
 function trackback_send($node) {
   $params = array(
     "title" => $node->title,
@@ -20,12 +34,56 @@
     $str[] = "$key=". urlencode($value);
   }
 
-  return drupal_http(
-    $node->tb_url,
-    $headers = array("Content-Type" => "application/x-www-form-urlencoded"),
-    "POST",
-    implode("&", $str)
-  );
+  $node->toping = ""; # Start from scratch
+
+  $tb_urls = $node->tb_url;
+  if (variable_get("trackback_autodiscovery",1)) {
+    $text = $node->body; 
+    if ($node->type == 'blog')
+      $text .= " ".$node->extended." ".$node->excerpt;
+    preg_match_all("|http://[\w\.\-\+\&\+\=\/\#\%]+|",$text,$murl);
+    $links = array_unique($murl[0]);
+    foreach ($links as $url) {
+      $result = drupal_http($url);
+      $result->data = preg_replace("/[\n\r]/"," ",$result->data);
+      $tb = preg_replace("/.*<rdf\:RDF.*trackback\:ping\=\"([^\"]+)\".*<\/rdf\:RDF>.*/","\\1",$result->data);
+      $tb_urls .= " ".$tb;
+    }
+  }
+
+  $urls = preg_split("/\s+/",$tb_urls);
+  foreach($urls as $url) {
+    # No need to ping empty URL
+    if (strlen($url)<=0) continue;
+
+    # Do not ping those already ping'ed unless explicitly specified 
+    if (strstr($node->pinged,$url) && !strstr($node->tb_url,$url)) continue;
+
+    $result = drupal_http(
+        $url,
+        $headers = array("Content-Type" => "application/x-www-form-urlencoded"),
+        "POST",
+        implode("&", $str)
+    );
+
+    if (strlen(trim($result->error))>0) {
+      drupal_set_message("Error! Unable to send Trackback ping to ".$url);
+      if (!strstr($node->toping,$url))
+        $node->toping .= "\n".$url; $node->toping = trim($node->toping);
+    } else {
+      drupal_set_message("Success! Trackback ping send to ".$url);
+      if (!strstr($node->pinged,$url))
+        $node->pinged .= "\n".$url; $node->pinged = trim($node->pinged);
+    }
+  }
+
+  $c = db_result(
+    db_query("SELECT COUNT(nid) FROM {tb} WHERE nid = %d", $node->nid));
+
+  if ($c>0) 
+      trackback_update($node);
+  else 
+      trackback_insert($node);
 }
 
 function trackback_receive($node) {
@@ -40,10 +98,13 @@
     $subject = ($_REQUEST["title"]) ? $_REQUEST["title"] : $trackback->url;
     $comment = "<strong>". t("TrackBack from %url", array("%url" => "<a href=\"$trackback->url\">$trackback->name</a>")) .":</strong><br />";
     $comment .= "<blockquote>$trackback->excerpt</blockquote>";
+    $anon = serialize(array(
+            'anon_name' => trim(strip_tags($trackback->name)),
+            'anon_url' => trim(strip_tags($trackback->url))));
     $cid = db_next_id("comments_cid");
     $thread = rtrim(db_result(db_query("SELECT MAX(thread) FROM {comments} WHERE nid = %d", $node->nid)), "/") + 1;
-    db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users, thread) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', %d, %d, %d, '%s', '%d/')",
-             $cid, $node->nid, 0, 0, $subject, $comment, getenv("REMOTE_ADDR"), time(), 0, 0, '', $thread);
+    db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, anon, thread) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', %d, %d, %d, '%s', '%s')",
+             $cid, $node->nid, 0, 0, $subject, $comment, getenv("REMOTE_ADDR"), time(), variable_get("trackback_moderation", 0), 0, $anon, $thread);
     watchdog("special", t("trackback: added '%subject'", array("%subject" => $subject)), l(t("view comment"), "node/view/". $node->nid ."#". $cid));
     $error = 0;
   }
@@ -63,36 +124,91 @@
 }
 
 function trackback_page() {
-  if (is_numeric(arg(1)) && $node = node_load(array("nid" => arg(1)))) {
-    header("Content-Type: text/xml");
-    print trackback_receive($node);
-  }
-  else {
-    drupal_goto();
-  }
+    global $base_url;
+
+    if (arg(1) == "url" && is_numeric(arg(2)) 
+        && $node = node_load(array("nid" => arg(2)))) {
+        $output = t("<p>The Trackback URL for node is:<br/><blockquote>url</blockquote></p>",
+                    array("node" => l("'$node->title'","node/view/$node->nid"),
+                          "url" => l($base_url . "/" . url("trackback/$node->nid"),
+                            "trackback/$node->nid")));
+
+        if (user_access("administer nodes")) {
+          $node = trackback_load_node($node);
+          $urls = preg_split("/\s+/",$node->pinged);
+          $head = 0;
+          foreach ($urls as $url) {
+            $url = strip_tags($url);
+            if (strlen(trim($url))<=0) continue;
+            if ($head == 0) {
+              $output .=  "<p>".
+                t("Trackback pings have been sent to the following URLs:");
+              $head = 1;
+            }
+            $output .= "<li>$url</li>\n";
+          }
+          if ($head) $output .= "</p>";
+        }
+
+        print theme('page', $output, t("Trackback URL"));
+    } elseif (is_numeric(arg(1)) && $node = node_load(array("nid" => arg(1)))) {
+        header("Content-Type: text/xml");
+        print trackback_receive($node);
+    } else {
+        drupal_goto();
+    }
 }
 
 function trackback_nodeapi(&$node, $op, $arg = 0) {
+  $node = trackback_load_node($node);
   switch ($op) {
     case "form post":
-      return form_textfield(t("Trackback URL"), "tb_url", $node->tb_url, 40, 255, t("Enter a URL to send the trackback to."));
+      $node->tb_url = $node->toping;
+      return form_textarea(t("Trackback URL"), "tb_url", $node->tb_url, 70, 3, t("Enter URLs to send the trackback to."));
     case "insert":
     case "update":
-      if ($node->tb_url && $node->nid) {
+      # send trackback only for published post
+      if ($node->nid && $node->status == 1
+        && ($node->tb_url || variable_get("trackback_autodiscovery",1)))
         trackback_send($node);
-      }
   }
 }
 
+function trackback_insert($node) {
+  db_query("INSERT INTO tb (pinged, toping, nid) VALUES ('%s', '%s', %d)",
+    $node->pinged, $node->toping, $node->nid);
+}
+
+function trackback_update($node) {
+  db_query("UPDATE {tb} SET pinged = '%s', toping = '%s' WHERE nid = %d",
+    $node->pinged, $node->toping, $node->nid);
+}
+
+function trackback_delete(&$node) {
+  db_query("DELETE FROM {tb} WHERE nid = %d", $node->nid);
+}
+
+function trackback_load($node) {
+  return db_fetch_object(db_query("SELECT pinged, toping FROM {tb} WHERE nid = %d", $node->nid));
+}
+
+function trackback_load_node($node) {
+  if ($result = trackback_load($node)) {
+    foreach ($result as $key => $value)
+      $node->$key = $value;
+  }
+  return $node;
+}
+
 function trackback_link($type, $node = 0, $main = 0) {
   if ($type == 'system') {
     menu('trackback', t('trackback'), trackback_page, 0, MENU_HIDE);
   }
   elseif ($type == "node") {
-    $link = l(t("trackback url"), "trackback/$node->nid");
+    $link = l(t("trackback url"), "trackback/url/$node->nid");
     if (!$main) {
-      $url = url("node/view/$node->nid");
-      $tb_url = url("trackback/$node->nid");
+      $url = url("node/view/$node->nid", NULL, NULL, 1);
+      $tb_url =  url("trackback/$node->nid", NULL, NULL, 1);
       $link .= "\n<!--\n";
       $link .= "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\">\n";
       $link .= "<rdf:Description rdf:about=\"$url\" dc:identifier=\"$url\" dc:title=\"$node->title\" trackback:ping=\"$tb_url\" />\n";
@@ -221,4 +337,17 @@
   }
   return $result;
 }
-?>
+
+function trackback_blogadmin($type = "") {
+  $list = array();
+
+  if ($type == "options") {
+    if (user_access("administer site configuration")) {
+      $list[l(t("Trackback options"),"admin/system/modules/trackback")] = t("Configure trackback options");
+    }
+  }
+
+  return $list;
+}
+
+?>
