<?php
header("Content-type: text/html; charset=utf-8");
require_once('inc/conn.php');

require_once('inc/constant.php');

require_once('inc/ls_syscode.php');



$opendb = new mydb();

require_once('inc/char_set.php');



$lss = $_GET['ls'];
$idd = $_GET['id'];
$pid = $_GET['pid'];
$yid=$_GET['yid'];
$pls = $_GET['pls'];
if ($lss == 'del') {
	$sql = "select * from ls_propic where ID=$idd";
	$query = $opendb->query($sql);
	$row = mysql_fetch_assoc($query);
	while (is_file($row['picPath']) == TRUE && is_file($row['thumbPicPath']) == true) {
		chmod($row['picPath'], 0666);
		unlink($row['picPath']);
		
		chmod($row['thumbPicPath'], 0666);
		unlink($row['thumbPicPath']);
	}
	$nid = $idd + 1;

	$sql = "select * from ls_propic where ID=$nid";
	$query = $opendb->query($sql);
	$row = mysql_fetch_assoc($query);
	if ($row['num'] != 0) {
		$del_sql = "delete from ls_propic where ID=$idd";
		$query = $opendb->query($del_sql);
		$update = "update ls_propic set num=$row[num] where ID=$nid";
	} else {
		$del_sql = "delete from ls_propic where ID=$idd";
		$query = $opendb->query($del_sql);
	}

	echo "<script>alert('数据更新成功!\\n请刷新本页！');location='modiproducts.php?id=" . $yid . "';</script>";
}
if($pls=='del'){
	$sql = "select * from partimages where ID=$pid";
	$query = $opendb->query($sql);
	$row = mysql_fetch_assoc($query);
	while (is_file($row['partImagesPath']) == TRUE) {
		chmod($row['partImagesPath'], 0666);
		unlink($row['partImagesPath']);
	}
	$nid = $pid + 1;

	$sql = "select * from partimages where ID=$nid";
	$query = $opendb->query($sql);
	$row = mysql_fetch_assoc($query);
	if ($row['num'] != 0) {
		$del_sql = "delete from partimages where id=$pid";
		$query = $opendb->query($del_sql);
		$update = "update partimages set num=$row[num] where ID=$nid";
	} else {
		$del_sql = "delete from partimages where id=$pid";
		$query = $opendb->query($del_sql);
	}

	echo "<script>alert('数据更新成功!\\n请刷新本页！');location='modiproducts.php?id=" . $yid . "';</script>";

}
?>