Archive for the ‘Uncategorized’ Category

How To Protect a Folder Using .htaccess From Command Line

Thursday, August 28th, 2008

We do often meet password protected directories on the Web. This is usually used to hide some information that should not be visible to all site users. Most common is .htaccess protection, that allows you to restrict users at Apache level and is also knows as http authentification. Today I will tell you how to protect your directory using command line.

As usually we need root access to the server and need to go to the folder which is waiting to be protected. First of all we need to create an .htaccess file that should contain the information that authentification is required to access this folder. The most common sample comes below:

AuthGroupFile /dev/null
AuthName “Closed User Group”
AuthType Basic
AuthUserFile /path_to_htpasswd_file/.htpasswd
require valid-use
r

Usually .htaccess and .htpasswd files are located in the same folder, but you can move .htpasswd anywhere you like: you will just need to point to its absolute location in .htaccess.  Then go to the directory where you’re planning to put your .htpasswd file.

Now we need to have username and password - that’s enough. The following command will create your .htpasswd file with login data so you can use it immediately.

htpasswd -bcm .htpasswd user password

You can read more about this command at Apache Site. But this command will help you to create a password file without any specific knowledge.

Please, note that .htpasswd is just the file name: you’re welcome to store your passwords in the files with any file names, but it would be better if it is started with a dot and if this file is stored in the directory that is not accessible from web.

How to Install Zip Functions Support For PHP

Monday, August 25th, 2008

Using zip files is a common practice for web. Zip archives are very useful as they are supported by all major operating systems and don’t require any special software. XP and Vista have the embedded support of this file format, you won’t also have problems opening these files in Linux. You can also work with these files in PHP. in order to do this, you should have ZZIPlib installed - it allows the easiest way to work with zip archives.

In this article I will tell you how to add zip file support for your PHP installation. As usually, we will need root access to our server with PHP compiled from source files.

In this article I will describe how to add zip support to PHP5 as it is installed at most servers at the moment. My OS is CentOS, but the installation should not differ from other operating systems, it’s easy enough to add zip functions.

First of all we need to ensure we have zlib installed. Run rpm -qa | grep zlib to check whether it is already installed and install it using yum if it is not present in the list created by the output of previous command. yum install zlib* should install everything related to zlib - that’s what we need to run zip.

Then run phpinfo() and copy the configure line you have. It should look like: ./configure –with-apxs –with-curl –with-curl-dir=/usr/local/lib –with-gd –with-gd-dir=/usr/local –with-gettext –with-jpeg-dir=/usr/local/lib –with-kerberos, etc. Then you need to add –enable-zip to this line.

Then you need to go to the directory where PHP source files are located. If you server has Directadmin installed, you should go to /usr/local/directadmin/customapache - your PHP files should be located there. Then change directory to the one with PHP source files and run the configuree command with –enable-zip added. Then - make and make install as usually.

After this all you need is to reboot apache. Your PHP installation should now support zip functions.

Excellent Software to Listen to Online Radio Stations

Sunday, August 3rd, 2008

Online radios are now as usual as FM radio stations. There are some details that make online radios more useful than the usual ones. The first is the diversity - online radios have greater variety of songs and genres, than usual radios. It is easier to switch between them, there are no annoying advertising messages and so on.

The best thing I found from online radios is that the variety of songs I can listen to is quite infinite and I am unable to keep such a number on my PC, even if I had several thousands of gigabytes of storage.

The program I found is named Screamer Radio and is absolutely free for use. It allows not only to listen tracks online, you can also record anything that is broadcasted into most popular formats. I remember the times I tried to record tracks from FM radio, when we didn’t know what are CD and mp3 discs :). Then the quality was very low but I was happy to have any kind of music. Now it’s much easier to find the radio you like.

Main interface of the program is screenshotted below:

Software comes with a great number of presets, so you don’t need to search for the radios - everything is organized very well, and you’re welcome to add your own channels. The list of genres has lots of presets. Here it is:

I really love this software that discovered online radios for me.

Free PHP Script to Work With File Sharing Services

Wednesday, July 16th, 2008

Today I found a nice script for those who need to manage file shares on most known filesharing services, like rapidshare.com and depositfiles.com. Here is the description from the developer site:

PHP RapidGet Pro — this is the rich set of PHP scripts to work with fileshares. Allows you to manage your downloads and uploads of fileshares.

What the script can do:
— Send files by mail, with split
— Support partial download with Resume feature
— Upload files to remote ftp servers
— File splitting with fixed filesize
— Pack file download
— Proxy Support
— Download\upload with premium account
— Pack files to Tar, Tar.bz2, Tar.gz, Zip, Rar
— Extension change
— Mass file rename
— Access to the script password
— Configuration almost of all elements

The list of supported service for download is extremely big:
100pudovo.net
2shared.com
archiv.to
axifile.com
www.axifile.com
binfile.org
cocoshare.cc
www.cocoshare.cc
d.turboupload.com
depositfiles.com
divshare.com
www.divshare.com
download.yousendit.com
w10.easy-share.com
w11.easy-share.com
w12.easy-share.com
w13.easy-share.com
w14.easy-share.com
w15.easy-share.com
w16.easy-share.com
w17.easy-share.com
w18.easy-share.com
w19.easy-share.com
w20.easy-share.com
filedepot.biz
filefactory.com
www.filefactory.com
fileho.com
filemaster.ru
www.filemaster.ru
files.filefront.com
filefront.com
files.to
filesend.net
fileshare.in.ua
getfile.biz
ifolder.ru
filearchiv.ru
multifile.ru
letitbit.net
100pudovo.net
r6.letitbit.net
r1.letitbit.net
megarotic.com
www.megarotic.com
megaupload.com
www.megaupload.com
momupload.com
mytempdir.com
www.mytempdir.com
sr1.mytempdir.com
oreys.com
www.oreys.com
filemashine.com
oxyshare.com
paid4load.de
www.paid4load.de
pirateshare.net
quicksharing.com
www.rapidshare.com
rapidshare.com
rapidshare.de
rogepost.com
rugcw.com
rutube.ru
www.rutube.ru
sendspace.com
www.sendspace.com
slil.ru
zalil.ru
softsearch.ru
www.softsearch.ru
skan.ru
www.skan.ru
downloads.ru
www.downloads.ru
freesoft.ru
www.freesoft.ru
softportal.com
www.softportal.com
speedyshare.com
storeandserve.com
www.storeandserve.com
uafile.com
www.uafile.com
ultrashare.net
up-file.com
www.up-file.com
up.spbland.ru
uploaded.to
www.uploaded.to
verzend.be
www.verzend.be
webfile.ru
www.2shared.com
www.4shared.com
adme.ru
www.adme.ru
www.bestsharing.com
www.egoshare.com
icefile.org
icefile.net
icefile.com
www.rapidshare.ru
rapidupload.com
www.savefile.com
www.sharebigfile.com
www.sharing.ru
www.speedshare.org
www.upload.com.ua
www.upload2.net
upload2.net
uploading.com
www.user.kz
www.xcitenetwork.com
youtube.com
www.youtube.com
zshare.net
zupload.com

The script is completely free and easy to understand. Happy file sharing with PHP! :)

How to Add an IP to a Linux Server

Sunday, July 13th, 2008

When you decide to rent a dedicated server, you almost in all cases get more than one IP address. This is used for DNS management and other stuff that is related to unique IPs. For example, you want to assign a dedicated IP to one of your site.

Let’s take we don’t have any panel installed (like CPanel, DirectAdmin, etc). How do we add an IP to server using command line only?

First of all, we need to login as root to perform IP addiction. Then we need to go to the folder with a configuration file:

cd /etc/sysconfig/network-scripts

I’d suggest you to backup your existing configuration if something goes wrong. Here is the command:

cp ifcfg-eth0 ifcfg-eth0_backup

Here I think that your main network interface is eth0, you should replace it with your interface name if it differs. We need to duplicate your working configuration file in order to create a new one for a new IP address we will add.

cp ifcfg-eth0 ifcfg-eth0:1

The command above copies your config file within the same directory. Now we need to open it with vi

vi ifcfg-eth0:1

Now we need to replace DEVICE=”eth0″ with DEVICE=”eth0:1″ and change IP address string IPADDR=”xxx.xxx.xxx.xxx” to the string with the IP you’re adding. You will probably need to assign this IP to your server on each boot. Then check the string below - it should look like ONBOOT=”yes”. Change this parameter to Yes if necessary. That’s all, let’s save the file by pressing ESC, then :wq, then Enter.

Let’s enable it by issuing the following command:

/sbin/ifup eth0:1

Now  if you type /sbin/ifconfig you should see your IP address under eth0:1 section.

Do service network restart. This will restart your network interfaces. You’re done. Your IP should be accessible at the moment,

Working With E-mail Using Telnet

Friday, July 11th, 2008

We often send and receive e-mails. Thanks to spammers, we do more receive mail than send it, but it is not the glue. We usually use e-mail clients that are negotiating with POP3 (IMAP) and SMTP servers. Though IMAP is more secure, POP3 is much simpler and you can find it anywhere. But… let’s imagine your e-mail client like Microsoft Outlook or The Bat! disappeared from your PC and you need to send and receive your e-mails. I will show you how to do it using telnet.

In order to connect to your mail server (I’ll start with SMTP server) you neet to know its address and port that is used if it is not standard. Usually it should be 25, but some administrators set up other ports to ensure protection. We’ll suppose we have a mail server that is accepting requests at port 25. So in order to connect to it we need to enter the following command:

telnet your.mailserver.com 25

This will open a telnet session to your server. Then I’ll show you the complete log of sending an e-mail - it is quite clear and you can see the commands entered. I found it here

telnet smtp.voliacable.com 25
Trying 82.144.192.38…
Connected to mail.voliacable.com.
Escape character is ‘]’.
220 mail.voliacable.com ESMTP Sendmail 8.12.9/8.12.9; Thu, 6 Jan 2005 00:50:47 +0200 (EET)
mail from:saygak@voliacable.com
250 2.1.0 saygak@voliacable.com… Sender ok
rcpt to:saygak@ukr.net
250 2.1.5 saygak@ukr.net… Recipient ok
data
354 Enter mail, end with “.” on a line by itself
From:saygak@voliacable.com
To: saygak@ukr.net Subject: Test letter Test Sincerely yours, Michael . 250 2.0.0 j05Moloq006122 Message accepted for delivery
quit
221 2.0.0 mail.voliacable.com closing connection
Connection closed by foreign host.

All entered commands are highlighted in bold. We need to specify mail from - sender address, rcpt to - recipient address and data: the text itself with all the necessary headers that should be located within data before the ending dot.

Another example will illustrate how to receive an e-mail using telnet:

telnet freemail.ukr.net 110
Trying 212.42.65.68…
Connected to freemail.ukr.net.
Escape character is ‘]’.
+OK mPOP POP3 server ready <51152.1104965808@ukr.net>
user saygak
+OK Password required for user saygak
pass MyPassword
+OK saygak’s maildrop has 5 messages (9471 octets)
list
+OK 5 messages (9471 octets)
1 1108
2 3591
3 2701
4 1197
5 874
.
retr 5
+OK 874 octets
From saygak@voliacable.com Thu Jan 06 00:52:35 2005
Return-path:
Received: from sled.volia.net ([82.144.192.38] helo=mail.voliacable.com)
by mx-1.ukr.net with esmtp ID 1CmK15-000Ep6-9T
for saygak@ukr.net; Thu, 06 Jan 2005 00:52:35 +0200
Received: from nowhere.com (nowhere.com [10.10.10.10])
by mail.voliacable.com (8.12.9/8.12.9) with SMTP id j05Moloq006122
for saygak@ukr.net; Thu, 6 Jan 2005 00:51:45 +0200 (EET)
Date: Thu, 6 Jan 2005 00:50:47 +0200 (EET)
From: saygak@voliacable.com
Message-Id: <200501052251.j05Moloq006122@mail.voliacable.com>
X-Authentication-Warning: sled.volia.net: nowhere.com [10.10.10.10] didn’t use HELO protocol
To: saygak@ukr.net
Subject: Test letter
Test
Sincerely yours,
Michael
.
dele 5
+OK message 5 deleted
quit
+OK POP3 server at ukr.net signing off
Connection closed by foreign host.

I think that everything is clear - we are connecting to a POP3 server, authenticating, getting the fifth message for reading and then delete it.

All SMTP commands are described at RFC 821 and POP3 specification may be found here: RFC 1725.

E-gold bankruptcy - Should We Trust or Not?

Wednesday, July 9th, 2008

Some days ago on a news site has appeared a press release about e-gold bankruptcy. This article spreaded very fast over the Web and was translated into many languages. Online currency exchange providers have dropped e-gold rate to the minimum level I’ve seen for recent years. But…

No official message comes from the site itself. It seems that everybody knows that e-gold is a bankrupt except e-gold.com. I don’t think the above source is one we could trust; it has nothing related to official new sources.

Though e-gold was unstable and dDos attacks were so frequent, I’ve always used their services and was satisfied with them, as with their shopping cart interface. They were always hard to communicate: no e-mail support, just support form on the site. But they were stable and I was always sure my money stored there will not disappear.

I think we should not panic after this news, as there were no official confirmations from e-gold.com. As soon as they appear we can do any conclusions, but now… I think we need to wait some time to get it clear…

Selecting All Files in Midnight Commander (mc)

Wednesday, July 9th, 2008

Midnight commander is a very useful tool in Linux. As I found from my previous experience, it is the only way to delete a plenty of files without overloading the server. If you are a Linux newbie, you might not know how to select all the files listed by Midnight Commander (Like Ctrl+A in Windows). I will tell ou this keyboard shortcut, you will find it useful when you want to copy all the files from a folder using graphic interface of mc.

To select all the items listed in mc, you need to Press “Alt”+”Shift”+”+”. This will show you the dialog window with “*” entered. You just need to press Enter (Return) to select all the files.

Solving Certificate Export Error in Mozilla Firefox

Monday, June 30th, 2008

Today I’ve got the message from Webmoney Transfer System that I should update my certificate in order to continue using them (Webmoney is a Russian electronic payment system). I have installed new certificate in Firefox (since it is my default browser) and then tried to export it in order to use it in Opera or any other browser. But the following screen has appeared:

I think everybody loves the following string in an error message: “for unknown reason”. I had to search for it in Google, but unknown reason remained an unknown reason. I’ve found a mailing list for Ubuntu (!) - I was dealing with Firefox in Windows. Here is what i found: Bug. I’ve had absolutely no idea how to fix this unknown error.

The only thing that worked was to disable ALL Firefox add-ons that I have installed. None of them had anything related to certificates, but it really worked! I was able to export my certificate only after this procedure.

Hope this will help you if you face this error exporting your certificates.

Preventing Bandwidth Leak With Correct Out URLs

Wednesday, May 21st, 2008

There is a common practice to use outgoing links from your site to track visitor activity. For example, your site is www.site.com, and external links look like www.site.com/out.php?url=http://anothersite.com . It is OK for counters and traffic tracking, but may be used for an uncommon way. It this sample you may replace http://anothersite.com with any other site and your site will redirect to it. Do you understand what can it be used for?

Spamming, phishing and other stuff like this often relies on such bugs. You may receive abuses from anybody because you cannot know what kind of sites will be promoted and what will be the way to do it.
Even monsters, like Google and ADRiver have such a traffic leak. I recently found in my mailbox e-mails with links to:
http://www.google.fr/pagead/SOME_PARAMS&adurl=SPAMMER’s URL and http://ad.doubleclick.net/SOME_PARAMS?SPAMMER’s URL .
How do you prevent such things? First of all, never use such a construction with url=http:// and so on. You can assign an unique id for each URL and store it into database or text file and create outgoing URLs with such IDs. www.site.com/out.php?id=YOUR_ID will be much better and will save you from this malicious activity.

Be patient with standard scripts, as some of them contain such a vulnerability. For example, Autorank Pro and some other may contain such URL syntax. Have a nice day and make your URLs in a correct way!