<!doctype html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
require_once('_approot.php');

$ls=$_GET['ls'];
$kw=trim($_GET['kw']);
if($kw=="" ||$kw=="Lanscend"||$kw=="Products") return;

$config_sql="update ls_config set ".$ls." ='".$kw."' ";
$config_query=$opendb->query($config_sql);

if($ls=='MSN3'){
	$srca= array('1' => '>PRODUCTS<','2' => '>PRODUCT<' ,'3' => '>Product Categories<' ,'4' => 'Product List'  );  //替换dwt  
	$obja= array('1' =>'>'.strtoupper($kw).'<','2' =>'>'.strtoupper($kw).'<','3' =>'>'.$kw.'<', '4' =>$kw   ); 
}

if($ls=='MSN4'){
	$srca= array('1' => 'About us','2' => 'About Us' ,'3' => 'Contact us' ,'4' => 'Contact Us' ,'5' => 'ABOUT US','6' => 'CONATCT US' );  //替换dwt  
	$obja= array('1' =>'About '.$kw,'2' =>'About '.$kw,'3' =>'Contact '.$kw, '4' =>'Contact '.$kw,'5' =>'ABOUT '.$kw, '5' =>'CONATCT '.$kw    ); 
}

// 递归操作
$filetpla=array("../Templates1", "../Templates");

foreach($filetpla as $filetpl1) { 
	$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($filetpl1), RecursiveIteratorIterator::SELF_FIRST); 
	foreach($iterator as $item) { 
		if(substr($item,-1)=="."|| $item=="../Templates1/opt"|| $item=="../Templates/opt"  ) continue;
		$desfile=str_replace($filetpl1,"../TemplatesBak",$item); //备份文件
		if(!file_exists($desfile))copy($item,$desfile );
		writereplacestr($item,$srca,$obja); // 替换 Template1 下模板
	} 
	$ls_msg.="模板 $filetpl1 中 ".$kw.'  已替换 ';
}
 
echo "success";  
$opendb->close();

?>
