<h2>Category Management</h2> <p> Adding/Modifying and deleting Categories</p> <form action="<? print $PHP_SELF; ?>" method="post"> <? $sessionToken = $_SESSION["token"]; $functions = $_POST['functions']; if (($action == 1) && ($sessionToken == $formToken)) { $totalAppClass = trim ($totalAppClass, ","); if (is_array($functions)) { $functions = implode (" ", $functions); } $categoryname = str_replace (" ", "_", $categoryname); add_new_category($categoryname, $totalAppClass, $categorydescription, $categorytype, $functions); echo "Category $categoryname added<br>"; $sessionToken = $sessionToken + 1; $_SESSION["token"] = $sessionToken; } elseif (($action == 2) && ($sessionToken == $formToken)) { delete_category($categoryname); echo "Category $categoryname deleted<br>"; $sessionToken = $sessionToken + 1; $_SESSION["token"] = $sessionToken; } elseif (($action == 3) && ($sessionToken == $formToken)) { $totalAppClass = trim ($totalAppClass, ","); if (is_array($functions)) {
$resources->reference = $product_xml->ItemNumber; $resources->price = floatval($product_xml->BasePrice); $resources->wholesale_price = floatval($product_xml->LowestPrice); $category = CategoryCore::searchByName(1, $product_xml->Category); if(!isset($category[0]['id_category'])){ $category_id = add_new_category($product_xml->Category,34); } else{ $category_id = $category[0]['id_category']; } if($product_xml->Category != $product_xml->SubCategory){ $sub_category = CategoryCore::searchByName(1, $product_xml->SubCategory); if(!isset($sub_category[0]['id_category'])){ $sub_category_id = add_new_category($product_xml->SubCategory,$category_id); } else{ $sub_category_id = $sub_category[0]['id_category']; } $resources->associations->categories->addChild('categories')->addChild('id',intval($sub_category_id)); $resources->id_category_default = intval($sub_category_id); } else{ $resources->id_category_default = intval($category_id); } $resources->associations->categories->addChild('categories')->addChild('id',intval($category_id)); $resources->item_number = $product_xml->ItemNumber; $parameter = array("ItemNumber"=>$product_xml->ItemNumber,
<?php $php_root_path = ".."; $privilege_root_path = "/admin"; require_once "includes/include_all_fns.inc"; session_start(); // extract ( $_SESSION , EXTR_REFS ) ; $err_message = " Unable to process your request due to the following problems: <br>\n"; //Code added to address security problem reported by Sebastian Held 14-Nov-2006 $header = "Add Category"; $accepted_privilegeID_arr = array(3 => ""); $accepted_phaseID_arr = array(1 => "", 2 => "", 3 => "", 4 => ""); authentication($header, $accepted_privilegeID_arr, $accepted_phaseID_arr, $homepage, $php_root_path, $GLOBALS["DB_PREFIX"], &$err_message); $catName = $_POST["catName"]; if ($_POST["Submit"] == "Cancel") { header("Location: view_categories.php"); exit; } if (add_new_category($catName)) { header("Location: view_categories.php"); exit; } else { do_html_header("Problem"); echo "Could not insert the category information - please try again later"; do_html_footer(); }