Formatting code for CkGarfDl


show source only

======Garfield comic strip downloader======

This is a shell script that allows you to download Garfield comic strips from the official site.

====Requirements====

~-php5-cli
~-wget

Tested on Linux, probably will work on other platforms supported by php-cli and wget as well. Your shell should support UTF-8 for this script to work flawlessly.

====The script (version 1.0.2)====

%%(php;1;ckgarfdl.php)
#!/usr/bin/php -q

<?php

$VeryFirstDay="19780619"; //the date of the first Garfield comic strip
$CurrentDay=date("Ymd", strtotime("today")); //today

$PrintErrorMsg=False;

if(($_SERVER["argc"] <= 1) || (($_SERVER["argc"] == 2) && ($_SERVER["argv"][1] == "help")))
{
print("Garfield comic strip downloader. Version 1.0.2 by Cyber Killer\n");
print("Get the latest version at http://digital.dharkness.info/CkGarfDl\n\n");
print("Usage:\n");
print("ckgarfdl.php help → print this text\n");
print("ckgarfdl.php all → gets all Garfield strips from the begining (1978-09-19) until today\n");
print("ckgarfdl.php <begin date> <end date> → gets all Garfield strips from the specified days\n");
print(" date should be in \"Ymd\" format e.g. 20100118 for 18th of January 2010\n");

$IsOkayToDownload=False;
}
elseif($_SERVER["argc"] == 2)
{
if($_SERVER["argv"][1] == "all")
{
$StartDay=$VeryFirstDay;
$EndDay=$CurrentDay;
$IsOkayToDownload=True;
}
else
{
$PrintErrorMsg=True;
$IsOkayToDownload=False;
}
}
elseif($_SERVER["argc"] == 3)
{
$StartDay=date("Ymd", strtotime($_SERVER["argv"][1]));
$EndDay=date("Ymd", strtotime($_SERVER["argv"][2]));
if((strcmp($StartDay, $VeryFirstDay) >= 0) && strcmp($EndDay, $CurrentDay) <= 0) //argument check
{
$IsOkayToDownload=True;
}
else
{
$PrintErrorMsg=True;
$IsOkayToDownload=False;
}
}
elseif($_SERVER["argc"] > 3)
{
$PrintErrorMsg=True;
$IsOkayToDownload=False;
}

if($PrintErrorMsg==True)
{
print("Syntax error!\n");
print("Try \"ckgarfdl.php help\" for help\n");
}

if($IsOkayToDownload==True)
{
$PlusDays = 0;
print("Starting download from " . $StartDay . " to " . $EndDay . "\n");
while((strcmp(date("Ymd", strtotime($StartDay . "+" . $PlusDays . " day")), date("Ymd", strtotime($EndDay)))) <= 0)
{
system("wget http://images.ucomics.com/comics/ga/" . date("Y", strtotime($StartDay . "+" . $PlusDays . " day")) . "/ga" . date("ymd", strtotime($StartDay . "+" . $PlusDays . " day")) . ".gif");
$PlusDays++;
}
print("Download finished!\n");
print("Saved " . $PlusDays . " files.\n");
}

?>

%%

Just click grab to save the file, or copy&paste it yourself to your favorite editor. Remember to add executable permissions.

====License====

""<!-- Creative Commons License -->
<a href="http://creativecommons.org/licenses/GPL/2.0/">
<img alt="CC-GNU GPL" border="0" src="http://creativecommons.org/images/public/cc-GPL-a.png" /></a><br />
This program is under the <a href="http://creativecommons.org/licenses/GPL/2.0/">CC-GNU GPL</a>, version 2.0 or later.
<!-- /Creative Commons License -->""

//Garfield © 2007 Paws//

----
CategoryProjekty
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
hosting provided by dharkness.info free hosting
ZielonyMail.com