<?php 
session_start();
$pagetitle = "Author Control Panel Homepage";
include('../config.php');
include('security.php');
include('header.php');

// A query to get article information 
	$query = "select * from articles where authorid =".$id.";";
	$result = mysql_query($query,$connection) or die(mysql_error());
	$totalarticles = mysql_num_rows($result);
	
	$query = "select * from articles where authorid =".$id." and status=1;";
	$result = mysql_query($query,$connection) or die(mysql_error());
	$reviewarticles = mysql_num_rows($result);

	$query = "select * from articles where authorid =".$id." and status=2;";
	$result = mysql_query($query,$connection) or die(mysql_error());
	$problemarticles = mysql_num_rows($result);

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


<!-- LEFT SIDEBAR -->
<?php include('../sidebar.php'); ?>


<!-- CONTENT AREA -->
<div id="content-full">	

<h1><?php echo $fname; ?>'s Author Dashboard</h1>

<div class="alert"><b>Welcome to your author dashboard!</b><br/> Here you can publish and edit your articles, update your author profile, manage your account settings, and more. </div>

<div style="float: right; width:250px; background: #eee; border: 1px solid #999; padding: 7px; margin: 5px 0; color: #666;">
<b><?php echo $fname; ?>'s Profile (<a href="profile.php">update</a>) &nbsp;</b><br/>
<img style="border:2px solid #999; margin: 6px 6px 8px 0; float: left;" src="<?php echo $gravatar; ?>" />
<?php echo $bio; ?>
<br/>

<div style="clear:both;"></div>

<b>Stats:</b><br/>
Live Articles:<b> <?php echo $totalarticles; ?> </b>(<a href="articles.php">Go</a>)<br/>
Articles in Review:<b> <?php echo $reviewarticles; ?> </b>(<a href="articles.php">Go</a>)<br/>
Problem Articles:<b> <?php echo $problemarticles; ?> </b>(<a href="articles.php">Go</a>)<br/>
Total Article Views:<b> <?php echo $totalviews; ?> &nbsp;</b><br/>
</div>
<br/>
<table width="490px"><tr>
<td><a href="submit.php"><center><img border="0" src="../images/icon_add.png" /><br/><b>Submit an Article</b></center></a></td>
<td><a href="articles.php"><center><img border="0" src="../images/icon_edit.png" /><br/><b>View/Edit Articles</b></center></a></td>
<td><a href="profile.php"><center><img border="0" src="../images/icon_profile.png" /><br/><b>View Your Profile</b></center></a></td></tr>
<tr><td height="25px" colspan="4"></td></tr>
<tr><td><a href="settings.php"><center><img border="0" src="../images/icon_settings.png" /><br/><b> Account Settings</b></center></a></td>
<td><a href="logout.php"><center><img border="0" src="../images/icon_logout.png" /><br/><b>Logout</b></center></a></td>
<td></td></td>
</tr></table>

<div style="clear:both; width: 100%; padding-top: 15px; border-bottom: 3px solid #F3F1E9;"></div>
</div> <!-- End Content -->


<?php include('../footer.php'); ?>