Article View: de.comp.lang.php
Article #24Re: Validate Domain Name
From: Darren Casey
Date: Sat, 01 Jul 2000 00:00
Date: Sat, 01 Jul 2000 00:00
53 lines
3244 bytes
3244 bytes
On Fri, 30 Jun 2000 13:23:37 +0200, "Jose Luis Rodr�guez Sevilla" <joseluis@REMOVEMEferca.com>
wrote:
>> How i can to validate a domain name that only must contain this characters
$bad_letters=array(
"!","\"","�","$","%","^","&","*","(",")","+","=","�",
"`","|","\\",".",",","<",">","?","/","{","}","[","]",
":",";","@","'","~","#"," ","�","�"
);
$min_allowed_len=3;
$max_allowed_len=60;
//----------------------------------------------------------------------------------------------
//Function to check a valid domain name has been entered
//I.E. Under s certain length
//No bad chars
//Note does not do a whois lookup
//Returns BLANK = Empty, TOLARGE, TOSMALL, BADLETTERS, OK
//----------------------------------------------------------------------------------------------
function checkdomain($domainname)
{
//Define Variable for use in this function
global $bad_letters;
global $max_allowed_len;
global $min_allowed_len;
// if $domainname is blank perform the following
if ($domainname=="")
return 'BLANK';
//Check to see if the domain name is to long
if (strlen($domainname)>$max_allowed_len)
return 'TOLARGE';
//Check to see if the domain name is to short
if (strlen($domainname)<$min_allowed_len)
return 'TOSMALL';
//search the $domainname for any of the bad letters
for($i=0; $i<count($bad_letters); $i++)
// strstr = find (haystack, needle)
if (strstr($domainname,$bad_letters[$i]))
//if it contains bad letters then return with the value bad letters
return 'BADLETTERS';
//if not and is ok then return with OK
return 'OK';
}
--
HTTP://WWW.PHP3HOSTING.COM ($) HTTP://WWW.PHP3HOSTING.CO.UK (�)
Website Hosting from $4.80/�3pm -- .COM/.NET $39.98/�24.99 - Search Engine Submission $4.78/�2.99
PHP3/4, Your own MySQL server, Full CGI capabilities, Shell Access, FTP, POP3, WAP
Support Forums - http://www.php3hosting.com/forum/
Technical Details
Message-ID:
<nrgslsc10vfd364ct0etqejcf2h4omb0c0@4ax.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8jhse0$p0o$1@talia.mad.ttd.net> <8jhvq9$s86$1@talia.mad.ttd.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10f92b,4026a23bcd365605 X-Google-Attributes: gid10f92b,public X-Google-Thread: 1148a8,4026a23bcd365605 X-Google-Attributes: gid1148a8,public X-Google-Thread: 10ce1c,4026a23bcd365605 X-Google-Attributes: gid10ce1c,public X-Google-Thread: 10b1d3,4026a23bcd365605 X-Google-Attributes: gid10b1d3,public From: Darren Casey <darren@php3hosting.com> Subject: Re: Validate Domain Name Date: 2000/07/01 Message-ID: <nrgslsc10vfd364ct0etqejcf2h4omb0c0@4ax.com> X-Deja-AN: 641278909 Content-Transfer-Encoding: 8bit References: <8jhse0$p0o$1@talia.mad.ttd.net> <8jhvq9$s86$1@talia.mad.ttd.net> Content-Type: text/plain; charset=ISO-8859-1 X-Abuse-Info: Otherwise we will be unable to process your complaint properly X-Complaints-To: abuse@GigaNews.Com X-Trace: sv2-mXgb0YP02Hmdl72HFZkYte29BMQ0yW+yPIkGPYArJ2oJCIZ4mg00cPJAFKMRhMedkrqtjLmgWjajecH!YpL1zIAub+I= Organization: Giganews.Com - Premium News Outsourcing MIME-Version: 1.0 NNTP-Posting-Date: Sat, 01 Jul 2000 14:10:41 CDT Newsgroups: de.comp.lang.php,ba.php,fr.comp.infosystemes.www.auteurs.php,ufra.lists.php