Text counter in PHP
A counter is an essential part of a site to know how many people are coming to site. Here is an easy way to make a counter. All you need is access to PHP and be able to chmod a directory. We’re going to save the amount of hits in a .dat file, so you don’t even need a mySQL database. First off, you have create a directory and CHMOD it 777 so PHP can write the counter.dat file.
Here is what we have to do:
- Use the file_exists() function in PHP and see if the counter.dat file exists. If it does, then open the file using the PHP fopen() function.
- Use the PHP fgets() function to find the number of hits there and save it in a variable.
- Add one to the variable.
- Close the file.
- Display the number of hits.
- Open the counter.dat file using the fopen() function and save it as a variable.
- Use the PHP fputs() function to insert the new number of hits.
- Close the file.
- If the counter.dat file doesn’t exist, then use the fopen() function and declare it as a variable.
- Use the Fputs() function and put a “1″ in there.
- Print out that 1 person has come to the page and then close the file.
Here is the code: Read more…
Changing Web Hosts ? Step-By-Step Guide
by Tweak on June 16, 2009
in Domain/Hosting
Every webmaster cringes at the thought of moving hosts. Like moving your home it can be messy and sometimes problems arise. But if you follow these simple steps, your move will be less painful.
Backup Backup Backup
If you’ve been diligent with your backups, you’ve got a lot of insurance to fall back on yet always make the latest backup. If you haven’t, before you do anything else, do a backup now. Backup anything and everything you can and don’t forget your database if your site relies on it. Save at least 2 copies and store them separately. One for you to work with, and the other as an archive. Do not underestimate how easy it is to copy over these files as you make changes or simply mess it up.
If you’re moving to a host who has as different control panel, make a manual backup by downloading all your files because different control panels may not be able to restore the backups made by your old host. They also have different directory structures so your file trees will be in a mess. If you need to, make a small note file with notepad with memos for you to remember the old server configurations. This will help you as you make changes on your new host server and save the confusion moving back and forth between hosts. Remember to make the correct transfer type (ASCII or Binary) as you download. If your download is not right chances are you’ll have a tough time getting your site to work on the new host server.
If server logs are especially important, remember to backup those too. There is no good way of moving logs yet because different hosts may log statistics differently. So the best thing to do is to download it and use a log analyzer on your computer to make references to later on.
Read more…
Create Random Text in PHP
Want to put a random quote on your site? Or randomize some other aspect of your site? It’s easy. You’ll want to use PHP or some other server-side scripting language instead of a client-side scripting language like JavaScript. Server-side languages write the content to the page in html before it ever leaves the server. Search engines will be able to read the content on your page, but with JavaScript they cannot, so you lose any content value of the random code. Also, if a user turns off JavaScript, that random content is lost. Google, MSN, and Yahoo will see that the content is changing often, and that may help your rankings (depending on your implementation).
Here’s how to put the random elements into your page, using PHP.
Step 1:
Create a text file called ‘myData.txt’. Open the file and put in your random elements, placing each random element on its own line, (whether text, images or html). Then place ‘myData.txt’ in the same directory as your page containing the PHP script.
Step 2:
Place the following PHP code into your page where you want the random element:
Read more…
IP country block downloads
All country IP block files are provided in CIDR format, at this time. Please note that we compile these lists from regional IP space providers. To correct any errors please contact your local IP space provider e.g. for Europe it’s Ripe, for North America it’s Arin.
Zone files last updated: Mon Jun 15 05:07:15 EDT 2009
Download compressed tar archive with all zone files in it: all-zones.tar.gz
Read more…
Installing Lighttpd With PHP5 Support On CentOS
Lighttpd is a secure, fast, standards-compliant web server designed for speed-critical environments. This tutorial shows how you can install Lighttpd on a CentOS 5.0 server with PHP5 support (through FastCGI) and MySQL support.
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
Afterwards, we can install Lighttpd like this:
yum install lighttpd Read more…
How to install winrar on CentOS
Rar is one of the common file format use for data compression and archiving. What happen if you have a rar file in Linux ? Don’t panic, just using the ‘rar’ program .There is some intro in Unrar the File.
Today I had to install rar support to archive and split large files. I’ve tried to download an rar from rarlab site
wget http://www.rarlab.com/rar/rarlinux-3.9.b2.tar.gz
Extract it:
tar -xf rarlinux-3.8.0.tar.gz
cd rar
Copy rar & unrar files to /usr/bin:
cp rar unar /usr/bin Read more…
Script to daily email APF status
You are running APF on your server, but sometimes you think “is APF running fine ?”
This script sends you an email with APF satus.
Log in to your server as root
Create the script:
nano apfstatus.sh
Put this on the file:
#!/bin/bash
tail -200 /var/log/apf_log | mail -s "APF Status" youemail@domain.com
Save and Exit
Ctrl+X and Y
Read more…
How to open winrar files with Linux
Introduction
To open RAR (those created with winrar) you will need unrar. There are lots of sites now providing files packaged under the rar format.
So you will need first to install unrar on your systems and therefore be able to list content and unpack the files into your hard disk to be able to work with them.
Installation unrar on Debian / Ubuntu
apt-get install unrar
Installation unrar on Fedora / Centos
Be sure to have rpmforge repository enabled on CentOS
yum install unrar
Using unrar
To read the contents of the file.
unrar l [filename.rar]
Read more…
How To remote backup with rsync
This is probably the simply way to backup data to other server using a secure protocoal an minimum bandwidh.
Note:
BackupServer.com – Is the backup server
MainServer.com – Is the server you want to backup
- Login to the server you want to backup
- Creating a key with the ssh-keygen utility:
ssh-keygen -t rsa -N '' (these are two single quotes) - Copy RSA encryption key to the backup server:
scp ~/.ssh/id_rsa.pub username@backupserver.com:keys/server1
ssh username@backupserver.com mergekeys
How To Install IonCube Loader
If you need IonCube loader in order to encode scripts. You will need to install IonCube loadar on your box.
- Login to your server as root and download the loaderfor your server: http://www.ioncube.com/loader_download.php
- Then extract it
tar -zxvf ioncube_loaders.tar.gz
cd ioncube - Copy ioncube-install-assistant.php file to a www diretory
cp ioncube-install-assistant.php /home/username_here/www