$_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";
}
?>
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";
//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 "