Find top level domain from international urls with PHP

Submitted by n8coder on Fri, 05/29/2009 - 00:50

The format of both "" and "" is similar for php. But one of them is top level domain and the other one is a subdomain. explode(".", $tld) is not enaugh to find real tld in this case. This function helps to dedect all known tlds including multi-level regional tlds. It could be useful for fraud dedection or finding duplicate sites under different tlds.


Url manipulation with mod_rewrite and php-catcher for beginners

Submitted by n8coder on Tue, 05/26/2009 - 02:56

Url manipulation is one of the hottest areas on the new generation web (2.0). It provides more security and flexibility. It is user and search-engine friendly. The most popular combination is Apache-webserver + mod_rewrite + server-side catcher(mostly a php-file). In this tutorial we use very short examples to make it easy for newbies.

Why url manipulation & mod_rewrite?

  1. more security: hide file location
  2. shorter urls without file extensions like .html
  3. easy to remember / recommend urls
  4. search engine friendly

Fix Google Adsense Search and Drupal Conflict

Google Adsense internal search code does not work with Drupal sites normally. The reason is $_GET[q] conflict between both services. $_GET[q] means "current page" for Drupal and "search query" for Google. We can fix it with two easy steps.

Step 1:
Create a custom page like "websearch" etc under Drupal and add Adsense Code for results page.

Step 2:
Add this code at the top of your Drupal's index.php:

// Fix Drupal-Adsense conflict
$_GET[q] = ($_GET['cx']) ? "websearch" : $_GET[q] ; 

Image watermark with PHP

Submitted by n8coder on Wed, 05/20/2009 - 17:30

To prevent quality images being stolen, we can use PHP to watermark web-images in popular formats like GIF/PNG/JPEG. We print a transparent gif-image on a jpeg-photo in this tutorial. For best results I prefer gif than png, because some png formats require extra functions to print a transparent image. We can convert this script to a batch-watermarker easily to watermark photo albums/galleries with multiple pictures by putting code in a loop or create a function.


Page generation time and http-referers with PHP

Submitted by php5 on Tue, 05/19/2009 - 23:57

Webmasters want to know where all visitors coming from, which pages they visit and how long does it take webpages to load in miliseconds. This tutorial shows how to save your visitors/website details like referrer, browser/client, ip-address, langind-page in three steps. Remember if your scripts ends with exit() or die() command, footer code will not work. Just remove that commands or put them below footer code.

  1. Create your mysql table
  2. Add top-code
  3. Add bottom-code

SQL Query

Alternative captcha ideas for future

Submitted by n8coder on Tue, 05/19/2009 - 16:12

Now there are multiple captcha types against spam/abuse:

image captcha
ascii captcha
audio captcha
math captcha
easy questions

How will next generation captchas look like? I think in the future there will be much more captchas types like:

car captcha
film captcha
famous people
famous places
number to text
word suggestion with add remove extra letters(ie: gogle, new yoork)
animals (ie: which animals do you see in this picture from left to right)
traffic captcha

What do you think what more could be one of next spam-preventing technologies?

Smart Multi-Uploader and Thumbnail Creator from GIF/ JPEG/ PNG with PHP

Submitted by n8coder on Sun, 05/17/2009 - 16:37

Image uploader and thumbnail generatorThis is a multiple image uploader with flexible thumbnail generator. You can set how many images you want to upload at once. This script creates thumbnails automagically from GIF / JPEG and PGN images. You can also disable thumbnails completely. You can change easily path/to/upload and thumbnails max width and height. Script dedect automagically which dimestion to use for resize. It checks image-type and max-image-size. Comments and featurequest are welcome!


Redirect webpages with HTML, PHP, .htaccess, Java+Script, CGI-Perl, ASP.NET and ColdFusion

Submitted by n8coder on Fri, 05/15/2009 - 00:04

Here are examples of code how to redirect an old page/url/domain to a new one with most popular client+server side programming/scripting languages. We use 301 http status code (permanent redirect). If you need temporary redirection use 302 status code instead of 301. It is better to prefer server-side redirection, because some clients are surfing with javascript and http-refresh disabled browsers. Do not forget to test your code first!

.htacces and Mod_Rewrite (Apache Webserver)

Check password strength / safety with PHP and Regex

Submitted by n8coder on Wed, 05/13/2009 - 15:51

Password Validation with PHP and Regular Expressions

What is a good password? Your birthday, favorite star or first school, car, ...? None of them, because all similar passwords are very easy to crack.

My golden rule for safe-passwords is simple: Google or any search engine should NOT find any result for your password-string. But do not search for your password without changing some characters, because it will be visible as clear-text to all networks between your pc and Google server.