<?php
session_start();
if (empty($_SESSION['namauser']) AND empty($_SESSION['passuser'])){
	header('location:../../404.php');
}else{
include_once '../../../po-library/po-database.php';
include_once '../../../po-library/po-function.php';

$val = new Povalidasi;
$mod=$_POST[mod];
$act=$_POST[act];

// Hapus Category
if ($mod=='category' AND $act=='delete'){
	$id = $val->validasi($_POST['id'],'sql');
	$tabledel = new PoTable('category');
	$tabledel->deleteBy('id_category', $id);
}

// Input Category
elseif ($mod=='category' AND $act=='input'){
$title_id = $val->validasi($_POST['title_id'],'xss');
$title_en = $val->validasi($_POST['title_en'],'xss');
$seotitle_id = seo_title($title_id);
$seotitle_en = seo_title($title_en);
	$table = new PoTable('category');
	$table->save(array(
		'title_id' => $title_id,
		'title_en' => $title_en,
		'seotitle_id' => $seotitle_id,
		'seotitle_en' => $seotitle_en
	));
	header('location:../../admin.php?mod='.$mod);
}

// Edit Category
elseif ($mod=='category' AND $act=='update'){
$id = $val->validasi($_POST['id'],'sql');
$title_id = $val->validasi($_POST['title_id'],'xss');
$title_en = $val->validasi($_POST['title_en'],'xss');
$seotitle_id = seo_title($title_id);
$seotitle_en = seo_title($title_en);
$active =  $val->validasi($_POST['active'],'xss');
	$data = array(
		'title_id' => $title_id,
		'title_en' => $title_en,
		'seotitle_id' => $seotitle_id,
		'seotitle_en' => $seotitle_en,
		'active' => $active
	);
	$table = new PoTable('category');
	$table->updateBy('id_category', $id, $data);
	header('location:../../admin.php?mod='.$mod);
}
}
?>