<?php
ob_start();
session_start();
require('login_user_check.php');
require("../conn.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style></head>
<body>
<?php
if ($_GET['type_action']=='add')
{
$file_info=str_sql($_FILES['file_info']['name']);
$link_value=$_POST['link_value'];
if ($file_info=='') { ?><script language="javascript">alert('请点浏览选择您需要上传的图片!');history.go(-1);</script><?php exit; }
$file_value=substr($file_info,strlen($file_info)-4,4);
if ($file_value=='.jpg' || $file_value=='.JPG' || $file_value=='.gif' || $file_value=='.GIF') {
move_uploaded_file($_FILES['file_info']['tmp_name'],'../upload/'.$_FILES['file_info']['name']);
$rand_number=rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
rename('../upload/'.$_FILES['file_info']['name'],'../upload/'.$rand_number.$_FILES['file_info']['name']);
$id=str_sql($_GET['id']);
$file_web_url='upload/'.$rand_number.$_FILES['file_info']['name'];
$file_update="update ad_info_data set pic_url='$file_web_url',url_info='$link_value' where id='$id'";
mysql_query ($file_update);
?><script language="javascript">location.href='upload_file.php?id=<?=$id?>&file_name=<?=substr($file_web_url,17,strlen($file_web_url))?>&width_value=<?=$_GET['width_value']?>&height_value=<?=$_GET['height_value']?>';</script><?php
} else {
?>
<script language="javascript">alert('对不起，只能上传格式为.gif或.jpg的图片!');history.go(-1);</script>
<?php
exit; }
}
?>
<form action="upload_file.php?type_action=add&id=<?=$_GET['id']?>&width_value=<?=$_GET['width_value']?>&height_value=<?=$_GET['height_value']?>" enctype="multipart/form-data" method="post" style="margin:0px;"><table width="900" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="80" height="50" align="left">广告图片：</td>
    <td width="250" align="left"><input name="file_info" type="file" style="width:230px;height:20px;border:1px #7E99B2 solid;">　
    </td>	
	<td width="620" align="left"><?php
$id=str_sql($_GET['id']);
$file_info_check="select * from ad_info_data where id='$id'";
$rs_file_info=mysql_query ($file_info_check);
$rs_info=mysql_fetch_object($rs_file_info);
?><img src="../<?=$rs_info->pic_url?>" width="<?=$_GET['width_value']?>" height="<?=$_GET['height_value']?>" align="absmiddle">　　<?php if ($_GET['file_name']!='') { ?>文件 <?=$_GET['file_name']?> 上传成功!<?php } ?></td>
</tr>
  <tr>
    <td height="30" align="left">链接网址：</td>
    <td colspan="2" align="left"><input name="link_value" type="text" id="link_value" style="width:400px;" value="<?=$rs_info->url_info?>">      　
      （提示：就是点击广告图片后，出现的页面网址）</td>
  </tr>
  <tr>
    <td height="30" align="left">&nbsp;</td>
    <td colspan="2" align="left"><input type="submit" value="提交" style="width:60px;height:20px;border:1px #7E99B2 solid;"></td>
  </tr>
</table>
</form>
</body>
</html>