",'',$html_string);
if ($language === 'zh') {
$html_string = str_replace('2', '', $html_string);
}
$html_string = str_replace("background-image: url(/uploads","background-image: url(//$domain/uploads",$html_string);
$html_string = str_replace("src=\"/uploads","src=\"//$domain/uploads",$html_string);
$html_string = str_replace("href=\"/uploads","href=\"//$domain/uploads",$html_string );
if(in_array($domain,["www.mydosports.com"])){
$html_string = str_replace('',"",$html_string );
}
if (!strpos($this->siteDomain, 'quanqiusou.cn') && !strpos($this->siteDomain, 'goodao.net')) {
$save_path = $this->htmlSavePath . '/' . $language . $html_path;
} else {
$save_path = $this->htmlPath . '/' . $language . $html_path;
}
if(strpos($html_path,".html") !== false){
file_put_contents($save_path , $html_string);
}else{
$this->createFile($save_path, 'index.html', $html_string);
}
$this->writeLog(1, $save_path . '效验成功!');
}
/**
* 头部特殊标签替换
* @param array $data
* @param string $string_html
* @return string
*/
public function replaceSpecialHtml($data, $string_html)
{
foreach ($data as $title => $value) {
if (!in_array($title, ['og_title', 'og_description', 'description', 'keywords'])) {
continue;
}
$key = array_keys($value)[0];
$item = array_values($value)[0];
if (empty($key) || empty($item)) {
continue;
}
// 判断当前$key 的长度
$str_array = explode(' ', $key);
$str_length = strlen($key);
$preg_key = $this->escape($key);
$pattern = '/(content=[\"\']?)' . $preg_key . '\"(?=[\"\']?[^<]*\/?>)/i';
if ($str_length > 32 || count($str_array) > 2) {
$string_html = str_replace($key, htmlspecialchars($item), $string_html);
} else {
$string_html = preg_replace($pattern, 'content="' . htmlspecialchars($item) . '"', $string_html);
}
}
return $string_html;
}
/**
* html 实体转义
* @param string $html
* @return string
*/
public function replaceSpecialUnicode($html) {
$html = str_replace('’', '’', $html);
$html = str_replace('&', '&', $html);
$html = str_replace('&', '&', $html);
$html = str_replace('…', '…', $html);
$html = str_replace('“', '“', $html);
$html = str_replace('”', '”', $html);
$html = str_replace('–', '–', $html);
return $html;
}
/**
* 写入新的文件
* @access public
* @param string $file_path 文件路径
* @param string $file_name 需要写入的文件名
* @param string $file_content 文件内容
*/
public function createFile($file_path, $file_name, $file_content)
{
// 判断当前路径是否存在 如果不存在创建文件夹和文件
$file_path = strtolower($file_path);
if (!file_exists($file_path)) {
mkdir($file_path, 0777, true);
}
file_put_contents($file_path . '/' . $file_name, $file_content);
/* 执行rsync同步到正式站 start */
$domain['host'] = $_SERVER["HTTP_HOST"];
// printy_r($domain);
if(strpos($domain['host'],'goodao.net') !== false || strpos($domain['host'],'quanqiusou.cn') !== false){
$shell_ar = file_get_contents("http://www.quanqiusou.cn/extend_api/api/rsync.txt");
$shell_ar = explode("\n",$shell_ar);
foreach ($shell_ar as $v){
if($v){
$v = trim($v);
if(strpos($v,$domain['host']) !== false){
$ar_info = explode('|',$v);
shell_exec('rsync -avu --progress /www/wwwroot/'.$ar_info[0].'/wp-content/cache/all/ root@'.$ar_info[1].' &> /dev/null &');
shell_exec('rsync -avu --progress /www/wwwroot/'.$ar_info[0].'/uploads/ root@'.$ar_info[1].'-uploads &> /dev/null &');
}
}
}
}
/* 执行rsync同步到正式站 end */
}
/**
* 获取过滤特殊标签键值对
* @access protected
* @param string $label_name
* @param string $string
* @return array
*/
public function filterSpecialLabel($label_name, $string)
{
if ($label_name == 'a') {
$script_preg = '/]*?>/si';
} else if ($label_name == 'ul_language') {
$script_preg = '/]*?>.*?<\/ul>/si';
} else if ($label_name == 'div_language') {
$script_preg = '/