« The new math | Main | Link values »

Blogroll

Some players are using the new blogshares.com version of the blogroll, rather than the original blogrolling.com version. Unfortunately, the javascript version of this is of no use, as the code that parses the blogroll doesn't know how to find the links in the blogshares version of the roll. Ack!


I rewrote a php script that allowed me to use this blogroll here:


<?php

// The standard script for inclusion of a blogroll from blogrolling
// experiences awful timeouts when blogrolling.com is offline.

// blogrolling.php retrieves your blogroll, and caches the results.
// upon failure of blogrolling.com, it presents the cache to the
// visitor, in stead of waiting 30 seconds before a time out
// occurs.

// (c) 2005, Cathelijne Hornstra
// This script is licensed GPL.
// Modifications by Jim Wright for BlogShares


// Just include from another php file. The webserver needs write
// permissions in the dir where you are calling blogrolling.php from.

// Change into anything you want/need
$cache_lifetime = 60;
$cache_file = "BSblogroll.cache";
$cache_message = "Cannot reach blogshares.com, looking for a cache file";
$cache_notfound = "Sorry, no cache file found";

///////////////////////////////////////////
// No need to change anything below here //
///////////////////////////////////////////

$blogrolling_host = "blogshares.com";
$blogrolling_path = "/bsblogroll.php?type=html";

if($conn = @fsockopen("$blogrolling_host", 80 ,$errno ,$errstr , 1)){
$request = "GET ";
$request .= $blogrolling_path;
$request .= " HTTP/1.0\n";
$request .= "Host: ";
$request .= $blogrolling_host;
$request .= "\n\n";

fwrite($conn,$request);

while(!feof($conn)) {
$rawroll .= @fread($conn, 255);
}

fclose($conn);

$blogroll = strstr($rawroll,'

if (!(file_exists($cache_file))) {
$file = fopen($cache_file, "w+");
fwrite($file,$blogroll);
fclose($file);
} elseif ((time() - filemtime("$cache_file")) > ($cache_lifetime * 60)) {
$file = fopen($cache_file, "w+");
fwrite($file,$blogroll);
fclose($file);
}

} else {

if (file_exists($cache_file)) {
$blogroll = file_get_contents($cache_file);
} else {
$blogroll = "$cache_notfound";
}

echo "$cache_message";
echo "
\n";
}

echo $blogroll;

?>

TrackBack

TrackBack URL for this entry:
http://www.wrightthisway.com/cgi-bin/mt/mt-tb.cgi/457

About

This page contains a single entry from the blog posted on March 16, 2008 8:24 PM.

The previous post in this blog was The new math.

The next post in this blog is Link values.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33