![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
|
IP Blocking Script
I've been trying to enforce an ip blocking feature on my website. Where if the user requesting any file within my site is on the blacklisted ip list it will block them and deny them access. I found a MySQL script online but I got an error when trying to upload it, something with the code (I'm not a programmer, can only edit & pick things out).
I also tried a search here but came up empty, too common search terms or something. Anyone?
__________________
~ RevHavoc ~ Universal PC Technician / Design Pro Last edited by RevHavoc; 05-08-2007 at 01:42 AM. |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
TSF Enthusiast
Join Date: Nov 2004
Posts: 555
OS: Windows XP Pro & Windows Vista Ultimate browsing the web with FF, Opera, Safari and IE.
|
Re: IP Blocking Script
@ RevHavoc: If your website is hosted on Apache server you can edit your .htacces-file, see here and here.
Remember, it might be that your hoster does not let you use MySQL...
__________________
KoosHopeloos, straight to you from .nl via the world wide web! ![]() |
|
|
|
|
|
#3 (permalink) | |
|
Registered User
|
Re: IP Blocking Script
Quote:
Linux (I think I can change it to Windows also) MySQL Admin server version: 4.1.22 MySQL Client version: 5.0.27 protocol 10
__________________
~ RevHavoc ~ Universal PC Technician / Design Pro Last edited by RevHavoc; 05-08-2007 at 04:02 AM. |
|
|
|
|
|
|
#4 (permalink) | |
|
Registered User
|
Re: IP Blocking Script
Here is the error I get when trying to import the file to the MySQL database:
Quote:
__________________
~ RevHavoc ~ Universal PC Technician / Design Pro |
|
|
|
|
|
|
#5 (permalink) |
|
Retired
|
Re: IP Blocking Script
by the looks of it, you're trying to use PHP within a mysql statement and that won't work. Here's what I would do:
You need to create a database first. Most hosting providers will supply a GUI (Graphical User Interface) to do this within your sites control panel. Next, make a file and name it "db_connect.php". Put this in it: PHP Code:
PHP Code:
Now, Create this file. It will get a little weird looking and complicated, but I'll explain it as best as possible. name it "add_ip.php" PHP Code:
PHP Code:
Put this following AT THE VERY TOP of every page you want their ip address to be checked: PHP Code:
__________________
|
|
|
|
|
|
#7 (permalink) |
|
Registered User
|
Re: IP Blocking Script
This is where I have been trying to create the ip block database. This is the only database GUI I have found. *see ref pic*
155290-1.jpg I have never created a database before, only upped reg files via FTP and the like. This isn't right is it?
__________________
~ RevHavoc ~ Universal PC Technician / Design Pro |
|
|
|
|
|
#8 (permalink) |
|
Retired
|
Re: IP Blocking Script
Thats the right place. Up at the top where it tells you your server and database names is saying that you already have a db made. I can't read the image very well, but it looks like "doac" or "doae". Anyways, that the name you want to put in the $dbname = "doac" variable. You can also create a table from that screen if you wish or just run the script that I provided. either will work fine.
__________________
|
|
|
|
|
|
#9 (permalink) | |
|
Registered User
|
Re: IP Blocking Script
Quote:
It's 'deac' (deactivate, want something descript for the database name ). I did edit the file accordingly.How do I run the script without manually creating a table (which looks like a pita to do)? Can't I just upload those x.php files into the db or doesn't it work like that? I tried import but I got an error similar to the one I was experiencing before. I don't think it's an issue with the code, my be filename/ext, or my id10t mistake. I wouldn't be normally asking questions like this but I tried looking it up myself to no avail in manuals and using support.
__________________
~ RevHavoc ~ Universal PC Technician / Design Pro |
|
|
|
|
|
|
#10 (permalink) |
|
Retired
|
Re: IP Blocking Script
all you do is copy/paste those scripts into notepad or whatever you use to make your pages. If it's Dreamweaver or Frontpage, make sure you paste them into code view. Save them as the names I suggested. Now they are their own seperate pages. All you need to do is call the "ip_table_create.php" page once and it will make the table for you in the database. Once that is done, you don't have to worry about ever using that page again. Treat each of these as web pages. They don't belong to or go into the database in any way, they just communicate with it whenever called upon. So to run the "ip_table_create.php" page, you would upload it into your web site like you do everything else and then open up a browser and go to "http://www.yourwebsite.com/ip_table_create.php". This will run the script and create the table for you. If it works it will say "successful" and you can close the browser. If it doesn't work, it will give you an error and, in that case, post the error here. Create the other pages the same way and upload them into your website also. Once that is done, all you need to do to check the users IP is put the last section of script at the very top of every page you want the user to be checked on. To add an IP address to the database, just go to "http://www.yourwebsite.com/add_ip.php" and put the desired IP in the box and click submit. Easy as pie!
__________________
|
|
|
|
|
|
#11 (permalink) | |
|
Registered User
|
Re: IP Blocking Script
Alright, that explanation / direction is making more sense.
I followed the instructions and havn't been able to create it yet. This is the error I keep receiving when trying to "call up" ip_table_create.php in my browser after uploading the 4 files into my http root docs: Quote:
__________________
~ RevHavoc ~ Universal PC Technician / Design Pro |
|
|
|
|
![]() |
| Thread Tools | |
|
|