<?php require_once 'header.php'; $controller = new ControllerCategory(); $extras = new Extras(); $category_id = $extras->decryptQuery1(KEY_SALT, $_SERVER['QUERY_STRING']); if ($category_id != null) { $category = $controller->getCategoryByCategoryId($category_id); if (isset($_POST['submit'])) { $itm = new Category(); $itm->category_id = $category_id; $itm->category = trim(strip_tags($_POST['category'])); $itm->created_at = time(); $itm->updated_at = time(); $itm->category_icon = $_POST['category_icon']; $count = count($_FILES["file"]["name"]); if (!empty($_FILES["file"]["name"][0])) { uploadFile($controller, $itm); } else { $controller->updateCategory($itm); echo "<script type='text/javascript'>location.href='categories.php';</script>"; } } } else { echo "<script type='text/javascript'>location.href='403.php';</script>"; } function uploadFile($controller, $itm) { $extras = new Extras(); $desired_dir = Constants::IMAGE_UPLOAD_DIR; $errors = array();
function getCategoryFromCategoryId($category_id) { $controllerCategory = new ControllerCategory(); return $controllerCategory->getCategoryByCategoryId($category_id); }