<?php session_start();  //Developed by ITechScripts
require 'include/configurations.php'; // ITECHBIDS Configuration File
require 'include/header.php';
?>

<style type="text/css">
<!--
.style1 {
	color: #666666;
	font-weight: bold;
}
-->
</style>
<html>
<head>
<title>ITECH HYIP::: Admin Area</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table align="center" width="100%" height="35" class="ft" heught=25">
  <tr>
    <td width="12%" align="center"><a href="article.php?type=art" id="link3">View Article</a></td>
    <td width="16%" align="center"><a href="article.php?type=sub" id="link3">Submit Article</a></td>
    <td width="16%" align="center"><a href="article.php?type=fea" id="link3">Featured Articles</a></td>
  </tr>
</table><br>
<?
	$type=$_GET['type'];
	$mode=$_GET['mode'];
	$artid=$_GET['artid'];

//---------------------Suspending or Activating an Article------------------------------
	
	if($mode=='act')
	$sus_query="update article_post set approved=0 where article_id=$artid";
	else if($mode=='in')
	$sus_query="update article_post set approved=1 where article_id=$artid";
	$sus_result=mysql_query($sus_query);
	
//----------------------Suspend or Activating Ends Here----------------------------------


//--------------------- Deleting the Selected Articles------------------------------------

	if(isset($_POST['btn_Delete'])) {
		$artid=$_POST['chkSub'];
		if(strlen($artid)!=0) {
			foreach($artid as $id) {
				$del_query="delete from article_post where article_id=$id";
				$del_res=mysql_query($del_query);
			}
		}
	}	
//----------------------Deleting Ends Here------------------------------------------------
	
	
	
	if(!$type) $type='art';
	if(!$mode) $mode='act';
	if($type=='art') {
		if($mode=='act')
		echo $art_query="select * from article_post where approved=1";
		else if($mode=='in')
		echo $art_query="select * from article_post where approved=0";
		$art_result=mysql_query($art_query);
?>
<table border="0" align="center" width="80%" cellpadding="5" cellspacing="2">
<tr>
<td><a href="article.php?type=art&mode=act" id="tablink">Currently Showing</a></td>
<td><a href="article.php?type=art&mode=in" id="tablink">In-Active</a></td>
</tr>
</table>
<br>
<table border="0" align="center" cellpadding="5" cellspacing="2" width="80%" class="ft">
<form name="frmArticle" method="post" action="<? $_SERVER['PHP_SELF']?>">
<tr class="ct" height="25">
  <td><input type="checkbox" name="chkMain" onClick="chkall();" class="check" value=1></td>
  <td><b>Article Title</b></td><td><b>Posted Date</b></td><td>&nbsp;</td></tr>
<?
	if(mysql_num_rows($art_result)>0) {
	while($art_row=mysql_fetch_array($art_result)){
	$artid=$art_row['article_id'];
?>
<tr bgcolor="#EFEFE7">
  <td><input name="chkSub[]" id="chkSub" type="checkbox" class="check" value="<?php echo $artid;?>"></td>
  <td><a href=article.php?type=dis&artid=<?=$artid?> id=link1><?=$art_row['article_title']?></a></td><td><?=$art_row['posted_date']?></td>
<td><? if($mode=='act') echo "<a href=article.php?type=art&mode=act&artid=$artid id=link1>Suspend</a>";else if($mode=='in') echo "<a href=article.php?type=art&mode=in&artid=$artid id=link1>Activate</a>";?>
</tr>
<?
	}
	}
	else {
?>
<tr bgcolor="#EFEFE7"><td colspan="4" align="center">No Article Found</td></tr>
<?
	}
?>
  <tr><td colspan="10" align="left"><input type="submit" class="button"   value="Delete" name="btn_Delete"  onClick="return condelete();"></td></tr>
</form>
</table>
<?
	}
	else if($type=='sub') {
	}
	else if($type=='fea') {
	}
	else if($type=='com') {
?>
<table border="0" align="center" cellpadding="5" cellspacing="2" width="100%" class="ft">
<tr class="ct" height="25"><td>View Comments</td></tr>
<?
	$view_comment_query="select * from article_comments where article_id=$artid";
	$view_comment_result=mysql_query($view_comment_query);
	if(mysql_num_rows($view_comment_result)>0) {
	while($view_comment_row=mysql_fetch_array($view_comment_result)) {
?>
<tr bgcolor="#EFEFE7"><td><?=$view_comment_row['subject']?></td></tr>
<tr bgcolor="#EFEFE7"><td><?=$view_comment_row['comments']?></td></tr>
<?
	}
	}
	else {
?>
<tr bgcolor="#EFEFE7"><td>No Comments Found for the Article</td></tr>
<?
	}
?>
</table>
<?		
	}
	else if($type=='vcom') {
?><table border="0" align="center" cellpadding="5" cellspacing="2" width="100%" class="ft">
<form name="form1" action="<? $_SERVER['PHP_SELF']?>" method="post" onSubmit="this.canAdd.value=1;">
<tr bgcolor="#EFEFE7" class="ct" height="25"><td colspan="2">Add Comment</td></tr>
<tr bgcolor="#EFEFE7"><td>Your Name</td><td><input type="text" class="bluetext"name="txtName" ></td></tr>
<tr bgcolor="#EFEFE7"><td>Subject </td><td><textarea name=""></textarea></td></tr>
</form>
</table>
<?	}
	else if($type=='dis') {
		$artid=$_GET['artid'];
		$art_query="select * from article_post where article_id=$artid";
		$art_result=mysql_query($art_query);
		$art_row=mysql_fetch_array($art_result);
		$articlename=$art_row['article_title'];
		$articledes=$art_row['article_description'];
		$postedby=$art_row['posted_by'];
		$posteddate=$art_row['posted_date'];
		$postedby=$art_row['posted_by'];
		$approved=$art_row['approved'];
		if($approved==0) $status='In Active';
		else if($approved==1) $status='Active';
?>
<table border="0" align="center" cellpadding="5" cellspacing="2" width="80%" class="ft">
<tr><td width="76%" class="ct" height="25">Viewing Details of <?=$articlename?></td>
  <td width="24%" class="ct" height="25"> <b>Rating:</b> 
                        <?php for ($i=1;$i<=$star;$i++) { ?>
                        <img src="../images/fullstar.gif"> 
                        <?php  } 
  $star2=substr($star,2,1);
  if ($star2>=5) { ?>
                        <img src="../images/halfstar.gif"> 
                        <?php 
  }
  $star1=round($star);?>
                        <?php for ($j=1;$j<=(5-$star1);$j++) { ?>
                        <img src="../images/emptystar.gif"> 
                        <?php } ?>
                      </td>
</tr>
<tr><td colspan="2" bgcolor="EFEFE7">Article Name : <?=$articlename?></td>
  </tr>
<tr><td colspan="2" bgcolor="EFEFE7">Article Description : <?=$articledes?></td>
  </tr>
<tr><td colspan="2" bgcolor="EFEFE7">Posted By : <?=$postedby?></td>
  </tr>
<tr><td colspan="2" bgcolor="EFEFE7">Posted Date : <?=$posteddate?></td>
  </tr>
<tr><td colspan="2" bgcolor="EFEFE7">Status : <?=$status?></td>
  </tr>
<tr>
  <td bgcolor="EFEFE7" colspan="2" align="center"><a href="article.php?type=com&artid=<?=$artid?>" id="link">View Comments</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="article.php?type=vcom&artid=<?=$artid?>" id="link">Add a New Comment</a></td>
</tr>
</table>
<?
	}
	require 'include/footer.php';
?>
</body>
</html>
<script language="javascript">
function chkall() {
	len=document.frmArticle.chkSub.length;
	if(len > 1) {
	for(i=0;i<len;i++) {
		if(document.frmArticle.chkMain.checked==true) {
			document.frmArticle.chkSub[i].checked=true;
		}
		else {
			document.frmArticle.chkSub[i].checked=false;
		}
	}
	}
	else {
		if(document.frmArticle.chkMain.checked==true) {
			document.frmArticle.chkSub.checked=true;
		}
		else {
			document.frmArticle.chkSub.checked=false;
		}
	
	}
	}

function condelete()
{
var confrm;
confrm=window.confirm("Are You sure you want to delete this User");
return confrm;
}
</script>
