zoukankan      html  css  js  c++  java
  • thinkphp屏蔽ip访问项目做法

    1.从入口文件下手,首先在index.php中顶部加入:(这一步是为了让显示信息以utf8编码格式显示)

    header("Content-Type:text/html;charset=utf8"); 

    2.找到thinkphp文件夹下start.php文件:

    <?php
    namespace think;
    use think\Request;
    require __DIR__ . '/base.php';
    $request = Request::instance();
    $request->ip();
    if($request->ip()=='124.116.71.69'){
        echo '您无权访问此网站!';
    	exit;
    }
    // 2. 执行应用
    App::run()->send();

    这个功能可以添加再后台设置多个ip被屏蔽访问,这里的需求只屏蔽一个,其它可自行扩展

    路是自己走出来的,而不是选出来的。
  • 相关阅读:
    Linux系统服务
    Linux进程管理
    Linux压缩打包
    Linux输入输出
    Linux权限管理
    Linux用户管理
    Linux文件管理
    Linux-Shell
    Centos7 安装jdk1.8
    Python数据分析之路
  • 原文地址:https://www.cnblogs.com/mo3408/p/15741748.html
Copyright © 2011-2022 走看看