<?php


include("../include/config.php");
include_once("../include/functions/import.php");
verify_login_admin();
        
		
if($_REQUEST['update'] == "success")
{
	$message = "Administrator Successfully Edited";
	Stemplate::assign('message',$message);
	STemplate::display("administrator/show_message.tpl");
}
        
if($_REQUEST['edit_ad'])
{
	$description = escape($_REQUEST['description']);
	$active = escape($_REQUEST['active']);
	$code = escape($_REQUEST['code']);
	$AID = escape($_REQUEST['AID']);
	
	$query = "update advertisements set
	description = '".mysql_real_escape_string($description)."',
	active = '".mysql_real_escape_string($active)."',
	code = '$code'
	where AID='".mysql_real_escape_string($AID)."'";
	$conn->execute($query);
	header("Location: listadsedit.php?update=success&AID=$AID");
}

if($_REQUEST['AID']!="")
{
$AID = escape($_REQUEST['AID']);
$query = $conn->execute("select * from advertisements where AID='".mysql_real_escape_string($AID)."' limit 1");
$advert = $query->getrows();
Stemplate::assign('advert', $advert[0]);
}

Stemplate::assign('error',$error);
STemplate::display("administrator/listadsedit.tpl");
?>