<?php
require_once('include/config.php');
if(!empty($_GET['ajax_del'])){
    $file = $_GET['ajax_del'];
    unlink($file);
    if ( !file_exists($file) )echo '1';
    die;
}
$c = $_GET['url'];
//http
if ( substr($c,0,4) =='http'){
     //判断后缀
     if (!strrpos($c,'.')+0){
        echo '-1';
        die;
     }else{
      $x = substr($c,strrpos($c,'.')+1,4);
       $arr = array('jpg','jpeg','gif','png');
       if ( !in_array($x,$arr) ){
        echo '-1';die;
       }
       //保存在images/upload
       $o = @file_get_contents($c);
       if (!$o){echo '-1';die;}
       $name = time().rand(11111,99999).'.'.$x;
       file_put_contents('./images/upload/'.$name,$o);
        echo $name; 
        
     }

}  else{
    echo '-1';
}