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

require("includes/global.php");

// build statistics
$sql = "SELECT albumid FROM " . $dbprefix . "albums";
$st1 = $db->execute($sql);
$stats_albums = $st1->rows;
$st1->clear();

$sql = "SELECT imageid FROM " . $dbprefix . "images";
$st2 = $db->execute($sql);
$stats_images = $st2->rows;
$st2->clear();

$sql = "SELECT userid FROM " . $dbprefix . "users";
$st3 = $db->execute($sql);
$stats_users = $st3->rows;
$st3->clear();

// check for actions
if ($usr->Access > 1){
	if ($_POST["do"] == "createalbum"){
		$errormsg = createalbum($_POST["title"], 0);
	} elseif ($_POST["do"] == "deletealbum"){
		$errormsg = deletealbum($_POST["albumid"], $_POST["confirm"]);
	}
}

// check for newbie registratin
if ($_GET["act"] == "newbie"){
	$errormsg = "Thanks for registering! You have been automatically signed in and can now access all the user functions. You can reach your control panel by clicking the users link on the navigation bar.";
} elseif ($_GET["act"] == "empty"){
	$errormsg = "The gallery is empty";
}

include("includes/page_header.php");

// set up variables
$t->set_var("STATS_ALBUMS", $stats_albums);
$t->set_var("STATS_IMAGES", $stats_images);
$t->set_var("STATS_USERS", $stats_users);

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

// albums
$sql = "SELECT * FROM " . $dbprefix . "albums WHERE parent = 0 AND visible >= " . $vis . " ORDER BY priority DESC, title ASC";
$alb = $db->execute($sql);
if ($alb->rows < 1){
	// no albums found
} else {
	do {
		if ($alb->fields["actasalbum"] == 0){
			$t->set_file("albumrow", "albumbit_container");
		} else {
			$t->set_file("albumrow", "albumbit");
		}
		
		$stack = fetchstack($alb->fields["albumid"]);
		$scan  = process_stack($stack);
		
		if ($alb->fields["visible"] == 0 && $alb->fields["status"] == 0){
			$t->set_var("ALBUM_FOLDER", "inactive");
		} elseif ($alb->fields["visible"] == 0){
			$t->set_var("ALBUM_FOLDER", "hidden");
		} elseif ($alb->fields["status"] == 0){
			$t->set_var("ALBUM_FOLDER", "locked");
		} else {
			$t->set_var("ALBUM_FOLDER", "open");
		}
		
		$t->set_var("ALBUM_ALBUMS", number_format(fetchalbumnum($scan, $alb->fields["albumid"])));
		$t->set_var("ALBUM_IMAGES", number_format(fetchimagenum($scan)));
		$t->set_var("ALBUM_LATEST", fetchlatestaddition($scan));
		
		$t->set_var("ALBUM_LINK", "viewalbum.php?albumid=" . $alb->fields["albumid"]);
		$t->set_var("ALBUM_TITLE", $alb->fields["title"]);
		$t->set_var("ALBUM_DESCRIPTION", $alb->fields["description"]);
		$t->parse("ALBUMS", "albumrow", true);
	} while ($alb->loop());
}

// do admin content?
if ($usr->Access > 1){
	$t->set_file("adminstuff", "galleryindex_admin");
	$t->set_var("FORM_LINK", "index.php");
	$t->parse("ADMIN_STUFF", "adminstuff");
}

// parse in error message?
if ($errormsg <> ""){
	$t->set_file("noticebox", "errorbox");
	$t->set_var("MESSAGE", $errormsg);
	$t->parse("ERRORMSG", "noticebox");
}

// parse in page
$t->set_file("page_content", "galleryindex");
$t->parse("page_all", "page_content", true);

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