$_SESSION['photoCount'])) { header("Location: photos.htm"); exit(); } } // If we got here from a link (not from within photos.htm), then the stored session information will // not be available, so we must rebuild it. if (($photoGalleryControl > 0) && (!isset($_SESSION['photos']))) { //open the database $db_conn = new mysqli(DSC_DB_SERVER, DSC_DB_USER, DSC_DB_PASSWORD, DSC_DB_DATABASE); if (mysqli_connect_errno()) { echo 'Connection to database failed: ' . mysqli_connect_error(); exit(); } //build query $queryString = "SELECT * FROM photos WHERE categoryid = " . mysqli_real_escape_string($db_conn, $photoGalleryControl) . " ORDER BY sortnumber ASC"; //get the results from the database $result = $db_conn->query($queryString); $_SESSION['photoCount'] = $numberOfResults = $result->num_rows; //check the number of results - if 0 then something is wrong, so got back to the list of galleries if ($numberOfResults == 0) { header("Location: photos.htm"); exit(); } for ($i = 0; $i < $numberOfResults; $i++) { $row = $result->fetch_assoc(); $photo[$i]['photoid'] = $row['photoid']; $photo[$i]['photographer'] = stripslashes($row['photographer']); $photo[$i]['photocaption'] = stripslashes($row['photocaption']); $photo[$i]['photowidth'] = stripslashes($row['photowidth']); $photo[$i]['photoheight'] = stripslashes($row['photoheight']); } $_SESSION['photos'] = $photo; //check the gallery name array - if it is empty, we got here via a link (not from the gallery list) so we need to rebuild it if (!isset($_SESSION['categories'])) { $queryString = "SELECT * FROM photocategory WHERE approved = '1' ORDER BY categorydate DESC"; //get the results from the database $result = $db_conn->query($queryString); $numberOfResults = $result->num_rows; for ($i = 0; $i < $numberOfResults; $i++) { $row = $result->fetch_assoc(); $catID = $row['categoryid']; $cat[$catID]['categoryid'] = $row['categoryid']; $cat[$catID]['categoryname'] = stripslashes($row['categoryname']); $cat[$catID]['categorydate'] = $row['categorydate']; } $_SESSION['categories'] = $cat; } mysqli_close($db_conn); } ?> Dallas Sierra Club 0) { ?> \n"; echo " window.name = ''; \n"; echo " function jumpScroll() {\n"; echo " document.getElementById('bodytag').removeAttribute('style')\n"; echo " }\n"; echo " function detectScroll() {\n"; echo " }\n"; } ?>
Bookmark and Share

Dallas Sierra Club Photo Gallery

Click on an image to see more photographs.
\n"; //open the database $db_conn = new mysqli(DSC_DB_SERVER, DSC_DB_USER, DSC_DB_PASSWORD, DSC_DB_DATABASE); if (mysqli_connect_errno()) { echo 'Connection to database failed: ' . mysqli_connect_error(); exit(); } $queryString = "SELECT * FROM photocategory WHERE approved = '1' ORDER BY categorydate DESC"; //get the results from the database $result = $db_conn->query($queryString); $numberOfResults = $result->num_rows; for ($i = 0; $i < $numberOfResults; $i++) { $row = $result->fetch_assoc(); $catID = $row['categoryid']; $cat[$catID]['categoryid'] = $row['categoryid']; $cat[$catID]['categoryname'] = stripslashes($row['categoryname']); $cat[$catID]['categorydate'] = $row['categorydate']; } $_SESSION['categories'] = $cat; $categoryCount = count($cat); echo "\n"; $j = 0; foreach($cat as $i => $value) { //get the number of photos in this category and a random photo id $queryString = "SELECT photoid, photowidth, photoheight FROM photos WHERE approved = '1' AND categoryid = " . $i . " ORDER BY RAND()"; $result = $db_conn->query($queryString); $photoCount = $result->num_rows; if ($photoCount > 1) { $row = $result->fetch_assoc(); $photoID = $row['photoid']; $photoWidth = $row['photowidth']; $photoHeight = $row['photoheight']; //do some scaling if ($photoWidth > $photoHeight) { $photoScale = 150 / $photoWidth; } else { $photoScale = 120 / $photoHeight; } //$scaledWidth = intval($photoWidth * $photoScale); // $scaledHeight = intval($photoHeight * $photoScale); $scaledWidth = intval($photoWidth * 0.20); $scaledHeight = intval($photoHeight * 0.20); $marginLeft = intval((150 - $scaledWidth) / 2); $j++; $photoName = "../photos/dsc_img_tmb_" . $photoID . ".jpg"; if ($j & 1) { echo "\n"; echo "\n"; echo "\n"; } if (!($j & 1)) { echo "\n"; echo "\n"; echo "\n"; } if (($categoryCount & 1) && ($categoryCount == $j)){ echo "\n"; } } } echo "
\n"; echo "Click to see all of the photos in this gallery section.\n"; echo "\n"; echo "

", $value['categoryname'], "

\n"; echo $photoCount, " photographs

\n"; echo "
\n"; echo "Click to see all of the photos in this gallery section.\n"; echo "\n"; echo "

", $value['categoryname'], "

\n"; echo $photoCount, " photographs

\n"; echo "
\n"; mysqli_close($db_conn); } else { //display an image //display gallery name header echo "

", $_SESSION['categories'][$photoGalleryControl]['categoryname'],"

\n"; echo "

 

\n"; //display buttons echo "
\n"; if ($photoImageControl == 1) { echo "\n"; } else { echo "\n"; } echo "\n"; if ($photoImageControl == $_SESSION['photoCount']) { echo "\n"; } else { echo "\n"; } echo "
\n"; //build image name $photoName = "dsc_img_" . $_SESSION['photos'][$photoImageControl - 1]['photoid'] . ".jpg"; $photoNameFull = $_SERVER['DOCUMENT_ROOT'] . '/photos/' . $photoName; //get the image size and calculate the margin needed to get everything lined up for different sized photos if ($_SESSION['photos'][$photoImageControl - 1]['photowidth'] > 0) { $margin = (890 - $_SESSION['photos'][$photoImageControl - 1]['photowidth']) / 2; } else { $imageSize = getimagesize($photoNameFull); $imageWidth = $imageSize[0]; $margin = (890 - $imageWidth) / 2; } //display file number and count echo "
"; echo "Image number: ", $_SESSION['photos'][$photoImageControl - 1]['photoid'], "Image ", $photoImageControl, " of ", $_SESSION['photoCount'], "\n"; echo "
\n"; //display photo echo "
\n"; //echo "Dallas Sierra Club photo gallery\n"; echo "Dallas Sierra Club photo gallery\n"; echo "
\n"; //display photo credit echo "
\n"; echo "Photo credit: ", $_SESSION['photos'][$photoImageControl - 1]['photographer'], "\n"; echo "
\n"; //display photo caption echo "
\n"; echo stripslashes($_SESSION['photos'][$photoImageControl - 1]['photocaption']), "\n"; echo "
\n"; //pre-load the next image to speed things up if ($photoImageControl != $_SESSION['photoCount']) { //get the next image name also, so we can preload it $photoNameNext = "../photos/dsc_img_" . $_SESSION['photos'][$photoImageControl]['photoid'] . ".jpg"; echo "
\n"; echo "  \n"; echo "
\n"; } } ?>