<?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 $url) {
$str="/^(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/";  
if (!preg_match($str,$url)){  
}else{
$type="WHERE url='$url'";
$row=queryall(zurl,$type);  
if(!$row){
$type="(`id`, `url`, `cs`, `zt`, `qx`, `shijian`) VALUES (null,'$url','0','正常','未使用','$shijian')"; 
dbinsert(zurl,$type);
}
}
}
$tip=iconv("GB2312","UTF-8","上传成功");
$json_data = array ('status'=>"true",'msg'=>$tip);   
echo json_encode($json_data);
?>
