zoukankan      html  css  js  c++  java
  • [MySQL] PHP IP登录限制的实现

    在登录的时候 , 对安全性比较高的业务 , 需要进行限制指定IP或IP段才能登录 , 企邮企业有的就限制只能在本企业内登录 

    这个时候设计一下数据库 , 实现这个功能可以这样

    表结构:

    CREATE TABLE `iplimit_list` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `ent_id` int(10) unsigned NOT NULL DEFAULT '0',
      `start` int(10) unsigned NOT NULL DEFAULT '0',
      `end` int(10) unsigned NOT NULL DEFAULT '0',
      `time` int(10) unsigned NOT NULL DEFAULT '0',
      `type` tinyint(3) unsigned NOT NULL DEFAULT '0',
      PRIMARY KEY (`id`),
      KEY `idx_user` (`ent_id`,`start`,`end`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8

    start是ip段的开始

    end是ip段的结束 

    都是int数值型的 , 把ip进行转换成long类型

    查询的时候可以这样查

    select * from iplimit_list where ent_id=23684 and 182322741>=start  and 182322741<=end

    182322741这个就是当前ip , 大于等于start的ip段 , 小于等于end的ip段

    实现的效果

  • 相关阅读:
    表详细操作
    库相关操作
    数据库一
    协程
    多线程2
    .Net鼠标随动窗口
    .Net操作音频
    .Net操作注册表--un
    .Net操作.exe文件
    .Net连接数据库(AOD.Net)
  • 原文地址:https://www.cnblogs.com/taoshihan/p/14149803.html
Copyright © 2011-2022 走看看