<?php
session_start();
require_once "../init.php";

$AgentInfo = load_config(1);
$uppath=isset($_REQUEST["upPath"])?$_REQUEST["upPath"]."/":"/uploadimg/";            
$formName=isset($_REQUEST["formName"])?$_REQUEST["formName"]:"form";         
$editName=isset($_REQUEST["editName"])?$_REQUEST["editName"]:"pic";  

$arProType = array();
$proType = new ProductType1();
$tree = $proType->ShowProClassTree('0',0,$arProType);

	$proInfo = $proType->GetProduct1($IDProduct);
	$ParentID = $proInfo['ParentID'];




if($_POST['NewsID'])
{
	$NewsID = $_POST['NewsID'];
}
else
{
	$NewsID = $_GET['NewsID'];
}

if($_POST['key'])
{
	$key = $_POST['key'];
}
else
{
	$key = $_GET['key'];
}
if($_POST['Edit'])
{
	$Edit = $_POST['Edit'];
}
else
{
	$Edit = $_GET['Edit'];
}
$ClassName = $_POST['ClassName'];
$Title = $_POST['Title'];

$showIndex =$_POST['showIndex'];
$Content = $_POST['Content'];
 
if(!CheckHashKey('news'.$NewsID,$key)){
   $DB->close();
   die("非法入侵");
}
if($NewsID != $_SESSION['AdmNewsID_S'])require_once "../authority.inc.php";
$sql = "select * from news where NewsID='$NewsID'";
$NewsInfo = $DB->getdata($sql);
?>
<!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" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<!--[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]-->
<!--/meta 作为公共模版分离出去-->


<title>修改网站语言</title>

 <script type="text/javascript" charset="gbk" src="../ueditor/lang/zh-cn/zh-cn.js"></script>

  <script type="text/javascript" charset="gbk" src="../ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="gbk" src="../ueditor/ueditor.all.min.js"> </script>
<script>
function check(form){
   if(form.Title.value==""){
       alert("请输入语言");
	   form.Title.focus();
	   return false;
   }
   form.Content.value = GetHtml();
   if(form.Content.value==""){
       alert("请输入内容");
	   return false;
   }
   form.submit();
}

</script>
<script src='../share/global.js'></script>
</head>
<body onLoad="init()">



	  <?

	

  if($Edit==1){


$uppath=isset($_REQUEST["upPath"])?$_REQUEST["upPath"]."/":"/uploadimg/";            
$formName=isset($_REQUEST["formName"])?$_REQUEST["formName"]:"form";         
$editName=isset($_REQUEST["editName"])?$_REQUEST["editName"]:"pic"; 
$OldLogo = $_POST['OldLogo'];
$DelOldLogo = $_POST['DelOldLogo'];

//转换根目录的路径
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.$filename)!=TRUE) mkdir($uppaths.$filename,0777);
// if(is_dir($filename."/".$ctime)!=TRUE) mkdir($filename."/".$ctime,0777);

$f = $_FILES['file1'];

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



if($f['name']){
$dest1 = $uppath.$filename."/".date("ymd")."_".$f['name'];//设置文件名为日期加上文件名避免重复
}
elseif($DelOldLogo)
{
	  $delpath = "../..$OldLogo";
		  @unlink($delpath);
$dest1="";
}
else
{
$dest1=$NewsInfo[pic];
}
$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>";
}


		  $sql="update news set Title='$Title',ClassName='$ClassName',Content='".$Content."',showIndex='$showIndex',pic='$dest1' where NewsID='$NewsID'";
		  $DB->query($sql);
		  echo "<center>";
 
		  echo "<br><br><br>修改网站语言 <font color='blue'>$Title</font> 成功";
		  echo "<br><br><br><a href='news_list.php'>[ 返 回 ]</a><br><br>";
	  }else{ 
	  ?>

<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>
      <form action="news_edit.php" method="post"  onSubmit="return check(this)" class="form form-horizontal" id="form-article-add" name="form1" enctype="multipart/form-data">

   <div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>语言标题：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text"  placeholder="" name="Title" value='<?=$NewsInfo[Title]?>'>
			</div>
		</div>


<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>分类栏目：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select name="ClassName" class="select">
				
 <?
			    for($i=0;$i<count($tree);$i++){
					$selected = ($NewsInfo[ClassName]==$tree[$i]['IDProduct'])?"selected":"";
                    echo "<option value='".$tree[$i]['IDProduct']."' $selected>".$tree[$i]['Disp']."</option>";
			    }
			    ?>

	
				</select>
				</span> </div>
		</div>


   <div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>封面：</label>
			<div class="formControls col-xs-8 col-sm-9">
			<input type="hidden" name="upPath" value="<?=$uppath?>">
          <input type="hidden" name="editName" value="<?=$editName?>">
          <input type="hidden" name="formName" value="<?=$formName?>">

			<input  type="file" name="file1"  class="inputline" > (如不修改请不要上传,只能上传图片文件或flash文件)
 <input name="OldLogo" type="hidden" value="<?=$NewsInfo['pic']?>">
		 <input name="DelOldLogo" id="DelOldLogo" type="checkbox" value="1" onchange="this.form.Logo.disabled = this.checked "> <label for='DelOldLogo'><font color='red'> 不需图片(删除)</font></label>
	
		 <? 
		 	if($NewsInfo['pic']){
			 	$src = $NewsInfo['pic'];
		   		if(preg_match("/(.swf)$/i",$NewsInfo['pic'])){
			  		$imagesize = getimagesize($src);
			  		echo "<br><br><embed width=140px height=90px src='$src' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='$imagesize[0]' height='$imagesize[1]'></embed>";
		   		}
				else
				{
			  		echo "<br><br><img width=140px height=90px style='padding:3px;border:1px solid #ccc;' src='$src'>";
		   		}
		 	}
			else
			{
				$src = '';
				//默认模板
				$src = "../../skin/".$AgentInfo['Skin']."/resources/no_pic.png";
				$html = "<br><img src='$src'>";
				echo $html;
			}
		 ?>


	
			</div>
		</div>

  	 <div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否显示：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select name="showIndex" class="select">
					<option value="1"<?=$NewsInfo[showIndex]==1?" selected":""?>>显示</option>
			<option value="0"<?=$NewsInfo[showIndex]==0?" selected":""?>>不显示</option>
				</select>
				</span> </div>
		</div>
	<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">文章内容：</label>
			<div class="formControls col-xs-8 col-sm-9"> 


  <script id="editor" type="text/plain" style="width:100%;height:500px;"  name="Content"><?=$NewsInfo[Content]?></script>

	</div>
		</div>

	<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				
  <input name="Edit" type="hidden" value="1">
				<input name="key" type="hidden" value="<?=$key?>">
				<input name="NewsID" type="hidden" value="<?=$NewsID?>">
<button onClick="article_save_submit();" class="btn btn-primary radius" type="submit" name="submit" ><i class="Hui-iconfont">&#xe632;</i> 保存并提交审核</button>
				<button name="reset" type="reset" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 重 填</button>
				<button onClick=" window.location.href='/admin/news/news_list.php';"  class="btn btn-default radius" type="button">&nbsp;&nbsp;返回列表&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</article>

<script type="text/javascript">
var ue = UE.getEditor('editor');

</script>


	<?}?>




    
	
<br><br>
<? 
$DB->close();
include "../share/bottom.php"?>
</body>
</html>
