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

include("template.class.php");
session_start();

//Initial DB Queries
	$query = 'select * from authors ' 
			 ."where username ='".$_SESSION['valid_user']."'";
	$result = mysql_query($query,$connection) or die(mysql_error());
	
	
//Create user data variables		
	$info = mysql_fetch_array($result);
	$id = $info['id'];
	$username = $info['username'];
	$password = $info['password'];
	$fname = htmlspecialchars($info['fname']);
	$lname = htmlspecialchars($info['lname']);
	$email = htmlspecialchars($info['email']);
	$displayname = htmlspecialchars($info['displayname']);
	$bio = htmlspecialchars($info['bio']);
	$avatar = $info['avatar'];
	$mailopt = $info['mailopt']; //0 == checked
	

//Create site settings variables			
	$sitequery = 'select * from settings;';
	$siteresult = mysql_query($sitequery,$connection) or die(mysql_error());
	$siteinfo = mysql_fetch_array($siteresult);
	$sitetitle = $siteinfo['title'];
	$siteurl = $siteinfo['url'];
	$universalid = $siteinfo['universalid'];
	$logo = $siteinfo['logourl'];
	$statcode = $siteinfo['statcode'];
	$template = $siteinfo['template'];
	
	if (is_file('seourls.php')) {
		include ('seourls.php');
		$seourls = 1;
	} else {
		$seourls = 0;
	}

// Needed to control file paths of the templates
	$sidebardir = "";


// Setup this page's template information
	$header = new Template("templates/".$template."/header.tpl");
	$header->set("sitetitle", $sitetitle );
	$header->set("siteurl", $siteurl);
	$header->set("logo", $logo);
	$header->set("metatitle", $metatitle);
	$header->set("thistemp", $template);
	
// Create the logo
	if ($logo) {
		$header->set("sitelogo", '<a href="'.$siteurl.'"> <img border="0" alt="'.$sitetitle.'" src="'.$siteurl.'/admin/images/logo/'.$logo.'" /></a>');
	} else {
		$header->set("sitelogo", '<a href="'.$siteurl.'"><h1 style=\"padding-left: 10px;\">'.$sitetitle.'</h1></a>'); 
	}


// Checks if user is logged in. If so, display custom header
 
	session_start();
	if (isset($_SESSION['valid_user'])) { 
		$header->set("loginarea", 'Welcome, '.$fname.' 
		(<a href="'.$siteurl.'/author/logout.php">Logout</a>)');
	} else { 
		$header->set("loginarea", '<a href="'.$siteurl.'/login.php">Login</a> 
		| <a href="'.$siteurl.'/login.php">Submit Articles</a> 
		| <a href="'.$siteurl.'/login.php">Register</a>');
	}


// Populates the Top Menu list with all pages
	$query = "select * from pages where onmenu=0;"; 
	$result = mysql_query($query,$connection) or die(mysql_error());
	$num_results = mysql_num_rows($result);
	
	if ($num_results == 0) {
		$header->set("topmenuitems", "");
	} else {	
		for ($i=0; $i <$num_results; $i++) { 
			$row = mysql_fetch_assoc($result); 
			if ($seourls == 1) { $scrubtitle = generate_seo_link($row['title']); }
		
			if ($seourls == 1) { // With SEO URLS 
				$headlist = "<li><a href=\"".$siteurl."/page/".$row['id']
						."/".$scrubtitle."/\">".$row['title']."</a></li>";
				$headoutput .= $headlist; 
			} else {
				$headlist = "<li><a href=\"".$siteurl."/page.php?p=".$row['id']."\">".$row['title']."</a></li>";
				$headoutput .= $headlist; 
			}
			$header->set("topmenuitems", $headoutput);
		}	
	}


// Checks if we need to create the category header

	if($cathead == 1) { 
	
		$catheader = new Template("templates/".$template."/cathead.tpl");
		$catheader->set("catheadtitle", $catheadtitle);
	
		$query = "select * from adboxes where id=2;"; 
		$result = mysql_query($query,$connection) or die(mysql_error());
		$info = mysql_fetch_assoc($result);
	
		$catheader->set("468adcode", stripslashes($info['adcode'])); 
		$header->set("catheader", $catheader->output());
	
	} else {
		$header->set("catheader", "");
	}

// Outputs the page template!
	 
	echo $header->output();

?>
Return current item: ArticleSetup