March 04, 2005
Dealing With Referrer Spam
Category: Site Management
In the last year referrer spam has been increasingly common. The target of the spammers are those people who publish their stats and/or referrers on their web sites, the spammers hope that by getting their links on those pages they will increase their visibility on search engines. Regardless of whether we do or don't publish our referrers we all get hit by referrer spam.
There is a way of combatting referrer spam using the .htaccess file. Basically what you need to do is create a list of referrers that are banned from your site. You can edit your .htaccess file using the File Manager in cPanel.
Log into cPanel and click File Manager, which will open in a new window. You will see something like this: (click to see a larger version)
Next, click on the folder next to public_html - this will open the public_html folder (if you click on the name you will only get a list of options for the folder) and you will see the following:
![]()
If you don't have an existing .htaccess file I will tell you how to create one near the end. Assuming you do, this time you need to click on the name of the .htaccess file and you will see some options appear in the top, right-hand side of the File Manager screen:
![]()
Click on Edit File. If you already have something in there you need to copy and past it into notepad and save it somewhere safe.
You need to add the following to the bottom of your .htaccess file:
SetEnvIfNoCase Referer ".*(terashells|crescentarian|future-2000|6q|yelucie|smsportali|nutzu|ronnieazza|isacommie|
chat-nett|musicbox1|psxtreme|credit|canadianlabels|8gold|texas-hold|hold-em|holdem|
fidelityfunding|condo|sportsparent|mortgage|spoodles|money|cash|hotel|houseofseven|stmaryonline|
newtruths|popwow|oiline|flafeber|thatwhichis|tmsathai|pisoc|crepesuzette|mediavisor|commerce|
easymoney|911|////.vi|gb////.com|4free|macsurfer|teen|pussy|discount|blogincome|lillystar|aizzo|
webdevsquare|laser-eye|escal8|xopy|vixen1|linkerdome|youradulthosting|fick|inkjet-toner|fuck|ime.nu|
perfume-cologne|italiancharmsbracelets|shoesdiscount|psnarones|hasfun|casino|gambling|poker|porn|sex|
paris|gabriola|nude|xxx|hilton|pics|video|adminshop|devaddict|iaea|empathica|insuranceinfo|atelebanon|
handy-sms|peng|just-deals|pisx|rimpim).*" BadReferrer
order deny,allow
deny from env=BadReferrer
The section in bold needs to be one, unbroken line otherwise you will get server errors when you try to view your site. It's best if you copy and paste into notepad (make sure word wrap is off) and get that long line right, then copy it into the file edit screen in cPanel. As you can see, it looks like there is a hard return after SetEnvIfNoCase Referer and before BadReferrer but there isn't, they are spaces.
Click Save and close the editing screen, which will have been opened in a new window. You should be able to access your site as normal, if you get any errors at all contact me.
Keep an eye on your stats and you should see those fake referrers dropping off your stats. As new URLs appear you can edit the list in the .htaccess file as necessary by adding string| after the "("
If you don't have an exisiting .htaccess file in public_html you will have to create one. You can create it in something like notepad and ensure that you have the one long line in the middle. call it .htaccess and upload it to your public_html folder either by using File Manager or your ftp client.
Thanks for this solution go to Dorothea at Caveat Lector
Posted by ShelaghG at 11:40 AM | Comments (1)
December 23, 2004
Logging In Using SSH
Category: Site Management
If you like to work from the command line you can log into the server via SSH. There is an SSH utility within cPanel but I find it rather slow and unpleasant to use. Putty is a great little SSH client - just download the executable file, save it to your PC and you're set to go.
To use it open the file, enter your domain name and make sure the SSH option is clicked. At this point you can enter a name in Saved Sessions and click Save - this will make logging into the server quicker in the future, just double-click on the name you saved and away you go. This first time you will have to click Load.
This will connect to the server and you will get a warning message (click to enlarge)
![]()
Click Yes, then enter your username and password at the prompts (these are the same as your cPanel login). You only get the warning message the first time you use Putty to connect to a domain, it will not appear in future sessions.
Posted by ShelaghG at 09:19 PM | Comments (0)
Exporting A MySQL Database From The Command Line
Category: Site Management
Log into the server via SSH, either through cPanel's SSH utility or a SSH client such as Putty. At the prompt type :
mysqldump -h server -u username -ppassword database > filename
server - your MySQL server name (usually localhost)
username - your database username
password - your database password (note there is no space between -p and the password)
database - your database name
filename - the name you want for the dump file
Download the file via FTP.
Posted by ShelaghG at 09:02 PM | Comments (0)
Exporting Your MySQL Database
Category: Site Management
Although a full back up of your account is taken every night there may be occasions when you want to take an export of your database(s); before an MT upgrade is a good time to do one, if the upgrade goes wrong you may need to re-install MT.
Taking a backup of your MySQL database is easy, the only downside is it can take a while if you're on a dial-up connection and have a big database. In the past I've had trouble trying to back up databases using Internet Explorer, for some reason it resets the connection part way through unless the database is very small, however I've had no problems downloading backups of large databases using Firefox.
The first thing you need to do is log into cPanel. At the bottom-right there's a link to PHPMyAdmin.

Click on the link and PHPMyAdmin will open in a new window.
On the left-hand side you will see the name of your database (if you have more than one database there will be a drop-down list.

Click on the name of your database to select it.
When you select your database the right-hand side of the window will change. You'll see a list of the tables on the right and a row of tabs at the top.

Click on the Export tab.
This will load the export view on the right-hand side of the window. You need to make the following selections :
Export - underneath the list of tables click "Select All", the list of tables should turn grey.
SQL options - in Structure the following boxes should be ticked : Add DROP TABLE, Add AUTO_INCREMENT value, Enclose table and field names with backquotes. In Data none of the boxes should be checked.
Tick the save as file but DO NOT enter a file name.
Your screen should look like this (click to enlarge)
![]()
Finally click on the "Go" button. A download box should open and you can select somewhere on your PC to save the file. (click to enlarge)
![]()
As you can see PHPMyAdmin assigned a perfectly sensible file name.
Posted by ShelaghG at 07:59 PM | Comments (0)
Changing File Permissions
Category: Site Management
If you log into your account via SSH you can bring up a list of files using the ls command. To see more information about the files use ls -l. This will bring up a list of files in the following format:
-rw-r--r-- 1 username groupname 13987 May 5 22:58 filename
The first part, -rw-r--r-- tells you if it's a file or a directory and what permissions exist. The first character is usually "-"(meaning it's a file) or "d" (it's a directory). Occasionally you will see "l" or "s" which denotes a linked directory or a symbolic link. The next 9 characters indicate the permissions, r=read, w=write, x=executable. These permissions are assigned to user (the owner of the file), group (the group the user belongs to) and other (anybody else). Just to make things more confusing permissions also have numerical values assigned to them:
Read=r=4
Write=w=2
Executable=x=1
The command used to change file permissions is chmod. Depending how extensively you want to change the permissions there are 2 ways to use the command. The first way is:
chmod ugo+rwx filename or chmod ugo-rwx filename
This is more useful if you just want to tweak the permissions. "ugo" refers to user, group, other - in other words who you want to assign the permisions to. You do not have to use all 3. "rwx" indicates the permissions you want to assign. Again, you do not have to use all 3 which is why using the chmod command this way is so useful for teaking file permissions. Use + to give permissions and use - to take them away.
For example if you realise you've assigned write permissions to everybody and only the user should have write permissions (otherwise anybody can update your file!) use the command:
chmod go-w filename
The second way to use the chmod command is by assigning permissions using numerical values. You need to specify a 3 digit number. The first digit is the user's permissions, the 2 digit is the group permissions and the 3rd digit is everyone else's permissions. You need to add together the read, write and executable values to arrive at each digit (see above for these values). You would use the command like this:
chmod 755 filename
755 is the value commonly assigned to cgi scripts. The user has full permissions (denoted by the 7). Both the group and other permissions are set to 5, ie, read and executable.
Many ftp packages allow you to change file permissions. You can also change via the Cpanel interface.
Posted by ShelaghG at 06:30 PM | Comments (0)

