Location: PHPKode > projects > ArticleSetup > ArticleSetup-v1-1/upload/index.php
<?php 

$cathead = 0;
$metatitle = $sitetitle;

include('config.php');
include('header.php'); 
include('sidebar.php'); 

	if ($seourls == 1) {
		include ('paginator-seo.php');
	} else {
		include ('paginator.php');
	}

// Setup the home template
	$home = new Template("templates/".$template."/home.tpl");
	$home->set("siteurl", $siteurl);
	$home->set("contenttitle", "Most Recent Articles");
	

	
// Setup pagination controls
	$rowsquery = "select * from articles where status=0";
	$rowsresults = mysql_query($rowsquery,$connection) or die(mysql_error());
	$rows_results = mysql_num_rows($rowsresults);
	
	$pages = new Paginator;
	if ($seourls == 1) {
		$pages->nav = $siteurl;
	} else {
		$pages->urlparam = "?";
	}
	$pages->items_total = $rows_results;
	$pages->mid_range = 9;
	$pages->paginate();

	if ($pages->items_total) {	
		$query = "select * from articles where status=0 order by date desc ".$pages->limit;
	} else {
		$query = "select * from articles where status=0	order by date desc";
	}

	$articleresults = mysql_query($query,$connection) or die(mysql_error());
	$num_results = mysql_num_rows($articleresults);


// BEGIN LOOPING THROUGH ALL ARTICLES

	if ($num_results == 0) { 
		echo "<p>No articles found!</p>";
	
	} else {
		for ($i=0; $i <$num_results; $i++) { 
			$row = mysql_fetch_assoc($articleresults); 
	
		//Get article info	
			$id = $row['id'];
			$authorid = $row['authorid'];
			$date = strtotime($row['date']);
			$artdate = date('m/d/y', $date);
			$categoryid = $row['categoryid'];
			$title = $row['title'];
			if ($seourls == 1) { $scrubtitle = generate_seo_link($title); }
			$body = strip_tags(substr($row['body'], 0, 300));

		//get author info
			$authorquery = "select * from authors where id=".$authorid;
			$authorresult = mysql_query($authorquery,$connection) or die(mysql_error());
			$authorinfo = mysql_fetch_array($authorresult);
			$authorname = $authorinfo['displayname'];
			if ($seourls == 1) { $scrubauthor = generate_seo_link($authorname); }
	
		//get category info
			$catquery = "select * from categories where id=".$categoryid;
			$catresult = mysql_query($catquery,$connection) or die(mysql_error());
			$catinfo = mysql_fetch_array($catresult);
			$categoryname = $catinfo['name'];
			$catparent = $catinfo['parentid'];
			if ($seourls == 1) {  $scrubcatname = generate_seo_link($categoryname); }
		
		// If this article doesn't have a parent, display this:
			if ($catparent == NULL) {
				if ($seourls == 1) { // With SEO URLS
					$displaycat = "<a href=\"".$siteurl."/category/".$categoryid."/"
					.$scrubcatname."/\"><b>".$categoryname."</b></a>";
				} else {
					$displaycat = "<a href=\"".$siteurl."/category.php?id=".$categoryid
					."\"><b>".$categoryname."</b></a>";
				}
			
			} else {
		// if it does have a parent, display this:
				$query = "select * from categories where id=".$catparent;
				$result = mysql_query($query,$connection) or die(mysql_error());
				$info = mysql_fetch_array($result);
				$parentname = $info['name'];
				if ($seourls == 1) { $scrubparent = generate_seo_link($parentname); }
	
				if ($seourls == 1) { // With SEO URLS
					$displaycat = "<a href=\"".$siteurl."/category/".$catparent
					."/".$scrubparent."/\"><b>".$parentname."</b></a> > 
				   <a href=\"".$siteurl."/category/".$categoryid."/".$scrubcatname
				   ."/\"><b>".$categoryname."</b></a>";
				} else {
					$displaycat = "<a href=\"".$siteurl."/category.php?id=".$catparent
					."\"><b>".$parentname."</b></a> > 
				   <a href=\"".$siteurl."/category.php?id=".$categoryid."\"><b>"
				   .$categoryname."</b></a>";
				}
			}
		
		// Display the articles!
			if ($seourls == 1) { // With SEO URLS
				$thisrow = "<h2><a href=\"".$siteurl."/".$id."/".$scrubtitle."/\">".$title."</a></h2>"; 
				$thisrow .= $body;
				$thisrow .= "<div class=\"article-meta\">".$displaycat." | By: <a href=\""
							.$siteurl."/profile/".$authorid."/".$scrubauthor."/\"><b>"
							.$authorname."</b></a> (".$artdate.")</div><br/>";

			} else {
				$thisrow = "<h2><a href=\"".$siteurl."/article.php?id=".$id."\">".$title."</a></h2>"; 
				$thisrow .= $body;
				$thisrow .= "<div class=\"article-meta\">".$displaycat." | 
							By: <a href=\"".$siteurl."/profile.php?a=".$authorid."\"><b>"
							.$authorname."</b></a> (".$artdate.")</div><br/>";
			}
		
		// add this row to the list of current rows
		$allrows .= $thisrow;

		} // closing the article loop
			
	} 


	$home->set("articlerows", $allrows);
	

//display pagination
		$home->set("paginationright", '<span style="float:right; margin: 10px 10px 2px 0;">
					<b>Page Navigation: '.$pages->display_pages().'</b></span>');


// Outputs the homepage template!
	 
	echo $home->output();

	include('rightsidebar.php');
	include('obinclude.php'); 
?>
Return current item: ArticleSetup