Location: PHPKode > projects > Free Blog Creator > freeblog/trackback.php
<?php
if($_GET['id']){

if(!preg_match('/^[0-9a-z-]{3,20}$/',$_GET['id'])) {
$flg = 1;
}
else{
require("cfg.php");
$sid = $_GET['id'];
$year = substr($sid, -4, 4);
}

if(!$flg){
$title = $_POST['title'];
$url = $_POST['url'];
$excerpt = $_POST['excerpt'];
$blog_name = $_POST['blog_name'];

$flag = 1;
$Log=@file("./log/entry/$year.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode("<>",$Log[$i]);
if($line[0]==$sid){
$flag = 0;
}

$pattern = '#(^|[^\"\'=\]])(http|HTTP|ftp)(s|S)?://((([^\s<>\.]+)\.)+[^\s<>\.]+)#sm';
if (!preg_match($pattern,$url)) {
$flag = 1;
}
else {
$Log=@file("./log/trackback/$year.cgi");
for($i=0;$i<sizeof($Log);$i++){
$line=explode("<>",$Log[$i]);
if(($line[1]==$sid)&&($line[6]==$url)){
$flag = 1;
}
}

$Log=@file("./log/basic2.cgi");
$line=explode(",",$Log[0]);
$delivfree=$line[0];
$delivmail=$line[1];
$commentname=$line[2];
$commentemail=$line[3];
$commentlink=$line[4];
$commenttext=$line[5];
$tblink=$line[6];
$arrip=$line[7];
$arrtext=$line[8];

if($arrip){
$ip = getenv("REMOTE_ADDR");
$iline = explode("<br />",$arrip);
for($i = 0; $i < count($iline); $i++) {
if (ereg($iline[$i], $ip)) {
$flag = 1;
}
}
}
if($arrtext){

$tline = explode("<br />",$arrtext);
for($i = 0; $i < count($tline); $i++) {
if (ereg($tline[$i], $excerpt)) {
$flag = 1;
}
if (ereg($tline[$i], $title)) {
$flag = 1;
}
if (ereg($tline[$i], $blog_name)) {
$flag = 1;
}
}
}

$httphost= str_replace(basename(__FILE__),"",'http://'.$_SERVER["HTTP_HOST"].$_SERVER[PHP_SELF])."";

if($tblink==1){

	$pattern = "/^(http:\/\/)([^\/]+)(\/.*$)/i";
	if ( preg_match ( $pattern, $url, $match ) ) {
		$domain = $match[2]; 
		$path = $match[3]; 
	} else {
		exit();
	}

	$fp = fsockopen ( $domain, 80 );
	if ( !$fp ) {
		exit();
	}

	$request = "GET ".$path." HTTP/1.0\n";
	$request .= "Host: " .$domain. "\n";
	$request .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\n"; //User-Agent:
	$request .= "\n";
	fputs ( $fp, $request );
	while ( !feof ( $fp ) ) {
		$html .= fgets ( $fp, 4096 );
	}
	fclose ( $fp );

$script = $httphost."?sid=".$sid."\n";

$page = strip_tags($html, '<a>');
if ($page) {
if (!ereg($script, $page)) {
$flag = 1;
}
}

}



if($flag){
print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
print "<response>\n";
print "<error>1</error>\n";
print "<message>Error</message>\n";
print "</response>\n";
}
if(!$flag){
$title = strip_tags($title);
$blog_name = strip_tags($blog_name);
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt,0,200);
$excerpt = htmlspecialchars($excerpt);
$excerpt=nl2br($excerpt);
$excerpt=str_replace("\n","",$excerpt);
$excerpt=str_replace("\r","",$excerpt);


$view = date("Y-m-d H:i", $datetime);
$code = $datetime;

$lines=array("$code","$sid","$year","$view","$blog_name","$title","$url","$excerpt","$ip","0","1"));
$lines=implode("<>",$lines);
$lines=$lines."\n";

$fp=fopen("./log/trackback/$year.cgi","a");
fputs($fp,$lines);	
fclose($fp);
chmod("./log/trackback/$year.cgi",0666);


if($delivfree==1){
$Subject="New Trackback";

$IP = getenv("REMOTE_ADDR");
$Host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$Useragent = $_SERVER['HTTP_USER_AGENT'];
$Referer = $_SERVER["HTTP_REFERER"];

$Content = "";
$Content .= "Name: $blog_name\n";
$Content .= "Title: $title\n";
$Content .= "URL: $url\n";
$Content .= "Content: $excerpt\n";
$Content .= "IP: $IP\n";
$Content .= "Host: $Host\n";
$Content .= "Useragent: $Useragent\n";
$Content .= "Referer: $Referer\n";
$Content .= "----------------------------------------------\n";

$Text.="Prodct Page:\n";
$Text.=$httphost."?sid=".$sid."\n";
$Sign.="--------------------\n";
$Sign.="$adminsign";
$Header2  = "From: $ad";
$Content2 .= "$Text\n";
$Content2 .= $Content;
$Content2 .= $Sign;
$Content2 =mb_convert_kana($Content2 ,"K", "SJIS");
mb_send_mail($arr[delivmail], $Subject, $Content2, $Header2);
}

print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
print "<response>\n";
print "<error>0</error>\n";
print "</response>\n";
}


}
}
?>
Return current item: Free Blog Creator