<?php
session_start();
require_once "../init.php";
require_once "../authority.inc.php";
$uppath=isset($_REQUEST["upPath"])?$_REQUEST["upPath"]."/":"/ueditor/php/upload/image";   
$formName=isset($_REQUEST["formName"])?$_REQUEST["formName"]:"form";          //回传到上页面编辑框所在Form的Name
$editName=isset($_REQUEST["editName"])?$_REQUEST["editName"]:"pic";  
$OldLogo = $_POST['OldLogo'];
$DelOldLogo = $_POST['DelOldLogo'];

$isindex= $_POST['isindex'];
$IDProduct = $_POST['IDProduct'];
$productid = $_POST['productid'];
$ParentID = $_POST['ClassName'];
$Type = $_POST['Type'];
$ProductName = $_POST['ProductName'];
$title = $_POST['title'];
$keywords =  $_POST['keywords'];
$description	 = $_POST['description'];
$LineType = $_POST['LineType'];
$ActionClass = $_POST['ActionClass'];
$head_css = $_POST['head_css'];
$lang = $_POST['lang'];
$foot_css = $_POST['foot_css'];
$main_css = $_POST['main_css'];
$OldIDProduct = $_POST['OldIDProduct'];
$showindex = $_POST['showindex'];
$product_new_name = $_POST['product_new_name'];
$product_new_info = $_POST['product_new_info'];
$menu_link= $_POST['menu_link'];
if($product_new_name)
{
	foreach($product_new_name as $key => $info)
	{
		$new_info = trim($info);
		if($new_info != null)
		{
			$new_arr[$new_info] = iconv("GBK", "UTF-8", trim($product_new_info[$key]));
		}
	}
}

$product_info = addslashes(json_encode($new_arr));


?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="../lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />

<!--[if IE 6]>
<script type="text/javascript" src="../static/h-ui.admin/js/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>增加产品类别</title>
<LINK href="../share/style.css" rel="stylesheet">
<script src="../share/global.js"></script>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 栏目管理 <span class="c-gray en">&gt;</span> 修改结果 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>

<? include "../share/top.php"?>
<table width="100%" border="0" cellpadding="1" cellspacing="1">
  <tr>
    <td><? include "news_nav.inc.php"?></td>
  </tr>
  <tr>
    <td height="3" bgcolor="#555555"></td>
  </tr>
  <tr>
    <td height="300" valign="top" align="center">
	<?php
	
	
//转换根目录的路径
if(strpos($uppath,"/")==0) {
      $i=0;
      $thpath=$_SERVER["SCRIPT_NAME"];
      $thpath=substr($thpath,1,strlen($thpath));
      while(strripos($thpath,"/")!==false){
          $thpath=substr($thpath,strpos($thpath,"/")+1,strlen($thpath));
          $i=++$i;        
      }

$pp="";
      for($j=0;$j<$i;++$j){
          $pp .="../";
      }

      $uppaths=$pp.substr($uppath,1,strlen($thpath));
}
$filename=date("y-m");
if(is_dir($uppaths."/image/".$filename)!=TRUE) mkdir($uppaths."/image/".$filename,0777);
// if(is_dir($filename."/".$ctime)!=TRUE) mkdir($filename."/".$ctime,0777);

$f = $_FILES['file1'];

$dest = $uppaths."/image/".$filename."/".date("ymd")."_".$f['name'];//设置文件名为日期加上文件名避免重复上传目录



if($f['name']){
$dest1 = $uppath.$filename."/".date("ymd")."_".$f['name'];//设置文件名为日期加上文件名避免重复
}
elseif($DelOldLogo)
{
if($OldLogo){
		  $delpath = "../..$OldLogo";
		  @unlink($delpath);
		  $plus .= "Logo='',";
		  $_POST[Logo]='';
	   }
$dest1="";
}
else
{
$dest1=$OldLogo;
}
$r = move_uploaded_file($f['tmp_name'],$dest);
if($f['size']>0){
  $delpath = "../..$OldLogo";
		  @unlink($delpath);
      echo    "<script>window.opener.document.".$formName.".".$editName.".value='".$dest1."'</script>";
}




 

	if($OldIDProduct>=1) $sql = "update menu set ";


	else
	
	

	$sql = "insert into menu set ";

        $sql .= "menu_link='$menu_link',ParentID='$ParentID',Type='$Type',productid='$productid',";
	$sql .= "ProductName='$ProductName',title='$title',isindex='$isindex',keywords='$keywords',description='$description',";
	$sql .= "head_css='$head_css',pic='$dest1',foot_css='$foot_css',lang='$lang',main_css='$main_css',showindex='$showindex'";
	

	if($OldIDProduct>=1) $sql .= "  where IDProduct='$OldIDProduct'";
	$DB->query($sql);
	//删除序列缓存文件,以便前台访问时重新设置序列缓存文件
	$sfile = "../../serialize/products.cache";
	@unlink($sfile);
	echo "<br><br><br>栏目 $ProductName 保存成功";
	echo "<br><br><br>您必须 <a href='../settings/cache.php?action=clear&actionname=清空缓存'>[清空网站缓存]</a>才能令您刚作的修改生效,请点击这里<a href='../settings/cache.php?action=clear&actionname=清空缓存'>[清空网站缓存]</a>";
	echo "<br><br><br><a href='pro_class.php'>[返回列表]</a>";
	?>
    </td>
  </tr>
</table>
<? 
$DB->close();
include "../share/bottom.php"?>
</body>
</html>
