Now that you have all the php files and the .csv database file, it's time to do the setup.
You need to create two new directories on your web site. The directories must be accessible to your web server just like any other file that is used on your website. Use whatever method you normally use when creating a new directory, also commonly known as a folder. In this documentation, I will refer to them as directories and subdirectories.
Give each directory a name that is very hard to guess. Something like "htcountryck1" and "htcountryck2" is good, but don't use those because they are mentioned in this documentation! Use a name that only you will know. Nobody from the rest of the world should have access to these directories or the files within them.
Whatever suits you is fine, the programs themselves don't care where the directories are or what you name them.
For the rest of this documentation, we will refer to the name of the two new directories as "country1" and "country2". The real names on your web site will be something different.
Make the "country2" directory so that the Apache webserver can write to it. Use whatever method works for you. If you have shell access, you can do the following:
chmod 777 country2
It's quite safe to use 777 since you are the only one who knows the name of the directory.
On some systems, 755 might work and some might be OK with 744. But 777 will always work. 755 might work if the "owner" and/or "group" of the directory is the Apache server. On a Debian Linux system, the owner is usually listed as "www-data". On other systems, it might be "apache". Use whatever method works so that the Apache web server can write in this directory. If you have shell access, the following command works:
chown www-data.www-data country2
Now, the web server has full read and write access to the 'country2' directory. If your web server uses a different name than 'www-data', just change the above command accordingly. This is not necessary if you set the permissions on the directory to 777.
Maybe on your system, your own username will work. You'll find out later when it comes time to create some files.
Next, use whatever method you normally use for copying (or uploading) files.
1. Upload the following files to the "country1" directory:
index.html countrycheck.php notfound.php badcountry.php
2. Upload the following files to the "country2" directory:
index.html (same file copied to both directories) menu.php countryhtsetup.php countryhtaccess.php iptocountry.php htblock00.html - htblock14.html (all the html doc files) and the .csv database file
For the rest of the setup, you may continue reading this documentation in text format, or you can read the html version directly from your website. Go to the following URL:
Just substitute your actual web site name in place of "yourwebsite.com". Throughout the rest of this documentation, your web site will be referred to as "yourwebsite.com".
Using your web browser go to:
If everything is working OK so far, you should have a screen display with four things you can click on, "Database Setup", "Country Selections", "IP to Country", and "Documentation".
The very first time you run this, you can only do two things, view the documentation or run the database setup utility. So, if you're ready to begin, click on "Database Setup". Don't click on "Country Selections" or "IP to Country" until after the database setup has been completed.
NOTE: This does not require a database like mySQL or Postgre. The database is fully contained within 256 new files that will be created in your "country2" directory.
Once you click on "Database Setup", a new page will display in your browser that says at the top:
"Generate Database Files for countryhtblock package"
If the page appears with no error messages, then your combination of web server and php functionality is working at this point. You should see a web page with some text and a single button that can be clicked on. If any error messages were displayed from either your browser, your web server, or php building a page with error messages, then something is wrong and needs to be fixed.
The most likely problem at this point is php isn't working for you. However, if you've downloaded this package with the intentions of using it, I have to assume you already have a functional php system running. If not, check the internet for help on getting it working for you. Getting php working is not the subject of this documentation.
It's OK if you get errors at this point because your website isn't affected yet. Your website is still functioning as always until we edit the .htaccess file.
If you get a screen that says "Internal Server Error", you might have a permission problem with one of the two directories or the files within them. Rather than guessing at the problem, check your error log if you know how to access it and read it. It will give you a clue about the problem. In some cases, the permissions on the country2 directory might be too much. Maybe your server is configured to not like 777. If so, try 775 or 755 on the country2 directory. 755 is the best as long as the web server can write in the directory.
If you see errors referring to individual files within the country1 or country2 directories, then you will have to adjust the permissions on those files as well. When the archive was originally packed up, the permissions were preset the way they should be to function correctly. All the php files were set at 775 and any text file or html file was set at 664. These settings aren't always maintained when unpacking or unzipping an archive.
If you received no apparent errors, move on...