<!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">
<?php
	//同步ftp上传更新的英文站文件到，其他语种，主要是 变化的程序，新增， 修改上传: 文件、文件夹时间大于 数据库上次上传时间

	$getpasshost="192.168.2.78";
	if(strpos($_SERVER['HTTP_REFERER'],$getpasshost)===false) die("from error"); //访问来源错误
	session_start();
	include("inc/ftp.php");
	ini_set('date.timezone','Asia/Shanghai');
	$ls=str_replace("http://","",$_GET['ls']);
	 

	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	$getpassusername="root";
	$getpasspassword =base64_decode('bHM4MTZzaGVuaWFu');
	$getpassdbname="getpass";
	
	$conn_gp=@mysql_connect($getpasshost,$getpassusername, $getpasspassword ) or die ("can't connect DBS getpass: ".$getpasshost.",".$getpassusername.",".$getpassdbname.",".$getpasspassword);
	mysql_select_db($getpassdbname,$conn_gp);
	mysql_query("SET character_set_client = utf8",$conn_gp);
	mysql_query("SET character_set_results = utf8",$conn_gp);
	mysql_query("SET character_set_connection = utf8",$conn_gp);
	$select_sql2="select * from ls_acc where domain='".$ls."' and  accType='虚拟主机' order  by date DESC ";
	//echo $select_sql2;
	$select_query2=mysql_query($select_sql2,$conn_gp);
	$rows=mysql_fetch_assoc($select_query2); //总数
	$ifhtdocs= (  strpos($rows['ip'],"pm")===false && strpos($rows['ip'],"lanscend.cn")===false );// ali 及其他 htdocs, SOFTLAYER非独立机 直接 根
	$rootfolder=(($ifhtdocs )?"/htdocs/":"/"); //ftp 根目录

	$thisurl=strtolower( trim($rows['url']));
	$thisurl=str_replace("https://","",str_replace("http://","",$thisurl));
	$thishost= ($thisurl !=""?  substr($thisurl,0,(strpos($thisurl,"/")===false?100:strpos($thisurl,"/"))) :  trim($rows['domain']) ); // 有临时网址用临时网址，没有用域名
	exec(" chmod -R 755    ../../".$ls." ");  //改权限
	exec("zip -r  ../../".$ls.".zip  ../../".$ls." ");  //压缩网站
	exec(" chmod -R 775    ../../".$ls." ");  //恢复权限

	
  	echo ' <script type="text/javascript"> window.open( "../../phpMAd/db_export.php?db='.$ls.'&server=1&token=","_blank");  </script>';//导出db sql  '.rand(1,100).'
	echo "已压缩 到 wwwroot/".$ls.".zip, 数据库已导出到 ".$ls."sql "."<br/>";
	
	$config=array('ftp_ip'=>$thishost,
	'ftp_port'=>"21",
	'ftp_username'=>$rows['username'],
	'ftp_password'=>base64_decode("NzE=").$rows['password'],
	'ftp_pasv'=>"");
	echo $rootfolder."== ".$thishost."== ".$rows['username']."== -----".substr($rows['password'],5,30)."<br/>" ; 
	$ftp = new FtpFile($config);
	 
	$ls_msg.=$ftp->upafile("../../".$ls.".zip", $rootfolder.$ls.".zip")."<br/>";
	echo $ls_msg;
	if($ifhtdocs) echo ' <script type="text/javascript"> window.open( "http://www.net.cn");  </script>'; 
	else echo ' <script type="text/javascript"> window.open( "https://jeep.websitewelcome.com:2083/");  </script>'; 
	
?>