<?php
error_reporting(0); 
include("../../config/ht.php");
session_start();
if(!isset($_SESSION['adminname'])){echo "<script>alert('请重新登录!')</script><script>top.location.href='/$htlj/'</script>";exit;}
$adminname=$_SESSION['adminname'];
$type="where name='$adminname'";
$adminpd=queryall(admin,$type);
if(!$adminpd){echo "<script>alert('请重新登录!')</script><script>top.location.href='/$htlj/'</script>";exit;}
if($adminpd[qx]=='超级管理员'){}else{echo "<script>alert('无权限')</script><script>top.location.href='/$htlj/'</script>";exit;}
$tmp = $_FILES['file']['tmp_name'];
$ar = array_map('trim', file($tmp));
foreach($ar as $row) {
if (strpos($row, '$') !== false) {
$p = explode('$',$row); 
$shipinname=$p[0];
$shipinurl=$p[1];
$shipinpic=$p[2];
$fl=$p[3];
}
$zykey=md5($urllist);
$sjmoney='2';
$gdmoney='5';
$type="where name='$shipinname'";
$row=queryall(shipin,$type);
if(!$row){
$type="order by id DESC limit 0,1";
$shipin=queryall(shipin,$type);
if ($shipin['id']==null){
$shipinid="1";
}else{
$shipinid=$shipin['id']+1;
}
$type="(`id`, `money`, `sj`, `cs`, `url`, `name`, `zykey`, `shijian`, `pic`, `flid`) VALUES ('$shipinid','$gdmoney','$sjmoney','0','$shipinurl','$shipinname','$zykey','$shijian','$shipinpic','$fl')"; 
dbinsert(shipin,$type);
$lujing="../../peizhi/xt/".$zykey.".txt";
$neir =$shipinid."|ubo|".'admin'."|ubo|".$sjmoney."|ubo|".$gdmoney."|ubo|"."0";
writefile($lujing,$neir);
$ddhtz2=md5($zykey);
$ddhtz=substr($ddhtz2,0,10);
$longurl='http://'.$url."/wx".random($size)."/".$zykey.$ddhtz.'ubogl';
$long=urlencode($longurl);
$link=dwz($long,$dwzjk);   
$type="(`id`,`name`,`link`,`code`) VALUES (null,'$shipinname','$link','$zykey')"; 
dbinsert(tglink,$type);
}
}
$tip=iconv("GB2312","UTF-8","上传成功");
$json_data = array ('status'=>"true",'msg'=>$tip);   
echo json_encode($json_data);
?>


