#!/usr/local/bin/perl
# Bitch: a program to submit junk to search engines..
# Submit-Bitch 2.0, a product of Gomad Heavy Industries.

# Notes: the first incarnation appears to work.. New features that should
# be added are: 1. Sectionalized form. (fill out a, or a+b or a+b+c) which
# gives you options for a few general webcrawlers, to specific targeted
# directories. 2. Use whois and integrated webcrawler to get address and
# company information, site description, and keywords. Give the user the
# option to use it or to fill it in hisself. Display the info on a 
# form (main page + 1) so he can edit it then submit it.
$OURNAME="submit.cgi";

require 'cgi-lib.pl';
&ReadParse;
if ($in{'action'} eq "") {
	&newurl;
} elsif ($in{'action'} eq "frame") {
	&frames;
} elsif ($in{'action'} eq "doit") {
	&doit;
} elsif ($in{'action'} eq "bequiet") {
	&bequiet;
} else {
	print <<EOF;
Content-Type: text/html

Opps, somthing went ary, you shouldnt be seeing this!
EOF
}

#
# newurl: default action of this script. Will prompt the user to enter the
# address he wishes to submit to engines.
#

sub newurl {
print "Content-type: text/html\n\n";
qs_spew("header.html");

print <<EOF;
<h1>Quick Submit</h1>
<p>Promote your site by registering it with the top search engines. This
tool will allow you to do this in seconds. Simply enter your URL and email
address below and click GO.</p>
<p>Submitting your URL without properly preparing your website with the
appropriate 'spyder food' may be a futile act. Find out how to prepare
your website before submitting it on our <a href=tips.html>Tips
Page</a></p>

<form action=$OURNAME method=get>
<input type=hidden name=action value=frame>
<table><tr><th>WebSite URL:</th><td>
<input type=text name=url size=40 value="http://www.website.com/">
</td><tr><th>Your Mail Address:</th><td>
<input type=text name=email value="user\@domain.net">
EOF

#</th></tr><tr><th>
#<select name=locale>
#<option default value="">Locale
#<option value=FL>Florida
#<option value=CA>California
#</select>
#</th><th>
#<select name=topic>
#<option default value="">Category
#<option value=comp>Computers and Internet
#<option value=food>Food, Restrants, and Dining
#</select>
print <<EOF;
</td></tr><tr><th colspan=2>
<input type=submit value=Go>
</th></tr></table>
</form>
<font size=-1>NOTICE: We do not sell, track, or otherwise use email
addresses entered in this form for anything except for the express
purpose of search engine registration.</font>

EOF
qs_spew("footer.html");
}


#
# Frames: Frames are ugly, but hitting the back button is uglier!
# The top frame contains the 'click me!' buttons, bottom is the target
# which will display the result of 'click me!'

sub frames {
print <<EOF;
Content-Type: text/html

<frameset rows="50%, *" frameborder=yes border=1 framespacing=0>
EOF
print "<frame src=\"$OURNAME?action=doit&url=".$in{'url'}."&email=".
	$in{'email'}."\" name=application>\n";

print <<EOF;
<frame src="$OURNAME?action=bequiet" name=data>


</frameset>
<noframes>
EOF
&doit;
print "</noframes>\n";
}

#
# doit: Display clickable links to register the URL's with search engines.
#
sub doit {

print "Content-type: text/html\n\n";
qs_spew("header.html");
print <<EOF;
<h1>Quick Submit</h1>
<p>Click on each of the search engines below to submit your site for
indexing. Engines take anywhere from 15 minutes to 2 months to include
your site in their databases.</p>

EOF
open(ENG,"engine.dat");
while (<ENG>) {
	@arr = split(/\\/,$_);
	$arr[1] =~ s/\|EMAIL\|/$in{'email'}/g;
	$arr[1] =~ s/\|URL\|/$in{'url'}/g;
	print "<a target=data href=\"".$arr[1]."\">".
		$arr[0]."</a> "."<br>\n";
}
close ENG;

qs_spew("footer.html");

}

sub bequiet {
print <<EOF;
Content-Type: text/html

<pre></pre>
EOF
}

sub qs_spew {
  ($filename) = @_;
  open(FILE,$filename);
  while(<FILE>) {
    print $_;
  }
  close FILE;
}
