Location: PHPKode > scripts > Particle Gallery > rank.php
<?php
define("IN_SCRIPT", true);

require("includes/global.php");
$pagetitle = "Search";

// work out visibility level
$vis = ($usr->Access > 1) ? 0 : 1;

// exclude hidden albums
if ($usr->Access > 1){
	$hid = "0";
} else {
	$hid = fetchhiddenstack();
	$hid = process_stack($hid);
}

// work out the page
if ($_GET["mode"] == "popular"){
	$mode = 2;
	$pagetitle = "Most Popular";
	$sortby = "views";
	$simple = "popular";
	$core = "rank.php?mode=popular";
} else {
	$mode = 1;
	$pagetitle = "Recently Added";
	$sortby = "postdate";
	$simple = "recent";
	$core = "rank.php?mode=recent";
}

// get images recordset
$sql = "SELECT * FROM " . $dbprefix . "images WHERE visible = 1 ORDER BY " . $sortby . " DESC";
$mex = $db->execute($sql);
if ($mex->rows < 1){ redirect("index.php?act=empty"); }

if(!isset($_GET["page"])){
    $page = 1;
} else {
    $page = intval($_GET["page"]);
    $page = ($page < 1) ? 1 : $page;
}

$maxitems = intval($config["imagesperpage"]);
$maxitems = ($maxitems < 1) ? 1 : $maxitems;
$from = (($page * $maxitems) - $maxitems);
$total_pages = ceil($mex->rows / $maxitems);

$sql .= " LIMIT " . $from . ", " . $maxitems;
$img  = $db->execute($sql);

// work out breadcrumbs
$bread = breadcrumbs($simple);

include("includes/page_header.php");

// work out inline title
if ($mode == 1){
	$t->set_var("RANK_PAGE", "Recently Added");
} else {
	$t->set_var("RANK_PAGE", "Most Popular");
}

// parse in the image results
// loop through images
$t->set_file("imgbit_container", "imagebit_container");

if ($config["thumbnailswithoutgd"] == "true"){
	$t->set_file("imgbit", "imagebit_size");
} else {
	$t->set_file("imgbit", "imagebit");
}

$row = 0;
$imagesperrow = intval($config["imagesperrow"]);
$imagesperrow = ($imagesperrow < 1) ? 1 : $imagesperrow;
$t->set_var("IMAGE_SIZE", $config["thumbnailsize"]);
$t->set_var("RESULTS_PAGING", dopaging($total_pages, $page, "search.php?q=" . urlencode(un($st)) . "&amp;user=" . urlencode(un($au)) . "&amp;order=" . $_GET["order"]));

do {

	if ($config["thumbnailswithoutgd"] == "true"){
		$t->set_var("IMAGE_WIDTH", $config["thumbnailsize"]);
		$t->set_var("IMAGE_HEIGHT", $config["thumbnailsize"]);
		$t->set_var("IMAGE_PATH", "generators/original.php?imageid=" . $img->fields["imageid"]);
	} else {
		$t->set_var("IMAGE_PATH", "generators/thumbnail.php?imageid=" . $img->fields["imageid"]);
	}
	
	$t->set_var("IMAGE_LINK", "viewimage.php?imageid=" . $img->fields["imageid"]);
	$t->set_var("IMAGE_CAPTION", $img->fields["title"]);
	$t->parse("IMAGEBIT", "imgbit");
	
	if ($row == $imagesperrow){
		$row = 0;
		$t->set_var("ROW_CODE", "</tr><tr>");
	} else {
		$t->set_var("ROW_CODE", "");
	}
	
	$t->parse("IMAGES", "imgbit_container", true);
	$row++;

} while ($img->loop());

$t->set_file("imagesholder", "viewalbum_images");
$t->parse("IMAGE_RESULTS", "imagesholder", true);

// parse it in
$t->set_var("PAGING", dopaging($total_pages, $page, $core));
$t->set_file("page_content", "rank");
$t->parse("page_all", "page_content", true);

include("includes/page_footer.php");
?>
Return current item: Particle Gallery