Heres the full code...
***Edit***
The code is fully working now like I wanted it too:)
***Edit***
The code is fully working now like I wanted it too:)
Code:
<?
################################################################################
# Dacio's Picture of the day v1.0
# Copyright 2003 by Dacio [email protected]
# Created 18.04.2003
# Dacio's PHP scripts http://www.geocities.com/daciofit/script
#
# This script is free to use and modify. However it is not free to
# re-distribute without written permission from the author.
#
# Change below to suit your needs
#
#
# Mods done by Nick Julian in 2004 [email protected]
# Modified August 13, 2004 http://gwars.mektek.net
# Mods added in: 1) Open picture of the day in a new window
# 2) Use small thumbnail instead of the full image for the potd to make page
# load up quicker so that larger/higher quality images can be used.
#
# Save thumbs with the exact same name as the original image (including the
# extention) into the thumbs folder and save them with photoshop 7 or 8 at a
# quality of 3 and a width of 200 px
################################################################################
# See readme.txt for more info
################################################################################
$flist = "potdst.txt"; //filename photo list
$nr = "potd/pnumber.inc"; //file with counter
$arhiv = "potd/arhiv.txt"; //arhiv photo list
if (file_exists ($flist)) { //if exist $flist
$photo = file($flist); //file with photo list
}
if (file_exists ($nr)) { //if exist $nr
$date_mod = date("d.m.y", filemtime ($nr)); //check files modified date
}
$date = date("d.m.y"); //todays date
//directory where photos are stored;don't forget "/" at the end
$inc_ext = ".inc"; //Puts the .inc at the end of the quote file name
$quote_folder = "potd/potd_quote/"; //Image Quote
$photo_thumbdir = "potd/potd_thumbs"; //Thumbnails folder
$photo_dir = "potd/potd"; //Photos folder
$photo_width = "90%"; //photo width
$photo_border = "0"; //photo border
$photo_alt = "VadaVaka's PotD"; //photo alt text
//don't change below ////////////////////////////////////////////////
$w = "width=".$photo_width;
$b = "border=".$photo_border;
$a = "alt=\"".$photo_alt."\"";
$photo_info = $w." ".$b." ".$a;
###########################################
# here deletes $photo file (if exist) #
# AND makes new one with photo list #
###########################################
if (file_exists ($flist)) {
unlink ($flist);
}
$handle = opendir($photo_dir);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$aq = fopen ($flist,"a+");
fputs ($aq, $file."\n");
fclose ($aq);
}
}
closedir($handle);
////////////////////////////////////////////////////////////////////
###########################################
# check date_mod not same as todays date #
# AND run script #
###########################################
if ($date_mod != $date) {
###############################################################
# if file exist read the number and encrease it by one #
# then show photo where line is same as number in pnumber.inc #
###############################################################
if (file_exists ($nr)) {
$fp = fopen ($nr,"r+");
$qc = fgets ($fp,4);
$qc = chop ($qc);
$qc += 1;
if ($qc >= count($flist))
$qc == 0;
rewind ($fp);
fputs ($fp,substr($qc." ",0,4));
fclose ($fp);
echo "<center><font COLOR=\"GOLDENROD\" face=\"verdana\" size=\"-1\"><h4>$photo_alt</h4></font>";
echo "<A HREF=\"$photo_dir/$photo[$qc]\" TARGET=_NEW $photo_info><img src=\"$photo_thumbdir/$photo[$qc]\" $photo_info></A>";
$quote_potd = $quote_folder.$photo[$qc].$inc_ext;
echo $quote_potd;
include ("$quote_potd");
# include ("copyright.inc");
//write info when did photo displayed AND which one
$ap = fopen ($arhiv,"a");
fputs ($ap, $date."\t".$photo[$qc]);
fclose ($ap);
###############################################################
# if file don't exist, make it and add null #
# then show photo where line is same as number in pnumber.inc #
###############################################################
} else {
$fp = fopen($nr,"w");
$qc = 0;
fputs ($fp,substr($qc." ",0,4));
fclose ($fp);
echo "<center><font COLOR=\"GOLDENROD\" face=\"verdana\" size=\"-1\"><h4>$photo_alt</h4></font>";
echo "<A HREF=\"$photo_dir/$photo[$qc]\" TARGET=_NEW $photo_info><img src=\"$photo_thumbdir/$photo[$qc]\" $photo_info></A>";
$quote_potd = $quote_folder.$photo[$qc].$inc_ext;
echo $quote_potd;
include ("$quote_potd");
}
##########################################################
# show photo where line is same as number in pnumber.inc #
##########################################################
} else {
$fp = fopen ($nr,"r");
$qc = fgets ($fp,4);
$qc = chop ($qc);
fclose ($fp);
echo "<center><font COLOR=\"GOLDENROD\" face=\"verdana\" size=\"-1\"><h4>$photo_alt</h4></font>";
echo "<A HREF=\"$photo_dir/$photo[$qc]\" TARGET=_NEW $photo_info><img src=\"$photo_thumbdir/$photo[$qc]\" $photo_info></A>";
$test = $photo[$qc];
$test = substr($test, 0, strlen($test)-1);
$quote_potd = $quote_folder.$test.$inc_ext;
# echo $test;
# echo $quote_potd;
include ($quote_potd);
}
?>