<?php
require_once(dirname(__FILE__)."/"."global.php");
if(!$lfjid){
	die('nologin');
}
$rsdb=$db->get_one("SELECT aid,fid,mid FROM {$pre}article WHERE aid=$aid");
if(!$rsdb){
	die('nodata');
}
unset($picdb);

$img=str_replace("$webdb[www_url]/$webdb[updir]/","",$img);
$query = $db->query("SELECT pid,imgurl FROM `{$pre}article_pic` WHERE id='$aid'");
while($rs = $db->fetch_array($query)){
	//过虑组图中重复的图片
	if(in_array($rs[imgurl],$picdb)){
		$db->query("DELETE FROM `{$pre}article_pic` WHERE pid='$rs[pid]'");
	}else{
		$picdb[]=$rs[imgurl];
	}
}
if(!$picdb){
	$db->query("UPDATE {$pre}article SET picurl='$img' WHERE aid='$aid' ");
}
if(in_array($img,$picdb)){
	die('haveimg');
}else{
	$db->query("INSERT INTO `{$pre}article_pic` ( `id` , `fid` , `mid` , `uid` , `type` , `imgurl`) VALUES ( '$aid', '$rsdb[fid]', '$rsdb[mid]', '$lfjuid', '0', '$img')");
	die('ok');
}
?>