<?php
if($_GET['type']){
    //1.将timestamp,nonce,toke按字典顺序排序 微信公众号服务消息配置校验
    $timestamp = $_GET['timestamp'];
    $nonce = $_GET['nonce'];
    $token = 'oCGye6';
    $signature = $_GET['signature'];
    $array = array($timestamp,$nonce,$token);
    //2.将排序后的三个参数拼接之后用sha1加密
    $tmpstr = implode('',$array);
    $tmpstr = sha1($tmpstr);
    //3.将加密后的字符串与signature进行对比，判断该请求是否来自微信
    if($tmpstr == $signature){
        echo $_GET['echostr'];
        exit;
    }
    // if(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false){
    // }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Alipay') !== false){
    // }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'baiduboxapp') !== false){
    // }
}else{
    if (file_exists(__DIR__ . '/install.lock')) {
        header('location: web/index.php');
    } else {
        header('location: web/index.php?r=install');
    }
}
