-
-
Save pjmorse/1131750 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php -q | |
<?php | |
/** | |
* Cron job to update the comics plan. | |
*/ | |
// TODO: archive; move to <comicname>@comics.planworld.net | |
// new: Bizarro, Mother Goose and Grimm | |
/* includes */ | |
$_base = dirname(__FILE__) . '/../'; | |
require_once($_base . 'config.php'); | |
require_once($_base . 'lib/Planworld.php'); | |
require_once($_base . 'lib/User.php'); | |
/* create a user object for the menu user */ | |
$_user = User::factory('comics'); | |
$content = ''; | |
$content .= "<p><strong>Doonesbury</strong><br /><img src=\"http://images.ucomics.com/comics/db/" . date("Y") . "/db" . date("ymd") . ".gif\" /></p>\n"; | |
// Foxtrot (Sundays only) | |
if (date("D") == "Sun") { | |
$content .= "<p><strong>Foxtrot</strong><br /><img src=\"http://picayune.uclick.com/comics/ft/" . date("Y") . "/ft" . date("ymd") . ".gif\" /></p>\n"; | |
} | |
$command = 'lynx -source http://comics.com/comics/getfuzzy/index.html | grep Get\ Fuzzy\ - '; | |
//echo $command . "\n"; | |
//echo `$command` . "\n"; | |
$content .= "<p><strong>Get Fuzzy</strong><br />" . trim(`$command`) . "</p>\n"; | |
$content .= "<p><strong>Non Sequitur</strong><br /><img src=\"http://images.ucomics.com/comics/nq/" . date("Y") . "/nq" . date("ymd") . ".gif\" /></p>\n"; | |
$content .= "<p><strong>Dilbert</strong><br />" . str_replace("img src=\"","img src=\"http://dilbert.com/",trim(`lynx -source http://dilbert.com/ | grep -m 1 href=\"/strips/comic | perl -pe 's/.+SRC=\"(.+)\" BORDER.*/$1/'`)) . "</p>\n"; | |
$content .= "<p><strong>Pearls Before Swine</strong><br />" . trim(`lynx -source http://comics.com/comics/pearls/index.html | grep Pearls\ Before\ Swine\ - | perl -pe 's/.+SRC=\"(.+)\" ALT.*/$1/'`) . "</p>\n"; | |
$content .= "<p><strong>Rhymes with Orange</strong> (delayed 2 weeks)<br /><img src=\"http://halogen.note.amherst.edu/~seth/comics/proxy.php?u=" . urlencode("http://est.rbma.com/content/Rhymes_with_Orange?date=" . date("Ymd", mktime() - 1209600)) . ";r=" . urlencode("http://www.rhymeswithorange.com/") . "\" /></p>\n"; | |
// $content .= "<p><strong>For Better or For Worse</strong><br /><img src=\"http://www.comics.com" . trim(`lynx -source http://www.comics.com/comics/forbetter/ | grep Today\'s\ Comic | perl -pe 's/.+SRC=\"(.+)\" ALT=.*BORDER.*/$1/'`) . "\" /></p>\n"; | |
$content .= "<p><strong>Monty</strong><br />" . trim(`lynx -source http://www.comics.com/comics/monty/ | grep Monty\ - | perl -pe 's/.+SRC=\"(.+)\" ALT=.*BORDER.*/$1/'`) . "</p>\n"; | |
$content .= "<p><strong>Zits</strong><br />" . trim(`lynx -source http://www.kingfeatures.com/features/comics/zits/aboutMaina.php | grep content/Zits | perl -pe 's/.+SRC=\"(.+)\" ALT=.*BORDER.*/$1/'`) . "</p>\n"; | |
//$content .= "<p><strong>Zits</strong><br /><img src=\"http://halogen.note.amherst.edu/~seth/comics/proxy.php?u=" . urlencode("http://est.rbma.com/content/Zits?date=" . date("Ymd")) . ";r=" . urlencode("http://www.kingfeatures.com/features/comics/zits/about.htm") . "\" /></p>\n"; | |
// PhD Comics | |
$phd = "http://www.phdcomics.com/comics/archive/phd" . date("mdy") . "s.gif"; | |
$phd_response = exec("curl --stderr /dev/null -I ${phd} | head -1"); | |
if (strpos($phd_response, "OK")!==FALSE) { | |
$content .= "<p><strong>PhD Comics</strong><br /><img src=\"${phd}\" /></p>\n"; | |
} else echo $phd_response . "\n"; | |
// TODO check Last-Modified header to decide whether to display this | |
$xkcd_url = exec("curl --stderr /dev/null http://xkcd.com/ | grep img | head -3 | tail -2"); | |
$content .= "<p><strong>xkcd</strong><br />${xkcd_url}</p>\n"; | |
// file_put_contents("comics.html", $content); | |
$_user->setLastLogin(mktime()); | |
$_user->setPlan($content); | |
$_user->setLastUpdate(mktime()); | |
$_user->save(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment