It is currently Thu Mar 28, 2024 2:43 am



Reply to topic  [ 1 post ] 
PHP Walrus script. 
Author Message
Minor Diety
User avatar

Joined: Fri Apr 11, 2003 5:09 pm
Posts: 4003
Location: Walsall, West Mids, UK
Reply with quote
Post PHP Walrus script.
I'm posting everywhere about this, because no where wants to have people online to help me.

Anyway, Basically, it's a webcomic archiving script.

www.paint-zone.co.uk/ball

Notice the red x.
Here's the code, help if you can.

Code:
<?
$gtod1 = gettimeofday();
// Thanks to Steve Napierski for the following addition, which should allow
// the code to work on more systems.
$date=$_GET['date'];

// -----------------------------------------------------------------------------
// PHP webcomic update script v. 2.1 by Jim Newberry with lots
// of help from Doug Shepherd's excellent article, located here:
// http://www.webtools.com/story/scripting/TLS20000421S0001
//
// Yes, I'm aware the article is no longer available. But I gotta
// give credit where it's due... so the link remains until I locate
// another version of the article :)
//
// To get a copy of this script, visit www.lifeofwily.com/walrus
// -----------------------------------------------------------------------------
//
// The following variables must be customized as indicated.

// Absolute path to your comic image files. Don't include a "/" on the end. This value
// is not a URL (http://...). It is the location of your website files on your host server.
// If you don't know it, ask your host or consult their FAQ.
    $comic_path = "/home/sites/www.paint-zone.co.uk/web";

// This is the relative URL of your comic image files. If this file is located at
// http://www.yoursite.com/index.php, and your comics are in the http://www.yoursite.com/strips
// directory, then the URL would be "strips". This value can be EITHER relative (as the example
// shows, or a full HTTP address: "http://www.yoursite.com/strips".
   $comic_url = "http://www.paint-zone.co.uk/ball/comic";

// Change the following variable to the suffix your comic files will use,
// for instance, if they are GIFs, use ".gif", ".png" for PNGs, and so on.
// This means all your comic files must be the same extension.
   $image_suffix = ".gif";

// This variable indicates whether or not you want the script to display comic images.
// In other words, you could just put your strips in .html files and have the script
// pull them that way. IMPORTANT: Either $strips or $news MUST be "yes" or you won't
// see either. They can BOTH be "yes" if you want.
   $strips = "yes"; // "yes" or "no"

// This variable indicates whether or not you want the script to display news posts
   $news = "no"; // "yes" or "no"

// Absolute path to the files containing your news posts. Don't include a "/" on the end.
// This value is not a URL (http://). It is the location of your website files on your host
// server. If you don't know it, ask your host or consult their FAQ.
   $news_path = "/home/sites/www.paint-zone.co.uk/web/ball";

// Change the following variable to the suffix your news posts will use,
// if they are HTML files, use .htm or .html. Be sure to include the "."
   $news_suffix = ".html";
   
// Change $first_strip to the date ("YYYY-MM-DD") of your first comic. This
// variable will control the "first" link in the navigation menu.
   $first_strip = "2004-08-28";

// For all practical purposes, leave this next variable alone unless you want to help
// me debug the problem where the most recent comic displays twice if its filename
// doesn't match today's date -- 86400 is fine even if you don't update every 24 hours,
// or even only once a week, or Monday Wednesday Friday. I repeat, if you change this
// variable, you might have trouble :)
   $update_interval = "86400";  // default "86400", 24 hours. Read above info.

// -----------------------------------------------------------------------------   
// Only change PHP code beyond this notice if you know what you're doing :)
// -----------------------------------------------------------------------------

   $version_url = "http://www.lifeofwily.com/walrus/images";  // location of current version GIF
   if ( ereg("^[0-9]{4}-[0-9]{2}-[0-9]{2}$", $date) )
   $todays_strip = $date;
    else
   $todays_strip = date("Y-m-d", time());
   
   function next_strip ($date) {
   global $comic_path;
   global $image_suffix;
   global $update_interval;
   $today = date("Y-m-d");
   $epoch = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4));
   while ($epoch = $epoch + $update_interval) {
       $newdate = date("Y-m-d", $epoch);
       if ($newdate > $today) {
      return '';
       }
       if (file_exists($comic_path . "/" . $newdate . $image_suffix)) {
          return $newdate;
       }
   }
    }

    function previous_strip ($date) {
   global $comic_path;
    global $first_strip;
   global $image_suffix;
   global $update_interval;
   $epoch = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4));
   while ($epoch = $epoch - $update_interval) {
       $newdate = date("Y-m-d", $epoch);
       if ($newdate < $first_strip) {
      return '';
       }
       if (file_exists($comic_path . "/" . $newdate . $image_suffix)) {
      return $newdate;
       }
   }
    }

    $previous = previous_strip($todays_strip);
    $next = next_strip($todays_strip);

// -----------------------------------------------------------------------------
// Now your HTML code begins. Be careful of the PHP scripts scattered within :)
// -----------------------------------------------------------------------------
?>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body class="main">
<table width="750" border="0" cellspacing="3" cellpadding="10" align="center" bgcolor="#000000">
  <tr>
    <td align="center" bgcolor="#FFFFFF">
      <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
        <?
   if ($strips != "yes") {                           // if $news is not "yes", display nothing
   
   } elseif (file_exists($comic_path . "/" . $todays_strip . $image_suffix)) {
       ?>
        <img src="<? echo $comic_url ?>/<? echo $todays_strip ?><? echo $image_suffix?>">
        <?
   } else {

// new code, fix for date bug provided by Hyde (hyde@ultra-caffeinated.com)
     
        $todays_strip = $previous;
        $previous = previous_strip($todays_strip);
        $next = next_strip($todays_strip);
 
        ?>
        <img src="<? echo $comic_url ?>/<? echo $todays_strip ?><? echo $image_suffix?>">
        <?
} // end of the Hyde Fix
?>
        </font></p>
      <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">

<?
// This is the part of the script that displays your news posts from the dated
// files you put in your default news directory.
      
   if ($news != "yes") {                         // if $news is not "yes", display nothing
            
   } elseif (file_exists($news_path . "/" . $todays_strip . $news_suffix)) { // look for current news post
       include $news_path . "/" . $todays_strip . $news_suffix;           // if $news is "yes"
               
   } else {
      include $news_path . "/" . $previous . $news_suffix;  // display previous news if no current news available
                                                             
}
?>
        </font></p>
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
            <?
        if ($previous) {

// The text following this comment will be displayed to point you to the next comic. You can
// change it to an image, or to say anything you like.
?>
            <a href="index.php?date=<? echo $previous; ?>">Previous</a>
            <?
        } else {

// The text inside the ECHO command, after this comment, will be displayed if there is NO
// comic BEFORE the one currently on display. Feel free to change it to something else. If
// You want to include HTML instead of PHP, just delete the entire * echo "Previous"; *
// and put regular HTML, including images, there instead.
?>
           
         <? echo "Previous"; ?>

            <?
   }
?>
            </font></td>
          <td align="center" width="25%"> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
            <a href="index.php?date=<? echo $first_strip; ?>">First</a></font></td>
          <td align="center" width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><a href="index.php">Last</a></font></td>
          <td align="right" width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
            <?
  $next = next_strip($todays_strip);
  if ($next) {

// The text following this comment will be displayed to point you to the next comic. You can
// change it to an image, or to say anything you like.
?>
            <a href="index.php?date=<? echo $next; ?>">Next</a>
            <?
        } else {
      
// The text inside the ECHO command, after this comment, will be displayed if there is NO
// comic AFTER the one currently on display. Feel free to change it to something else. If
// You want to include HTML instead of PHP, just delete the entire * echo "Next"; *
// and put regular HTML, including images, there instead.
?>
           
         <? echo "Next"; ?>

            <?
   }
?>
            </font></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td align="center" bgcolor="#000000">
      <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Powered
        with Pride by </font><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><a href="http://www.lifeofwily.com/php">Walrus</a></font><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">™</font></p>
      <p><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a href="http://www.lifeofwily.com/walrus"><font size="2" color="#FFFFFF">Walrus™
        2.2</font><font color="#FFFFFF"> - The PHP Webcomic Archive and Live Rant
        Update Script</font></a><font color="#FFFFFF"> -- current version: <img src="<? echo $version_url ?>/php_current_version.lGIF" width="30" height="16"></font></font></p>
    </td>
  </tr>
</table>

_________________
Games to complete:
GTA IV [100%] (For Multiplayer next!)
Fallout 3 [50%]
Rock Band [35%]
http://www.cafepress.com/SmeepProducts


Sat Sep 11, 2004 5:31 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.