<? session_start();  ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	$opendb=new mydb();
	require_once('inc/char_set.php');
function xmlencode($tag){
	$tag = str_replace("&", "&amp;", $tag);
	$tag = str_replace("<", "&lt;", $tag);
	$tag = str_replace(">", "&gt;", $tag);
	$tag = str_replace("'", "&apos;", $tag);
	$tag = str_replace("/", '&quot;', $tag);
	return $tag;
	}
	
function getolddir($content)
{	
	require_once('inc/conn.php');
	$opendb=new mydb();
	require_once('inc/char_set.php');
	$olddir_sql="select * from ls_products where position('ls_admin' IN ".$content.")>0 ";
	$olddir_query=$opendb->query($olddir_sql);
	$olddir_rows=mysql_fetch_assoc($olddir_query); 
	$olddirstr=$olddir_rows[$content];
	$olddir=substr($olddirstr,0,strpos($olddirstr,'ls_admin'));
	$olddir=substr($olddir,strrpos($olddir,'"')+1).'ls_admin';
	
	return($olddir);
}

	$ls=$_POST['ls'];
	$replacedir=$_POST['replacedir'];
	
	$templates = "";
	file_exists("widget/ls_config_template.php")?$templates = $_POST['select2']:$templates = "Templates1";

	
if($_POST['name_']!='' && $_POST['tel_']!='' && $_POST['sub2']!=''){
	//print_r($_POST);
	$png = new Two($_POST['name_'],$_POST['tel_']);
	if(file_exists('company_logo/logo.jpg')){
		$png->setLogo('company_logo/logo.jpg');
	}
	if(file_exists('company_logo/logo.png')){
		$png->setLogo('company_logo/logo.png');
	}
	
	if($_POST['email_']!=''){
		$png->setEmail($_POST['email_']);
	}
	if($_POST['adr_']!=''){
		$png->setAdr($_POST['adr_']);
	}
	if($_POST['url_']!=''){
		$png->setUrl($_POST['url_']);
	}
	$png->show();
	$msg = true;
	//生成xml文件  er.xml 保存二维码数据 转义符号
	
	$name_ = xmlencode($_POST['name_']);
	$tel_ = xmlencode($_POST['tel_']);
	$email_ = xmlencode($_POST['email_']);
	$adr_ = xmlencode($_POST['adr_']);
	$url_ = xmlencode($_POST['url_']);
	
	$text = '<?xml version="1.0"?>
<body>
	<name>'.$name_.'</name>
	<tel>'.$tel_.'</tel>
	<email>'.$email_.'</email>
	<adr>'.$adr_.'</adr>
	<url>'.$url_.'</url>
</body>';
$handle = fopen('code/er.xml','w+');
if($handle){
	//$xml = simplexml_load_string($text);
	fwrite($handle,$text);
	fclose($handle);
}
	
}

if($_POST['text']!='' && $_POST['sub1']!=''){

	$png = new Two();
	if(file_exists('company_logo/logo.jpg')){
		$png->setLogo('company_logo/logo.jpg');
	}
	if(file_exists('company_logo/logo.png')){
		$png->setLogo('company_logo/logo.png');
	}
	$png->show($_POST['text']);
	$msg = true;
	
	//生成xml文件  er.xml 保存二维码数据
	$text = xmlencode($_POST['text']);
	$text = '<?xml version="1.0"?>
<body>
	<content>'.$text.'</content>
</body>';
$handle = fopen('code/er.xml','w+');
if($handle){
	fwrite($handle,$text);
	fclose($handle);
}
}
	if($_POST['del']!=""){
		if(file_exists('code/2.png')){
			unlink('code/2.png');
			$msg_er =  "<script>alert('删除成功')</script>";
		}
	}
//  end


	if ($ls=="modi")
	{
		$languages = "";
		$language = $_POST['language'];  //获取的多选框的值，为一个数组，通过下面的foreach对数据进行操作
		$languages .= count($language);
		if($language != null){
			foreach($language as $employee_id) {
				$languages .= $employee_id;
			}
		}
		$modi_sql=sprintf("update ls_config set companyNameCn=%s, companyName=%s, siteKeywords=%s, siteDescription=%s, address=%s, tel=%s, fax=%s, email=%s, MSN=%s, feedback=%s, ICP=%s, qq=%s, people=%s, feedbackEmail=%s, bottomMenu=%s, website=%s, templates=%s, email2=%s, email3=%s, email4=%s, tel2=%s, tel3=%s, tel4=%s, MSN2=%s, MSN3=%s, MSN4=%s, skype=%s, skype2=%s, skype3=%s, skype4=%s, facebook=%s, twitter=%s, linkedin=%s, google=%s, pinterest=%s, youtube=%s, language=%s, shieldIP=%s",
				GetSQLValueString($_POST['companyNameCn'], "text"),
				GetSQLValueString(str_replace(array("\r\n", "\r", "\n"), "", $_POST['companyName']), "text"),
				GetSQLValueString(str_replace(array("\r\n", "\r", "\n"), "", $_POST['siteKeywords']), "text"),
				GetSQLValueString(str_replace(array("\r\n", "\r", "\n"), "", $_POST['siteDescription']), "text"),
				GetSQLValueString($_POST['address'], "text"),
				GetSQLValueString($_POST['tel'], "text"),
				GetSQLValueString($_POST['fax'], "text"),
				GetSQLValueString($_POST['email'], "text"),
				GetSQLValueString($_POST['MSN'], "text"),
				GetSQLValueString($_POST['feedback'], "text"),
				GetSQLValueString($_POST['ICP'], "text"),
				GetSQLValueString($_POST['qq'], "text"),
				GetSQLValueString($_POST['people'], "text"),
				GetSQLValueString($_POST['feedbackEmail'], "text"),
				GetSQLValueString($_POST['bottomMenu'], "text"),
				GetSQLValueString($_POST['website'], "text"),
				GetSQLValueString($templates, "text"),
				GetSQLValueString($_POST['email2'], "text"),
				GetSQLValueString($_POST['email3'], "text"),
				GetSQLValueString($_POST['email4'], "text"),
				GetSQLValueString($_POST['tel2'], "text"),
				GetSQLValueString($_POST['tel3'], "text"),
				GetSQLValueString($_POST['tel4'], "text"),
				GetSQLValueString($_POST['MSN2'], "text"),
				GetSQLValueString($_POST['MSN3'], "text"),
				GetSQLValueString($_POST['MSN4'], "text"),
				GetSQLValueString($_POST['skype'], "text"),
				GetSQLValueString($_POST['skype2'], "text"),
				GetSQLValueString($_POST['skype3'], "text"),
				GetSQLValueString($_POST['skype4'], "text"),
				GetSQLValueString($_POST['facebook'], "text"),
				GetSQLValueString($_POST['twitter'], "text"),
				GetSQLValueString($_POST['linkedin'], "text"),
				GetSQLValueString($_POST['google'], "text"),
				GetSQLValueString($_POST['pinterest'], "text"),
				GetSQLValueString($_POST['youtube'], "text"),
				GetSQLValueString($languages, "text"),
				GetSQLValueString($_POST['shieldIP'], "text")
				);
		//echo $modi_sql;
		$modi_query=$opendb->query($modi_sql);
		$ls_msg="修改配制操作成功！";
	}
	if($replacedir=="进行目录整理")
	{
		$currentdir=trim($_POST['currentdir']);
		$olddir=trim($_POST['olddir']);
		$replacedir_sql="update  ls_products set productSpecification=replace(productSpecification,'".$olddir."','".$currentdir."'),   cateBrief=replace(cateBrief,'".$olddir."','".$currentdir."'), cateDetail=replace(cateDetail,'".$olddir."','".$currentdir."'), midcateBrief=replace(midcateBrief,'".$olddir."','".$currentdir."'), midcateDetail=replace(midcateDetail,'".$olddir."','".$currentdir."'), subcateBrief=replace(subcateBrief,'".$olddir."','".$currentdir."'), subcateDetail=replace(subcateDetail,'".$olddir."','".$currentdir."') where 1 ";
		$replacedir_query=$opendb->query($replacedir_sql);  //产品表目录整理
		
		$replacedir_sql="update  ls_singlepages set pageText=replace(pageText,'".$olddir."','".$currentdir."') where 1 ";
		$replacedir_query=$opendb->query($replacedir_sql);  //singlepage目录整理
		
		$replacedir_sql="update  ls_article  set articleText =replace(articleText ,'".$olddir."','".$currentdir."') where 1 ";
		$replacedir_query=$opendb->query($replacedir_sql);  //article目录整理
		
		$replacedir_sql="update   ls_news   set newsText =replace(newsText ,'".$olddir."','".$currentdir."') where 1 ";
		$replacedir_query=$opendb->query($replacedir_sql);  //news目录整理
		
		 $ls_msg="已经进行了目录整理操作";
	}
	
	$config_sql="select * from ls_config ";
	$config_query=$opendb->query($config_sql);
	$config_rows=mysql_fetch_assoc($config_query);
	$olddir=getolddir('productSpecification');
	if($olddir=='ls_admin'){$olddir=getolddir('cateBrief');}
	if($olddir=='ls_admin'){$olddir=getolddir('cateDetail');}
	if($olddir=='ls_admin'){$olddir=getolddir('midcateBrief');}
	if($olddir=='ls_admin'){$olddir=getolddir('midcateDetail');}
	if($olddir=='ls_admin'){$olddir=getolddir('subcateBrief');}
	if($olddir=='ls_admin'){$olddir=getolddir('subcateDetail');}
	//echo $olddir;
	$currentdir=dirname($_SERVER['HTTP_REFERER']);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/admin.css" rel="stylesheet" type="text/css">
<link href="css/newui.css" rel="stylesheet" type="text/css">
<SCRIPT type=text/javascript src="js/ls2.js"></SCRIPT>
<style type="text/css"> 
div,ul,li {margin:0;padding:0;}
ul{list-style-type:none;}
#fo li{ width:350px;}
#tul{list-style-type:none;width:240px;background:#D6DFF7;margin-bottom:30px;}
#tul:after{content:".";display:block;clear:both;line-height:0px;height:0;visibility:hidden;}
.tul li { width:50%; height:30px; line-height:30px; text-align:center; color:#0c3d66;background:#e3e6ed; font-size:14px; float:left;  color:#2064ae;cursor: hand;!important;cursor: pointer}
.tul .check { background:white;font-weight: bold; } 
.slist { width:350px; height:170px;margin:auto;}
#cont{
	width:380px;
	height:250px;
	border:1px solid gray;
}
#nei{
	clear:both;
	width:360px;
	height:100px;
	padding:10px;
}
</style> 
<script type="text/javascript" src="code/jquery.min.js"></script>
<script type="text/javascript">
	
	function setInnerHTML(){
		var path1 = document.getElementById("select2").value;
		document.getElementById("img1").innerHTML="<img src='../"+path1+"/"+path1+".jpg' width='400' />";
	}
    
    jQuery(document).ready(function(){
        jQuery('.tul li').click(
                function(){
                        jQuery(this).siblings().removeClass("check");
                        jQuery(this).addClass("check");
                        var tid = "#" + jQuery(this).attr('id') + "_cont";
                        jQuery(tid).siblings().hide();
                        jQuery(tid).show();
                        
                },
                function(){}
        );
});
	
</script>
<script language="javascript"> 
function keypress2() //textarea输入长度处理 
{
var text1=document.getElementById("siteDescription").value;
var text2=document.getElementById("siteKeywords").value;
var text3=document.getElementById("companyName").value;

var len;//记录剩余字符串的长度
var len2;
var len3;
if(text2.length>=244 || text1.length>=267 || text3.length>=114)//textarea控件不能用maxlength属性，就通过这样显示输入字符数了 
{
len=244-(text2.length);
len2=267-(text1.length); 
len3=114-(text3.length); 
} 
else 
{ 
len=244-(text2.length);
len2=267-(text1.length); 
len3=114-(text3.length); 
} 
var show="还可输"+len+"个";
var show2="还可输"+len2+"个"; 
var show3="还可输"+len3+"个"; 
document.getElementById("pinglun").innerText=show;
document.getElementById("pinglun2").innerText=show2;
document.getElementById("pinglun3").innerText=show3;
} 

</script>
</head>
<body>
<? echo $msg_er;?>
<table width="880" border="0" cellpadding="3" cellspacing="1" bgcolor="#6396d6">
	<tr bgcolor="#6396d6">
		<td colspan="4" bgcolor="#6396d6" align="center" height="18"><font color="#FFFFFF"><strong>系统配置</strong></font></td>
	</tr>
	<tr bgcolor="#6396d6">
		<td align="center" bgcolor="#D6DFF7" ><form name="fmconfig" method="post" enctype="multipart/form-data"  action="<?php echo $PHP_SELF;?>">
			<input type="hidden" name="ls" value="modi" />
			<table width="829" style="margin-top:16px;">
				<tr>
					<td colspan="2" align="left">提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
					<td width="402" colspan="2">&nbsp;</td>
				</tr>
				<tr>
			</table>
			<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF" style=" margin-bottom:20px;">
			<tr>
				<td colspan="4" bgcolor="#B9DAFF">&nbsp;</td>
			</tr>
			<tr bgcolor="#f4f4f4" >
				<td colspan="2"><fieldset class="infofield" >
						<legend>基本信息</legend>
						<table width="380" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="100" align="right">公司名称：</td>
								<td width="280"><textarea name="companyNameCn" class="inputareashort"  ><?php echo $config_rows['companyNameCn'];?></textarea></td>
							</tr>
                            <td colspan="2">&nbsp;</td>
							<tr>
								<td align="right">首页标题<br />Title： </td>
								<td><textarea name="companyName" id="companyName" class="inputareashort" onKeyUp="keypress2()" onBlur="keypress2()"><?php echo $config_rows['companyName'];?></textarea></td>
							</tr>
                            <tr>
							  <td colspan="2" align="right" style="padding-right:18px;">最多114个字符，<font color="#FF0000">
				              <label id="pinglun3">还可输114个</label>
							  </font></td>
							</tr>
						</table>
					</fieldset></td>
				<td colspan="2"><fieldset class="infofield"  >
				  <legend><strong>SEO优化</strong></legend>
						<table width="380" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="93" align="right"><br />
									首页关键字<br />
									Keywords：</td>
								<td width="287"><textarea name="siteKeywords" id="siteKeywords" class="inputareashort" onKeyUp="keypress2()" onBlur="keypress2()" ><?php echo $config_rows['siteKeywords'];?></textarea></td>
							</tr>
                            <tr>
							  <td colspan="2" align="right" style="padding-right:18px;" >最多 244个字符，<font color="#FF0000">
				              <label id="pinglun">还可输244个</label>
							  </font></td>
							</tr>
							<tr>
								<td align="right">首页描述<br />
									Description：</td>
								<td><textarea name="siteDescription" id="siteDescription" class="inputareashort" onKeyUp="keypress2()" onBlur="keypress2()" ><?php echo $config_rows['siteDescription'];?></textarea></td>
							</tr>
                            <tr>
							  <td colspan="2" align="right" style="padding-right:18px;" >最多267个字符，<font color="#FF0000">
				              <label id="pinglun2">还可输267个</label>
							  </font></td>
							</tr>
						</table>
					</fieldset></td>
			</tr>
            <script> keypress2();</script>
			<tr bgcolor="#f4f4f4">
				<td colspan="4"><fieldset class="communfield"  >
						<legend>基本联系信息</legend>
						<table width="800" border="0" cellspacing="0" cellpadding="0">
							<!--<tr>
								<td width="160" height="32" align="right">Tel（电话）： </td>
								<td width="240" align="left"><input type="text" value="<?php echo $config_rows['tel'];?>" name="tel" class="ifinfoinputshort"  onblur="writetel(this);"  ></td>
								<td width="160" align="right">Fax（传真）：</td>
								<td width="240"><input type="text" onblur="write2()" value="<?php echo $config_rows['fax'];?>" name="fax" class="ifinfoinputshort" /></td>
							</tr>
							<tr>
								<td align="right" height="32">E-Mail（网站邮箱）：</td>
								<td align="left"><input type="text" id="email" value="<?php echo $config_rows['email'];?>" name="email" class="ifinfoinputshort"   onblur="this.form.feedbackEmail.value==''?this.form.feedbackEmail.value=this.value:''; writeemail(this);"  /></td>
								<td align="right">MSN：</td>
								<td><input type="text" value="<?php echo $config_rows['MSN'];?>" name="MSN" class="ifinfoinputshort"    /></td>
							</tr>-->
							<tr>
								<td width="143" height="32" align="right">E-Mail（反馈表邮箱）：</td>
								<td width="274" align="left"><input type="text" value="<?php echo $config_rows['feedbackEmail'];?>" name="feedbackEmail" class="ifinfoinputshort"    />
							  <td width="44" style="padding-left:10px;">品牌：</td>
								<td width="339" align="left"><input type="text" value="<?php echo $config_rows['bottomMenu'];?>" name="bottomMenu" class="ifinfoinputshort" /> (多品牌用逗号隔开)</td>
                                <tr bgcolor="#f4f4f4">
		<td colspan="4"><div class="lsconeditorarea2" align="right"><input type="submit" value="保存" class="submitbuttonsf4"></div></td>
	</tr>
							<!--<tr>
								<td align="right" height="32">Website（网址）：</td>
								<td align="left"><input type="text" onblur="writeurl(this)" value="<?php echo $config_rows['website'];?>" name="website" class="ifinfoinputshort"    /></td>
								<td align="right">Skype：</td>
								<td><input type="text" onblur="write2()" value="<?php echo $config_rows['skype'];?>" name="skype" class="ifinfoinputshort" /></td>
							</tr>
                            <tr>
								<td align="right" height="32">qq：&nbsp;&nbsp;&nbsp;</td>
								<td align="left"><input type="text"  value="<?php echo $config_rows['qq'];?>" name="qq" class="ifinfoinputshort"    /></td>
								<td align="right">联系人</td>
								<td><input type="text"  value="<?php echo $config_rows['people'];?>" name="people" class="ifinfoinputshort"    /></td>
							</tr>
							<tr>
								<td align="right" height="32">Address（经营地点）： </td>
								<td colspan="3" align="left"><input onblur="writeadr(this)" type="text" value="<?php echo $config_rows['address'];?>" name="address" class="ifinfoinputlong" style="width:97%;"   /></td>
							</tr>
							<tr>
								<td height="32" align="right"><a id=requestimg 
      onclick="javascript:showtable('notmust');" href="javascript:void(0);"><img src="../img/ico-.gif" border="0" 
      id=ico /> 更多联系</a></td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>-->
								
						</table>
						<table width="95%" height="80" border="0" align="right" cellpadding="0" cellspacing="0" id="notmust" style="DISPLAY:none ; " >
							<tr>
								<td width="120" align="right">Tel 2： </td>
								<td width="162" align="left"><input type="text" value="<?php echo $config_rows['tel2'];?>" name="tel2" class="ifinfoinputshort2" /></td>
								<td width="69" align="right">Tel 3： </td>
								<td width="162" align="left"><input type="text" value="<?php echo $config_rows['tel3'];?>" name="tel3" class="ifinfoinputshort2" /></td>
								<td width="70" align="right">Tel 4：</td>
								<td width="187" align="left"><input type="text" value="<?php echo $config_rows['tel4'];?>" name="tel4" class="ifinfoinputshort2" /></td>
							</tr>
							<tr>
								<td align="right">Email 2： </td>
								<td align="left"><input type="text" value="<?php echo $config_rows['email2'];?>" name="email2" class="ifinfoinputshort2" /></td>
								<td align="right">Email 3： </td>
								<td align="left"><input type="text" value="<?php echo $config_rows['email3'];?>" name="email3" class="ifinfoinputshort2" /></td>
								<td align="right">Email 4：</td>
								<td align="left"><input type="text" value="<?php echo $config_rows['email4'];?>" name="email4" class="ifinfoinputshort2" /></td>
							</tr>
							<tr>
								<td align="right">MSN 2： </td>
								<td align="left"><input type="text" value="<?php echo $config_rows['MSN2'];?>" name="MSN2" class="ifinfoinputshort2" /></td>
								<td align="right">MSN 3： </td>
								<td align="left"><input type="text" value="<?php echo $config_rows['MSN3'];?>" name="MSN3" class="ifinfoinputshort2" /></td>
								<td align="right">MSN 4：</td>
								<td align="left"><input type="text" value="<?php echo $config_rows['MSN4'];?>" name="MSN4" class="ifinfoinputshort2" /></td>
							</tr>
							<tr>
								<td align="right">Skype 2： </td>
								<td align="left"><input type="text" value="<?php echo $config_rows['skype2'];?>" name="skype2" class="ifinfoinputshort2" /></td>
								<td align="right">Skype 3： </td>
								<td align="left"><input type="text" value="<?php echo $config_rows['skype3'];?>" name="skype3" class="ifinfoinputshort2" /></td>
								<td align="right">Skype 4：</td>
								<td align="left"><input type="text" value="<?php echo $config_rows['skype4'];?>" name="skype4" class="ifinfoinputshort2" /></td>
							</tr>
						</table>
					</fieldset>
					<br />
					</td>
	</tr>
	<tr bgcolor="#f4f4f4">
	<td colspan="4">
	<?php file_exists("widget/ls_language.php")?include "widget/ls_language.php":"" ?>
	</td>
	</tr>
    <tr bgcolor="#f4f4f4">
	<td colspan="4">
	<?php file_exists("widget/ls_shieldIP.php")?include "widget/ls_shieldIP.php":"" ?>
	</td>
	</tr>
	<tr bgcolor="#f4f4f4">
	<td colspan="4">
	<?php file_exists("widget/ls_config_weibo.php")?include "widget/ls_config_weibo.php":"" ?>
	</td>
	</tr>
	<tr bgcolor="#f4f4f4">
		<td colspan="4"><?php file_exists("widget/ls_config_template.php")?include "widget/ls_config_template.php":"" ?></td>
	</tr>
	<tr bgcolor="#f4f4f4">
		<td colspan="4"><?php file_exists("widget/ls_config_feedback.php")?include "widget/ls_config_feedback.php":""  ?></td>
	</tr>
    <tr bgcolor="#f4f4f4">
		<td colspan="4"><div class="lsconeditorarea2" align="right"><input type="submit" value="保存" class="submitbuttonsf4"></div></td>
	</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
