<?php
	require_once('_approot.php');
	
	$act=$_POST['Changehtaccess'];
	
	$statistics=$_POST['statistics'];
	$statisticsCodeURL=$_POST['statisticsUrl'];
	$conversion=$_POST['conversion'];
	 
	$onlines=$_POST['onlines'];
	//echo $onlines."==";
	$maps=$_POST['maps'];
	$share=$_POST['share'];
	$indexKeywords=$_POST['indexKeywords'];
	$productsKeywords=$_POST['productsKeywords'];
	$shield=$_POST['shield'];
	$aboutLenght=$_POST['aboutLenght'];
	$indexPassword=$_POST['indexPassword'];
	$htaccess=$_POST['htaccess'];
	$robot=$_POST['robot'];
	$statisticsUrl=$_POST['statisticsUrl'];
	
	$onlinechartUrl=$_POST['onlinechartUrl']; //与 onlinechart 同一个enable
	$onlinechart=$_POST['onlinechart'];
	$mapsAddress=$_POST['mapsAddress'];
	$onlinechartName=$_POST['onlinechartName'];
	$onlinechartPsd=$_POST['onlinechartPsd'];
	
	$code2=$_POST['code2'];
	$reserve1=$_POST['reserve1'];
	$reserve2=$_POST['reserve2'];
	$reserve3=$_POST['reserve3'];
	$ls=$_POST['ls'];
	
	//二维码参数  开始
	$data=$_POST['data'];
	$olddata=$_POST['olddata'];
	$level=$_POST['level'];
	$size=$_POST['size'];
	
	$logo_name=$_FILES['logoFile']['name'];
	$logo_size=$_FILES['logoFile']['size'];
	$logo_type=$_FILES['logoFile']['type'];
	$ChangecatePagePic=$_POST['ChangecatePagePic'];
	$ChangecatePage=$_POST['ChangecatePage'];
	//二维码参数  结束
	$htaccess_path = "../.htaccess";
	$robots_path = "../robots.txt";
	
	//增加重定向
	$oldredirect301=$_POST['oldredirect301']; 
	$add301=$_POST['add301'];
	$redirect301=$_POST['redirect301'];
	$redirectfrom=trim($_POST['redirectfrom']);
	$redirectto=trim($_POST['redirectto']);
	 
	if($redirectfrom!="" && $redirectto !="" && $redirectfrom!="源网址" && $redirectto !="目标网址"){
		if($redirectfrom=="" || redirectto=="" ){
			$ls_msg="增加301跳转时，源网址或者目标网址不能为空 ";
		}else{
			$addstr301 = "RewriteRule ^(".$redirectfrom.")$ https://".$_SERVER['SERVER_NAME']."/".$redirectto." [R=301,NC,L] \r\n";	//RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,NC,L]		
			$redirect301.= strpos($redirect301,$addstr301)===false? $addstr301:"";
		}
	}
	
	//是否启用
	if($_POST['statistics2_enable']!=NULL){$statistics2_enable = 1;}else{$statistics2_enable = 0;}
	if($_POST['conversion_enable']!=NULL){$conversion_enable = 1;}else{$conversion_enable = 0;}
	if($_POST['onlines2_enable']!=NULL){$onlines2_enable = 1;}else{$onlines2_enable = 0;}
	if($_POST['onlinechart_enable']!=NULL){$onlinechart_enable = 1;}else{$onlinechart_enable = 0;}
	if($_POST['onlinechart2_enable']!=NULL){$onlinechart2_enable = 1;}else{$onlinechart2_enable = 0;}
	if($_POST['maps2_enable']!=NULL){$maps2_enable = 1;}else{$maps2_enable = 0;}
	if($_POST['share2_enable']!=NULL){$share2_enable = 1;}else{$share2_enable = 0;}
	if($_POST['indexKeywords2_enable']!=NULL){$indexKeywords2_enable = 1;}else{$indexKeywords2_enable = 0;}
	if($_POST['productsKeywords2_enable']!=NULL){$productsKeywords2_enable = 1;}else{$productsKeywords2_enable = 0;}
	if($_POST['htaccess2_enable']!=NULL){$htaccess2_enable = 1;}else{$htaccess2_enable = 0;}
	if($_POST['robot2_enable']!=NULL){$robot2_enable = 1;}else{$robot2_enable = 0;}
	if($_POST['shield2_enable']!=NULL){$shield2_enable = 1;}else{$shield2_enable = 0;}
	if($_POST['canshu2_enable']!=NULL){$canshu2_enable = 1;}else{$canshu2_enable = 0;}
	if($_POST['basicInfo2_enable']!=NULL){$basicInfo2_enable = 1;}else{$basicInfo2_enable = 0;}
	if($_POST['additionalInfo2_enable']!=NULL){$additionalInfo2_enable = 1;}else{$additionalInfo2_enable = 0;}
	 
	if($_POST['folderchange_enable']!=NULL  ){ $folderchange_enable = 1;}else{$folderchange_enable = 0;}
	if($_POST['redirect3012_enable']!=NULL){$redirect3012_enable = 1;}else{$redirect3012_enable = 0;}
	
	  
	switch($ls)
	{
		case "insert": //确定
			$select_sql="select * from ls_functioncode ";
			$select_query=$opendb->query($select_sql);
			
			writeconstant("folderchange",GetSQLValueString($folderchange_enable, "int"),"int"); //写入writeconstant
			if( $htaccess2_enable==1){ 
				if(file_exists($htaccess_path)){
					if (is_file ($htaccess_path)){ 
						@unlink ($htaccess_path); //若文件已存在，则删除
					}
				}
				
/*				$fp = fopen($htaccess_path,"w");
				fwrite($fp,$htaccess);
				fclose($fp);
*/			}
		 
			if( $robot2_enable==1){ 
				if(file_exists($robots_path)){
					if (is_file ($robots_path)){ 
						@unlink ($robots_path); //若文件已存在，则删除
					}
				}
				$fp = fopen($robots_path,"w");
				fwrite($fp,$robot);
				fclose($fp);
			}
			
			while ($select_rows = mysqli_fetch_assoc($select_query)){
				switch($select_rows['codeID']){
					case "statistics":  //访问统计
						$update_sql=sprintf("update ls_functioncode set code=%s, codeURL=%s, enable=%s where codeID=%s", 
							GetSQLValueString($statistics, "text"),
							GetSQLValueString($statisticsCodeURL, "text"),
							GetSQLValueString($statistics2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "conversion":  //转化
						$update_sql=sprintf("update ls_functioncode set code=%s, codeURL=%s, enable=%s where codeID=%s", 
							GetSQLValueString($conversion, "text"),
							GetSQLValueString($conversionCodeURL, "text"),
							GetSQLValueString($conversion_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "onlines":  //尾部code （onlines）
						$update_sql=sprintf("update ls_functioncode set code=%s, enable=%s where codeID=%s", 
							GetSQLValueString($onlines, "text"),
							GetSQLValueString($onlines2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "onlinechart":  //在线联系代码 （QQ）
						$update_sql=sprintf("update ls_functioncode set code=%s, enable=%s where codeID=%s", 
							GetSQLValueString($onlinechart, "text"),
							GetSQLValueString($onlinechart_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "onlinechartUrl":  //在线客服
						$update_sql=sprintf("update ls_functioncode set code=%s, codeURL=%s, enable=%s where codeID=%s", 
							GetSQLValueString($onlinechartPsd, "text"),
							GetSQLValueString($onlinechartUrl, "text"),
							GetSQLValueString($onlinechart_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "maps":
						$update_sql=sprintf("update ls_functioncode set code=%s, codeURL=%s, enable=%s where codeID=%s", 
							GetSQLValueString($maps, "text"),
							GetSQLValueString($mapsAddress, "text"),
							GetSQLValueString($maps2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "share":
						$update_sql=sprintf("update ls_functioncode set code=%s, enable=%s where codeID=%s", 
							GetSQLValueString($share, "text"),
							GetSQLValueString($share2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "indexKeywords":
						$update_sql=sprintf("update ls_functioncode set code=%s, enable=%s where codeID=%s", 
							GetSQLValueString($indexKeywords, "text"),
							GetSQLValueString($indexKeywords2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "productsKeywords":
						$update_sql=sprintf("update ls_functioncode set code=%s, enable=%s where codeID=%s", 
							GetSQLValueString($productsKeywords, "text"),
							GetSQLValueString($productsKeywords2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "htaccess":
						$update_sql=sprintf("update ls_functioncode set code=%s, enable=%s where codeID=%s", 
							GetSQLValueString($htaccess, "text"),
							GetSQLValueString($htaccess2_enable, "int"), 
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "robot":
						$update_sql=sprintf("update ls_functioncode set code=%s, enable=%s where codeID=%s", 
							GetSQLValueString($robot, "text"),
							GetSQLValueString($robot2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "shield":
						$update_sql=sprintf("update ls_functioncode set code=%s, enable=%s where codeID=%s", 
							GetSQLValueString($shield, "text"),
							GetSQLValueString($shield2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "qrdata":
						$update_sql=sprintf("update ls_functioncode set code=%s where codeID=%s", 
							GetSQLValueString($data, "text"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "aboutLenght":
						$update_sql=sprintf("update ls_functioncode set code=%s where codeID=%s", 
							GetSQLValueString($aboutLenght, "text"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "indexPassword":
						$update_sql=sprintf("update ls_functioncode set code=%s where codeID=%s", 
							GetSQLValueString($indexPassword, "text"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "canshu":
						$update_sql=sprintf("update ls_functioncode set enable=%s where codeID=%s", 
							GetSQLValueString($canshu2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					case "basicInfo":
						$update_sql=sprintf("update ls_functioncode set enable=%s where codeID=%s", 
							GetSQLValueString($basicInfo2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break; 
					case "additionalInfo":
						$update_sql=sprintf("update ls_functioncode set enable=%s where codeID=%s", 
							GetSQLValueString($additionalInfo2_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
					break;
					 
					case "redirect301":
						$update_sql=sprintf("update ls_functioncode set code=%s, enable=%s where codeID=%s", 
							GetSQLValueString($redirect301, "text"),
							GetSQLValueString($redirect3012_enable, "int"),
							GetSQLValueString($select_rows['codeID'], "text")
							);
						$update_query=$opendb->query($update_sql);
						
						if(file_exists($htaccess_path) && $oldredirect301!=$redirect301 ){ //重写 htaccesss
								writeTag($htaccess_path,"#redirect301","#redirect301end","\r\n".$redirect301);
/*
								$fp	   = fopen ($htaccess_path,"r");
								$fileaccess=fread ($fp,filesize ($htaccess_path));
								if(trim($fileaccess)!="")$htaccess =$fileaccess ;
								fclose ($fp);
								$fileaccess =str_replace("RewriteEngine on\r\n".$oldredirect301,"RewriteEngine on\r\n".$redirect301,$fileaccess); //
								$fp = fopen($htaccess_path,"w");
								fwrite($fp,$fileaccess);
								fclose($fp);*/
								
								$ls_msg.="301重定向已更新，.htaccess已更新。";
						}
						
						 
					break;
					 
				}
			}
			
			break;
	}
	
	$select_sql="select * from ls_functioncode ";
	$select_query=$opendb->query($select_sql);
	
	while ($select_rows = mysqli_fetch_assoc($select_query)){
		switch($select_rows['codeID']){
			case "statistics":  //访问统计
				$statistics2 = $select_rows['code'];
				$statisticsCodeURL2 = $select_rows['codeURL'];
				$statistics2_enable = $select_rows['enable'];
			break;
			case "conversion":  //追踪转化
				$conversion = $select_rows['code'];
				$conversionCodeURL = $select_rows['codeURL'];
				$conversion_enable = $select_rows['enable'];
			break;
			case "onlinechart":  //在线联系代码 （QQ）
				$onlinechart = $select_rows['code'];
				$onlinechart_enable = $select_rows['enable'];
			break;
			case "onlines":  //在线联系代（onlines）
				$onlines2 = $select_rows['code'];
				$onlines2_enable = $select_rows['enable'];
			break;
			case "onlinechartUrl":  //在线客服
				$onlinechart=$select_rows['code'];
				$onlinechartUrl2 = $select_rows['codeURL'];
				$onlinechart_enable = $select_rows['enable'];
			break;
			case "maps":  //地图代码
				$maps2=$select_rows['code'];
				$mapsAddress2 = $select_rows['codeURL'];
				$maps2_enable = $select_rows['enable'];
			break;
			case "share":  //社交网站分享 代码
				$share2=$select_rows['code'];
				$share2_enable = $select_rows['enable'];
			break;
			case "indexKeywords":  //首页关键词
				$indexKeywords2=$select_rows['code'];
				$indexKeywords2_enable = $select_rows['enable'];
			break;
			case "productsKeywords":  //产品页关键词
				$productsKeywords2=$select_rows['code'];
				$productsKeywords2_enable = $select_rows['enable'];
			break;
			case "htaccess":  //.htaccess
				$htaccess=$select_rows['code'];
				$htaccess2_enable = $select_rows['enable'];
			break;
			case "robot":  //robots.txt
				$robot=$select_rows['code'];
				$robot2_enable = $select_rows['enable'];
			break;
			case "shield":  //屏蔽代码
				$shield2=$select_rows['code'];
				$shield2_enable = $select_rows['enable'];
			break;
			case "qrdata":  //二维码生成
				$qr_data=$select_rows['code'];
				$qr_data_enable = $select_rows['enable'];
			break;
			case "aboutLenght":  //首页“关于我们”截取长度
				$aboutLenght=$select_rows['code'];
				$aboutLenght_enable = $select_rows['enable'];
			break;
			case "indexPassword":  //访问密码
				$indexPassword=$select_rows['code'];
				$indexPassword_enable = $select_rows['enable'];
			break;
			case "canshu":  //业务信息
				$canshu2_enable = $select_rows['enable'];
			break;
			case "basicInfo":  //基本信息
				$basicInfo2_enable = $select_rows['enable'];
			break;
			case "additionalInfo":  //附加信息
				$additionalInfo2_enable = $select_rows['enable'];
			break;
			case "redirect301":  //访问密码
				$redirect301=$select_rows['code'];
				$redirect3012_enable = $select_rows['enable'];
			break;
 
		}
	}
	$ls_msg.="“确定”将保存以下项目内容，网站生成时，会把“启用”的内容写入相应页面或文件。";

	
function getolddir($content)
{	
	require_once('inc/conn.php');
	$opendb=new mydb();
	$olddir_sql="select * from ls_products where position('ls_admin' IN ".$content.")>0 ";
	$olddir_query=$opendb->query($olddir_sql);
	$olddir_rows=mysqli_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);
}
	$replacedir=trim($_POST['replacedir']);
	if($replacedir=="进行目录整理")
	{
		 file_exists("widget/ls_config_replace.php")?include "widget/ls_config_replace.php":"";
	}
	
	$config_sql="select * from ls_config ";
	$config_query=$opendb->query($config_sql);
	$config_row=mysqli_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']);
	if(file_exists($robots_path)){
		 	$fp	   = fopen ($robots_path,"r");
			$filerobots=fread ($fp,filesize ($robots_path));
			
			if(trim($filerobots)!="")$robot =$filerobots ;
			 
			fclose ($fp);
	}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 rel="stylesheet" href="../themes/default/default.css" />
          <link rel="stylesheet" href="css/style2.css" />
        <script language="JavaScript" src="js/jquery.js"></script>
		<script language="JavaScript" src="js/ls.js"></script>
        <style>button{padding:5px 10px;}</style>
</head>
<body>
		<table width="98%" border="0" align="center" cellpadding="1" cellspacing="1">
            <tr>
				<td height="18" style="border-bottom:2px solid #00c0ef; padding-bottom:5px;"><div align="center"><font color="#3c8dbc" style="font-size:16px;">高级配置</font></div>
				</td>
			</tr>
			<tr>
				<td height="213" align="center" valign="top" ><p>快速导航：<a href="#st">头部代码</a> &nbsp;&nbsp; <a href="#tl">尾部代码</a> &nbsp;&nbsp; <a href="#st">统计转化</a> &nbsp;&nbsp; <a href="#30">301网页跳转</a> &nbsp;&nbsp; <a href="#ro">robot.txt</a>  &nbsp;&nbsp; <a href="#on">在线客服</a> &nbsp;&nbsp; <a href="#mp">地图代码</a> &nbsp;&nbsp; <a href="#sh">社交分享</a> &nbsp;&nbsp; <a href="#sd">屏蔽国内</a> &nbsp;&nbsp; <a href="#qc">二维码</a> &nbsp;&nbsp;&nbsp; <a href="#dr">目录整理</a></p>
				 <form name="newsform" enctype="multipart/form-data" method="post" action="ls_functioncode.php<?="?".$_SERVER["QUERY_STRING"]?>" >
					<input type="hidden" value="insert" name="ls">
                    <input type="hidden" value="<?=$code?>" name="code2">
                    <input type="hidden" name="ChangecatePagePic" value="no">
                    <input type="hidden" name="ChangecatePage" value="no">
                    <input type="hidden" name="Changehtaccess" value="no">
				   <table border="0" width="98%" align="center">
						<tr>
							<td height="39">提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
							<td align="right">&nbsp;</td>
						</tr>
					</table>
					<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#f0f0ee">
                      <tr bgcolor="#f0f0ee">
                        <td width="12%" rowspan="2" align="center">参数选择</td>
                        <td height="53" style="padding-left:30px;" >
                        	首页“关于我们”长度：                       	    
                        	  <input name="aboutLenght" type="text" class="" value="<?php echo $aboutLenght;?>" size="4"  >
                        </td>
                        <td style="padding-left:30px;" >类别管理：
                          <label>
   <?php if($folderchange_enable == 1){ ?><input name="folderchange_enable" type="checkbox" id="folderchange_enable" value="1" checked="checked" /> <?php }else{ ?><input name="folderchange_enable" type="checkbox" id="folderchange_enable" value="0"  /><?php } ?>
 文件夹可改                          </label></td>
                        <td width="9%">&nbsp;</td>
                        <td align="center"><span style="padding-left:10px;">
                          <?php if($ls_local&&!($ifflm)){ ?>
                        </span><span style="padding-left:10px;">
                        <a href="democlear.php" target="_blank">清除全部数据</a>
                        <?php } ?>
                        </span></td>
                      </tr>
                      <tr>
                        <td colspan="3" style="padding-left:30px;"><label>
                          类别/产品属性信息启用：
                          <?php if($canshu2_enable == 1){ ?>
                          <input name="canshu2_enable" type="checkbox" id="canshu2_enable2" value="1" checked="checked" />
                          <?php }else{ ?>
                          <input name="canshu2_enable" type="checkbox" id="canshu2_enable2"  value="0" />
                          <?php } ?>
                        </label>
                          <?=$showprocanshu?> &nbsp;
                          <label>
                            <?php if($basicInfo2_enable == 1){ ?>
                            <input name="basicInfo2_enable" type="checkbox" id="basicInfo2_enable2" value="1" checked="checked" />
                            <?php }else{ ?>
                            <input name="basicInfo2_enable" type="checkbox" id="basicInfo2_enable2"  value="0" />
                            <?php } ?>
                          </label>
                          <?=$showprobasicInfo?>  &nbsp;
                          <label>
                            <?php if($additionalInfo2_enable == 1){ ?>
                            <input name="additionalInfo2_enable" type="checkbox" id="additionalInfo2_enable2" value="1" checked="checked" />
                            <?php }else{ ?>
                            <input name="additionalInfo2_enable" type="checkbox" id="additionalInfo2_enable2"  value="0" />
                            <?php } ?>
                          </label>
                          <?=$showproaddinfo?>  &nbsp; <font color="#CC0000"><a name="st" id="st"></a></font></td>
                        <td align="center" style="padding-right:10px;" ></td>
                      </tr>
					  <tr bgcolor="#f0f0ee">
                      	<td width="12%" rowspan="2" align="center"><p>统计代码<br />
                   	    statistics</p>
                   	    <p>转化追踪<br />
conversion</p></td>
						<td colspan="4" valign="middle"  style="padding-left:30px;">
                        <textarea name="statistics" style="width:75%;height:120px;"><?php echo $statistics2; ?></textarea>
                        启用
                        <label>
                          <?php if($statistics2_enable == 1){ ?><input name="statistics2_enable" type="checkbox" value="1" id="statistics2_enable" checked="checked" /> <?php }else{ ?><input name="statistics2_enable" type="checkbox" id="statistics2_enable"  value="0"  /><?php } ?>
                        </label></td>
					  </tr>
                      
                      <tr bgcolor="#f0f0ee">
                      	<td style="padding-left:30px;" colspan="2" >
                        	访问统计链接 
                        	  <input type="text" value="<?php echo $statisticsCodeURL2?>" name="statisticsUrl" id="statisticsUrl" style="width:70%;" >
                   	    <a name="st" id="hd"></a></td>
                        <td width="9%"><input type="button" onclick="if($('#statisticsUrl').val().length>0)window.open('<?=$statisticsCodeURL2?>')" value="查看统计" /></td>
                        <td width="17%" align="center">&nbsp;</td>
                      </tr>
                      
                        <tr>
                          <td width="12%" rowspan="3" align="center">头部代码<br />
                          head code</td>
                          <td colspan="4" valign="middle"  style="padding-left:30px;">&nbsp;</td>
                        </tr>
                        
						<td colspan="4" valign="middle"  style="padding-left:30px;">
                        <textarea name="conversion" style="width:75%;height:120px;"><?php echo $conversion; ?></textarea>
                        启用
                        <label>
                          <?php if($conversion_enable == 1){ ?><input name="conversion_enable" type="checkbox" value="1" id="conversion_enable" checked="checked" /> <?php }else{ ?><input name="conversion_enable" type="checkbox" id="conversion_enable"  value="0"  /><?php } ?>
                        </label></td>
					  </tr>
                      
                      <tr bgcolor="#f0f0ee">
                      	<td style="padding-left:30px;" colspan="2" ><a name="st" id="tl"></a>
                        	 
                        </td>
                        <td width="9%"> </td>
                        <td width="17%" align="center"><button type="submit" value="确定" />确定</button></td>
                      </tr>
                      
                        <tr bgcolor="#f0f0ee">
                        <td align="center">尾部代码<br />
bottom code</td>
						<td colspan="4"  style="padding-left:30px;"><a name="st" id="ro"></a>
<textarea name="onlines" style="width:75%;height:120px;"><?php echo $onlines2; ?></textarea>
                        启用
                        <label>
                          <?php if($onlines2_enable == 1){ ?><input name="onlines2_enable" type="checkbox" id="onlines2_enable" value="1" checked="checked" /> <?php }else{ ?><input name="onlines2_enable" type="checkbox" id="onlines2_enable" value="0"  /><?php } ?>
                        </label></td>
						</tr>
                        <tr bgcolor="#f0f0ee">
                          <td align="center">&nbsp;</td>
                          <td colspan="4"  style="padding-left:30px;">&nbsp;</td>
                        </tr>
                        <tr bgcolor="#f0f0ee">
                          <td align="center">屏蔽蜘蛛抓取<br />
  robot.txt</td>
                          <td colspan="4"  style="padding-left:30px;"><a name="st" id="30"></a>
                            <textarea name="robot" style="width:75%;height:120px;"><?php echo $robot; ?></textarea>
启用
<label>
  <?php if($robot2_enable == 1){ ?>
  <input name="robot2_enable2" type="checkbox" id="robot2_enable2" value="1" checked="checked" />
  <?php }else{ ?>
  <input name="robot2_enable2" type="checkbox" id="robot2_enable2" value="0"  />
  <?php } ?>
</label></td>
                        </tr>
                        <tr bgcolor="#f0f0ee">
                          <td rowspan="3" align="center">301网页跳转<br />
                          301redirect</td>
                          <td colspan="4"  style="padding-left:30px;">&nbsp;</td>
                        </tr>
                        <tr bgcolor="#f0f0ee">
                          <td colspan="4"  style="padding-left:30px;"><input type="hidden" name="oldredirect301" value="<?=$redirect301?>" />
                            <a name="rd" id="on"></a>
                            <textarea name="redirect301"  id="redirect301" style="width:75%;height:120px;"  <?=$func301readonly?> ><?=$redirect301?></textarea>
                            
启用
  <label>
    <?php if($redirect3012_enable == 1){ ?>
    <input name="redirect3012_enable" type="checkbox" id="redirect3012_enable" value="1" checked="checked" />
    <?php }else{ ?>
    <input name="redirect3012_enable" type="checkbox" id="redirect3012_enable"  value="0" />
    <?php } ?>
    <input type="button" name="add" value="清除" onclick=" if(confirm('确定清除全部重定向内容？') )$('#redirect301').val('');" />
  </label></td>
                        </tr>
                        <tr bgcolor="#f0f0ee">
                          <td colspan="2"  style="padding-left:30px;">从 /
                            <input type="text" value="源网址" name="redirectfrom" id="redirectfrom" style="width:40%;" onclick="if(this.value=='源网址')this.value='';" />
跳转到 -&gt; /
<input type="text" value="目标网址" name="redirectto"  id="redirectto" style="width:40%;"  onclick="if(this.value=='目标网址')this.value='';"/></td>
                          <td  style=""><input type="button" name="add301" value="增加重定向" onclick="if($('#redirectfrom').val().length>0&& $('#redirectfrom').val()!='源网址'&& $('#redirectto').val().length>0&& $('#redirectto').val()!='目标网址')this.form.submit();" /></td>
                          <td  style="padding-left:30px;">&nbsp;</td> 
                        </tr>
                        <tr bgcolor="#f0f0ee">
                          <td width="12%" rowspan="3" align="center">在线客服<br />
                          onlinechart</td>
                          <td colspan="4"  style="padding-left:30px;">
</td>
                        </tr>
                        <tr bgcolor="#f0f0ee">
                          <td colspan="4"  style="padding-left:30px;"> 
					<textarea name="onlinechart" style="width:75%;height:120px;"><?php echo $onlinechart; ?></textarea>
                            启用
                            <label>
                              <?php if($onlinechart_enable == 1){ ?><input name="onlinechart_enable" type="checkbox" id="onlinechart_enable" value="1" checked="checked" /> <?php }else{ ?><input name="onlinechart_enable" type="checkbox" id="onlinechart_enable"  value="0" /><?php } ?>
                          </label></td>
                        </tr>
                          <tr bgcolor="#f0f0ee">
                            <td style="padding-left:30px;" colspan="2" >
                                <a name="st" id="mp"></a>登录链接
<input type="text" value="<?php echo $onlinechartUrl2;?>" name="onlinechartUrl" id="onlinechartUrl" style="width:70%;" /></td>
                            <td width="9%"><input type="button" onclick="if($('#onlinechartUrl').val().length>0)window.open('<?=$onlinechartUrl2?>')" value="登录客服" /></td>
                            <td width="17%" align="center"><button type="submit" value="确定" />确定</button></td>
                          </tr>
                          <?php
						  if($mapsAddress2 != NULL){
						  	$mapsAddressArray = explode(",", str_replace(' ', '', $mapsAddress2));
						  }
						   ?>
                         <tr bgcolor="#f0f0ee">
                           <td width="12%" rowspan="3" align="center">地图代码<br />
                           mapsAddress</td>
                            <td colspan="4"  style="padding-left:30px;">&nbsp;</td>
                      </tr>
                         <tr bgcolor="#f0f0ee">
                          <td colspan="4"  style="padding-left:30px;"><textarea name="maps" id="maps" style="width:75%;height:120px;"><?php $maps2; ?></textarea>
                        启用
                        <label>
                          <?php if($maps2_enable == 1){ ?><input name="maps2_enable" type="checkbox" id="maps2_enable" value="1" checked="checked" /> <?php }else{ ?><input name="maps2_enable" type="checkbox" id="maps2_enable"  value="0" /><?php } ?>
                        </label></td>
                        </tr>
                          <tr bgcolor="#f0f0ee">
                            <td style="padding-left:30px;" colspan="2" >
                            <a name="st" id="sh"></a>标注地址
                            <input type="text" value="<?php echo $mapsAddress2;?>" name="mapsAddress" id="mapsAddress" style="width:70%;" > &nbsp;</td>
                            <td   ><input type="button" value="生成代码" onclick="
                            if($('#mapsAddress').val().length>0){
						$('#maps').val('&lt;script type=&quot;text/javascript&quot; src=&quot;http://maps.google.cn/maps/api/js?sensor=false&amp;language=en&quot;&gt;&lt;/script&gt;   &lt;script type=&quot;text/javascript&quot;&gt;   var geocoder;   var map;   function initialize() {   geocoder = new google.maps.Geocoder();   var myOptions = { \n  zoom : 8,  \n mapTypeId : google.maps.MapTypeId.ROADMAP  \n } \n  map = new google.maps.Map(document.getElementById(&quot;map_canvas&quot;),  \n myOptions); \n  codeAddress(); \n } \n function codeAddress() {   var address = &quot;<?=$mapsAddress2;?>&quot;;   geocoder.geocode({   &quot;address&quot; : address   }, function(results, status) {   if (status == google.maps.GeocoderStatus.OK) {   map.setCenter(results[0].geometry.location);   var marker = new google.maps.Marker({   map : map,   position : results[0].geometry.location,   title : address,   animation : google.maps.Animation.DROP   });   var display = &quot;Address: &quot; + results[0].formatted_address;  var infowindow = new google.maps.InfoWindow({   content : &quot;&lt;span style=font-size:11px &gt;&lt;b&gt;Name: &lt;/b&gt;&quot;   + address + &quot;&lt;br&gt;&quot; + display + &quot;&lt;/span&gt;&quot;,   pixelOffset : 0,   position : results[0].geometry.location     });   infowindow.open(map, marker);   google.maps.event.addListener(marker, &quot;click&quot;, function() {   infowindow.open(map, marker);   });   } else {   alert(&quot;Geocode was not successful for the following reason: &quot; + status);   }   });   }   &lt;/script&gt;  &lt;div id=&quot;map_canvas&quot; style=&quot;width: 100%; height: 600px;&quot;&gt;&lt;/div&gt; &lt;script&gt;initialize()&lt;/script&gt;');
                        }else{
                        alert('地图地址不能为空！');
                        }"/></td>
                            <td width="17%" align="center"></td>
                          </tr>
                        <tr bgcolor="#f0f0ee">
                            <td align="center">&nbsp;</td>
                            <td colspan="4"  style="padding-left:30px;">&nbsp;</td>
                      <tr bgcolor="#f0f0ee"> 
                        <td align="center">社交分享<br />
                        share2</td>
						<td colspan="4"  style="padding-left:30px;">
                        <a name="st" id="sd"></a>
                        <textarea name="share" style="width:75%;height:120px;"><?php echo $share2; ?></textarea>
                        启用
                        <label>
                          <?php if($share2_enable == 1){ ?><input name="share2_enable" type="checkbox" id="share2_enable" value="1" checked="checked" /> <?php }else{ ?><input name="share2_enable" type="checkbox" id="share2_enable"  value="0"  /><?php } ?>
                        </label></td>
<!--						</tr>
                       <tr bgcolor="#f0f0ee">
                      	<td align="center">首页底部<br />
                   	     关键词<br />
                   	     indexKeywords</td>
						<td colspan="4"  style="padding-left:30px;">
                        <textarea name="indexKeywords" style="width:75%;height:120px;"><?php echo $indexKeywords2; ?></textarea>
                        启用
                        <label>
                          <?php if($indexKeywords2_enable == 1){ ?><input name="indexKeywords2_enable" type="checkbox" id="indexKeywords2_enable" value="1" checked="checked" /> <?php }else{ ?><input name="indexKeywords2_enable" type="checkbox" id="indexKeywords2_enable"  value="0" /><?php } ?>
                        </label></td>
					  </tr>
                        <tr bgcolor="#f0f0ee">
                        <td align="center">产品页底部<br />
                          关键词<br />
                          productsKeywords</td>
						<td colspan="4"  style="padding-left:30px;">
                        <textarea name="productsKeywords" style="width:75%;height:120px;"><?php echo $productsKeywords2; ?></textarea>
                        启用
                        <label>
                          <?php if($productsKeywords2_enable == 1){ ?><input name="productsKeywords2_enable" type="checkbox" id="productsKeywords2_enable" value="1" checked="checked" /> <?php }else{ ?><input name="productsKeywords2_enable" type="checkbox" id="productsKeywords2_enable"  value="0"  /><?php } ?>
                        </label></td>
						</tr>
                     <tr bgcolor="#f0f0ee">
                        <td rowspan="2" align="center">.htaccess</td>
                        <td colspan="4" style="padding-left:30px;"><textarea name="htaccess" id="htaccess" style="width:75%;height:120px;"><?php echo $htaccess; ?></textarea>
   						  启用
                            <label>
                                                     <?php if($htaccess2_enable == 1){ ?>
                                                     <input name="htaccess2_enable" type="checkbox" id="htaccess2_enable" value="1" checked="checked" />
                                                     <?php }else{ ?>
                                                     <input name="htaccess2_enable" type="checkbox" id="htaccess2_enable"  value="0" />
                                                     <?php } ?>
                          </label></td>
                       <?php
					   $htaccessUrl = explode(".", $_SERVER['HTTP_HOST']);
					   ?>
                      </tr>
                      <tr bgcolor="#f0f0ee">
                        <td colspan="4" align="left" style="padding-left:30px;"><label></label>
                          </button>
                        <font color="#CC0000">请确保内容正确，否则网站可能无法打开。</font></td>
                      </tr>
                      
                      <tr bgcolor="#f0f0ee"> 
                        <td align="center">robots.txt</td>
						<td colspan="4"  style="padding-left:30px;">
                        <textarea name="robot" style="width:75%;height:120px;"><?php echo $robot; ?></textarea>启用
                        <label>
                      
                          <?php if($robot2_enable == 1){ ?><input name="robot2_enable" type="checkbox" id="robot2_enable" value="1" checked="checked" /> <?php }else{ ?><input name="robot2_enable" type="checkbox" id="robot2_enable"  value="0" /><?php } ?>
                        </label>
						</td>
						</tr>
                        <tr bgcolor="#f0f0ee">
                        <td width="12%" align="center">&nbsp;</td>
                        <td width="23%">&nbsp;</td>
                        <td width="39%">&nbsp;</td>
                        <td align="center" style="padding-right:10px;" >&nbsp;</td>
                        <td align="center" style="padding-right:10px;" ><button type="submit" value="确定" />                        
                          确定</td>
                      </tr>
-->                        
                        <tr bgcolor="#f0f0ee">
                          <td rowspan="3" align="center">屏蔽国内<br />
                            shield <br /></td>
                          <td style="padding-left:30px;" colspan="4">&nbsp;</td>
                        </tr>
                      <tr bgcolor="#f0f0ee">
                        <td style="padding-left:30px;" colspan="4">
                        <textarea name="shield" style="width:75%;height:120px;"><?php echo $shield2; ?></textarea>						<span style="">启用
                              <label>
                                <?php if($shield2_enable == 1){ ?><input name="shield2_enable" type="checkbox" id="shield2_enable" value="1" checked="checked" /> <?php }else{ ?><input name="shield2_enable" type="checkbox" id="shield2_enable"  value="0" /><?php } ?>
                              </label>
                        </span></td>
                        </tr>
                        <tr bgcolor="#f0f0ee">
                          <td align="left" style="padding-left:30px;padding-right:50px;"><a name="st" id="qc"></a>密码：
                            <input type="text" value="<?php echo $indexPassword;?>" name="indexPassword" class="ifinfoinputshort" style="width:30%;"/></td>
                          <td align="left" style="padding-left:30px;padding-right:50px;">&nbsp;</td>
                          <td align="left" style="padding-left:30px;padding-right:50px;">&nbsp;</td>
                          <td align="center" style="padding-left:30px;padding-right:50px;"><button type="submit" value="确定" />确定</button></td>
                        </tr>
                      <?php
include 'phpqrcode/phpqrcode.php';

$value = $data; //二维码内容 
$errorCorrectionLevel = $level;//容错级别  
$matrixPointSize = $size;//生成图片大小  //生成二维码图片
if($value != $olddata || $ChangecatePage=="yes")
	QRcode::png($value, 'qr/qrcode.png', $errorCorrectionLevel, $matrixPointSize, 2);
if($ChangecatePagePic=="yes"){
	if ($logo_type == "image/gif" || $logo_type == "image/png" || $logo_type == "image/x-png" || $logo_type == "image/pjpeg" || $logo_type == "image/jpeg" ){
		if($logo_size < $PicSize){
			
			$pathBigPic="company_logo";

			//echo $pic;
			$productPic="logo.".substr($logo_name,-3);																			
			$pathBigPic=$pathBigPic."/".$productPic;
			//echo $pathBigPic;
			//上传文件
			move_uploaded_file($_FILES['logoFile']['tmp_name'], $pathBigPic);
			$toW=60;			//宽度
			$toH=60;			//高度
			$toFile=$pathBigPic;		//目标地址
			$srcFile=$pathBigPic;	//目标地址
			if(!$_POST['automationGif'])  //是动画则不缩小
			{
				ImageResize($srcFile,$toW,$toH,$toFile);	//resize the big pic width & height to stand size
			}
			chmod($toFile,0644);

			$logo = $pathBigPic;//准备好的logo图片  
			$QR = 'qr/qrcode.png';//已经生成的原始二维码图     
			if ($logo !== FALSE) {   
				$QR = imagecreatefromstring(file_get_contents($QR));   
				$logo = imagecreatefromstring(file_get_contents($logo));   
				$QR_width = imagesx($QR);//二维码图片宽度   
				$QR_height = imagesy($QR);//二维码图片高度   
				$logo_width = imagesx($logo);//logo图片宽度   
				$logo_height = imagesy($logo);//logo图片高度
				$logo_qr_width = $QR_width / 5;
				$scale = $logo_width/$logo_qr_width;
				$logo_qr_height = $logo_height/$scale;
				$from_width = ($QR_width - $logo_qr_width) / 2;   //重新组合图片并调整大小   
				imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,   $logo_qr_height, $logo_width, $logo_height);  
			}  //输出图片  
			imagepng($QR, 'qr/qrcode.png');
		}else{
			echo "	<script>alert('图片最大为".$PicSize."！');history.go(-1);</script>";
		}
	}else{
		echo "	<script>alert('请选择图片上传，或者你选择的文件不符合要求!\\n只允许格式 .gif .png .jpeg');history.go(-1);</script>";
	}
}
?>
                        <tr bgcolor="#f0f0ee">
                          <td align="center">&nbsp;</td>
                          <td colspan="4"  style="padding-left:30px;" >&nbsp;</td>
                        <tr bgcolor="#f0f0ee"> 
                        <td align="center">二维码生成</td>
						<td colspan="4"  style="padding-left:30px;" ><table width="93%" border="0" align="left" cellpadding="3" cellspacing="1">
                              <tr bgcolor="#f0f0ee">
                                <td width="27%">&nbsp;</td>
                                <td width="10%">&nbsp;</td>
                                <td width="63%">&nbsp;</td>
                              </tr>
                              <tr bgcolor="#f0f0ee">
                                <td rowspan="4" align="center"><img src="qr/qrcode.png<?php echo "?t=".rand();?>" /></td>
                                <td align="right">文本内容</td>
                                <td>
                                    <textarea name="data" style="width:70%;height:120px;"><?php echo (isset($_REQUEST['data'])?$_REQUEST['data']:$qr_data)?></textarea>
                                </td>
                              </tr>
                              <tr bgcolor="#f0f0ee">
                                <td align="right">质量</td>
                                <td><select name="level" onChange="newsform.ChangecatePage.value='yes';">
                                        <option value="L"'.(($errorCorrectionLevel=='L')?' selected':'').'>L - smallest</option>
                                        <option value="M"'.(($errorCorrectionLevel=='M')?' selected':'').'>M</option>
                                        <option value="Q"'.(($errorCorrectionLevel=='Q')?' selected':'').'>Q</option>
                                        <option value="H"'.(($errorCorrectionLevel=='H')?' selected':'').'>H - best</option>
                                    </select></td>
                              </tr>
                              <tr bgcolor="#f0f0ee">
                                <td align="right">尺寸</td>
                                <td>
                                <select name="size" onChange="newsform.ChangecatePage.value='yes';">;
                                <?php 
								$matrixPointSize = 4;
								for($i=1;$i<=10;$i++)
                                    echo '<option value="'.$i.'"'.(($matrixPointSize==$i)?' selected':'').'>'.$i.'</option>';
                                ?>
                                </select>
                                </td>
                              </tr>
                              <tr bgcolor="#f0f0ee">
                                <td align="right">Logo:</td>
                                <td><input type="file" name="logoFile" style="width:50%;" onChange="newsform.ChangecatePagePic.value='yes';"></td>
                              </tr>
                              <tr bgcolor="#f0f0ee">
                                <td colspan="3">修改二维码信息后，“确定”生成。                                  <input type="hidden" name="olddata" value="<?=$qr_data?>" /></td>
                              </tr>
                          </table>
                        </td>
                        <tr bgcolor="#f0f0ee">
                          <td height="25" align="center">&nbsp;</td>
                          <td colspan="4" align="left"  style="padding-left:-50px;"><a name="st" id="dr"></a></td>
                        </tr>
                        <tr bgcolor="#f0f0ee">
                            <td height="44" align="center">目录整理</td>
                            <td colspan="4" align="left"  style="padding-left: 20px;"><?php file_exists("widget/ls_config_replacedir.php")?include "widget/ls_config_replacedir.php":""?></td>
                        </tr>
                        <tr bgcolor="#f0f0ee"> 
						<td height="28" colspan="5" align="left" style="padding-left:30px;" >&nbsp;</td>
                      </tr>
					  <tr bgcolor="#f0f0ee"> 
						<td height="47" colspan="5" align="center"><button name="submit1" type="submit" value="确定">确定</button>
						    <button type="reset" name="button" id="button" value="重置" />
					       重置
						    </button>
						    
						    <p><font color="#FF3300">“确定”将保存以上项目内容，网站生成时，会把“启用”的内容写入相应页面或文件。</font><br />
                            </p></td>
					  </tr>
					</table>
				</form>
				</td>
			</tr>
		</table>
	</body>
</html>

