Location: PHPKode > projects > ZompLog > admin/category.php
<?php

/* Written by Gerben Schmidt, http://scripts.zomp.nl */
ob_start();

include_once("functions.php");
include('config.php');
include("session.php");
include("header.php");

$user = loadUser($_SESSION['login'],$link,$table_users);
if(!$_SESSION["loggedIn"] || !$user['admin']){ echo "You don't have enough privileges to view this page."; exit; }

checkLoggedIn("yes");


if($_POST["addcat"]){
	
	if(!$_POST[catname]){
		$messages[]="$lang_message006";
	}
	
	
	if(empty($messages)) {
		
		newCat($link,$table_cat);
		
header("Location: category.php?message=6");
ob_end_flush();		
		

	}
}

if($_POST["editcat"]){
	
	if(!$_POST[catname]){
		$messages[]="$lang_message006";
	}
	
	
	if(empty($messages)) {

changeCat($link,$table_cat);

header("Location: category.php?message=7");
ob_end_flush();		


	}
}

if(isset($_POST['sortableListsSubmitted'])) {

	$orderArray = SLLists::getOrderArray($_POST['categoriesListOrder'],'categories');
	foreach($orderArray as $item) {
		$query = "UPDATE $table_cat SET catorder=".$item['order']." WHERE id=".$item['element'];
		$result = mysql_query ($query, $link) or die("Died getting info from db.  Error returned if any: ".mysql_error());
	}
	header("Location: category.php");
	ob_end_flush();
	 }

$user = loadUser($_SESSION['login'],$link,$table_users);

?>

	<script language="JavaScript" 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">&nbsp;</div>
<div class="box"><?php
if(!empty($messages)){
	displayErrors($messages);
}

elseif($_GET[message] && empty($messages)){
displayMessage($_GET[message]);
  }

else{
echo "$lang_reorder_cats \"$lang_reorder\".";
}  
  
?>
</div></div>


<div id="main">	
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">
		<h1><?php echo "$lang_manage_categories"; ?></h1><br />
			<fieldset id="titlediv">
      <legend><?php echo "$lang_new_category"; ?></legend>
          <table width="421" border="0" class="text">
            
            <tr>
              <td width="165"><?php echo "$lang_category_name"; ?></td>
              <td width="246"><input name="catname" type="text" id="catname"></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><input type="submit" name="addcat" value="<?php echo "$lang_submit"; ?>"></td>
            </tr>
          </table>
		  </fieldset>
		  <br />
        </form>
          <form action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">
		  	<fieldset id="titlediv">
      <legend><?php echo "$lang_edit_category"; ?></legend>
            <table width="422" border="0" class="text">
              <tr>
                <td><?php echo "$lang_choose_category"; ?></td>
                <td><select name="catid" style="width: 140px" onChange="MM_jumpMenu('parent',this,0)">
                    <option selected><?php echo "$lang_category"; ?></option>
                    <?php
	  
$cat_array = loadCat($link,$table_cat);
foreach ($cat_array as $mycat){

echo '<option value="category.php?catid='.$mycat["id"].'">'.$mycat["name"];
}

?>
                </select></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td width="165"><?php echo "$lang_edit_category_name"; ?></td>
                <?php
if($_GET[catid]){
$category = loadOnecat($link,$table_cat);
}
?>
                <td width="226"><input name="catname" type="text" value="<?php print($category['name']); ?>"></td>
                <td width="17"><input type="hidden" name="id" value="<?php print($category['id']); ?>"></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><input type="submit" name="editcat" value="<?php echo "$lang_submit"; ?>"></td>
              </tr>
            </table>
			</fieldset>
          </form>
		  <br />
		  		  	<fieldset id="titlediv">
      <legend><?php echo "$lang_delete_category"; ?></legend>
	  <?php if ($cat_array){ ?>

	 <?php } ?>
		  <ul id="categories" class="sortableList">
		  
            <?php
  foreach ($cat_array as $mycat){
?>
  <li id="item_<?php echo "$mycat[id]"; ?>">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="text"><tr>
<td width="96%"><?php echo "$mycat[name]"; ?></td>
<td width="4%"><a href="schredder.php?table=<?php echo "$table_cat"; ?>&id=<?php echo "$mycat[id]"; ?>" onclick="return verify()"><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
			if($cat_array){
			
$sortableLists->printForm($_SERVER['PHP_SELF'], 'POST', $lang_reorder, 'button');

}
		?>	
        
		  </fieldset>
</div>
	
	<?php
$sortableLists->printBottomJS();
?>
	<?php include("footer.php"); ?>
Return current item: ZompLog