|
Posted by Maxim Heijndijk on 01/20/07 17:42
Hello, this is my first on this list. I have a photography website and I
want to gradually convert it to PHP. I'm new to PHP, but I do have some
Perl knowledge and I am an expert in Bash-scripting (linux). Up till now
I used a script to generate a list of nearly identical html-files like
photo/01.html, photo/02.html, photo/03.html etc.. Every page constists
of a picture with caption an previous/next buttons. The photo's are
numbered 01.jpg, 02.jpg etc. The only varying content in the pages is
the size (horizontal/vertical) of the pictures and the captions. The
whole thing acts as a slide show. I want to write a PHP script which can
replace the list of HTML files, is such a thing possible? TIA, Max.
This is the site what it's about (not a plug!! I only want technical
information) http://www.maccusfoto.nl/
This is the Bash-script I use to generate the pages:
#!/bin/bash
clear
# Check for configuration file
if [ ! -f ./genpages.conf ]; then
echo -e "Configuration file not found! Aborting..."
exit 1
else
echo -e "Reading configuration file..."
sleep 1
. ./genpages.conf
echo -e "Done..."
fi
# Check for base directory
if [ ! -d "${ROOTDIR}" ]; then
echo -e "${ROOTDIR} Not found! Edit configuration file. Aborting..."
sleep 2
exit 1
fi
# Set direcory level
case ${DIRLEVEL} in
1) DIRLEVEL="../";;
2) DIRLEVEL="../../";;
3) DIRLEVEL="../../../";;
esac
LOOPCOUNT="0"
until [ "${LOOPCOUNT}" -ge "${PAGES}" ]; do
# Count the pages and set the variables
LOOPCOUNT="`expr ${LOOPCOUNT} + 1`"
if [ "${LOOPCOUNT}" -lt "10" ]; then
if [ "${LOOPCOUNT}" -eq "9" ]; then
NEXT="$(expr ${LOOPCOUNT} + 1)"
else
NEXT="0$(expr ${LOOPCOUNT} + 1)"
fi
LOOPCOUNT="0${LOOPCOUNT}"
PREV="0$(expr ${LOOPCOUNT} - 1)"
elif [ "${LOOPCOUNT}" -eq "10" ]; then
NEXT="$(expr ${LOOPCOUNT} + 1)"
PREV="0$(expr ${LOOPCOUNT} - 1)"
elif [ "${LOOPCOUNT}" -gt "10" ]; then
NEXT="$(expr ${LOOPCOUNT} + 1)"
PREV="$(expr ${LOOPCOUNT} - 1)"
fi
[ "${PREV}" = "00" ] && PREV="${DIRLEVEL}${STARTPAGE}"
[ "${LOOPCOUNT}" = "${PAGES}" ] && NEXT="${DIRLEVEL}${STARTPAGE}"
# Check for image files
if [ ! -f "${ROOTDIR}/${SUBDIR}/images/${LOOPCOUNT}.jpg" ]; then
echo "No image(s) found in ${ROOTDIR}/${SUBDIR}/images/"
# Create subdirectory
if [ ! -d "${ROOTDIR}/${SUBDIR}" ]; then
mkdir -p "${ROOTDIR}/${SUBDIR}/images/orig"
echo -e "Created ${ROOTDIR}/${SUBDIR}/images. Add your images."
fi
echo -e "Aborting..."
sleep 2
exit 1
fi
ORIENTATION="`identify ${ROOTDIR}/${SUBDIR}/images/${LOOPCOUNT}.jpg
| cut -d " " -f 3`"
WIDTH="`echo ${ORIENTATION} | cut -d "x" -f 1`"
HEIGHT="`echo ${ORIENTATION} | cut -d "x" -f 2`"
CAPTION="`grep "CAPTION_${LOOPCOUNT}=" ./genpages.conf | sed
"s|CAPTION_${LOOPCOUNT}=|| ; s|[\\\"]||g"`"
# Write the HTML pages
echo "Writing ${ROOTDIR}/${SUBDIR}/${LOOPCOUNT}.html"
echo -e "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<title>${GENERAL_TITLE} - Photo ${LOOPCOUNT}</title>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />
<meta http-equiv=\"refresh\" content=\"15;URL=${NEXT}.html\" />
<meta name=\"author\" content=\"Fotografie & Webdesign:
Maxim Heijndijk\" />
<meta name=\"copyright\" content=\"Fotografie & Webdesign:
Maxim Heijndijk\" />
<link rel=\"stylesheet\" type=\"text/css\"
href=\"${DIRLEVEL}../index.css\" />
</head>
<body oncontextmenu=\"return false\">
<table summary=\"${GENERAL_TITLE} - Photo ${LOOPCOUNT}\"
align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"
width=\"100%\" class=\"caption\">
<tr>
<td align=\"right\" valign=\"bottom\" width=\"10%\">
<a href=\"${PREV}.html\"><img alt=\"Previous\"
src=\"${DIRLEVEL}images/prev.gif\" border=\"0\" width=\"22\"
height=\"24\" /></a>
</td>
<td align=\"center\" valign=\"bottom\" width=\"80%\">
<a href=\"${NEXT}.html\"><img alt=\"${IMG_ALT}\"
src=\"images/${LOOPCOUNT}.jpg\" border=\"0\" width=\"${WIDTH}\"
height=\"${HEIGHT}\" /></a>
</td>
<td align=\"left\" valign=\"bottom\" width=\"10%\">
<a href=\"${NEXT}.html\"><img alt=\"Next\"
src=\"${DIRLEVEL}images/next.gif\" border=\"0\" width=\"22\"
height=\"24\" /></a>
</td>
</tr>
<tr>
<td align=\"center\" nowrap=\"nowrap\" valign=\"top\" width=\"100%\"
height=\"10%\" colspan=\"3\">
<br />
${CAPTION}
<br />
<br />
</td>
</tr>
</table>
</body>
</html>" > "${ROOTDIR}/${SUBDIR}/${LOOPCOUNT}.html"
done
# Backup the configuration
cp -f "./genpages.conf" "${ROOTDIR}/${SUBDIR}/genpages.conf"
exit 0
[Back to original message]
|