<?php
ob_start();
require_once("init.php"); 


$tmpl = new Koobi("templates/".ADMINTHEME."/active/");
$tmpl->assign("theme", ADMINTHEME);
$tmpl->assign("langadmin", $langadmin);
$tmpl->assign("kversion", KVERSION);
$tmpl->assign('uid', UID);
$tmpl->assign('pref', $pref);

if ( !permission('settings')  ) { echo error($langadmin['noperms']); exit; }
switch($_REQUEST['action']){
	
	case "save" :
	if($_POST['active']>=1){
		foreach ($_POST['active'] as $val => $active) {
			$result = new dbc("UPDATE ".PREFIX."_active   set active='$active' WHERE val = '$val'");
		}
	}
	alog("alog_active_edit");
	header("location:active.php");
	break;
	
	case "":
	$items = array();
	$sql = new dbc("SELECT * FROM ".PREFIX."_active  ORDER by val ASC");
	while($row = $sql->fetchrow()){
		$row->name = $langadmin['active_'.$row->val];
		array_push($items,$row);
	}
	$tmpl->assign('items',$items);
	$tmpl->display('active.tpl');
}


?>