Location: PHPKode > scripts > Hot or Not Clone > hotornot/control/managearticles.php
<?
include("../config.php");
include("checksession.php");

function getRatings($id)
{
							$sql1="select * from ratings where postsid=$id";
							$result1=mysql_query($sql1);
							if(!mysql_num_rows($result1))
							{
								$rating="<font class='smallblack'>Not rated yet</font>";
							}
							else
							{
									$sql1="select * from ratings where postsid=$id and rating=0";
									$result1=mysql_query($sql1);
									$negratings=mysql_num_rows($result1);
									$sql1="select * from ratings where postsid=$id and rating=1";
									$result1=mysql_query($sql1);
									$posratings=mysql_num_rows($result1);
									$pos=($posratings/($posratings+$negratings))*5;

									$rating="";
									for($i=0;$i<floor($pos);$i++)
									$rating=$rating."<img src='images/starp.gif'>";
									$numleft=5-$i;
									if(($pos-$i)>=0.5)
									{
									$numleft=$numleft-1;
									$rating=$rating."<img src='images/starm.gif'>";
									}
									for($i=0;$i<$numleft;$i++)
									$rating=$rating."<img src='images/starn.gif'>";
							}
							return $rating;
}

function getCategories($catid,$level)
{
	global $appendstr,$gbcatid;
	{
		$sql="select * from category where categoryid=$catid";
		$result=mysql_query($sql);
		if($obj=mysql_fetch_object($result))
		{
			$sel="";
			if($gbcatid==$catid)$sel=" selected ";
			$appendstr=$appendstr."<option $sel value='$catid'>";
			$spacer="";
			for($i=0;$i<$level;$i++)
			$spacer=$spacer."&nbsp;&nbsp;&nbsp;&nbsp;";
			$appendstr=$appendstr.$spacer.$obj->catname."</option>\n";
		}
	}
	
		$sql="select * from category where parent=$catid";
		$result=mysql_query($sql);
		while($obj=mysql_fetch_object($result))
		{
			$catid=$obj->categoryid;
			getCategories($catid,($level+1));
		}
}

function getCategoryName($catid)
{
		if($catid==0)return "Root Category";
		$sql="select * from category where categoryid=$catid";
		$result=mysql_query($sql);
		if($obj=mysql_fetch_object($result))
		{
			return $obj->catname;
		}
}

if(empty($mode))
{
//view answered questions
$sql="select * from posts where approved='Y'";
}
else
{
	//view unanswered questions
	if($admin_username!="admin")
	{
		header("location:logout.php");
	}
	$sql="select * from posts where approved='N'";
}

if(!empty($catid))
{
	$sql=$sql." and catid=$catid";
	$gbcatid=$catid;
}
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" href="stylesheet.css" type="text/css">

<title>Control Panel</title>

<script language="JavaScript">

function clicklink(id1){
window.document.hidform.id.value=id1
window.document.hidform.submit();
}
function checkifvalid(){
if (window.document.myform.subject.value=="")
{
alert("please enter the Subject");
window.document.myform.catname.focus();
return false;
}
return true;
}
</script>
</head>
<script language="JavaScript">
 <?php
    if(isset($success))
    {
		print("alert('Category Added!');");
	}
    ?>
</script>
</head>

<body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FCFAF7" text="#000000" >
<form name="hidform" action="editarticle.php" method="post">
<input type="hidden" name="id" value="">
</form>
<div align="left"> 
  <table border="0" cellpadding="0" cellspacing="0" width="100%" height="41">
    <tr> 
      <td width="150%" bgcolor="#000000" height="1"></td>
    </tr>
    <tr > 
      <td width="100%" align="left" valign="bottom" bgcolor="#FFFFFF" class="topheader"  > 
        Control Panel </td>
    </tr>
  </table>
</div>

<div align="left"> 
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td width="20%" align="left" valign="top"> 
        <? include("sidelinks.php"); ?>
      </td>
      <td width="80%" valign="top" align="center"><br>
        <br>
        <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="4"> <div align="center">
                <table width="87%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td>     <table width="87%" height="10" border="0" align="center" cellpadding="0" cellspacing="0" >
                        <tr> 
                    <form action="managearticles.php" method="post">
					<input type="hidden" name="mode" value="<? print $mode; ?>"	>
                      <td > <div align="right">Select Category: 
                          <select name="catid" id="catid">
						   <option value="">All</option>
                            <option value="0">Root</option>
                            <? $appendstr=""; getCategories(0,"",0); print $appendstr;?>
                          </select>
                          <input type="submit" name="Submit" value="Filter">
                        </div></td>
                    </form>
                  </tr>
                </table></td>
                  </tr>
                </table>
              </div></td>
          </tr>
          <tr> 
            <td><div align="center"> 
                <table width="87%" height="10" border="0" cellpadding="0" cellspacing="0" class="mytable">
                  <tr> 
                    <td > <div align="center"> 
                        <table width="100%" border="0" align="center" bordercolor="#000080">
                          <tr class="header"> 
                            <td colspan="5">Articles <? if (!empty($mode))print "Unanswered";?></td>
                          </tr>
                          <tr> 
                            <td height="19"><strong><font face="Verdana" size="2">Article 
                              Title</font></strong></td>
                            <td><strong>Category</strong></td>
                            <td height="19"><strong>Ratings</strong></td>
                            <td height="19" colspan="2"><strong><font face="Verdana" size="2">Options</font></strong></td>
							<?
							$result=mysql_query($sql);
							while($obj=mysql_fetch_object($result))
							{
							$lock="";
							if($obj->adminaccess=="Y")$lock="<img src='images/lock.gif'>";
							$id=$obj->postsid;
							$title=$obj->subject;
							$category=getCategoryName($obj->catid);
							
							$sql1="select * from ratings where postsid=$id";
							$result1=mysql_query($sql1);
							if(!mysql_num_rows($result1))
							{
								$rating="Not rated yet";
							}
							else
							{
									$rating=getRatings($id);
							}

							?>
                          <tr> 
                            <td width="23%" height="19"><font face="Verdana" size="2"> 
                              <? print $lock.$title; ?></font></td>
                            <td width="34%"><? print $category;?></td>
                            <td width="19%" height="19"><? print $rating; ?></td>
                            <td width="11%" height="19"><font face="Verdana" size="2"><a href="#" onClick="javascript:clicklink(<? print $obj->postsid; ?>)">Edit</a></font></td>
                            <td width="13%" height="19"><font face="Verdana" size="2"><a href="deletearticle.php?id=<? print $obj->postsid;if(!empty($catid))print "&catid=$catid"; if (!empty($mode))print "&mode=$mode"; ?>">Delete</a></font>
							</td>
							</tr>
							<?
							}
							?>
							</table>
                      </div></td>
                  </tr>
                </table>
              </div></td>
          </tr>
        </table>
      </td>
    </tr>
	
  </table>
</div>
</body>

</html>
<? include("conclose.php"); ?>
Return current item: Hot or Not Clone