Location: PHPKode > projects > ArticleSetup > ArticleSetup-v1-1/upload/profile.php
<?php 
include('config.php');
	if ($seourls == 1) {
		include ('paginator-seo.php');
	} else {
		include ('paginator.php');
	}

	//Create site settings variables			
	$sitequery = 'select * from settings;';
	$siteresult = mysql_query($sitequery,$connection) or die(mysql_error());
	$siteinfo = mysql_fetch_array($siteresult);
	$siteurl = $siteinfo['url'];
	
	$author = $_GET['a'];	
	
      if (!is_numeric($author)) {
              header('Location: '.$siteurl); 
         }
        
        else

        {   

//get author info
	$authorquery = "select * from authors where id=".$author;
	$authorresult = mysql_query($authorquery,$connection) or die(mysql_error());
	$authorinfo = mysql_fetch_array($authorresult);
	$authorname = $authorinfo['displayname'];
	$authorbio = $authorinfo['bio'];
	$gravatar = $authorinfo['gravatar'];
	$url = $authorinfo['url'];

	$query = "select SUM(articleviews.views) from articles, articleviews 
			where authorid = ".$author." and articleviews.articleid = articles.id; "; 
	$result = mysql_query($query,$connection) or die(mysql_error());
	$getviews = mysql_fetch_array($result);
	$totalviews = $getviews['SUM(articleviews.views)'];

	$query = "select * from articles where status = 0 and authorid =".$author.";";
	$result = mysql_query($query,$connection) or die(mysql_error());
	$totalarticles = mysql_num_rows($result);
	
//Meta info
	$cathead = 0;
	$metatitle = $authorname."'s Profile - ";
	include('header.php'); 
	include('sidebar.php'); 


// Setup the profile template
	$profiletemp = new Template("templates/".$template."/profile.tpl");
	$profiletemp->set("siteurl", $siteurl);


//for pagination
	$rowsquery = "select * from articles where status=0 and authorid =".$author;
	$rowsresults = mysql_query($rowsquery,$connection) or die(mysql_error());
	$rows_results = mysql_num_rows($rowsresults);
	
	$pages = new Paginator;
	$pages->urlparam = "?a=".$author;
	$pages->items_total = $rows_results;
	$pages->mid_range = 9;
	$pages->paginate();


	if ($pages->items_total) {	
		$query = "select * from articles where status=0 and authorid =".$author." order by date desc ".$pages->limit;
	} else {
		$query = "select * from articles where status=0 and authorid =".$author." order by date desc";
	}
	$results = mysql_query($query,$connection) or die(mysql_error());
	$num_results = 	mysql_num_rows($results);	
	

// 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($results); 
	
		//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
			
	} 

// Setup all template variables for display	
	$profiletemp->set("articlerows", $allrows);
	$profiletemp->set("authorname", $authorname);
	$profiletemp->set("authorlink", $url);
	$profiletemp->set("totalarticles", $totalarticles);
	$profiletemp->set("totalviews", $totalviews);
	$profiletemp->set("gravatar", $gravatar);
	$profiletemp->set("bio", $authorbio);
	
	
//display pagination
		$profiletemp->set("paginationright", '<span style="float:right; margin: 10px 10px 2px 0;">
					<b>Page Navigation: '.$pages->display_pages().'</b></span>');



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

	include('rightsidebar.php');
	include('obinclude.php'); 

}

?>
Return current item: ArticleSetup