<?php
ob_start();

$llym = $_SERVER["HTTP_REFERER"];
echo $llym;
session_start(); 
if (empty($_SESSION['name'])){
?>
<script language="javascript">setTimeout(function (){location.href='<?php echo $llym; ?>';},2);</script>
<?
    $_GET['id'] = "";
}

include("sql/conn.php"); 

$result = mysql_query("SELECT * FROM ".$_GET['k']." WHERE id='".$_GET['id']."'");

while($row = mysql_fetch_array($result))
  {
  $bzbzbz = $row['bz'];
  }


/////、、、、、、、、、、、、、、、、、、、///如果是广告主或管理员，那么继续
if ($_SESSION['name'] != $_SESSION['adm'])///////判断如果不是管理员
{
	        if($_SESSION['name'] != $bzbzbz)///////判断如果不是广告主
	        {
	      	$_GET['id'] = "";
			////$_POST['kf'] = "=".$_SESSION['name']."=".$bzbzbz."=";
?>
<script language="javascript">setTimeout(function (){location.href='<?php echo $llym; ?>';},2);</script>
<?
			}
}
/////、、、、、、、、、、、、、、、、、、、///如果是广告主或管理员，那么继续
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<?php

if ($_POST['name']=="" or $_POST['ip']=="" or $_POST['js']=="")
{
	header("Location: my.php");
    $_GET['id'] = "";
}
else
{

include("han.php");///加入符号与数字转换的函数
$ip = strip_tags ($_POST['ip']); 
$ip = f_z($ip);
$js = strip_tags ($_POST['js']); 
$js = f_z($js);

$kf = strip_tags ($_POST['kf'],"<a>"); 
$kf = str_replace("<a","<a target=_blank ",$kf);
$kf = str_replace("<A","<a target=_blank ",$kf);
$kf = str_replace("私服","",$kf);
$kf = str_replace("TTPK","",$kf);

$name = strip_tags ($_POST['name']); 
$name = f_z($name);
$name = str_replace("私服","",$name);
$name = str_replace("TTPK","",$name);

$len = str_replace("私服","",$len);
$len = str_replace("TTPK","",$len);
if($_POST['zt']==""){$_POST['zt']=9;}

mysql_query("UPDATE ".$_GET['k']." SET name = '".$name."' WHERE id = '".$_GET['id']."'");
mysql_query("UPDATE ".$_GET['k']." SET ip = '".$ip."' WHERE id = '".$_GET['id']."'");
mysql_query("UPDATE ".$_GET['k']." SET kf = '".$kf."' WHERE id = '".$_GET['id']."'");
mysql_query("UPDATE ".$_GET['k']." SET js = '".$js."' WHERE id = '".$_GET['id']."'");
mysql_query("UPDATE ".$_GET['k']." SET zt = '".$_POST['zt']."' WHERE id = '".$_GET['id']."'");



if($_POST['time']==""){
mysql_query("UPDATE ".$_GET['k']." SET time = NULL WHERE id = '".$_GET['id']."'");
}


if($_POST['bz']!=""){
mysql_query("UPDATE ".$_GET['k']." SET bz = '".$_POST['bz']."' WHERE id = '".$_GET['id']."'");
}

if($_POST['long1']!=""){
mysql_query("UPDATE ".$_GET['k']." SET long1 = '".$_POST['long1']."' WHERE id = '".$_GET['id']."'");
}

if($_POST['len']!=""){
mysql_query("UPDATE ".$_GET['k']." SET len = '".$_POST['len']."' WHERE id = '".$_GET['id']."'");
}

if($_POST['time']!=""){
mysql_query("UPDATE ".$_GET['k']." SET time = '".$_POST['time']."' WHERE id = '".$_GET['id']."'");
}



$iipp = $_SERVER["REMOTE_ADDR"];
$noww = time();
mysql_query("INSERT INTO text (name, time, ip, ing, f,bz) 
VALUES ('".$bzbzbz."', '".$noww."', '".$iipp."', '修改广告', '0','".$_POST['ps']."')");


?>
<script language="javascript">setTimeout(function (){location.href='<?php echo $llym; ?>';},2);</script>
<?
}


?>