Code:
$url = "http://thedilbertstore.com/images/periodic_content/dilbert/dt".date("ymd")."dhct.jpg";
One liner for the URL, lol. Compare it to the GIF version:
Code:
$url = "http://www.dilbert.com/dyn/str_strip/"; // base URL
$dirSize = 9; // Number of 0s in the most significant digit for the Dilbert GIF images.
$baseDate = strtotime("2013-11-08"); // UNIX timestamp, reference date for getting future strips.
$curDate = strtotime('now');
$baseIndex = 202256;
// Subtract UNIX timestamps and divide by 86,400 to get the days (decimal), then floor() it to remove the decimal.
$curIndex = $baseIndex + floor(($curDate - $baseDate) / 86400 );
$dirDiff = $dirSize - strlen($baseIndex); // Get the current number of unused significant directory digits.
$paddedIndex = str_repeat("0", $dirDiff) . $curIndex; // Sort-of hacky but it feels like the easiest way to deal with the 0'd directories.
// The two least significant digits of the index don't matter, everything beforehand is used in the URL directory listing.
for($i = 0; $i < $dirSize - 2; $i++)
{
// Add "$dirsize - (i + 1)" 0s to the current digit directory to pad it out accordingly
$url .= $paddedIndex[$i] . str_repeat("0", $dirSize - ($i + 1)) . "/";
}
$url .= "{$curIndex}/{$curIndex}.strip.gif";
Will make the image generation/caching code tonight if I can stop faffing about.