<?php
	include("connect.php");
	include("admin.config.inc.php");
	include("resize.php");
	include("security.php");
//include("category_function.php");
	include("imgsize.php");
	$type1 = "1";
	$type3 = "3";
	include("pagepermission.php");

	$qrylang = "select * from language";
	$reslang = mysql_query($qrylang);
	$totallang = mysql_num_rows($reslang);

function update_products_Count_Value_For_Categories_Delete($catid)
{
	$qrysel = "select products_count from categories where categoryID='$catid'";
	$ressel = mysql_query($qrysel);
	$totalsel = mysql_affected_rows();
	if($totalsel>0)
	{
		$rowsel = mysql_fetch_object($ressel);
		$totproduct = $rowsel->products_count;
		$totproducts = $totproducts = $totproduct - 1;
		$qryupd = "update categories set products_count=".$totproducts." where categoryID='$catid'";
		mysql_query($qryupd) or die (mysql_error());
	}
}	

function update_products_Count_Value_For_Categories($catid)
	{
		$qrysel = "select products_count from categories where categoryID='$catid'";
		$ressel = mysql_query($qrysel);
		$totalsel = mysql_affected_rows();
		if($totalsel>0)
		{
			$rowsel = mysql_fetch_object($ressel);
			$totproduct = $rowsel->products_count;
			$totproducts = $totproduct + 1;
			$qryupd = "update categories set products_count=".$totproducts." where categoryID='$catid'";
			mysql_query($qryupd) or die (mysql_error());
		}
	}
?>
<?php
Class upload 
{ 
var $upload_name; 
var $upload_tmp_address; 
var $upload_server_name; 
var $upload_filetype ; 
var $file_type; 
var $file_server_address; 
var $image_w=120; //要显示图片的宽 
var $image_h=160; //要显示图片的高 
var $upload_file_size; 
var $upload_must_size= 50000000; //允许上传文件的大小，自己设置 
function upload_file() 
{ 
$this->upload_name = $_FILES["file"]["name"]; //取得上传文件名 
if(empty($this->upload_name)){
return "";
}
$this->upload_filetype = $_FILES["file"]["type"]; 
$this->upload_server_name = date("Y_m_dH_i_s").$this->upload_name; 
$this->upload_tmp_address = $_FILES["file"]["tmp_name"]; //取得临时地址 
$this->file_type = array("image/gif","image/pjpeg","image/png","image/jpg"); //允许上传文件的类型 
$this->upload_file_size = $_FILES["file"]["size"]; //上传文件的大小 
if(in_array($this->upload_filetype,$this->file_type)) 
{ if($this->upload_file_size < $this->upload_must_size) 
	{ 
	$this->file_server_address = "../images/".$this->upload_server_name; 
	move_uploaded_file($this->upload_tmp_address,$this->file_server_address);//从TEMP目录移出 
	return $this->file_server_address; //
	} 
	else 
	{ 
	echo("文件容量太大,请重新选择"); 
echo "<script>javascript:history.back();</script>";
	} 
} 
else 
{ 
echo("不支持此文件类型，请重新选择"); 
echo "<script>javascript:history.back();</script>";
} 

} 

} 
?>

<?
include("gd.inc.php");
		//*** ADD PRODUCT ***//
		if($_POST['flash'])
		{
$dd = new upload; 
$imageurl=$dd->upload_file(); 
$imageurl=str_replace("../images","images",$imageurl);
			$imgurl 	= $imageurl;
			$flashtitle = $_POST['flashtitle'];
			$flashurl 	= $_POST['flashurl'];
			$qryselcat  = "INSERT INTO `flash` (`imgurl` ,`imgname` ,`arcurl` )VALUES ('$imgurl', '$flashtitle', '$flashurl')";
			$resselcat  = mysql_query($qryselcat);
			echo "<script>alert('添加成功')</script>";
 			echo "<script>javascript:window.location.href='addflash.php';</script>";
		} 
		
?>
<HTML>
<HEAD>
<TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=<?=$lng_characset;?>">
<LINK href="main.css" type=text/css rel=stylesheet>
</HEAD>
<BODY bgColor=#ffffff>   
<form name="f1" action='addflash.php' method='POST' enctype="multipart/form-data">
<input type="hidden" name="flash" value="save">
<table width="100%" cellpadding="0" cellSpacing="10">
	<tr>
		<td class="H1">&nbsp;</td>
	</tr>
	<tr>
	  <td>
		  <table cellpadding="1" cellspacing="2">
			<tr>
				<TD class="f-c" align="right"  ><font class="a">*</font>图片标题 :</TD>
				
				<TD ><input type="text" name="flashtitle" size="30" class="solidinput"> </TD>
			</tr>
			  <tr valign="middle">
                <td class="f-c" align="right" valign="middle" width="191">图片链接:</td>
                <td><input name="flashurl" type="text" size="60"></td>
              </tr>
			<tr>
				<td class="f-c"  align="right">上传图片 :</td>
				<td><table>
                  <tr>
                    <td><input name="file" type="file" class="solidinput"  size="35"></td>
                  </tr>
                </table></td>
			</tr>
			<tr>
				<td   align="right">&nbsp;</td>
				<td><table>
                  <tr>
                    <td><input type="submit" value="上传"></td>
                  </tr>
                </table></td>
			</tr>
			
<!--			<tr>
				<td class="f-c" align="right" >Image Description :</td>
				<td ><input type="hidden" class="solidinput" size="50" maxlength="50" name="imagedesc" value=""></td>
			</tr>-->
			
			<!---------THIS PART OF EXTRA FIELD -->
			<!--***********EXTRA FIELD****************-->
			<tr >
				<td colspan="2">&nbsp;</td>
			</tr>
			</table>
			
</td>
	</tr>
</table>
</form>
<br><br>
</BODY>
</HEAD>
</HTML>
