Thursday, June 28, 2012

Check Valid domain name in php

This post explain how to check domain name is valid or not

Domain Name Full fill the following Conditions
  • Domain Name Must contain Alpha Numeric 
  • Only special character (-) hyphen. is allowed on domain names.
  • Check the generic domain extension (.com, .edu, .gov, .int, .mil, .net, and .org)
  • All International domain extensions (TLDs) approved by ICANN

Check Valid domain name in php using Regular Express and preg_match


function is_valid_domain_extension($domain)
 return preg_match('/^([a-z0-9]([-a-z0-9]*[a-z0-9])?\\.)+((a[cdefgilmnoqrstuwxz]|aero|arpa)|(b[abdefghijmnorstvwyz]|biz)|(c[acdfghiklmnorsuvxyz]|cat|com|coop)|d[ejkmoz]|(e[ceghrstu]|edu)|f[ijkmor]|(g[abdefghilmnpqrstuwy]|gov)|h[kmnrtu]|(i[delmnoqrst]|info|int)|(j[emop]|jobs)|k[eghimnprwyz]|l[abcikrstuvy]|(m[acdghklmnopqrstuvwxyz]|mil|mobi|museum)|(n[acefgilopruz]|name|net)|(om|org)|(p[aefghklmnrstwy]|pro)|qa|r[eouw]|s[abcdeghijklmnortvyz]|(t[cdfghjklmnoprtvwz]|travel)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])$/i',$domain);

// Example 
// .MZ the domain for Republic of Mozambique
// I aware of the Region when I am working for this function.
echo is_valid_domain_extension(""); // 


Thursday, June 21, 2012

Create a Zip Archive File Using PHP

Today we are going to program, How to build a Zip Archive from the Entire Directory or Create Zip file from selected file from server. Here is the solution to Create Zip file with PHP

Following PHP Program you can build Zip file
1 . Zip Entire Directory
2.  Zip Selected Files


$createZipFile=new CreateZipFile;


define("ZIP_DIR",1); // Make it 0 to Archive selected file(s)

//Code toZip a directory and all its files/subdirectories

$fd=fopen($zipName, "wb");

Download This Script     Download Script    

Monday, June 11, 2012

redirect with WWW htaccess

If you need to redirect your domain name with "WWW" you can use the following htaccess code for Apache based web servers.

Redirect with WWW htaccess

Options +FollowSymLinks
RewriteEngine On

# Mention Domain name

RewriteCond %{HTTP_HOST} ^ [NC]
Rewriterule ^(.*)$$1 [R=301,NC]

# OR
# get domain name automatically.

RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

Saturday, June 9, 2012

Custom File upload control jQuery

Making Stylish HTML Form file input control in designing part of Web Layout was create browser compatibility issues and upload problems. Customizing Form Input Control using following jQuery technique.


(function($) {
    $.fn.fileControl = function(options) {
        /* TODO: This should not override CSS. */
        var settings = {
            width : 250
        if(options) {
            $.extend(settings, options);
        return this.each(function() {
            var self = this;
            var wrapper = $("<div>")
                                "width": settings.imagewidth + "px",
                                "height": settings.imageheight + "px",
                                "background": "url(" + settings.image + ") 0 0 no-repeat",
                                "background-position": "right",
                                "display": "inline",
                                "position": "absolute",
                                "overflow": "hidden"
            var filename = $('<input class="file">')
                                 "display": "inline",
                                 "width": settings.width + "px"


                        "position": "relative",
                        "height": settings.imageheight + "px",
                        "width": settings.width + "px",
                        "display": "inline",
                        "cursor": "pointer",
                        "opacity": "0.0"

            if ($.browser.mozilla) {
                if (/Win/.test(navigator.platform)) {
                    $(self).css("margin-left", "-142px");                    
                } else {
                    $(self).css("margin-left", "-168px");                    
            } else {
                $(self).css("margin-left", settings.imagewidth - settings.width + "px");                

            $(self).bind("change", function() {


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Custom File Upload Control -</title>

<script type="text/javascript" src=""></script>
<script type="text/javascript" src="jquery.filecontrol.js"></script>

<script type="text/javascript">


// Custom File Input Control
 image: "browse_btn.png",
 imageheight : 39,
 imagewidth : 128,
 width : 175,

<style type="text/css">
body,td,th {
 color: #D3BCA7;
body {
 background-color: #333;

.attachment, .attach


<form method="post" enctype="multipart/form-data">
<input type="file" class="attachment" /><br />
<input type="file" class="attachment" /><br />
<input type="file" class="attachment" /><br />
<input type="submit" class="attach" value="Upload" />


Copy Button Image