Welcome to Geeklog Wednesday, February 20 2019 @ 02:39 pm EST

Geeklog Forums

Broken DailyDilbert temp Fix


Status: offline

mthomas

Forum User
Full Member
Registered: 18/04/04
Posts: 148
hopeful
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.
PHP Formatted Code

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 = "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');
// Work around for failing downloads, this is dirty but works....for now.
        if (strlen($image)==0){
         $Site = file_get_contents ("http://www.dilbert.com");
         $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 ("
http://www.dilbert.com/comics/dilbert/archive/images/{$Gif}");
        }
// End workaround
        fwrite($fp,$image);
        fclose($fp);
    }

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

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

All times are EST. The time is now 02:39 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content