First of all, thanks very much for providing this forum. It is very much appreciated!
My son-in-law created a php script for my website about 10 years ago to show pictures like a manual slideshow, and it worked fine until we moved to a new server.
Now the first pic shows a . , the second shows .. , and the third shows the first pic.
He told me to add a # before @files in the
#remove the .. and . directories
and it should remove the dots but it does not. He can't think of any other suggestions. The full code is as follows:
#!/usr/bin/perl
#this script will act as a type of slide show
use CGI;
if(CGI::param('directory') eq undef) {
print CGI::header();
open(F, "pictures.txt");
chop(@directories = <F>);
close(F);
foreach (@directories) {
my($pDirectory, $title) = split(/::/);
my($hrefTitle) = $title;
$pDirectory = $pDirectory;
#remove the spaces
$pDirectory =~ s/ /%20/g;
$hrefTitle =~ s/ /%20/g;
print " <A HREF="/cgi-bin/pics.pl?directory=$pDirectory&title=$hrefTitle">$title</A><BR>";
}
} else {
#variables
my($serverRoot) = "/home/ma3ry/christiangays.com";
my($directory) = "/" . CGI::param('directory');
my($i) = 0;
my($max) = 0;
my(@files) = ();
$i = CGI::param('picNum') unless(CGI::param('picNum') == undef);
#open the directory
if(opendir(DIR, "$serverRoot/$directory")) {
#read in the contents of the directory
my(@files) = readdir(DIR);
#remove the .. and . directories
#@files = splice(@files, 2);
#sort the files
@files = sort(@files);
#find out how many pics there are
my($max) = @files *1;
#build the page
&createPage($directory, $files[$i], $i, $max, CGI::param('directory'), CGI::param('title'));
#close the directory
closedir(DIR);
} else {
#directory is not found
print "Content-type: text/htmlnn";
print "Couldn't open directory $directory!nn";
}
}
exit(0);
sub createPage {
my($directory) = shift;
my($picName) = shift;
my($i) = shift;
my($max) = shift;
my($hrefDirectory) = shift;
my($title) = shift;
my($j) = $i - 1;
$i++;
print "Content-type: text/htmlnn";
print (<<HTML);
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML LANG="en">
<HEAD>
<meta http-equiv="Content-Language" content="en-us">
<TITLE></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-">
<META NAME="generator" CONTENT="Jeff Berwick OR A PROGRAM WRITTEN BY HIM">
<META NAME="AUTHOR" CONTENT="Jeff Berwick">
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/css.css">
</HEAD>
<BODY>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY="LAYOUT" width="100%">
<TR>
<TD>
<img src="/images/blank.gif" width="10" height="1" alt="" border="0">
</td>
<TD class="yellow">
<img src="/images/blank.gif" width="15" height="1" alt="" border="0">
</td>
<td class="yellow2">
<BR><BR><BR>
HTML
#replace the spaces
$title =~ s/ /%20/g;
if($j >= 0) {
print "<a href="/cgi-bin/pics.pl?directory=$hrefDirectory&title=$title&picNum=$j">Previous</a><BR><BR>n";
} else {
print "previous<BR><BR>n";
}
if($i - 10 > 0) {
print "<a href="/cgi-bin/pics.pl?directory=$hrefDirectory&title=$title&picNum=", $i - 11, "">Jump back<BR> 10 pictures</a><BR><BR>n";
} else {
print "Jump back<BR> 10 pictures<BR><BR>n";
}
if($i - 1 != 0) {
print "<a href="/cgi-bin/pics.pl?directory=$hrefDirectory&title=$title&picNum=0">Start</a>n";
} else {
print "startn";
}
#put the spaces back in
$title =~ s/%20/ /g;
print(<<HTML);
<BR><BR>
<BR><BR>
<a href="/pics.shtml">Return to pictures list</a>
</td>
<td class="yellow">
<H1 class="center">$title</H1>
<P class="main2">
You are viewing picture $i of $max
</P>
<P class="main2">
<img src="$directory/$picName" alt="$picName" border="0">
</P>
<BR><BR>
</td>
<td class="yellow3">
<BR><BR><BR>
HTML
#drop the extra one off the end
$max--;
#take out the spaces
$title =~ s/ /%20/g;
if($i <= $max) {
print "<a href="/cgi-bin/pics.pl?directory=$hrefDirectory&title=$title&picNum=$i">Next</a><BR><BR>n";
} else {
print "next<BR><BR>n";
}
if($i <= $max - 10) {
print "<a href="/cgi-bin/pics.pl?directory=$hrefDirectory&title=$title&picNum=", $i + 9, "">Jump ahead<BR> 10 pictures</a><BR><BR>n";
} else {
print "Jump ahead<BR> 10 pictures<BR><BR>n";
}
if($i <= $max) {
print "<a href="/cgi-bin/pics.pl?directory=$hrefDirectory&title=$title&picNum=", $max, "">End</a>n";
} else {
print "endn";
}
print (<<HTML);
<BR><BR>
<BR><BR>
<a href="/index.shtml">Return to ChristianGays.com</a>
</td>
<TD class="yellow">
<img src="/images/blank.gif" width="15" height="1" alt="" border="0">
</td>
<TD>
<img src="/images/blank.gif" width="10" height="1" alt="" border="0">
</td>
</tr>
</table>
</BODY>
</HTML>
HTML
}
Really need helps regarding Pagination with Sort
I need someone helps regarding pagination problem...i actually want to make my page limited to let say 50 so it will look like this page1=0-50page2=51-100Then i want to sort let say based on the name
Problems with adding a link to one position in a 'foreach' loop, please help
Hello!Iam pretty new to programming and I wanna create a table with users from an array. It works just fine but in one table row I wanna add a link to it so I can click on the username to edit it
Operating System
How in PHP or other language can I detect Operating system, ie Windows XP Home, Windows 7 Ultimate, Mac OS 10?Anyone know how?Thanks
this code is strange !
Hi i got this code from the web.. It checks for live and dead socksIt is working perfectly on my localhost. but does not work in any webserver ! any ideas ?<?php$filename =
check if value exists
I have googled this for a while and I am getting lots of different results. Is there a standard method used for checking to see if a value exists in a database before inserting a value? I have a form,
DELETE rows based on content
I have a link in my rows$bit="http://bit.ly/abcd";$query = mysql_query("DELETE FROM *table* WHERE sentence........");//I need to delete all sentence rows which DOES NOT contain my
Set Categories
I am creating a submission form for somebody to come in and submit products. These products are separated by brand. How can I get them to display according to the brand?Here is the form code:Code:
Quick variable question
hey guys/gals, im trying to write a php script and it works fine as i have it, but i need to set it to where it pulls the var from mysql table that it is displayed differeantly. i.e. if $var==abcdefg
PHP Multiples of 2, Show posts...not working (wordpress)
I have been using this code to show div.example with 6 li columns inside it, each li is a post with its info inside.Once it gets to the 6th li it closes the div.example and starts a new one. This to
Transform value 0 in no and 1 in yes help needed
Hello,I have this in the table: "value" type int 0 to represent false and 1 to represent true. everything works great in display to the user end it sees 0 or 1 i want to replace the 0 to