<?php
/* Written by Gerben Schmidt, http://scripts.zomp.nl */
include_once("functions.php");
include('config.php');
include("session.php");
include("header.php");
if(!$_SESSION["loggedIn"]){ echo "You are not allowed to view this page, please log in first."; exit; }
?>
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<div id="submenu"><a href="newentry.php" class="sub"><?php echo "$lang_newentry"; ?></a> | <a href="entry.php" class="sub"><?php echo "$lang_edit_delete"; ?></a><?php if($user[admin]){ ?> | <a href="comments.php" class="sub"><?php echo "$lang_manage_comments"; ?></a> | <a href="category.php" class="sub"><?php echo "$lang_manage_categories"; ?></a><?php } ?></div>
<div id="side">
<div class="title"> </div>
<div class="box"><?php
if(!empty($messages)){
displayErrors($messages);
}
elseif($_GET[message] && empty($messages)){
displayMessage($_GET[message]);
}
else{
echo "$lang_message004";
}
?>
</div>
<br />
<div class="box">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="text">
<tr valign="top"><td width="22px"><img src="icons/hourglass.png" alt="<?php echo "$lang_not_published"; ?>" title="<?php echo "$lang_not_published"; ?>"width="16" height="16" align="absmiddle" /></td><td><?php echo "$lang_not_published"; ?></td></tr>
<tr valign="top"><td width="22px"><img src="icons/delete.png" alt="<?php echo "$lang_expired"; ?>" title="<?php echo "$lang_expired"; ?>" width="16" height="16" align="absmiddle" /></td><td><?php echo "$lang_expired"; ?></td></tr>
<tr colspan="2"><td> </td></tr>
<tr valign="top"><td width="22px"><img src="icons/pencil.png" alt="<?php echo "$lang_edit"; ?>" title="<?php echo "$lang_edit"; ?>" width="16" height="16" align="absmiddle" /></td><td><?php echo "$lang_edit"; ?></td></tr>
<tr valign="top"><td width="22px"><img src="icons/cross.png" alt="<?php echo "$lang_delete"; ?>" title="<?php echo "$lang_delete"; ?>" width="16" height="16" align="absmiddle" /></td><td><?php echo "$lang_delete"; ?></td></tr>
</table>
</div>
</div>
<div id="main">
<form name="form1" method="post" action="schredder.php">
<input name="table" type="hidden" value="<?php echo "$table"; ?>">
<h1><?php echo "$lang_edit_delete"; ?></h1><br />
<?php
$query = "SELECT * FROM $table WHERE username = '$user[login]' ORDER BY id DESC";
$result = mysql_query ($query, $link) or die("Died getting info from db. Error returned if any: ".mysql_error());
$numrows = mysql_num_rows($result);
$entries = arrayMaker($result,MYSQL_ASSOC);
?>
<fieldset id="titlediv">
<legend><?php echo "$lang_your_entries"; ?></legend>
<div class="text">
<?php
if(!$numrows){ echo "$lang_no_results</div>";}
else
{
?>
<ul class="List">
<?php
foreach($entries as $entry){
$query = "SELECT * FROM $table_cat WHERE id = $entry[catid]";
$result = mysql_query($query,$link);
$cat = mysql_fetch_array($result);
// determine status: not yet published / expired
$rev_datetime = date('YmdHis');
if ($entry[date] > $rev_datetime) {
$status = "<img src='icons/hourglass.png' alt='$lang_not_published' title='$lang_not_published'>";
} else {
if ($entry[expirydate] < $rev_datetime) {
$status = "<img src='icons/delete.png' alt='$lang_expired' title='$lang_expired'>";
} else {
$status = "";
}
}
?>
<li>
<table width="100%" border="0" cellspacing="0" cellpadding="3" class="text">
<tr valign="top">
<td width="3%"><?php echo $status; ?></td>
<td width="4%"><a href="editor.php?id=<?php echo "$entry[id]"; ?>"><img src='icons/pencil.png' border='0' alt="<?php echo "$lang_edit"; ?>" title="<?php echo "$lang_edit"; ?>" ></a></td>
<td width="49%"><?php echo "$entry[title]"; ?></td>
<td width="15%"> </td>
<td width="25%"><?php echo "$cat[name]"; ?></td>
<td width="4%"><a href="schredder.php?table=<?php echo "$table"; ?>&id=<?php echo "$entry[id]"; ?>"><img src='icons/cross.png' border='0' alt="<?php echo "$lang_delete"; ?>" title="<?php echo "$lang_delete"; ?>"></a></td>
</tr>
</table>
</li>
<?php } ?>
</ul>
</div>
<?php } ?>
</fieldset>
<br />
<?php
if($user[admin]){
$query = "SELECT * FROM $table WHERE username != '$_SESSION[login]' ORDER BY id DESC";
$result = mysql_query ($query, $link) or die("Died getting info from db. Error returned if any: ".mysql_error());
$numrows_others = mysql_num_rows($result);
$entries = arrayMaker($result,MYSQL_ASSOC);
?>
<fieldset id="titlediv">
<legend><?php echo "$lang_entries_by_others"; ?></legend>
<div class="text">
<?php if(!$numrows_others){ ?>
<?php echo "$lang_no_results"; ?>
<?php
}
else
{
?>
<ul class="List">
<?php
foreach($entries as $entry){
$query = "SELECT * FROM $table_cat WHERE id = $entry[catid]";
$result = mysql_query($query,$link);
$cat = mysql_fetch_array($result);
// determine status: not yet published / expired
$rev_datetime = date('YmdHis');
if ($entry[date] > $rev_datetime) {
$status = "<img src='icons/hourglass.png' alt='$lang_not_published' title='$lang_not_published'>";
} else {
if ($entry[expirydate] < $rev_datetime) {
$status = "<img src='icons/delete.png' alt='$lang_expired' title='$lang_expired'>";
} else {
$status = "";
}
}
?>
<li>
<table width="100%" border="0" cellspacing="0" cellpadding="3" class="text">
<tr valign="top">
<td width="3%"><?php echo $status; ?></td>
<td width="4%"><a href="editor.php?id=<?php echo $entry[id]; ?>"><img src='icons/pencil.png' border='0' alt="<?php echo "$lang_edit"; ?>" title="<?php echo "$lang_edit"; ?>"></a></td>
<td width="49%"><?php echo "$entry[title]"; ?></td>
<td width="15%"><?php echo "$entry[username]"; ?></td>
<td width="25%"><?php echo "$cat[name]"; ?></td>
<td width="4%"><a href="schredder.php?table=<?php echo $table; ?>&id=<?php echo $entry[id]; ?>"><img src='icons/cross.png' border='0' alt="<?php echo "$lang_delete"; ?>" title="<?php echo "$lang_delete"; ?>"></a></td>
</tr>
</table>
</li>
<?php } ?>
</ul>
<?php }
?>
</div>
</fieldset>
<?php } ?>
</form>
</div>
<?php include("footer.php"); ?>