Subject: Broken DailyDilbert temp Fix

Posted on: 27/01/06 06:28pm
By: mthomas

Hey All Long time no Post :-)
Here is dirty fix for the broken dilbert blocks out there.

Replace your existing block code with the below.
function phpblock_dailydilbert() {
    global $_CONF;

    /* Create a unique name for the Daily Dilbert comic file */
    $dilbert_todayfile = 'images/comics/dilbert_'. strtotime(date('m/d/Y')) . '.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 = "";
        $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');
// Work around for failing downloads, this is dirty but works....for now.
        if (strlen($image)==0){
         $Site = file_get_contents ("");
         $A1 = '<IMG SRC="/comics/dilbert/archive/images/dilbert';
         $A2 = '.gif" ALT="Today's Comic"';
         $pos1 = stripos($Site,$A1);
         $pos2 = stripos($Site,$A2);
         $Gif = substr($Site, $pos1+strlen($A1)-7,($pos2-$pos1)-(strlen($A2)+12));
         $image=file_get_contents ("{$Gif}");
// End workaround

    $imageurl = "{$_CONF['site_url']}/$dilbert_todayfile";

    return ("<a href='{$_CONF['site_url']}/images/comics/'><img src='{$imageurl}' width='180' border='0'></a>");

Geeklog - Forum