Simple Server Response Checker With PHP and cURL

I often need to check website lists for error codes (yesterday I’ve told you about 4XX codes). There is a simple solution written in PHP that allows to d this. You need cURL support enabled (please, let me know if I need to describe cuRL installation process on my blog) and that’s all. Here is the code: <?… Read More »

Uncategorized

Showing an Image on Remote Server Error

If you’re hotlinking images from other servers (this is often used when adding banner codes), you might face the situation when remote server becomes unavailable. This will spoil your site look, if you don’t add a simple code, that allows to solve this issue. <img src=”BANNER URL(REMOTE)” onError=”this.src=’LOCAL URL SHOWN ON REMOTE SERVER ERROR'” height=31 width=88> This simple… Read More »

Uncategorized

How to Edit Crontab From Command Line

Editing crontab from command line In some cases you need to edit your crotab via command line interface. That’ s easy, but if you’ re not familiar with vi and its commands, you might have problems saving and editing cronjobs. First of all, let’s[ list your current crontab contents by issuing the following command: crontab – l This… Read More »

Uncategorized

Adding Wildcard DNS Using Directadmin

Now to add wildcard DNS using DirectAdmin If you ‘re planning to use multiple subdomains within your account you will need to setup wildcard DNS resolving. There is an easy solution in DirectAdmin that allows you to do this without modification of certain configuration files. Just log in as admin and choose DNS administration tab under Admin Tools.… Read More »

Uncategorized

Cleaning HTML Code From Tags with PHP

Often, especially when you copy text from WYSIWYG browser editors, the code is copied with tags you don’t need. In any way, if you’re working with text in PHP, you will often need to clean it from useless HTML code. Let’s see how can we do this. If yo need to clean the entire code, you’ll need php… Read More »

Uncategorized

Detecting High Server Load in Linux

For a long time I’ve been thinking that load average numbers that are produced by top command output truely represent server load. My first idea was that these numbers show me the percentage of relative server load, combining CPU usage, Memory usage, etc. Somebody even told me that this parameter should not exceed 3. If it is higher… Read More »

Uncategorized

Testing Regular Expressions Online

Just wanted to share some useful links with you. If you often use regular expressions, you might find useful to check them online or anywhere else before your code is executed. First of all, an Online Service that seems to be free: RegExr: Online Regular Expression Testing Tool It allows you to check whatever you want and has… Read More »

Uncategorized

Useful Date Formats in PHP

Often you need to generate a timestamp with PHP. It should represent the current date or the date in the future. It should show the date, month and year in all possible readable formats. I’ve created a list that has most often used date formats. Here it is: F j, Y F j, y F d, Y F… Read More »

Uncategorized

Disable Directory Listing Without Slash – Apache Config

Sometimes you need to deny directory listing on user input. For example, you don’t want your blog to be accessed at http://yoursite.com/blog, using only http://yoursite.com/blog/. This slash is added by mod_dir, that allows automatic adding of trailing slashes. A “trailing slash” redirect is issued when the server receives a request for a URL http://servername/foo/dirname where dirname is a… Read More »

Uncategorized

Getting a Random String From a Big File with PHP

When you’re working with big files, it is not ok to use such functions like file(), file_get_contents, or anything else that loads the whole file content into memory. You often need to take just one random string from a very big file. Let’s take we have a file with proxy servers and should select one of them for… Read More »

Uncategorized