Photo Slideshow – Part Two – Simple Slideshow

After I got my photos resized it was time to move on to a simple slideshow. It doesn’t get more simple then this. I’ll go with the code first then provide a full explanation.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>Simple SlideShow</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<?php
  //the first thing we need to do is determine if we are on index or if we are on a picture
  $picture_num = (isset($_GET['pic'])) ? $_GET['pic']: 1;
  //now we'll also need to read the full directory
  $files = scandir('images/700w', 1);
  $total_num = count($files) - 2;

  $prev = ($picture_num == 1) ? $total_num : $picture_num - 1;
  $next = ($picture_num == $total_num) ? 1 : $picture_num + 1;
?>

<body style="margin:0 auto;text-align:center;">
    <div class='navigation'>
      <a href="index.php?pic=<?php echo $prev; ?>">< Previous</a> |
      <?php echo $picture_num . ' of ' . $total_num; ?> |
      <a href="index.php?pic=<?php echo $next; ?>">Next ></a>
    </div>

    <div id='photo'>
      <a href="images/originals/<?php echo $files[$picture_num - 1]; ?>">
        <img src="images/700w/<?php echo $files[$picture_num - 1]; ?>" alt="Picture" style="border:none;">
      </a>
    </div>

    <div class='navigation'>
      <a href="index.php?pic=<?php echo $prev; ?>">< Previous</a> |
      <?php echo $picture_num . ' of ' . $total_num; ?> |
      <a href="index.php?pic=<?php echo $next; ?>">Next ></a>
    </div>


</body>
</html>

This simple slideshow uses a GET request to do it’s work. This is going to dirty up our URL’s but it follows KISS. If ‘pic’ is not set it is set to 1.

Scandir reads into an array the files and directories from a directory. I cheat here and read in the directory backwards to avoid numbering issues and to get rid of the . and .. problem. Don’t put any directories in the originals or you’ll end up with a broken picture.

We subtract two from the total number of entries to get the number of pictures we have to show. I then set my previous and next buttons. This isn’t as simple as subtracting or adding one. We need to cycle around if we are at the beginning or end.

With that information it’s a simple matter of putting it on the screen. I have a small amount of CSS in there to center and remove a border. There are a lot of features that could be added and a few quirks to iron out. What do you guys think?

Linux Supports Microsoft MN-130 Network Card Unlike Windows

I recently was asked to troubleshoot a computer with network problems.

The computer had a Microsoft MN-130 network card installed but the proper software was not. Seeing as it’s a Microsoft card I thought for sure the drivers would be available within Windows XP. A few clicks and the computer would be fixed.

I suppose if it was that simple then someone would have done so. Upon running the add new hardware wizard I was left with a very long pause which eventually led to the software not being found.

Then interestingly enough Windows XP offered to download the driver for the network card from the Internet. I almost thought of clicking the button just to see it choke up but I had already wasted enough time.

So I scoured the Internet looking for the driver. I found plenty of sleazy download driver sites that claimed to have it but all but one led me to the same broken link on Microsoft’s website. One seemed to actually host the file, but after a series of approximately ten annoying advertisements I was rewarded only with a 404 not found error. I checked newsgroups and ftp searches to no avail.

I thought I’d have to buy a new one. Network cards are fairly cheap but it still bothered me that here was a perfectly good one that just wouldn’t work because of a silly missing driver.

So I wondered if Linux supported it. A check on the Internet led me to a post where someone had hacked it to work by recompiling a driver module. The post was dated 2003 and I thought maybe by now someone had implemented this hack permanently.

I am happy to say Puppy Linux picked it up upon booting. And no work was required to get it working. So much for Microsoft.

In the end I ended up swapping cards with this particular machine and charging the owner twenty dollars for my time and the discomfort of running a Microsoft card in a Linux machine. I probably should have charged more for the ugly stigmata. Anyone know of any other Microsoft hardware supported by Linux and not it’s creator?