<?php
    
	if(!$dprotect) die ('Access Denied!');	
        
	switch($link[2]) {
		
		case 'edit':
			if($_POST['action'] == 'edit' && $core->updateAdvert($link[3], $_POST['text'], (isset($_POST['active']) ? 1 : 0) )) {
				header('Location: '.$config['url'].'admin/adverts');
				exit();
			} elseif(!$_POST['action']) {
				$page = $core->advertDetailsForId($link[3]);
				foreach($page as $k => $v) { $_POST[$k] = $v; }
			}
		break;
		
		default:
			is_numeric($link[2]) ? null : $link[2] = 1;
			$smarty->assign('list', $core->searchAdverts($_SESSION['auth']['search']['page'], $link[2], (int)$config['perpage']));
			
	}	
	
?>