首页 技术教程 实用代码 注册破解 正则表达式 网址导航 电子书籍

限制IP访问的思路和PHP代码

那天写自己的网站,想到要有关于限制IP的功能,至少要包括能够在后台设置要限制的IP,还有,能够对IP段进行限制,比如 192.168.0.* 一样的就能够限制整个段,左思右想,用了好几个if判断才解决,把简单的代码如下:(程序中使用了phplib中的db类) <?php error_reporting(7); session_start(); // 发送字符头信息 if ($headercharset) header("Content-Type:text/html; charset=gb2312"); // 加载公共文件 require_once("config.php"); require_once("global.php"); require_once("db_mysql.php"); /***************** 进行客户端能否访问本网站校验 ************/ //...
类别:网页编程 - PHP技术    查看:87    更新:2014-05-19

ASP实例:限制ip投票

要求同一IP只能对同一用户投票一次,贴Asp代码: <% db_conn(dbs) Voteusername=trim(request.QueryString("username")) rs_create("select username from [user] where username ='"&Voteusername&"'") if rs.eof and rs.bof then response.write "错误的参数,请从正确访问!" response.end() end if '第一种情况是第一次点击,cookies为空,ip为空 '第二种情况是点第二个人投票,第一个人的cookies存在,第二个的的cookies不存在,但是ip存在 '第三种情况是换ip投票,cookies存在,ip为空 if Request.cookies("dwww")(""&Voteusername&"")="&...
类别:网页编程 - ASP技术    查看:90    更新:2014-05-04