Solved

CGI Searcher

Posted on 2001-07-28
9
179 Views
Last Modified: 2013-12-25
Dear Sir,

What I want is - I wanted a text file and on that file, whenever anyone registered them selves like, Let say domains registration process. when ever user register thier domain like www.anything.com it will search the text file and tell them if the domain is available i dont wanted to involve INTERNIC WHOIS DATABASE, when ever user register thier domain , thru web interface form and let say the user is looking for www.ab.com and that domain is available and then user hit submit button after submitting the form and when he submit the form, the ab.com is got in to the text file on my server, so after if any other user is looking for the ab.com it will tell them that ab.com is already book.. by looking the text file. how I am going to do that. Please let me know. Thanks.
0
Comment
Question by:sohaib69
  • 6
  • 3
9 Comments
 
LVL 8

Expert Comment

by:bebonham
ID: 6330300
so you don't care if the domain is registerd with internic

right?

this is purely internal?
0
 
LVL 1

Author Comment

by:sohaib69
ID: 6330770
yes this is purly internal...
0
 
LVL 8

Accepted Solution

by:
bebonham earned 100 total points
ID: 6330789
here is a crude example

#!/usr/local/bin/perl

use CGI ':standard';




### vars

$dfile='domain.txt';  ##datafile for storing domain names
####


print header, start_html;


if(!param())
{
if(-e $dfile)
{
open NAMES, $dfile;

@names=<NAMES>;
close NAMES;

print "the names already in use are:<BR>";
foreach(@names)
{
print "$_<BR>";
}
}
print "pick a domainname like books.com<BR>";
print start_form,
textfield(-name=>'domain'), submit();
}

if(param('domain'))
{
my $d=param('domain');
open NAMES, $dfile;

while(<NAMES>)
{
if($_=~/$d/i)
{
print h1('sorry that is taken');
exit;
}
}
close NAMES;

open NAMES, ">>$dfile";
print NAMES param('domain') . "\n";
close NAMES;
print "done, hit back button and reload prev. page";
}
0
 
LVL 1

Author Comment

by:sohaib69
ID: 6330800
Is that a script which can tell if the domain is taken or not right, so how is going to be the html file

when ever user submit the form by putting the domain what is going to be the field name of the domain box , so that it can tell if the domain is taken or not.

thanks for ur help
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:sohaib69
ID: 6330803
$dfile='domain.txt';  ##datafile for storing domain names

and that file is going to be like

$dfile='/home/www/domain.txt';  ##datafile for storing domain names

the location of the text file right..

0
 
LVL 1

Author Comment

by:sohaib69
ID: 6330811
what is the problem with that script is, when ever I look for the domain like abc.com it's just storing the domain. like i do abc.com , and yahoo.com first it says , after putting yahoo.com done, hit back button and reload prev. page.. then after I reload page it show that name yahoo.com on that file..

What I want the user can look for a domain by html form and then this file can tell if the domain is available, and then after this script registered the domain by storing on that domain.txt .. You know what I mean
0
 
LVL 1

Author Comment

by:sohaib69
ID: 6330836
Excellen question thats what I am looking for, and you made my work more easier, but also as I mention on my next ticket please tell me what to do with that .. Thanks
0
 
LVL 1

Author Comment

by:sohaib69
ID: 6331024
the script Accepts anything, like if you enter books.tatat.tete or books.sex or anything .  let say if I wanted to limit the script to search only .net and nothing else except for .net how I am going to do that. so that no one cant search that script to books.com or books.tatat.tete or books.com just only books.net where I wILL modify the script so that it will just search .net let me know please..
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6331941
try this:

#!/usr/local/bin/perl

use CGI ':standard';




### vars

$dfile='domain.txt';  ##datafile for storing domain names
@allowedDomains=qw/.net .com .org/;  ## only accept these domains

####


print header, start_html;


if(!param())            

if(-e $dfile)
{
open NAMES, $dfile;

@names=<NAMES>;
close NAMES;

print "the names already in use are:<BR>";
foreach(@names)
{
print "$_<BR>";
}
}
print "pick a domainname like books.com<BR>if your name is taken ";
print "or if it is not valid we will return an error message\n";
print start_form,
textfield(-name=>'domain'), submit();
}

if(param('domain'))
{
my $d=param('domain');

$d=~/.*(\..*)$/;
$true=0;
foreach(@allowedDomains)
{
if($1 eq $_)
{
$true=1;
}
}
unless($true){
print h1("sorry, we do not allow $1");
exit};

open NAMES, $dfile;

while(<NAMES>)
{
if($_=~/$d/i)
{
print h1('sorry that is taken');
exit;
}
}
close NAMES;        

open NAMES, ">>$dfile";
print NAMES param('domain') . "\n";
close NAMES;
print "done, hit back button and reload prev. page";
}  

                   
Bob
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now