PX : code

Pic of the day by Oscar Ferrer
Download this code


<?
#Chage the path for the Directory where you have the pictures
$dirname = \"/home/yuruani/yuruani-www/pictures\";
$dirname_for_html = \"../pictures\";

#------------------------------------------------------------------
#Normally you shouldn\'t have to chage anything else from this point
#------------------------------------------------------------------

$dir = opendir($dirname);
$i=0;

while ($file_name = readdir($dir)) { //Put the list of files in the array
 if (($file_name != \".\") && ($file_name != \"..\")) {
  $pic_array[$i] = \"$file_name\";
  $i++;
 }
}
closedir($dir);

$day = date(\"j\"); //Get the day of the month (line 22)
$day--;

$next_pic = date(\"H\");
$next_pic = 24 - $next_pic;

$pic_path = \"$dirname_for_html/$pic_array[$day]\";
?>

<html>
<head>
<title>Picture of the Day!</title>
</head>
<body>

<p><center><font size=\"5\" face=\"Verdana, Arial, Helvetica, sans-serif\"><b>Today\'s Picture</b></font></center></p>

<table width=\"408\" border=\"1\" align=\"center\">
  <tr>
    <td width=\"580\"><center><? echo \"<img src=\\\"$pic_path\\\">\"; ?></center></td>
  </tr>
  <tr>
    <td width=\"580\">
      <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">There will be another picture in about <? echo \"$next_pic\" ?> hour(s)</font></div>
    </td>
  </tr>
</table>


</body>
</html>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.