Jan 13 2005 Daily Dilbert Comic Block Blaine Lang blaine@portalparts.com www.portalparts.com This is a quick block that uses a native Web Service to retrieve the Daily Dilbert Comic. It will create a local cached copy of the image. The Web Service will be called only once per day. This could be modified to delete older images easily as well. The block will show a reduced size image and link to the full sized image. Installation Steps: 1: Download the nusoap PHP WebService Library http://sourceforge.net/project/showfiles.php?group_id=57663&package_id=53241 2: Copy the nusoap.php to your system directory ( geeklog_dir/system ) where lib-custom.php is located 3: Create a "comics" folder under your public_html/images (or equivelent) folder. This will be used to cache the daily image files. You may want to purge older files once in a while. It would be an easy addition to have this block just re-use the same file or delete older image files. For now - it creates a new file for each day. Make sure you have permissions on the images/comics directory to allow the php script to write or create new files. 4: Add this function to your lib-custom.php file <<< BEGIN CODE >>> /* Geeklog Block to retrieve the Daily Dilbert Comic * Created by Blaine Lang * Jan 13 2005 * www.portalparts.com */ function phpblock_dailydilbert() { global $_CONF; /* Create a unique name for the Daily Dilbert comic file */ $dilbert_todayfile = 'images/comics/dilbert'. date('Ymd') . '.gif'; $file = "{$_CONF['path_html']}$dilbert_todayfile"; /* Check if today's Dilbert comic already exists - if not retrieve it and create the image */ if (!file_exists($file)) { /* Setup the Web Service Client */ include ($_CONF['path_system'] .'nusoap.php'); $wsdl = "http://www.esynaps.com/WebServices/DailyDilbert.asmx?WSDL"; $client = new soapclient( $wsdl,"true"); /* Call the Web Service and decode the base64 contents back to a GIF file */ $image = base64_decode($client->call('DailyDilbertImage', '')); /* Now write the raw image and create the image file */ $fp = fopen("{$_CONF['path_html']}$dilbert_todayfile",'w'); fwrite($fp,$image); fclose($fp); } $imageurl = "{$_CONF['site_url']}/$dilbert_todayfile"; return (""); } <<< END OF CODE >>> 5: Create a block definition using the block editor Block Title: What you want to see as the title on the displayed block. I use "Daily Dilbert" Block Name: Unique name - no spaces - used by GL to reference this block - I use "DailyDilbert" Block Type: PHP Block PHP Block Options - Define the Block Function name here - This is the name of the function in lib-custom - phpblock_dailydilbert - Note, you do not need to add the brackets, just the name - Set the location (order and side) as desired