<?php
session_start();
error_reporting(0);
if(!isset($_SESSION['admin_name'])){exit;}
header("content-type:text/html;charset=utf-8");
date_default_timezone_set("PRC");
include "../sql.php";
$id=$_POST['xg_id2'];
$biaoti=$_POST['biaoti'];
$wangzhi=$_POST['wangzhi'];
$shijian=$_POST['shijian'];
$neirong=$_POST['neirong'];
$jiage=$_POST['jiage'];
$xg_meige=$_POST['xg_meige'];
$xg_image=$_POST['xg_image'];
$xg_geshu=$_POST['xg_geshu'];
$xg_jilian=$_POST['xg_jilian'];
$jieshu=$_POST['jieshu'];
$file_error=$_FILES['tupian']['error'];
$file_name=$_FILES['tupian']['name'];
$file_tmp=$_FILES['tupian']['tmp_name'];
$file_exp=explode(".",$file_name);
$file_new=date("YmdHis",time()).mt_rand().".".array_pop(($file_exp));
$file_new2="../../image/wenzhangimage/".$file_new;
if($file_error==4){
    $sql="update user_renwu set biaoti='{$biaoti}',wangzhi='{$wangzhi}',tiaozhuan='{$shijian}',neirong='{$neirong}',image='{$xg_image}',jiner='{$jiage}',yuer='{$jiage}',meijian='{$xg_meige}',jianshu='{$xg_geshu}',jilian='{$xg_jilian}',jieshu='{$jieshu}',username='admin',time='".time()."' where id='{$id}'";
   if(mysql_query($sql)){
       echo "<script>alert('修改成功！');location='../index.php';</script>";
   }else{
        echo "<script>alert('修改失败！')；history.back();</script>";
   }
}elseif($file_error==0){
    if(move_uploaded_file($file_tmp,$file_new2)){
        $sql="update user_renwu set biaoti='{$biaoti}',wangzhi='{$wangzhi}',tiaozhuan='{$shijian}',neirong='{$neirong}',image='{$file_new}',jiner='{$jiage}',yuer='{$jiage}',jianshu='{$xg_geshu}',jieshu='{$jieshu}',username='admin',time='".time()."' where id='{$id}'";
        if(mysql_query($sql)){
            echo "<script>alert('修改成功！');location='../index.php';</script>";
        }else{
             echo "<script>alert('修改失败！')；history.back();</script>";
        }
   }
}
?>