<?php


require_once( "_inc.php" );
$adId = !empty( $_GET['aId'] ) ? intval( $_GET['aId'] ) : "";
$backUrl = !empty( $_GET['back'] ) ? trim( $_GET['back'] ) : "";
if ( empty( $adId ) )
{
	header( "location: ad_list.php" );
	exit( );
}
if ( !empty( $_GET['btnSubmit'] ) )
{
	util::auth( );
	$name = !empty( $_GET['name'] ) ? trim( $_GET['name'] ) : "";
	$code = !empty( $_GET['code'] ) ? trim( $_GET['code'] ) : "";
	if ( empty( $name ) )
	{
		$tpl->assign( "msg", "缺少参数。" );
		$tpl->display( "_msg.tpl" );
		exit( );
	}
	$sql = "UPDATE ".$gDb['prefix'].( "ads SET f_name='".$name."', f_code='{$code}' WHERE (f_id='{$adId}')" );
	$db->query( $sql );
	$tpl->assign( "msg", "保存成功。" );
	$tpl->assign( "backUrl", base64_decode( $backUrl ) );
	$tpl->display( "_msg.tpl" );
	exit( );
}
$tpl->assign( "adId", $adId );
$tpl->assign( "backUrl", $backUrl );
$tpl->display( );
?>
