Index: trackback.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/trackback/trackback.module,v
retrieving revision 1.6
diff -u -u -F^function -r1.6 trackback.module
--- trackback.module	13 Jul 2004 20:36:23 -0000	1.6
+++ trackback.module	23 Jul 2004 13:22:14 -0000
@@ -3,7 +3,7 @@
 
 function trackback_help($section) {
   switch ($section) {
-    case 'admin/system/modules#description':
+    case 'admin/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.");
   }
 }
@@ -20,7 +20,7 @@ function trackback_send($node) {
     $str[] = "$key=". urlencode($value);
   }
 
-  return drupal_http(
+  return drupal_http_request(
     $node->tb_url,
     $headers = array("Content-Type" => "application/x-www-form-urlencoded"),
     "POST",
@@ -40,11 +40,11 @@ function trackback_receive($node) {
     $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>";
-    $cid = db_next_id("comments_cid");
+    $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/')",
+    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);
-    watchdog("special", t("trackback: added '%subject'", array("%subject" => $subject)), l(t("view comment"), "node/view/". $node->nid ."#". $cid));
+    watchdog("special", t("trackback: added '%subject'", array("%subject" => $subject)), l(t("view comment"), "node/view/". $node->nid ."#comment-". $cid));
     $error = 0;
   }
   else {
@@ -110,122 +110,4 @@ function trackback_menu() {
   return $items;
 }
 
-/**
-* @param $url http://example.com/path?query
-* @param $headers array("header" => "value");
-* @param $method method to use, defaults to GET
-* @param $data post data / return data
-* @param $retry how many times to retry (follow redirects, etc)
-*/
-function drupal_http($url, $headers = array(), $method = "GET", $data = "", $retry = 3) {
-  static $retries;
-
-  // Parse the URL, and make sure we can handle the schema
-  $uri = parse_url($url);
-  switch ($uri["scheme"]) {
-    case "http":
-      $fp = @fsockopen($uri["host"], ($uri["port"] ? $uri["port"] : 80), $errno, $errstr, 15);
-      break;
-    case "https":
-      // Note: only works for PHP 4.3 compiled with openssl
-      $fp = @fsockopen("ssl://$uri[host]", ($uri["port"] ? $uri["port"] : 443), $errno, $errstr, 20);
-      break;
-    default:
-      $result->error = "invalid schema $uri[scheme]";
-      return $result;
-  }
-
-  // Make sure the socket opened properly
-  if (!$fp) {
-    $result->error = trim("$errno $errstr");
-    return $result;
-  }
-
-  // Construct the path to act on
-  if ($uri["path"]) {
-    $path = $uri["path"];
-  }
-  else {
-    $path = "/";
-  }
-  if ($uri["query"]) {
-    $path .= "?$uri[query]";
-  }
-
-  // Create http request
-  $defaults = array(
-    "host"       => "Host: $uri[host]",
-    "user-agent" => "User-Agent: Drupal/4.0 (+http://www.drupal.org/)",
-    "content-length" => "Content-length: ". strlen($data)
-  );
-
-  foreach ($headers as $header => $value) {
-    $defaults[$header] = "$header: $value";
-  }
-
-  $request = "$method $path HTTP/1.0\r\n";
-  $request .= implode("\r\n", $defaults);
-  $request .= "\r\n\r\n";
-  if ($data) {
-    $request .= "$data\r\n";
-  }
-  $result->request = $request;
-
-  fwrite($fp, $request);
-
-  // Featch response
-  while (!feof($fp)) {
-    $response[] = fgets($fp);
-
-    /*
-    ** Make sure there is still data left to read, necessary to not block
-    ** processing in case the remote site doesn't return EOF properly.
-    */
-    $status = socket_get_status($fp);
-    if ($status["unread_bytes"] = 0) {
-      break;
-    }
-  }
-  fclose($fp);
-
-  // Parse response
-  list($protocl, $code, $text) = explode(" ", trim(array_shift($response)), 3);
-  $result->code = $code;
-  $result->headers = array();;
-  $result->data = "";
-
-  // Parse headers
-  while ($line = trim(array_shift($response))) {
-    if ($line == "") {
-      break;
-    }
-    list($header, $value) = explode(":", $line, 2);
-    $result->headers[$header] = trim($value);
-  }
-
-  while ($line = array_shift($response)) {
-    $result->data .= $line;
-  }
-
-  switch ($result->code) {
-    case 200: // OK
-    case 304: // Not modified
-      break;
-    case 301: // Moved permanently
-    case 302: // Moved temporarily
-      $location = $result->headers["Location"];
-      if ($retries < $retry) {
-        $retries++;
-        $result = drupal_http($result->headers["Location"], $headers, $method, $data, $retry);
-      }
-      else {
-        $result->error = "Too many retries";
-      }
-      $result->url = $location;
-      break;
-    default:
-      $result->error = $text;
-  }
-  return $result;
-}
-?>
\ No newline at end of file
+?>
