Solved

CGI Searcher

Posted on 2001-07-28
9
183 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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
 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access Control Entries lost in Windows folders 3 54
Stupid git question 2 89
ROBOFTP UNZIP 1 46
Grunt Copy file to another destination. 1 37
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

810 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