PHP禁止外站提交、禁止直接访问
    文章作者:恒爱网络 阅读次数:6675 发布时间:2015-4-14

    // 检查是否直接访问本页面
    if( isset($_SERVER['HTTP_REFERER']) ) {
        $url_array = explode('http://', $_SERVER['HTTP_REFERER']);
        $url = explode('/', $url_array[1]);
        if($_SERVER['SERVER_NAME'] != $url[0]) {
            // 您不是从本站来的;
            exit('Access Denied! You are not coming from the site!');
        }
    } else {// 禁止直接访问此页;
        exit('Access Denied! Please do not load this page directly.');
    }

    ?>