Location: PHPKode > projects > Particle Blogger > particle-blogger/index.php
<?php
include("includes/global.php");

// now validate the status
$usr->Auth(0);

// check for a tag
if ($_GET["tag"] <> ""){
	$sql = "SELECT * FROM " . $dbprefix . "tags WHERE slug = '" . dbSecure($_GET["tag"]) . "'";
	$tag = $db->execute($sql);
	if ($tag->rows < 1){ notfound(); }
	
	$pagetitle = $tag->fields["tag"];
	
	$sql = "SELECT * FROM " . $dbprefix . "posts AS p INNER JOIN " . $dbprefix . "posttags AS pt ON p.ID = pt.postid INNER JOIN " . $dbprefix . "tags AS t ON pt.tagid = t.tagid WHERE status > 0 AND postdate <= " . time() . " AND t.tagid = " . $tag->fields["tagid"] . " ORDER BY postdate DESC LIMIT 0, " . intval($config["homeposts"]);
	
} else {

	$pagetitle = "Homepage";
	
	$sql = "SELECT * FROM " . $dbprefix . "posts WHERE status > 0 AND postdate <= " . time() . " ORDER BY postdate DESC LIMIT 0, " . intval($config["homeposts"]);
	
}

// ok, go ahead and draw page
include("includes/page_header.php");

// build an array of tags
$tags = taglist();

// write in the recent blog posts
$recent = $db->execute($sql);
if ($recent->rows < 1){
	$t->set_var("RECENT_POSTS", "There are no recent posts on this blog");
} else {
	$t->set_file("recentposts", "list_posts.tpl");
	do {
		$t->set_var("POST_TITLE", $recent->fields["title"]);
		$t->set_var("POST_DATE", date($config["dateformat"], $recent->fields["postdate"]));
		$t->set_var("POST_BODY", Encode($recent->fields["body"]));
		$t->set_var("POST_LINK", LinkPost($recent->fields["ID"]));
		$t->set_var("POST_USER", GetUsername($recent->fields["author"]));
		$t->set_var("POST_TAGS", displaytags($recent->fields["ID"]));
		$t->parse("RECENT_POSTS", "recentposts", true);
	} while ($recent->fields = mysql_fetch_array($recent->res));
}

// set the pages content
$t->set_file("page_body", "homepage.tpl");
$t->parse("page_all", "page_body", true);

// and page footer
include("includes/page_footer.php");
?>
Return current item: Particle Blogger