Zend - The PHP Company




Graphics

Add Code


Display the daily UserFriendly comic strip  

Type: code fragment
Added by: karakas
Entered: 28/11/2002
Last modified: 02/11/2001
Rating: - (fewer than 3 votes)
Views: 5404
This PHP script will display the daily comic from the well-known User Friendly site (www.userfriendly.org).


<?php

/************************************************************************/
/*                                                                      */
/* User Friendly Comic Block                                            */
/* =========================                                            */
/*                                                                      */
/* Copyright (c) 2002 by Chris Karakas <chris@karakas-online.de>        */
/* http://www.karakas-online.de                                         */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/*                                                                      */
/* This PHP         block will display the daily comic from the         */
/* well-known User Friendly site (www.userfriendly.org).                */
/* It reads the page http://www.userfriendly.org/static/ line by line,  */
/* searches for the pattern                                             */
/*                                                                      */
/* whatever<IMG ALT="Latest Strip"whateverSRC="imagefile">whatever,     */
/*                                                                      */
/* extracts the location of the image file (imagefile) from it          */
/* and displays it.                                                     */
/*                                                                      */
/* Please mail me if this should not work some day. In the meantime,    */
/* enjoy!                                                               */
/*                                                                      */
/* Chris                                                                */
/*                                                                      */
/************************************************************************/


$ufurl =  "http://www.userfriendly.org/static/";
$content "<i>ufurl:</i> $ufurl<br>";

$imagefile "";


if (!(
$textfile fopen"$ufurl",  "r"))) {
    
$content .= "$ufurl<br> could not be opened<br>";
    die();
}

while (!
feof($textfile)) {
    
$line fgets($textfile1500);
    if (
eregi".*<IMG ALT="Latest Strip".*SRC="(.*)">.*"$line$out)) {
        
$imagefile $out[1];
        break;
    }
}

fclose($textfile);

$content "<p align=center>";
$content .= "<A HREF="http://www.userfriendly.org" target="_blank"><IMG SRC="$imagefile" alt="User Friendly by Illiad"></A>";

$content .= "<p>";
$content .= "See the <a href="http://www.karakas-online.de/myServices/showfile.php?highlight=userfriendly">source code.</a>";

echo $content;

?>




Usage Example


See the example


Rate This Script





Search



This Category All Categories