getConfig(); $dbh = &$site->getDatabase(); $common = new HTMLPage($config, "common", "templates"); $common->setHomePage(); switch($site->getAction()) { case "jump": if(is_numeric($page_num)) { $page_num--; $image_search = $_SESSION['image_search']; $image_search->setStartIndex($page_num * $image_search->getResultsPerPage()); $_SESSION['image_search'] = $image_search; } header('location: ' . $_SERVER["PHP_SELF"] . '?action=results'); exit; break; case "setPageSize": if(is_numeric($value)) { $image_search = $_SESSION['image_search']; $image_search->setResultsPerPage($value); $_SESSION['image_search'] = $image_search; } header('location: ' . $_SERVER["PHP_SELF"] . '?action=results'); exit; break; case "prev_page": $image_search = $_SESSION['image_search']; $image_search->prevPage(); $_SESSION['image_search'] = $image_search; header('location: ' . $_SERVER["PHP_SELF"] . '?action=results'); exit; break; case "next_page": $image_search = $_SESSION['image_search']; $image_search->nextPage(); $_SESSION['image_search'] = $image_search; header('location: ' . $_SERVER["PHP_SELF"] . '?action=results'); exit; break; case "results": $page = new HTMLPage($config, "gallery", "templates"); $sections = Gallery::getSectionList(); $gallery = new Gallery(); $gallery->loadFromDatabase($dbh, $_SESSION['gallery_current_id']); $section = $sections[$gallery->getSectionID()]; $image_search = $_SESSION['image_search']; $images = $image_search->getResults($dbh); $common->displayParsedTemplate("header"); $page->addVars('main', $gallery->getValueArray()); $page->addVar('main', 'SECTIONNAME', $section); $page->addVar('main', 'GALLERYID', $gallery->getID()); if(count($images)) { for($i=0; $iclearTemplate('normal_image'); $page->clearTemplate('video_clip'); if(($i > 0) && (($i % $config['images_per_row']) == 0)) { $page->parseTemplate('image_row', 'a'); $page->clearTemplate('image'); } $image = $images[$i]; $page->addVars('image', $image->getValueArray()); $page->addVar('image', 'DESCRIPTION', nl2br(htmlspecialchars($image->getDescription()))); $page->addVar('image', 'IMAGE_NUM', $i); if(strcmp(substr($image->getType(), 0, strlen('video/')), 'video/') == 0) { $page->addVars('video_clip', $image->getValueArray()); $page->addVar('video_clip', 'IMAGE_NUM', $i); $page->setAttribute('video_clip', 'visibility', 1); $page->setAttribute('normal_image', 'visibility', 0); } else if(strcmp(substr($image->getType(), 0, strlen('image/')), 'image/') == 0) { $page->addVars('normal_image', $image->getValueArray()); $page->addVar('normal_image', 'IMAGE_NUM', $i); $page->setAttribute('normal_image', 'visibility', 1); $page->setAttribute('video_clip', 'visibility', 0); } $page->parseTemplate('normal_image'); $page->parseTemplate('video_clip'); $page->parseTemplate('image', 'a'); } $page->parseTemplate('image_row', 'a'); $start_record = $image_search->getStartIndex() + 1; $end_record = $image_search->getStartIndex() + $image_search->getCurrPageSize(); $total_records = $image_search->getTotalResults($dbh); $prev_link = (($start_record > 1)?(1):(0)); $next_link = (($end_record < $total_records)?(1):(0)); $page->setAttribute("prev_link", "visibility", (($prev_link)?(1):(0))); $page->setAttribute("next_link", "visibility", (($next_link)?(1):(0))); $page->setAttribute("nav_dot", "visibility", (($prev_link && $next_link)?(1):(0))); } else { $page->setAttribute('gallery','visibility',0); $page->setAttribute('no_images','visibility',1); } $page->displayParsedTemplate("main"); $common->displayParsedTemplate("footer"); break; default: $gallery = new Gallery(); $gallery->loadFromDatabase($dbh, $_GET['galleryID']); if($gallery->getPrivate()) { if (!isset($PHP_AUTH_USER)) { header('WWW-Authenticate: Basic realm="Private Gallery"'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.'; exit; } else { if(($PHP_AUTH_USER != $gallery->getUsername()) || ($PHP_AUTH_PW != $gallery->getPassword())) { header('WWW-Authenticate: Basic realm="Private Gallery"'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.'; exit; } } } $image_search = new ImageSearch(); $image_search->setOrderByField("sortOrder"); $image_search->setOrderByOrder("ASC"); $image_search->setResultsPerPage($config['images_per_row'] * $config['rows_of_images']); if(strlen($_GET["galleryID"]) > 0) { $image_search->addCriteria("galleryID", $_GET["galleryID"], SEARCH_OP_EQUAL); } $_SESSION['image_search'] = $image_search; $_SESSION['gallery_current_id'] = $_GET['galleryID']; header("location: {$_SERVER["PHP_SELF"]}?action=results"); exit; break; } ?>