Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need a little php help
#2
Heres the full code...

***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 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[email protected]
# Created 18.04.2003
# Dacio's PHP scripts &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;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 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [email protected]
# Modified August 13, 2004 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //filename photo list
$nr = "potd/pnumber.inc"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //file with counter
$arhiv = "potd/arhiv.txt"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//arhiv photo list

if (file_exists ($flist)) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//if exist $flist
&nbsp; &nbsp;$photo = file($flist); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //file with photo list
}
if (file_exists ($nr)) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if exist $nr
$date_mod = date("d.m.y", filemtime ($nr)); //check files modified date
}
$date = date("d.m.y"); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //todays date



//directory where photos are stored;don't forget "/" at the end
$inc_ext = ".inc"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Puts the .inc at the end of the quote file name
$quote_folder = "potd/potd_quote/"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Image Quote
$photo_thumbdir = "potd/potd_thumbs"; &nbsp; &nbsp; &nbsp; &nbsp;//Thumbnails folder
$photo_dir = "potd/potd"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//Photos folder
$photo_width = "90%"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//photo width
$photo_border = "0"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //photo border
$photo_alt = "VadaVaka's PotD"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//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) &nbsp; &nbsp; #
# AND makes new one with photo list &nbsp; &nbsp; &nbsp; #
###########################################
if (file_exists ($flist)) {
&nbsp;unlink ($flist);
}
$handle = opendir($photo_dir);
while (false !== ($file = readdir($handle))) {
&nbsp; &nbsp; &nbsp; if ($file != "." &amp;&amp; $file != "..") {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$aq = fopen ($flist,"a+");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fputs ($aq, $file."\n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fclose ($aq);
&nbsp; &nbsp; &nbsp; }
}
closedir($handle);
////////////////////////////////////////////////////////////////////

###########################################
# check date_mod not same as todays date &nbsp;#
# AND run script &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#
###########################################
if ($date_mod != $date) {

&nbsp;###############################################################
&nbsp;# if file exist read the number and encrease it by one &nbsp; &nbsp; &nbsp; &nbsp;#
&nbsp;# then show photo where line is same as number in pnumber.inc #
&nbsp;###############################################################
&nbsp;if (file_exists ($nr)) {
&nbsp; &nbsp; &nbsp; &nbsp;$fp = fopen ($nr,"r+");
&nbsp; &nbsp; &nbsp; &nbsp;$qc = fgets ($fp,4);
&nbsp; &nbsp; &nbsp; &nbsp;$qc = chop ($qc);
&nbsp; &nbsp; &nbsp; &nbsp;$qc += 1;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ($qc >= count($flist))
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$qc == 0;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewind ($fp);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fputs ($fp,substr($qc." &nbsp; ",0,4));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fclose ($fp);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo "<center><font COLOR=\"GOLDENROD\" face=\"verdana\" size=\"-1\"><h4>$photo_alt</h4></font>";
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo "<A HREF=\"$photo_dir/$photo[$qc]\" TARGET=_NEW $photo_info><img src=\"$photo_thumbdir/$photo[$qc]\" $photo_info></A>";
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$quote_potd = $quote_folder.$photo[$qc].$inc_ext;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo $quote_potd;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;include ("$quote_potd");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# include ("copyright.inc");

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//write info when did photo displayed AND which one
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ap = fopen ($arhiv,"a");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fputs ($ap, $date."\t".$photo[$qc]);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fclose ($ap);


&nbsp;###############################################################
&nbsp;# if file don't exist, make it and add null &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #
&nbsp;# then show photo where line is same as number in pnumber.inc #
&nbsp;###############################################################
&nbsp;} else {
&nbsp; &nbsp; &nbsp; &nbsp;$fp = fopen($nr,"w");
&nbsp; &nbsp; &nbsp; &nbsp;$qc = 0;
&nbsp; &nbsp; &nbsp; &nbsp;fputs ($fp,substr($qc." &nbsp; ",0,4));
&nbsp; &nbsp; &nbsp; &nbsp;fclose ($fp);
&nbsp; &nbsp; &nbsp; &nbsp;echo "<center><font COLOR=\"GOLDENROD\" face=\"verdana\" size=\"-1\"><h4>$photo_alt</h4></font>";
&nbsp; &nbsp; &nbsp; &nbsp;echo "<A HREF=\"$photo_dir/$photo[$qc]\" TARGET=_NEW $photo_info><img src=\"$photo_thumbdir/$photo[$qc]\" $photo_info></A>";
&nbsp; &nbsp; &nbsp; &nbsp;$quote_potd = $quote_folder.$photo[$qc].$inc_ext;
&nbsp; &nbsp; &nbsp; &nbsp;echo $quote_potd;
&nbsp; &nbsp; &nbsp; &nbsp;include ("$quote_potd");

&nbsp;}

##########################################################
# 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);

}
?>
Reply


Messages In This Thread
Need a little php help - by Gwarsbane - 08-13-2004, 05:46 PM
Need a little php help - by Gwarsbane - 08-13-2004, 05:46 PM
Need a little php help - by Gwarsbane - 08-13-2004, 07:31 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)