ban ip/device?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ban ip/device?

    People, how do i ban people frm my site?? e.g i gota message board on my site i get a ip numba lyk 195.189.143.50 how can i use that number 2 ban them? e.g when that person spam, etc.

    #2
    Which Script u use

    Comment


      #3
      Dude, im kinda new at this php and sql... Itz a php script .. But u can check loverzone.wen.ru

      Comment


        #4


        Edit and use this.

        <?php
        /*
        usage
        1.create database
        2.connect to database
        3.use the table "current" to store the current ip's of visitors - automatic insert - this table allow unique ip's only
        4.use table "bann" to insert what ip's you want to bann/block - for this make manual insert - this table allow unique ip's only


        */

        /*
        database

        -- phpMyAdmin SQL Dump
        -- version 2.7.0-pl1
        -- phpMyAdmin
        --
        -- Host: localhost
        -- Generation Time: Dec 06, 2004 at 04:05 PM
        -- Server version: 5.0.17
        -- PHP Version: 5.1.1
        --
        -- Database: `bann`
        --

        -- --------------------------------------------------------

        --
        -- Table structure for table `bann`
        --

        CREATE TABLE `bann` (
        `id` int(11) NOT NULL auto_increment,
        `ip` text NOT NULL,
        PRIMARY KEY (`id`),
        UNIQUE KEY `ip` (`ip`(15))
        ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

        --
        -- Dumping data for table `bann`
        --

        INSERT INTO `bann` VALUES (2, '127.0.0.5');
        INSERT INTO `bann` VALUES (3, '127.0.0.2');
        INSERT INTO `bann` VALUES (4, '127.0.0.1');

        -- --------------------------------------------------------

        --
        -- Table structure for table `current`
        --

        CREATE TABLE `current` (
        `id` int(11) NOT NULL auto_increment,
        `ip` text NOT NULL,
        PRIMARY KEY (`id`),
        UNIQUE KEY `ip` (`ip`(15))
        ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

        --
        -- Dumping data for table `current`
        --

        INSERT INTO `current` VALUES (1, '127.0.0.1');



        */
        // connect to database
        $link = mysql_connect("localhost", "root", "");
        if(!$link)
        { echo "Not Connected To SQL" .mysql_error();
        }
        $ip = $_SERVER['REMOTE_ADDR'];
        // select database
        $select_db = mysql_select_db('bann', $link);

        if(!$select_db)
        {
        echo "Not Connected To DB" .mysql_error();
        }
        // insert the current ip
        $insert = "INSERT INTO `current` ( `id` , `ip` )
        VALUES (NULL , '$ip')";
        @mysql_query($insert);

        // select ip for bann processing
        $select_accept = "SELECT * FROM bann INNER JOIN current ON bann.ip = current.ip";
        $result_accept = mysql_query($select_accept);
        if(mysql_num_rows($result_accept))
        {

        echo 'ip not ok, banned';

        }
        else
        {
        echo "ip ok, not banned, continue with the script";

        }
        mysql_close();
        ?>
        Last edited by blackhowk; 20.07.09, 06:36.
        http://ngeo.ro

        Comment

        Working...
        X