<?php
class send_trackback{
	var $timeout = 10;
	function send_trackback(){

	}
	function send($host,$title,$url,&$excerpt) {
		global $_SET;
		$excerpt = qbase::substrs($excerpt,252);
		$blog_name = $_SET['title'];
		$blog_name = str_replace("'", "''", $blog_name);;
		$query = 'title=' . rawurlencode($title);
		$query .= '&url=' . rawurlencode($url);
		$query .= '&excerpt=' . rawurlencode($excerpt);
		$query .= '&blog_name=' . rawurlencode($blog_name);

		$buf = qbase::load($host, 0, $query , '', false, '', $this->timeout);
		if(empty($buf )){
			$this->log("ping return empty");
			return false;
		}
		$r = preg_match("/\<error\>([0-9])\<\/error\>/ies", $buf, $return);
		if($r){
			$return_num = intval($return[1]);
			if($return_num == 0){
				return true;
			}else{
				$r = preg_match("/\<message\>(.*)\<\/message\>/ies", $buf, $return);
				if($r){
					$this->log($return[1]);
				}
				return false;
			}
		}else{
			return false;
		}
	}

	function log($msg){
		qbase::createdir(C_P . "/log/");
		qbase::writetofile(C_P . "/log/trackback.txt", $msg . "\n", 'a+');
	}
}
?>