<?php
function check_wap(){
    if(stristr($_SERVER['HTTP_VIA'],"wap")){
        return true;
    }elseif(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML") > 0){
        return true;
    }elseif(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;
    }
}

function isAndroid(){
    if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
       return false;
    }
    return true;
}

$image   = isset($_GET['img'])?$_GET['img']:'0';
$title   = isset($_GET['title'])?$_GET['title']:'Crazy Coin';
$content = isset($_GET['content'])?$_GET['content']:'Crazy Coin is the most exciting and fun social game in the world';
$imageUrl= 'https://god.superant.cc/img/feed/'.$image.'.jpg';
$baseUrl = "https://crazycoin.superant.cc/m/share.php";
$url = $baseUrl.'?image='.$image.'&title='.$title.'&content='.$content;
$url = str_replace(' ','+',$url);
$paramList = $_GET;
$paramStr = '?';
foreach ($paramList as $n => $val) {
    $paramStr .= $n.'='.$val.'&';
}
$paramStr = rtrim($paramStr, '&');

/**
 * Coins Master IOS deepLink:coinmaster://promotions?af_deeplink=true&campaign=pe_FCBjNmeOf_20201110&media_source=FB_PAGE
 */

if(isset($_GET['share'])){
    $str = $_GET['share'];;
    $appLink  = 'crazycoin://promotions?jump='.$str;
    $appLink2 = 'superant://crazygod?jump='.$str;
}else{
    $appLink  = 'crazycoin://promotions';
    $appLink2 = 'superant://crazygod';
}


//<meta property="fb:app_id" content="2017964004965884" />
//<meta property="al:ios:url"          content="crazycoin://" />
//<meta property="al:ios:app_store_id" content="1505268807" />
//<meta property="al:ios:app_name"     content="Crazy Coin" />
//<meta property="al:android:url" content="superant://crazygod" />
//<meta property="al:android:package" content="com.superant.crazygod" />
//<meta property="al:android:app_name" content="Crazy Coin" />

?>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=0.66"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="Keywords" content="coin,coinmaster,coins,crazygod,crazycoin" />
    <meta name="description" content="Crazy Coin is the most exciting and fun social game in the world" />

    <meta property="og:url"  content="<?php echo $url;?>" />
    <meta property="og:type" content="game" />
    <meta property="og:title" content="<?php echo $title;?>" />
    <meta property="og:image" content="<?php echo $imageUrl;?>" />
    <meta property="og:description" content="<?php echo $content;?>" />

    <title>Crazy Coin</title>
    <style>
        /* CSS Document */
        .menu {
            margin:0 auto;
            border:1pt solid #999999;
            border-radius:5px;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
        }
        .menu a {
            text-decoration:none;
            height:100%;
            display:block;
            border-radius:5px;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px; color:#333;
        }
        .menu a:visited {
            text-decoration:none;
            color:#000000;
        }
        .menu a:active {
            text-decoration:none;
        }
        .link-web{
            width:210px;
            height:40px;
            margin:0 auto;
            border-radius:4px;
            -webkit-border-radius: 4px;
            -moz-border-radius: 4px;
            /*text-shadow:0 2px 0 #FFF;*/
            font-family: "", "";
            font-size:18px;
        }
        .link-web a{
            text-decoration:none;
            width:210px;
            height:40px;
            display:block;
            border-radius:4px;
            -webkit-border-radius: 4px;
            -moz-border-radius: 4px;
            background-color: #F5F5F5;
            border:1px dashed #cccccc;
            color:#333;
        }
        .link-web a:visited{
            text-decoration:none;
            color:#333;
        }
        .link-web a:active{
            text-decoration:none;
            color:#333;
        }
        .font-arial{
            font-family: "微软雅黑", "", Arial, "Arial Black";
        }
        .font-italic{
            font-style:italic;
        }
        .font-blod{
            font-weight:bold;
        }
        .font-app{
            text-align:left;
            font-size:25px;
            color: #666666;
        }
        .font-app-display{
            text-align:left;
            font-size:20px;
            color:#999999;
            text-shadow:0 2px 0 #FFF;
        }
        .font02{
            font-size:18px; color:#999999;
            text-align:left;
        }
        .dp_copy{
            margin-top:10px;
            text-align:center;
            color:#919090;
            font-size:22px;
        }
    </style>

</head>
<body style="margin:0;padding:0;background:#EFEFEF;text-align:center;" onload="onLoad()">
<?php if(check_wap()){ ?>
    <div>
        <div style="display: none">
            <img src="/img/icon152.png"/>
        </div>
        <div>
            <img src="/m/link/bg.jpg" style="width: 100%;height: 100%;">
            <a id="aLink" href="<?php echo isAndroid() ? $appLink2 : $appLink;?>">
                <img src="/m/link/btn.png" style="z-index: 999;position: absolute;bottom: 22%;left: 27%;">
            </a>
        </div>
    </div>
<?php }else{?>
    <div id="page-android" style="width:400px; height:800px; margin:0 auto; display:;">
        <div style="display: none">
            <img src="/img/icon152.png"/>
        </div>
        <div style="padding:50px 0 0px 0">
            <img src="/img/r1.png"/>
        </div>
        <div style="padding:50px 0 0px 0">
            <a id="aLink" href="<?php echo $appLink2;?>">
                <img src="/img/icon152.png" alt="Crazy Coin"/>
            </a>
        </div>
        <div class="font-arial" style="font-size:32px; line-height:34px; height:45px; text-shadow:0 2px 0 #FFF; color:#999999; text-shadow: white 2px 2px; font-weight: bold; letter-spacing:2px;">Crazy Coin</div>
        <p class="dp_copy">The most exciting and fun social game in the world</p>
        <br/>
        <div class="font-arial" style=" width:400px; font-size:20px; line-height:30px; height:50px; color:#999999; letter-spacing:2px; text-align:left; margin: 0 auto;">Choose the version available :</div>
        <br/>
        <div  style="width:400px; height:100px;">
            <a href="itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1505268807" target="Crazy Coin">
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" height="100px">
                    <tr>
                        <td width="100" align="center" valign="middle" >
                            <img src="/img/ios.jpg" alt="" border="0"  />
                        </td>
                    </tr>
                </table>
            </a>
        </div>
        <div style="height:60px;"></div>
        <div style="width:400px; height:100px;">
            <a href="market://details?id=com.superant.crazygod">
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" height="100px">
                    <tr>
                        <td width="100" align="center" valign="middle">
                            <img src="/img/android.jpg" alt="" border="0" />
                        </td>
                    </tr>
                </table>
            </a>
        </div>
        <br/>
        <br/>
        <br/>
        <br/>
        <a id="copy" style="height:20px; font-size:22px;font-family: 微软雅黑; text-shadow:0 2px 0 #FFF; text-align:center; margin:0px" href="https://fb.me/crazycoin.global">Fans Page</a>
        <br/>
        <br/>
        <br/>
        <div id="copy" style="height:18px; color:#999999; font-size:15px;font-family: 微软雅黑; text-shadow:0 2px 0 #FFF; text-align:center; margin:0px">Copyright © 2019 SuperAnt Technology Co., Ltd..All Rights Reserved.</div>
    </div>
<?php } ?>
<script type="text/javascript">document.write(unescape("%3Cspan id='cnzz_stat_icon_1279082262'%3E%3C/span%3E%3Cscript src='https://v1.cnzz.com/z_stat.php%3Fid%3D1279082262%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));</script>
<script>
    var aLink = document.getElementById("aLink");
    document.getElementById("cnzz_stat_icon_1279082262").style.display = 'none';
    var timeOutId = 0;
    // IOS
    var IOS ="<?php echo $appLink;?>";
    var ITUNES = "itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1505268807";

    // Android
    var ANDROID = "<?php echo $appLink2;?>";
    var MARKET = "market://details?id=com.superant.crazygod";

    // PC
    var PCURL  = "https://fb.me/crazycoin.global";

    function onLoad() {
        if (navigator.userAgent.match(/Android/)) {
            var iframe = document.createElement("iframe");
            iframe.style.visibility = 'hidden';
            iframe.style.border = "none";
            iframe.style.width = "1px";
            iframe.style.height = "1px";
            iframe.src = ANDROID;
            iframe.onload = function () { window.location = MARKET; };
            document.body.appendChild(iframe);
        }
        else if (navigator.userAgent.match(/(iPhone|iPad|iPod)/i)) {
            aLink.setAttribute("href",IOS);
            // IOS
            window.location = IOS;
            timeOutId = setTimeout(function() {
                window.location = ITUNES;
            }, 2000);
        } else {
            window.location.href = PCURL;
        }
    }
    window.onbeforeunload=function(){
        clearTimeout(timeOutId);
    }
</script>

</body>
</html>
