Solved

CGI Searcher

Posted on 2001-07-28
9
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

710 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