| px | top | add code | search | signup | login | help |
<?php
// The purpose of this code is to allow you to use the free
// Loquacious comment server at http://www.greenspun.com/,
// and serve the comments from your server on appended to
// the bottom of your page that they are for. This is the
// same look as the http://www.photo.net/ pages.
// Basically PHP first reads and displays your local file that
// you want to add comments to the bottom of. Then things get
// a little trickier. The greenspun.com pages don't give their
// full URL, so if you just did another readfile("http:...),
// none of the links would work. So instead we read the file
// into an array and then step though the array, replacing the
// incomplete URLs with complete ones and spitting the file out
// portion by portion from the array. The strip slashes is
// necessary to keep slashes from showing up around the
// parentheses surrounding URLs.
// enjoy! Sam Snow, <snowsam@eng.auburn.edu>
ReadFile("/full/path/to/your/file.html");
$b = file("http://www.greenspun.com/com/youruser/file.html");
$i=0;
while($i < count($b)){
$s = ereg_replace("/com/home.html", "http://www.greenspun.com/com/home.html",$b[$i]);
$s = ereg_replace("/com/_classify_input/", "http://www.greenspun.com/com/_classify_input/", $s);
$s = ereg_replace("/com/admin/", "http://www.greenspun.com/com/admin/", $s);
$s = stripslashes($s);
echo $s;
$i++;
}
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.