File:  [mozdev] / cdn / www / b2trackback.php
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Thu Mar 6 11:19:39 2003 UTC (16 years, 9 months ago) by cdn
Branches: MAIN
CVS tags: HEAD
b2 blog cafelog.com

    1: <?php if (!empty($tb)) { ?>
    2: <!-- you can START editing here -->
    3: 
    4: 	<?php // don't touch these 2 lines
    5: 	$queryc = "SELECT * FROM $tablecomments WHERE comment_post_ID = $id AND comment_content LIKE '%<trackback />%' ORDER BY comment_date";
    6: 	$resultc = mysql_query($queryc); if ($resultc) {
    7: 	?>
    8: 
    9: <a name="trackbacks"></a>
   10: <div><strong><span style="color: #0099CC">::</span> trackbacks</strong></div>
   11: 
   12: <p>
   13: ( The URL to TrackBack this entry is:<br />
   14: &nbsp;&nbsp;<em><?php trackback_url() ?></em> )
   15: </p>
   16: 
   17: 	<?php /* this line is b2's motor, do not delete it */ while($rowc = mysql_fetch_object($resultc)) { $commentdata = get_commentdata($rowc->comment_ID); ?>
   18: 	
   19: 
   20: <a name="tb<?php comment_ID() ?>"></a>
   21: 	
   22: 
   23: <!-- trackback -->
   24: <p>
   25: <?php comment_text() ?>
   26: <br />
   27: <strong><span style="color: #0099CC">&middot;</span></strong>
   28: <em>Tracked on <a href="<?php comment_author_url(); ?>" title="<?php comment_author() ?>"><?php comment_author() ?></a> on <?php comment_date() ?> @ <?php comment_time() ?></em>
   29: </p>
   30: <p>&nbsp;</p>
   31: <!-- /trackback -->
   32: 
   33: 
   34: 	<?php /* end of the loop, don't delete */ } ?>
   35: 
   36: 
   37: <p>&nbsp;</p>
   38: <div><b><span style="color: #0099CC">::</span> <a href="javascript:history.go(-1)">return to the blog</a></b></div>
   39: 
   40: 
   41: 	<?php /* if you delete this the sky will fall on your head */ } ?>
   42: 
   43: 
   44: </div>
   45: 
   46: 
   47: 
   48: <!-- STOP editing there -->
   49: 
   50: <?php
   51: 	
   52: } else {
   53: 
   54: if (!empty($HTTP_GET_VARS['tb_id'])) {
   55: 	// trackback is done by a GET
   56: 	$tb_id = $HTTP_GET_VARS['tb_id'];
   57: 	$url = $HTTP_GET_VARS['url'];
   58: 	$title = $HTTP_GET_VARS['title'];
   59: 	$excerpt = $HTTP_GET_VARS['excerpt'];
   60: 	$blog_name = $HTTP_GET_VARS['blog_name'];
   61: } elseif (!empty($HTTP_POST_VARS['url'])) {
   62: 	// trackback is done by a POST
   63: 	$request_array = 'HTTP_POST_VARS';
   64: 	$tb_id = explode('/', $HTTP_SERVER_VARS['REQUEST_URI']);
   65: 	$tb_id = $tb_id[count($tb_id)-1];
   66: 	$url = $HTTP_POST_VARS['url'];
   67: 	$title = $HTTP_POST_VARS['title'];
   68: 	$excerpt = $HTTP_POST_VARS['excerpt'];
   69: 	$blog_name = $HTTP_POST_VARS['blog_name'];
   70: }
   71: 
   72: if ((strlen(''.$tb_id)) && (empty($HTTP_GET_VARS['__mode'])) && (strlen(''.$url))) {
   73: 
   74: 	@header('Content-Type: text/xml');
   75: 
   76: 
   77: 	require_once("b2config.php");
   78: 	require_once("$b2inc/b2template.functions.php");
   79: 	require_once("$b2inc/b2vars.php");
   80: 	require_once("$b2inc/b2functions.php");
   81: 
   82: 	if (!$use_trackback) {
   83: 		trackback_response(1, 'Sorry, this weblog does not allow you to trackback its posts.');
   84: 	}
   85: 
   86: 	dbconnect();
   87: 
   88: 	$url = addslashes($url);
   89: 	$title = strip_tags($title);
   90: 	$title = (strlen($title) > 255) ? substr($title, 0, 252).'...' : $title;
   91: 	$excerpt = strip_tags($excerpt);
   92: 	$excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252).'...' : $excerpt;
   93: 	$blog_name = htmlspecialchars($blog_name);
   94: 	$blog_name = (strlen($blog_name) > 255) ? substr($blog_name, 0, 252).'...' : $blog_name;
   95: 
   96: 	$comment = '<trackback />';
   97: 	$comment .= "<b>$title</b><br />$excerpt";
   98: 
   99: 	$author = addslashes($blog_name);
  100: 	$email = '';
  101: 	$original_comment = $comment;
  102: 	$comment_post_ID = $tb_id;
  103: 	$autobr = 1;
  104: 
  105: 	$user_ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
  106: 	$user_domain = gethostbyaddr($user_ip);
  107: 	$time_difference = get_settings('time_difference');
  108: 	$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
  109: 
  110: 	$comment = convert_chars($comment);
  111: 	$comment = format_to_post($comment);
  112: 
  113: 	$comment_author = $author;
  114: 	$comment_author_email = $email;
  115: 	$comment_author_url = $url;
  116: 
  117: 	$author = addslashes($author);
  118: 
  119: 	$query = "INSERT INTO $tablecomments VALUES ('0','$comment_post_ID','$author','$email','$url','$user_ip','$now','$comment','0')";
  120: 	$result = mysql_query($query);
  121: 	if (!$result) {
  122: 		die ("There is an error with the database, it can't store your comment...<br>Contact the <a href=\"mailto:$admin_email\">webmaster</a>");
  123: 	} else {
  124: 
  125: 		if ($comments_notify) {
  126: 
  127: 			$notify_message  = "New trackback on your post #$comment_post_ID.\r\n\r\n";
  128: 			$notify_message .= "website: $comment_author (IP: $user_ip , $user_domain)\r\n";
  129: 			$notify_message .= "url    : $comment_author_url\r\n";
  130: 			$notify_message .= "excerpt: \n".stripslashes($original_comment)."\r\n\r\n";
  131: 			$notify_message .= "You can see all trackbacks on this post there: \r\n";
  132: 			$notify_message .= "$siteurl/$blogfilename?p=$comment_post_ID&tb=1\r\n\r\n";
  133: 
  134: 			$postdata = get_postdata($comment_post_ID);
  135: 			$authordata = get_userdata($postdata["Author_ID"]);
  136: 			$recipient = $authordata["user_email"];
  137: 			$subject = "trackback on post #$comment_post_ID \"".$postdata["Title"]."\"";
  138: 
  139: 			@mail($recipient, $subject, $notify_message, "From: b2@".$HTTP_SERVER_VARS['SERVER_NAME']."\r\n"."X-Mailer: b2 $b2_version - PHP/" . phpversion());
  140: 			
  141: 		}
  142: 
  143: 		trackback_response(0);
  144: 	}
  145: 
  146: }/* elseif (empty($HTTP_GET_VARS['__mode'])) {
  147: 
  148: 	header('Content-type: application/xml');
  149: 	echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">\n<response>\n<error>1</error>\n";
  150: 	echo "<message>Tell me a lie. \nOr just a __mode or url parameter ?</message>\n";
  151: 	echo "</response>";
  152: 
  153: }*/
  154: 
  155: 
  156: }
  157: 
  158: ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>