Location: PHPKode > projects > PHPDug > adm/view_stories.php
<?php
require_once("../includes/config.php");
require_once("../includes/functions/func.global.php");
require_once("../includes/functions/loggincheck.php");
require_once('../includes/lang/admin/lang_'.$config['lang'].'.php');
require_once("class.menu.php");

// Connect to database
db_connect($config);

$obj = new Menu();
$nav = $obj->get_js_menu(0,$config,$lang);

//Pagination Start
if (isset($_GET['pageno'])) 
{
   $pageno = $_GET['pageno'];
}
else 
{
   $pageno = 1;
}

if(isset($_GET['OPER']))
{
	$_POST['OPER'] = $_GET['OPER'];
	$_POST['amount'] = $_GET['amount'];
	$_POST['field'] = $_GET['field'];
	$_POST['id'] = '';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>PHPDug Admin - Search Stories</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="images/style.css">
<SCRIPT LANGUAGE="JavaScript" SRC="menu/JSCookMenu.js"></SCRIPT>
<LINK REL="stylesheet" HREF="menu/themes/Office/theme.css" TYPE="text/css">
<SCRIPT LANGUAGE="JavaScript" SRC="menu/themes/Office/theme.js"></SCRIPT>
<LINK REL="stylesheet" HREF="menu/themes/Office/theme.css" TYPE="text/css">
<SCRIPT LANGUAGE="JavaScript" SRC="menu/themes/Office/theme.js"></SCRIPT>
<script language="JavaScript"><!--
function checkBox(theBox){
  var aBox = theBox.form["list[]"];
  var selAll = false;
  var i;
  for(i=0;i<aBox.length;i++){
    if(aBox[i].checked==false) selAll=true;
  }
  if(theBox.name=="selall"){
    for(i=0;i<aBox.length;i++){
      aBox[i].checked = selAll;
    }
    selAll = !selAll;
  }
  //theBox.form.selall.checked = selAll;
}
function init(){
  var theForm = document.f1;
  var aBox = theForm["list[]"];
  var selAll = false;
  var i;
  for(i=0;i<aBox.length;i++){
    if(aBox[i].checked==false) selAll=true;
    aBox[i].onclick = function(){checkBox(this)};
  }
  //theForm.selall.checked = selAll;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//--></script>
</head>
<body>
<!--Start top-->
<table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="100%" height="42" align="left" background="images/bg_top.gif"><a href="index.php"><img src="images/logo.gif" width="127" height="37" hspace="10" border="0"></a></td>
  </tr>
  <tr>
    <td><img src="images/dot.gif" width="1" height="1" alt=""></td>
  </tr>
</table>
<!--End top-->
<!--Start topmenu-->
<table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#F0F0F0" height="25" style="padding-left:20px;" id="menu"><SCRIPT language="JavaScript" type="text/javascript">
			var myMenu =
				
			// Start the menu
[
<?php echo $nav; ?>
];				

			// Output the menu
			cmDraw ('menu', myMenu, 'hbr', cmThemeOffice, 'ThemeOffice');
			</SCRIPT></td>
  </tr>
  <tr>
    <td bgcolor="#333333"><img src="images/dot.gif" width="1" height="1" alt=""></td>
  </tr>
</table>
<br>

<!--End topmenu-->
<!--Start heading page-->
<table width="850" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td class="heading"><img src="images/icons/icon_search.gif" width="22" height="23" alt="" align="absmiddle" hspace="5">Search Stories</td>
</tr>
<tr>
<td bgcolor="#333333"><img src="images/dot.gif" width="1" height="1" alt=""></td>
</tr>
</table>
<!--End heading page-->
<!--Start form-->
<br>
<table width="850" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #CCCCCC;">
  <tr>
    <td align="center" bgcolor="#F6F6F6" style="padding:15px;"><div align="right">
        <form action="story_delete.php" method="post" name="f1" id="f1">
          <div align="right"> <br>
          </div>
          <table width="99%" border="0" align="center" cellpadding="2" cellspacing="0">
            <tr bgcolor="#FF9900">
              <td width="50" height="30"><div align="center">
                  <input type="checkbox" name="selall" value="checkbox" onClick="checkBox(this)">
              </div></td>
              <td width="200" height="30" class="rowheader">Title</td>
              <td height="30" bgcolor="#FF9900" class="rowheader">Url</td>
			  <td height="30" width="150" bgcolor="#FF9900" class="rowheader">Options</td>
            </tr>
            <tr>
              <td style="padding:0px;" height="1" colspan="4" bgcolor="#000000"><img src="images/dot.gif" height="1"></td>
            </tr>
            <?php
$count = 0;
$counter = 0;

if(isset($_POST['id']))
{
	if(trim($_POST['id']) == '')
	{
		$query = "SELECT 1 FROM ".$config['db']['pre']."stories WHERE ".$_POST['field'].$_POST['OPER']."'".addslashes($_POST['amount'])."'";
	}
	else
	{
		$query = "SELECT 1 FROM ".$config['db']['pre']."stories WHERE story_id='".addslashes($_POST['id'])."'";
	}
}
else
{
	$query = "SELECT 1 FROM ".$config['db']['pre']."stories";
}
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
$lastpage = ceil($numrows/10);
if ($pageno < 1) 
{
	$pageno = 1;
} 
elseif($pageno > $lastpage) 
{
	$pageno = $lastpage;
}
$limit = 'LIMIT '.(($pageno-1)*10) .',10';

if(isset($_POST['id']))
{
	if(trim($_POST['id']) == '')
	{
		$query = "SELECT story_id,story_title,story_url,story_digs FROM ".$config['db']['pre']."stories WHERE ".$_POST['field'].$_POST['OPER']."'".addslashes($_POST['amount'])."' ".$limit;
	}
	else
	{
		$query = "SELECT story_id,story_title,story_url,story_digs FROM ".$config['db']['pre']."stories WHERE story_id='".addslashes($_POST['id'])."' ".$limit;
	}
}
else
{
	$query = "SELECT story_id,story_title,story_url,story_digs FROM ".$config['db']['pre']."stories ORDER BY story_id ASC ".$limit;
}
$query_result = mysql_query($query);
while ($info = @mysql_fetch_array($query_result))
{
	$counter++;
	IF($count == 0)
	{
		$colour = '#F7F7F7';
		$count = 1;
	}
	ELSE
	{
		$colour = '#EFEFEF';
		$count = 0;
	}
?>
            <tr bgcolor="<? echo $colour; ?>">
              <td width="50" height="25" align="center"><input type="hidden" name="titles[]" id="titles[]" value="<?=$info['story_title'];?>">
                  <input type="checkbox" name="list[]" id="list[]" value="<?=$info['story_id'];?>"></td>
              <td height="25" width="200"><span class="title1"><?=substr(stripslashes($info['story_title']),0,40);?></span></td>
              <td height="25"><span class="title1"><a href="<?=$info['story_url'];?>" target="_blank"><?=substr($info['story_url'],0,60);?></a></span></td>
			  <td height="25">
			  <table border="0" cellpadding="0" cellspacing="0"><tr><td>
                <select name="amenu<?=$info['story_id'];?>" id="amenu<?=$info['story_id'];?>" onChange="MM_jumpMenu('parent',this,0)" style="width:145px">
				  <option value=""><?php echo $lang['OPTIONS']; ?></option>
                  <option value="story_edit.php?id=<?=$info['story_id'];?>">View/Edit Story</option>
                  <option value="story_delete.php?id=<?=$info['story_id'];?>">Delete Story</option>
                </select>
</td>
			  </tr>
			  </table>
			  </td>
            </tr>
            <?php
}
?>
            <tr bgcolor="#000000">
              <td style="padding:0px;" height="1" colspan="4"><img src="images/dot.gif" width="1" height="1" alt=""></td>
            </tr>
          </table>
          <div align="left"> <br>
              <table width="99%"  border="0" align="center" cellpadding="2" cellspacing="0">
                <tr>
                  <td width="200" valign="middle"><?php echo $lang['WITHSEL']; ?>&nbsp;<a href="#" onclick="document.f1.action='story_edit.php'; document.f1.submit();"><img src="images/button_edit.gif" width="12" height="13" border="0"></a>
                      <input name="imageField" type="image" src="images/button_empty.gif" width="11" height="13" border="0"></td>
                  <td valign="middle">
<?php
if($numrows==0)
{
	$st=0;
	$en=0;
}
elseif($lastpage==$pageno)
{
	$st=$numrows-$counter+1;
	$en=$numrows;
}
else
{
	$st=((($pageno-1)*10)+1);
	$en=$counter*$pageno;
}
?>
                      <div align="center"><?php echo $lang['SHOWING']; ?> <? echo $st ?>-<? echo $en; ?> <?php echo $lang['OF']; ?> <? echo $numrows; ?> <?php echo $lang['RESULTS']; ?></div></td>
                  <td width="200" valign="middle"><div align="right">
<?php
if(isset($_POST['OPER']))
{
	if ($pageno != 1 AND $numrows!=0) 
	{
	   echo " <a href='".$_SERVER['PHP_SELF']."?id=&OPER=".$_POST['OPER']."&amount=".$_POST['amount']."&field=".$_POST['field']."&pageno=1'>&lt;&lt;</a> ";
	   $prevpage = $pageno-1;
	   echo " <a href='".$_SERVER['PHP_SELF']."?id=&OPER=".$_POST['OPER']."&amount=".$_POST['amount']."&field=".$_POST['field']."&pageno=".$prevpage."'>&lt;</a> ";
	}
	echo " ( Page $pageno of ".$lastpage." ) ";
	
	if ($pageno != $lastpage AND $numrows!=0) 
	{
	   $nextpage = $pageno+1;
	   echo " <a href='".$_SERVER['PHP_SELF']."?id=&OPER=".$_POST['OPER']."&amount=".$_POST['amount']."&field=".$_POST['field']."&pageno=".$nextpage."'>&gt;</a> ";   
	   echo " <a href='".$_SERVER['PHP_SELF']."?id=&OPER=".$_POST['OPER']."&amount=".$_POST['amount']."&field=".$_POST['field']."&pageno=".$lastpage."'>&gt;&gt;</a> ";
	}
}
else
{
	if ($pageno != 1 AND $numrows!=0) 
	{
	   echo " <a href='".$_SERVER['PHP_SELF']."?pageno=1'>&lt;&lt;</a> ";
	   $prevpage = $pageno-1;
	   echo " <a href='".$_SERVER['PHP_SELF']."?pageno=".$prevpage."'>&lt;</a> ";
	}
	echo " ( Page $pageno of ".$lastpage." ) ";
	
	if ($pageno != $lastpage AND $numrows!=0) 
	{
	   $nextpage = $pageno+1;
	   echo " <a href='".$_SERVER['PHP_SELF']."?pageno=".$nextpage."'>&gt;</a> ";   
	   echo " <a href='".$_SERVER['PHP_SELF']."?pageno=".$lastpage."'>&gt;&gt;</a> ";
	}
}
?>
                  </div></td>
                </tr>
              </table>
          </div>
        </form>
    </div></td>
  </tr>
</table>
<!--End form-->
<br><br>
<!--Start bottom-->
<table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#333333"><img src="images/dot.gif" width="1" height="1" alt=""></td>
</tr>
<tr>
<td style="padding:15px;" align="center">
<span class="copyright">Copyright &copy; 2008 <a href="http://www.kubelabs.com/phpdug/" class="copyright" target="_blank">Kubelabs.com</a> All Rights Reserved.</span></td>
</tr>
</table>
<!--End bottom-->
</body>
</html>
Return current item: PHPDug