Recent Topics

1 Dec 13, 2007 12:38    

Warning: Cannot modify header information - headers already sent by (output started at /home/***/public_html/inc/comments/_trackback.funcs.php:72) in /home/***/public_html/inc/_core/_misc.funcs.php on line 2411

Warning: Cannot modify header information - headers already sent by (output started at /home/***/public_html/inc/comments/_trackback.funcs.php:72) in /home/***/public_html/inc/_core/_misc.funcs.php on line 2414

Above appears when sending trackbacks after posting a new post.
The post gets through the db, so I just have to "Back" my browser and reload the dashboard.

Trackback also gets through fine despite the errors above.

2 Dec 17, 2007 13:54

Crack open inc/comments/_trackback.funcs.php and replace this function ( approx 57 -> 181 )

/**
 * Send Trackback to single URL
 *
 * trackback(-)
 *
 * @todo add autodiscovery
 */
function trackback(
	$trackback_url,
	$title,
	$excerpt,
	$ID) // post ID
{
	global $app_name, $app_version, $Blog, $Messages;

	$trackback_message = T_('Sending trackback to:').' '.htmlspecialchars($trackback_url).' ';

	$title = rawurlencode($title);
	$excerpt = rawurlencode($excerpt);
	$blog_name = rawurlencode($Blog->get( 'name' ));
	$ItemCache = & get_Cache( 'ItemCache' );
	$Item = & $ItemCache->get_by_ID( $ID );
	$url = rawurlencode( $Item->get_permanent_url('', '', '&') );
	// dis is the trackback stuff to be sent:
	$query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
	// echo "url:$trackback_url<br>$sending:$query_string<br />";

	$result = '';
	if (strstr($trackback_url, '?'))
	{
		$Messages->add( $trackback_message.'[get]', 'note' );
		$trackback_url .= "&".$query_string;;
		flush();
		if( $fp = fopen($trackback_url, 'r') )
		{
			// blueyed>> why do we here just read the first 4kb, but in the POSTed response everything?
			// fp>> this is dirty code... I've never really reviewed it entirely. Feel free to refactor as much as needed.
			$result = fread($fp, 4096);
			fclose($fp);

			/* debug code
			$debug_file = 'trackback.log';
			$fp = fopen($debug_file, 'a');
			fwrite($fp, "\n*****\nTrackback URL query:\n\n$trackback_url\n\nResponse:\n\n");
			fwrite($fp, $result);
			fwrite($fp, "\n\n");
			fclose($fp);
			*/
		}

	}
	else
	{
		$Messages->add( $trackback_message.'[post]', 'note' );
		$trackback_url = parse_url($trackback_url);
		if( ! empty($trackback_url['host']) && ! empty($trackback_url['path']) )
		{ // Only try trackback if we have host and path:
			$port = isset($trackback_url['port']) ? $trackback_url['port'] : 80;
			$http_request  = 'POST '.$trackback_url['path']." HTTP/1.0\r\n";
			$http_request .= 'Host: '.$trackback_url['host']."\r\n";
			$http_request .= 'Content-Type: application/x-www-form-urlencoded'."\r\n";
			$http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
			$http_request .= "User-Agent: $app_name/$app_version\r\n";
			$http_request .= "\r\n";
			$http_request .= $query_string;
			flush();
			if( $fs = @fsockopen($trackback_url['host'], $port, $errno, $errst, 20) ) // this timeout is just for setting up the socket
			{
				// Set timeout for data:
				if( function_exists('stream_set_timeout') )
				{
					stream_set_timeout( $fs, 20 ); // PHP 4.3.0
				}
				else
				{
					socket_set_timeout( $fs, 20 ); // PHP 4
				}
				fputs($fs, $http_request);
				$result = '';
				while(!feof($fs))
				{
					$result .= fgets($fs, 4096);
				}

				/* debug code
				$debug_file = 'trackback.log';
				$fp = fopen($debug_file, 'a');
				fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n$result");
				while(!@feof($fs)) {
					fwrite($fp, @fgets($fs, 4096));
				}
				fwrite($fp, "\n\n");
				fclose($fp);
				*/

				fclose($fs);
			}
		}
	}
	// extract the error code and message, then make the error code readable
	if ( preg_match("/<error>[\r\n\t ]*(\d+)[\r\n\t ]*<\/error>/", $result, $error) )
	{
		preg_match("/<message>(.*?)<\/message>/", $result, $error_message);

		$message = isset($error_message[1]) ? $error_message[1] : '';

		switch ($error[1]) {
			case '0':
				$result_message = '[' . T_('Succeeded') . '] ' . $message;
				break;
			case '1':
				$result_message = '[' . T_('Failed') . '] ' . $message;
				break;
			default:
				$result_message = '[' . T_('Unknown error') . ' (' . $error[1] . ')] ' . $message;
				break;
		}
	}
	else
	{
		$result_message = T_('No valid trackback response. Maybe the given url is not a Trackback url.') . ' &quot;' . $result . '&quot;';
	}
	$Messages->add( T_('Response:').' '.strip_tags($result_message), 'note' );
	return $result;
}

¥

3 Dec 18, 2007 12:57

Hi thanks. Will test this weekend. My holiday vacation from work starts this Saturday :D

4 Dec 19, 2007 00:47

I just had to look up the definition of vacation ... sounds like a scary time, no work, no pc, just sunshine and beaches, and women in bugger all clothes, cheap alcohol and lazy nights ....... hope you survive :|

¥

5 Dec 19, 2007 05:36

¥åßßå wrote:

I just had to look up the definition of vacation ... sounds like a scary time, no work, no pc, just sunshine and beaches, and women in bugger all clothes, cheap alcohol and lazy nights ....... hope you survive :|

¥

ROFL

For me, hmm... I still have a PC at home, but no beaches at home heheheh :p


Form is loading...