Simple DailyPic / Picture of the Day

7:18:00 PM | ,

Below is a quick and simple way to achieve a Picture of the Day / DailyPic script without database access for your website. You can just about put this anywhere in your web site.

Usage

Modify the following variables to fit your Website. For your images you must name them according to date format 2011-08-19.jpg and place them in the folders expected by image_urlimage_dir, etc.

print?
1<?php
2 
3$date date("Y-m-d");
4 
5// URL to Images.
6$image_url "http://yourwebsite/DailyPic/photos/";
7 
8// Path to Images
9$image_dir "/path/to/your/site/htdocs/DailyPic/photos/";
10 
11// Default if no image is available for Today
12$default "http://yourwebsite/DailyPic/photos/default.jpg";
13 
14// Image Extension for Your Pics
15$ext ".jpg";
16 
17$photo "$image_dir/$date" $ext "";
18 
19if (file_exists ($photo)){
20    echo '
21        <div class="potd">
22        <img src="'.$image_url.'/'.$date.$ext.'" border="0">
23        </div>
24    ';
25else {
26    echo '
27        <div class="potd">
28        <img src="'.$default.'" border="0">
29        </div>
30    ';
31}
32?>