<?php
require_once("_config.php");
// ---------------------------------------------------------------------------

$delete = trim($_GET['img']);

// 路径中获取文件名称 去除\ 或 / 
preg_match('/[0-9a-z_]+\.(gif|png|jpe?g)$/i', $delete, $m);
$delete = $m[0];

// 获取文件ip
list($ip2long, $filename) = explode('_', $delete);
if ($ip2long == md5($_SERVER['REMOTE_ADDR'])) {
    $filepath = sprintf("%s/%s", SAVE_DIR, $delete);
    $r = unlink($filepath);
    echo $r ? true : false;
}
else {
    echo false;
}
?>