#!/home/y/bin/perl

#use CGI::Carp qw(fatalsToBrowser);

 

#################################################################################################

#

# All-purpose whois script for SimpleNet.  Written by Michael Sussna, October 1999.

#

# Two forms call this, both on the same HTML page, /whois/lookup.html.

#

# Form1 allows a domain lookup with user-specified tld.  Lookup details are optional.

# Form2 allows lookups on hypothetical domain names based on user or company name, hobby, etc.

#

#################################################################################################

 

use LWP::UserAgent;

use HTTP::Request;

 

use lib '/Space/CGI/modules';

 

use YDNSTools;

use UDB_access;

 

require '/Space/CGI/libraries/domains-api-post.lib';

require '/Space/CGI/libraries/yid.pl'; # yahoo id extractor

 

 

#require '/Space/CGI/libraries/domain-name-availability.pl';

#require '/Space/209.132.1/068/cgi-bin/domain-name-availability.pl';

 

@result_rows = "";

$result_rownum = 0;

$num_per_page = "500";

$error_flag = 0;

 

#################################################################################################

#DoTimeIn();

 

GetFormInput();

Init();

 

# Action 1 = internal to blackbox, 2 = external (e.g. from banner)

 

SetupLookAndFeel();

PostSetupInit();

 

if       ($aForm{action} eq "")                  {Error("0"); ExitScript();}

if       ($aForm{name} eq "")

{

       if       ($landing)                 {OutputPage(); ExitScript();}

       else                               {Error("1"); ExitScript();}

}

 

if     (

              $aForm{update_my_list}

       or       $aForm{review_my_list}

       or       $aForm{'view_more.x'}

       or       $aForm{update_my_list_viewmore}

       )

                                          {UpdateAndOutputPage(); ExitScript();}

      

if     (

              $aForm{update_my_list_review}

       or       $aForm{secure_checkout}

       )

                                          {UpdateReview(); ExitScript();}

 

if       ($aForm{num_domains} > 0)        {NotFirstTime();}

else                                      {$first_time = 1; Form1();}

 

OutputPage();

 

ExitScript();

 

#################################################################################################

sub Init

{

       $|=1;

 

       $property = "domains";

#       $property = $aForm{property};

 

       yid_main();

 

       if       ($yid)       {$auth_time_limit = 172800;} # 48 hours

       else          {$auth_time_limit = 3600;} # 1 hour

 

       # Set the domain bit of the cookie as appropriate according to the cookie RFC

       $cookie_auth_domain = $ENV{HTTP_HOST};

       $cookie_auth_domain =~ s/^(whois)\.//i;

       $cookie_auth_domain =~ s/\:.*//;

       $cookie_auth_domain_nodot = $cookie_auth_domain;

       $cookie_auth_domain = ".$cookie_auth_domain";

 

       if       (

                     (not $aForm{update_my_list})

              and       (not $aForm{update_my_list_review})

              and       (not $aForm{secure_checkout})

              and       (not $aForm{review_my_list})

              and       (not $aForm{'view_more.x'})

              and       (not $aForm{update_my_list_viewmore})

              )

       {

              print "Content-type: text/html\n\n";

       }

 

       $woops = "";

       $woops_count = 0;

       $first_time = 0;

       $landing = 0;

 

       if ($aForm{ext} eq "" or $aForm{ext} eq "null") {$aForm{ext} = "\.xxx";}

 

       $num_oingo_fields_before_tlds = 3;

 

       srand (time ^ $$ ^ unpack "%32L*", `ps axww | gzip`);

       $ran = int rand 1000000000;

 

       if ($aForm{name} eq "" and $aForm{action} =~ /2/) {$landing = 1;}

       $secondary_avails_here = 0;

       if ($aForm{'view_more.x'})

       {

              $something_new = 1;

              @oingo_tldfields = split /,/,$aForm{oingo_tld_fields};

       }

       else       {$something_new = 0;}

       $something_more = 0;

       $tld_requested = 0;

 

       $aForm{template} =~ /(.*)_.*/;

       $template_directory = $1;

      

       $biz_blurb = "

              <div align=\"left\"><font size = -2 face = arial,helvetica>

              Registrations in the .biz top-level domain (TLD) must be used or intended to be used primarily for bona fide

              business or commercial purposes. For more information about appropriate & inappropriate use, refer to the

              <a href=\"http://domains.yahoo.com/inwwagree.html\">Domain Registration Agreement</a>.</font><br><br></div>

       ";

}

 

 

sub SetupLookAndFeel

{

       # Template 1 is the results page, template 2 is the landing page.

       # Split each into two parts.  Part "a" is output before the blackbox output,

       # part "b" after it.

      

       # Look and feel variables in the blackbox html are first filled

       # in from the defaults in the defaults file.  Then any user-defined

       # overrides are applied on top of that, from the user variables file.

       # The black box html (with search results, if any) is inserted at

       # the appropriate point in the template html.

 

       if (-e "/Space/209.132.1/068/Server/Documents/Templates/$template_directory/$aForm{template}_1.html"

       and -e "/Space/209.132.1/068/Server/Documents/Templates/$template_directory/$aForm{template}_2.html")

       {

              $template1_path = "/Space/209.132.1/068/Server/Documents/Templates/$template_directory/$aForm{template}_1.html";

              $template2_path = "/Space/209.132.1/068/Server/Documents/Templates/$template_directory/$aForm{template}_2.html";

       }

       else

       {

              $template1_path = "/Space/209.132.1/068/Server/Documents/Templates/domains/domains_a_1.html";

              $template2_path = "/Space/209.132.1/068/Server/Documents/Templates/domains/domains_a_2.html";

       }

 

       open(TEMPLATE1_FILE,"$template1_path") or die "Can't open $template1_path: $!\n";

       while ($line = <TEMPLATE1_FILE> and $line !~ /blackboxoutput/)

       {

              $template1a_html .= $line;

       }

       while ($line = <TEMPLATE1_FILE>) {$template1b_html .= $line;}

       close TEMPLATE1_FILE;

 

       open(TEMPLATE2_FILE,"$template2_path") or die "Can't open $template2_path: $!\n";

       while ($line = <TEMPLATE2_FILE> and $line !~ /blackboxoutput/)

       {

              $template2a_html .= $line;

       }

       while ($line = <TEMPLATE2_FILE>) {$template2b_html .= $line;}

       close TEMPLATE2_FILE;

 

       open(BLACKBOX_FILE,"/Space/209.132.1/068/Server/Documents/Templates/blackbox.html") or die "Can't open /Templates/blackbox.html: $!\n";

       while ($line = <BLACKBOX_FILE>)

       {

              $blackbox_html .= $line;

       }

       close BLACKBOX_FILE;

 

       if       ($landing)

       {

              $blackbox_html =~ s/searchbox_/landing_searchbox_/ig;

              $blackbox_html =~ s/main_border_/landing_main_border_/ig;

              $blackbox_html =~ s/main_interior_/landing_main_interior_/ig;

       }

       else

       {

              $blackbox_html =~ s/searchbox_/results_searchbox_/ig;

              $blackbox_html =~ s/main_border_/results_main_border_/ig;

              $blackbox_html =~ s/main_interior_/results_main_interior_/ig;

       }

 

       # Populate look and feel variables hash with default values

       open(DEFAULT_VARIABLES_FILE,"/Space/209.132.1/068/Server/Documents/Templates/default/default_variables.txt") or die "Can't open /Templates/default/default_variables.txt: $!\n";

       while ($line = <DEFAULT_VARIABLES_FILE>)

       {

              if       ($line =~ /^\#/ or $line =~ /^\s/)       {next;}

              if       ($line =~ /=/)

              {

                     ($name,$value) = split /=/,$line,2; # 2 allows ='s in value

                     chomp($value);

                     $lookandfeel{$name} = $value;

              }

       }

       close DEFAULT_VARIABLES_FILE;

 

       # Override any look and feel variables with values that user has supplied

       open(USER_VARIABLES_FILE,"/Space/209.132.1/068/Server/Documents/Templates/$template_directory/$aForm{template}_variables.txt") or die "Can't open /Templates/$template_directory/$aForm{template}_variables.txt: $!\n";

       while ($line = <USER_VARIABLES_FILE>)

       {

              if       ($line =~ /^\#/ or $line =~ /^\s/)       {next;}

              if       ($line =~ /=/)

              {

                     ($name,$value) = split /=/,$line,2; # 2 allows ='s in value

                     chomp($value);            

                     $lookandfeel{$name} = $value;

              }

       }

       close USER_VARIABLES_FILE;

 

       # Do this now so any overrides already seen are overriden by this

       if ($landing) {$lookandfeel{searchagain_type} = "box";}

 

       if ($aForm{review_my_list}

       or $aForm{update_my_list}

       or $aForm{update_my_list_review}

       or $aForm{'view_more.x'}

       or $aForm{update_my_list_viewmore} 

       )

       {

              $lookandfeel{primary_border_color} = "#FFFFFF";

       }

 

       if ($lookandfeel{user_show_landing} =~ /y/ or $lookandfeel{user_show_results} =~ /y/)

       {SetupUseridAppearance();}

 

       # Apply merged variable values to blackbox html

       foreach $key (sort keys %lookandfeel)

       {

              $temp = $lookandfeel{$key};

              $blackbox_html =~ s/$key/$temp/ig;

       }

}

 

 

sub PostSetupInit

{

       @tld = split /,/, $lookandfeel{tld_list};

 

       @default_tlds = split /,/,$lookandfeel{default_tld};

      

       $num_primary_domains = $#tld + 1;

 

       $num_secondary_rows_page1 = $lookandfeel{secondary_display_number1};

       if       ($lookandfeel{secondary_display_number2} =~ /all/)

       {

              $max_viewmore_rows = 999;

       }

       else       # Set to 0 to turn off

       {

              $max_viewmore_rows = $lookandfeel{secondary_display_number2};

       }

#       $num_secondary_rows_page1 = 3;

#       $max_viewmore_rows = 50;  # Set to 0 to turn off

}

 

 

sub ExitScript

{

       #DoTimeOut();

       exit; 

}

 

 

sub OutputPage

{

       OutputBlackboxA();

       OutputBeginning();

 

       if       ($error_exists or $landing)                   {}

       elsif

       (

              $aForm{update_my_list}

       or       $aForm{review_my_list}

       or       $aForm{update_my_list_review}

       or       $aForm{update_my_list_viewmore}

       or       $aForm{secure_checkout}

       )

                                                        {OutputReview();}

       elsif       ($aForm{'view_more.x'})                        {OutputViewMore();}

       else       # I.e., first time

       {

              OutputPreliminary();

              if       (not $aForm{'view_more.x'})            {OutputPrimary();}

              if       ($lookandfeel{secondary_show} =~ /y/i)       {OutputSecondary();}

              if        ($lookandfeel{user_show_results} =~ /y/i

                     and $yid

                     and not $aForm{'view_more.x'})            {OutputUserid();}

              OutputButtonsResults();

              OutputEndForm();

       }

 

       OutputSearchagain();

       if ($landing and $lookandfeel{user_show_landing} =~ /y/i)

       {

              $first_time = 1;

              $aForm{name} = "fromlanding";

              $num_domains = $aForm{num_domains};

              OutputFormAndMiscHiddens();

              if ($yid) {OutputUserid();}

              UpdateDomainlistCookieHiddens(); # Needs OutputUserid done 1st to get s_d_l

              @sorted_page_list = @page_list;

              $num_domains = @sorted_domain_list;

              OutputButtonsResults();

              OutputEndForm();

       }

        OutputBeacon();

        OutputEnd();

        OutputBlackboxB();

}

 

 

sub OutputBlackboxA

{

       SetupPersonalization();

      

       if       ($landing)                               # Landing page

       {

              (@out_lines_a) = split /\n/,$template2a_html;

              (@out_lines_b) = split /\n/,$template2b_html;

       }

       else                                             # Results page

       {

              (@out_lines_a) = split /\n/,$template1a_html;

              (@out_lines_b) = split /\n/,$template1b_html;

       }

      

       foreach $line (@out_lines_a) {print "$line\n";}

      

       SetupQuerystring(); # Do now, before split, even if not used

 

       (@out_blackbox_lines) = split /\n/,$blackbox_html;

       ChopupBlackbox();

             

       $bbi = 0;

}

 

 

sub SetupPersonalization

{

       if       ($yid)

       {     

              $person = "

<table width=750 cellpadding=2 cellspacing=0 border=0 bgcolor=\"#dcdcdc\" align=\"center\">

  <tr>

    <td><font face=arial size=-1><b>Welcome, $yid!</b></font></td>

    <td align=right nowrap><font face=arial size=-1><a href=http://edit.yahoo.com/config/eval_profile?.done=http%3a//domains.yahoo.com/>Account Info</a> -

      <a href=http://login.yahoo.com/config/login?logout=1&.intl=us&.src=dom&.done=http%3a//login.yahoo.com/config/login%3f.intl=us%26.src=dom%26.done=http%253a//domains.yahoo.com>Sign Out</a></font></td>

    </tr>

</table>";

       }

       else

       {

              $person = "

<table width=750 cellpadding=2 cellspacing=0 border=0 bgcolor=\"#dcdcdc\" align=\"center\">

  <tr>

    <td><font face=arial size=-1><b>Welcome, Guest</b></font></td>

    <td align=right nowrap><font face=arial size=-1>

      <a href=http://login.yahoo.com/config/login?.src=dom>Sign In</a></font></td>

  </tr>

</table>";

       }

 

       if       ($landing)

       {

              $template2a_html =~ s/begin personalization bar -->/begin personalization bar --> $person/;

       }

       else

       {

              $template1a_html =~ s/begin personalization bar -->/begin personalization bar --> $person/;

       }

}

 

 

sub ChopupBlackbox

{

       CaptureBeginning();

       CaptureBeginForm();

       CapturePrimary();

       CaptureSecondary();

       CaptureUserid();

       CaptureReview();

       CaptureResultSubmit();

       CaptureSearchagain();

       CaptureBeacon();

       CaptureEnd();

}

 

 

sub CaptureBeginning

{

       my $bbi = 0;

       until (@out_blackbox_lines[$bbi] =~ /Start the begin-form tag/)

       {

              push @blackbox_beginning_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

}

 

 

sub CaptureBeginForm

{

       my $bbi = 0;

       while (@out_blackbox_lines[$bbi] !~ /Start the begin-form tag/) {$bbi++;}

       until (@out_blackbox_lines[$bbi] =~ /End the begin-form tag/)

       {

              push @blackbox_beginform_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

       push @blackbox_beginform_lines,@out_blackbox_lines[$bbi];

}

 

 

sub CapturePrimary

{

       my $bbi = 0;

       while (@out_blackbox_lines[$bbi] !~ /Start Holding Table Primary Output/) {$bbi++;}

       until (@out_blackbox_lines[$bbi] =~ /End Holding Table Primary Output/)

       {

              push @blackbox_primary_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

       push @blackbox_primary_lines,@out_blackbox_lines[$bbi];

}

 

 

sub CaptureSecondary

{

       my $bbi = 0;

       while (@out_blackbox_lines[$bbi] !~ /Start Holding Table Secondary Output/) {$bbi++;}

       until (@out_blackbox_lines[$bbi] =~ /End Holding Table Secondary Output/)

       {

              push @blackbox_secondary_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

       push @blackbox_secondary_lines,@out_blackbox_lines[$bbi];

}

 

 

sub CaptureUserid

{

       my $bbi = 0;

       while (@out_blackbox_lines[$bbi] !~ /Start Holding Table Userid Output/) {$bbi++;}

       until (@out_blackbox_lines[$bbi] =~ /End Holding Table Userid Output/)

       {

              push @blackbox_userid_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

       push @blackbox_userid_lines,@out_blackbox_lines[$bbi];

}

 

 

sub CaptureReview

{

       my $bbi = 0;

       while (@out_blackbox_lines[$bbi] !~ /Start Holding Table Review Output/) {$bbi++;}

       until (@out_blackbox_lines[$bbi] =~ /End Holding Table Review Output/)

       {

              push @blackbox_review_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

       push @blackbox_review_lines,@out_blackbox_lines[$bbi];

}

 

 

sub CaptureResultSubmit

{

       my $bbi = 0;

       while (@out_blackbox_lines[$bbi] !~ /Start Result Submit Buttons/) {$bbi++;}

       until (@out_blackbox_lines[$bbi] =~ /End Result Submit Buttons/)

       {

              push @blackbox_resultsubmit_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

       push @blackbox_resultsubmit_lines,@out_blackbox_lines[$bbi];

}

 

 

sub CaptureSearchagain

{

       my $bbi = 0;

       while (@out_blackbox_lines[$bbi] !~ /Start Holding Table Searchagain Output/) {$bbi++;}

       until (@out_blackbox_lines[$bbi] =~ /ALL three are included here\./)

       {

              push @blackbox_searchagain_start_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

       push @blackbox_searchagain_start_lines,@out_blackbox_lines[$bbi];

       $bbi++;

       until (@out_blackbox_lines[$bbi] =~ /End searchagain = none/)

       {

              push @blackbox_searchagain_middle_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

       push @blackbox_searchagain_middle_lines,@out_blackbox_lines[$bbi];

       $bbi++;

       until (@out_blackbox_lines[$bbi] =~ /End Holding Table Searchagain Output/)

       {

              push @blackbox_searchagain_end_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

       push @blackbox_searchagain_end_lines,@out_blackbox_lines[$bbi];

}

 

 

sub CaptureBeacon

{

       my $bbi = 0;

       while (@out_blackbox_lines[$bbi] !~ /Start Beacon/) {$bbi++;}

       until (@out_blackbox_lines[$bbi] =~ /End Beacon/)

       {

              push @blackbox_beacon_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

       push @blackbox_beacon_lines,@out_blackbox_lines[$bbi];

}

 

 

sub CaptureEnd

{

       my $bbi = 0;

       until (@out_blackbox_lines[$bbi] =~ /End Holding Table Searchagain Output/) {$bbi++;}

       $bbi++;

       while (@out_blackbox_lines[$bbi])

       {

              push @blackbox_end_lines,@out_blackbox_lines[$bbi];

              $bbi++;

       }

}

 

 

sub OutputBlackboxB

{

       foreach $line (@out_lines_b) {print "$line\n";}

}

 

 

sub OutputBeginning

{

       my $bbi = 0;

       while (@blackbox_beginning_lines[$bbi]) {print "@blackbox_beginning_lines[$bbi]\n"; $bbi++;}

}

 

 

sub OutputPreliminary

{

       UpdateDomainlistCookieHiddens();

       @sorted_page_list = @page_list;

       $num_domains = @sorted_domain_list;

       OutputFormAndMiscHiddens();

}

 

 

sub OutputPrimary

{

       my $bbi = 0;

       while (@blackbox_primary_lines[$bbi] !~ /Put out the primary results messages/) {print "@blackbox_primary_lines[$bbi]\n"; $bbi++;}

       print "@blackbox_primary_lines[$bbi]\n";

       $bbi++;

      

       OutputResultsMessage();

 

       while (@blackbox_primary_lines[$bbi] !~ /Start "primary results" table/) {print "@blackbox_primary_lines[$bbi]\n"; $bbi++;}

       print "@blackbox_primary_lines[$bbi]\n";

       $bbi++;

 

       while (@blackbox_primary_lines[$bbi] !~ /Start loop through search for primary list of tlds/) {print "@blackbox_primary_lines[$bbi]\n"; $bbi++;}

       print "@blackbox_primary_lines[$bbi]\n";

       $bbi++;

 

       PutOutResults();

 

       print "$hidden_domains\n";

      

       while (@blackbox_primary_lines[$bbi] !~ /End Holding Table Primary Output/) {print "@blackbox_primary_lines[$bbi]\n"; $bbi++;}

       print "@blackbox_primary_lines[$bbi]\n";

       $bbi++;

}

 

 

sub OutputSecondary

{

       my $bbi = 0;

       while (@blackbox_secondary_lines[$bbi] !~ /Start Secondary output results heading 1/) {print "@blackbox_secondary_lines[$bbi]\n"; $bbi++;}     

       print "@blackbox_secondary_lines[$bbi]\n";

       $bbi++;

 

       if ($lookandfeel{secondary_show} !~ /n/i)

       {

              BuildSecondaryOutput();

              if ($something_new)

              {

                     print <<EOF;

                        <table width="100%" border=0 cellspacing=0 cellpadding=0 bgcolor="$lookandfeel{secondary_header_bgcolor}">

                          <tr bgcolor="$lookandfeel{secondary_header_bgcolor}">

                            <td><font face=arial,helvetica color="$lookandfeel{secondary_header_text_color}"><b>$lookandfeel{secondary_header_text_text}</b></font></td>

                            <td></td>

                          </tr>

                        </table>

EOF

              }

       }

 

       while (@blackbox_secondary_lines[$bbi] !~ /Start Secondary output results heading 2/) {print "@blackbox_secondary_lines[$bbi]\n"; $bbi++;}     

       print "@blackbox_secondary_lines[$bbi]\n";

       $bbi++;

 

       if ($lookandfeel{secondary_show} !~ /n/i and $something_new)

       {

              print "$secondary_output1";

       }

 

       while (@blackbox_secondary_lines[$bbi] !~ /Start Secondary output results body/) {print "@blackbox_secondary_lines[$bbi]\n"; $bbi++;}     

       print "@blackbox_secondary_lines[$bbi]\n";

       $bbi++;

 

       if ($lookandfeel{secondary_show} !~ /n/i and $something_new)

       {

              print "$secondary_output2";

 

              while (@blackbox_secondary_lines[$bbi] !~ /Start Secondary output view more link/) {print "@blackbox_secondary_lines[$bbi]\n"; $bbi++;}     

              print "@blackbox_secondary_lines[$bbi]\n";

              $bbi++;

              print "$secondary_output3";            

       }

 

       while (@blackbox_secondary_lines[$bbi] !~ /Start Secondary Hiddens/) {print "@blackbox_secondary_lines[$bbi]\n"; $bbi++;}     

       print "@blackbox_secondary_lines[$bbi]\n";

       $bbi++;

 

       if ($lookandfeel{secondary_show} !~ /n/i and $something_new)

       {

              if ($aForm{'view_more.x'})

              {

                     $num_domains = $aForm{num_domains};

                     foreach $oingotld (@oingo_tldfields) {$oingo_tld_fields .= $oingotld . ",";}

                     chop $oingo_tld_fields; # Remove last comma

              }

      

              print "                        <input type = \"hidden\" name = \"oingo_tld_fields\" value = \"$oingo_tld_fields\">\n";

              print "$hidden_domains\n";

       }

        while (@blackbox_secondary_lines[$bbi] !~ /End Holding Table Secondary Output/) {print "@blackbox_secondary_lines[$bbi]\n"; $bbi++;}

       print "@blackbox_secondary_lines[$bbi]\n";

        $bbi++;

}

 

 

sub OutputViewMore

{

       OutputFormAndMiscHiddens();

        OutputSecondary();

       OutputButtonsResults();

       OutputEndForm();

}

 

 

sub OutputUserid

{

       my $bbi = 0;

       AccessUDB();

       BuildUseridDomainstubList();

#       $aForm{name} = $yid;

 

       while (@blackbox_userid_lines[$bbi] !~ /Start Userid output results heading 1/) {print "@blackbox_userid_lines[$bbi]\n"; $bbi++;}     

       print "@blackbox_userid_lines[$bbi]\n";

       $bbi++;

 

       my $colspan = $#tld + 2;

       print <<EOF;

                        <table width="100%" border=0 cellspacing=0 cellpadding=0 bgcolor="$userid_bgcolor">

                          <tr bgcolor="$userid_bgcolor">

                            <td><font face=arial,helvetica color="$userid_text_color">$userid_heading</font></td>

                            <td></td>

                          </tr>

                        </table>

EOF

       while (@blackbox_userid_lines[$bbi] !~ /Start Userid output results body/) {print "@blackbox_userid_lines[$bbi]\n"; $bbi++;}     

       print "@blackbox_userid_lines[$bbi]\n";

       $bbi++;

 

       if ($lookandfeel{user_show_landing} =~ /y/i) {BuildHeaderRow();}

 

       foreach $userid_domainstub (@userid_domainstub_list) {BuildPrimaryContentRowUserid("$userid_domainstub");}

 

       while (@blackbox_userid_lines[$bbi] !~ /Start Userid Hiddens/) {print "@blackbox_userid_lines[$bbi]\n"; $bbi++;}     

       print "@blackbox_userid_lines[$bbi]\n";

       $bbi++;

 

       print "$hidden_domains\n";

 

        while (@blackbox_userid_lines[$bbi] !~ /End Holding Table Userid Output/) {print "@blackbox_userid_lines[$bbi]\n"; $bbi++;}

       print "@blackbox_userid_lines[$bbi]\n";

        $bbi++;

}

 

 

sub SetupUseridAppearance

{

       $userid_heading = '';

       if       ($landing)  

       {

              $lookandfeel{user_border_color} = $lookandfeel{user_landing_border_color};

              $userid_heading = $lookandfeel{user_landing_header_text_text};

              $userid_bgcolor = $lookandfeel{user_landing_header_bgcolor};

              $userid_text_color = $lookandfeel{user_landing_header_text_color};

       }

       else

       {

              $lookandfeel{user_border_color} = $lookandfeel{user_results_border_color};

              $userid_heading = $lookandfeel{user_results_header_text_text};

              $userid_bgcolor = $lookandfeel{user_results_header_bgcolor};

              $userid_text_color = $lookandfeel{user_results_header_text_color};

       }

 

       if ($lookandfeel{user_landing_header_text_bold} =~ /on/)

       {$userid_heading = "<b>$userid_heading</b>";}

}

 

 

sub AccessUDB

{

       my $udb = new UDB_access();

       $udb->uid("y.$yid");

       $udb->add_keys("demog");

       my $demog = $udb->get("demog");

 

       if ($udb->{ERROR})

       {

# comment this out or log it when going live

#              print "ERROR: $udb->{ERROR}";

#              exit;

       }

#      print "demog = $demog<br>\n";

 

       @udb_keys = split /\cA/,$demog;

       foreach $key (@udb_keys)

       {

              my @temp = split /\cB/,$key;

              $udb_data{$temp[0]} = $temp[1];

       }

 

       $first_name = lc($udb_data{'FN'});

       $last_name = lc($udb_data{'LN'});

       $first_initial = substr($first_name,0,1);

}

 

 

sub BuildUseridDomainstubList

{

       @userid_domainstub_list = ("$last_name", "$first_name", "$first_initial$last_name",

       "$first_name$last_name", "$last_name$first_name");

      

       my $work_yid = lc($yid);

 

       $work_yid =~ s/_/-/g;

 

       # Yahoo! ID might match one of other entries based on name.  If so, omit it.

       my $dup = 0;

       foreach $entry (@userid_domainstub_list)

       {

              if ($work_yid eq $entry) {$dup = 1; last;}

       }

 

       if (not $dup) {$userid_domainstub_list[$#userid_domainstub_list+1] = $work_yid;}

}

 

 

sub OutputReview

{

       my $bbi = 0;

        while (@blackbox_review_lines[$bbi] !~ /Start Holding Table Review Output/) {$bbi++;}

       print "@blackbox_review_lines[$bbi]\n";       # Put out comment line

       $bbi++;

        while (@blackbox_review_lines[$bbi] !~ /Start Review table/) {print "@blackbox_review_lines[$bbi]\n"; $bbi++;}

       print "@blackbox_review_lines[$bbi]\n";       # Put out comment line

       $bbi++;

       print "@blackbox_review_lines[$bbi]\n";       # Put out table tag

       $bbi++;

 

       PutReviewForm();

       if ($cookie_domains[0]) {OutputButtonsReview();}

      

        while (@blackbox_review_lines[$bbi] !~ /End Holding Table Review Output/) {print "@blackbox_review_lines[$bbi]\n"; $bbi++;}

       print "@blackbox_review_lines[$bbi]\n";

       $bbi++;

}

 

 

sub OutputSearchagain

{

       my $bbi = 0;

       while (@blackbox_searchagain_start_lines[$bbi] ne '') {print "@blackbox_searchagain_start_lines[$bbi]\n"; $bbi++;}

      

       $bbi = 0;    

       if       ($lookandfeel{searchagain_type} =~ /box/)

       {

              while (@blackbox_searchagain_middle_lines[$bbi] !~ /Set up form for subsequent search/) {print "@blackbox_searchagain_middle_lines[$bbi]\n"; $bbi++;}

              print "@blackbox_searchagain_middle_lines[$bbi]\n";

 

              OutputFormAndMiscHiddensSearchbox();

 

              if ($error_exists)

              {

                     while (@blackbox_searchagain_middle_lines[$bbi] !~ /searchagain message color: display_searchtext/) {print "@blackbox_searchagain_middle_lines[$bbi]\n"; $bbi++;}

                     print "@blackbox_searchagain_middle_lines[$bbi]\n";

                     $bbi++;

                     @blackbox_searchagain_middle_lines[$bbi] =~ s/color=".*"/color="$lookandfeel{error_text_color}"/ig;

                     @blackbox_searchagain_middle_lines[$bbi] =~ s/<b>.*<\/b>/<b>$msg<\/b>/ig;

                     print "@blackbox_searchagain_middle_lines[$bbi]\n";

                     $bbi++;

              }

 

              while (@blackbox_searchagain_middle_lines[$bbi] !~ /End searchagain = box/) {print "@blackbox_searchagain_middle_lines[$bbi]\n"; $bbi++;}

              print "@blackbox_searchagain_middle_lines[$bbi]\n";

              $bbi++;

       }

       elsif       ($lookandfeel{searchagain_type} =~ /link/)

       {

              if ($error_exists)

              {

                     while (@blackbox_searchagain_middle_lines[$bbi] !~ /ALL three are included here/) {print "@blackbox_searchagain_middle_lines[$bbi]\n"; $bbi++;}

                     print "@blackbox_searchagain_middle_lines[$bbi]\n";

                     $bbi++;

                     print "<font face=\"arial\" color=\"$lookandfeel{error_text_color}\"><b>$msg</b></font>";

              }

 

              # Bypass searchagain = box

              while (@blackbox_searchagain_middle_lines[$bbi] !~ /Start searchagain = link/) {$bbi++;}

              $bbi++;

 

              while (@blackbox_searchagain_middle_lines[$bbi] !~ /End searchagain = link/) {print "@blackbox_searchagain_middle_lines[$bbi]\n"; $bbi++;}

              print "@blackbox_searchagain_middle_lines[$bbi]\n";

       }

       else

       {

              if ($error_exists)

              {

                     while (@blackbox_searchagain_middle_lines[$bbi] !~ /ALL three are included here/) {print "@blackbox_searchagain_middle_lines[$bbi]\n"; $bbi++;}

                     print "@blackbox_searchagain_middle_lines[$bbi]\n";

                     $bbi++;

                     print "<font face=\"arial\" color=\"$lookandfeel{error_text_color}\"><b>$msg</b></font>";

              }

 

              while (@blackbox_searchagain_middle_lines[$bbi] !~ /Start searchagain = none/) {$bbi++;}

              print "@blackbox_searchagain_middle_lines[$bbi]\n";

              $bbi++;

              print "@blackbox_searchagain_middle_lines[$bbi]\n";

       }

 

       $bbi = 0;    

       while (@blackbox_searchagain_end_lines[$bbi] ne '') {print "@blackbox_searchagain_end_lines[$bbi]\n"; $bbi++;}

}

 

 

sub OutputBeacon

{

       if ($landing and $lookandfeel{user_show_landing} =~ /n/i) {return;}

 

       my $bbi = 0;

       while (@blackbox_beacon_lines[$bbi] !~ /Start Beacon/) {print "@blackbox_beacon_lines[$bbi]\n"; $bbi++;}

       print "@blackbox_beacon_lines[$bbi]\n"; $bbi++; # Print comment line

       print "@blackbox_beacon_lines[$bbi]\n"; $bbi++; # Print <tr>

       print "@blackbox_beacon_lines[$bbi]\n"; $bbi++; # Print <td>

 

              if          ($aForm{update_my_list} or $aForm{review_my_list} or $aForm{update_my_list_review})

              {

              print <<EOF;

                        <img alt="Yahoo Image" width=1 height=1 border=0 src="http://pclick.yahoo.com/p/s=$lookandfeel{data_beacon_reviewlist}/lng=us/rand=$ran">

EOF

              return;

              }

              elsif       ($aForm{'view_more.x'} or $aForm{update_my_list_viewmore})

              {

              print <<EOF;

                        <img alt="Yahoo Image" width=1 height=1 border=0 src="http://pclick.yahoo.com/p/s=$lookandfeel{data_beacon_viewmore}/lng=us/rand=$ran">

EOF

              return;

              }

             

              # Viewing results

       if ($tld_not_found)    # Unsupported or garbage tld entered

       {

              print <<EOF;

                        <img alt="Yahoo Image" width=1 height=1 border=0 src="http://pclick.yahoo.com/p/s=$lookandfeel{data_beacon_none}/lng=us/rand=$ran">

EOF

       }

       elsif (! $avails_here)       # None available

       {

              print <<EOF;

                        <img alt="Yahoo Image" width=1 height=1 border=0 src="http://pclick.yahoo.com/p/s=$lookandfeel{data_beacon_none}/lng=us/rand=$ran">

EOF

       }

       elsif ($status eq "A")   # Yours is available

       {

              print <<EOF;

                        <img alt="Yahoo Image" width=1 height=1 border=0 src="http://pclick.yahoo.com/p/s=$lookandfeel{data_beacon_yes}/lng=us/rand=$ran">

EOF

       }

       else       # Yours isn't available, but another *is*

       {

              print <<EOF;

                        <img alt="Yahoo Image" width=1 height=1 border=0 src="http://pclick.yahoo.com/p/s=$lookandfeel{data_beacon_other}/lng=us/rand=$ran">

EOF

       }

 

       while (@blackbox_beacon_lines[$bbi] !~ /End Beacon/) {print "@blackbox_beacon_lines[$bbi]\n"; $bbi++;}

       print "@blackbox_beacon_lines[$bbi]\n"; $bbi++;

}

 

 

sub OutputButtonsResults

{

       my $bbi = 0;

       while (@blackbox_resultsubmit_lines[$bbi] !~ /Start Result Submit Buttons/) {print "@blackbox_resultsubmit_lines[$bbi]\n"; $bbi++;}     

       print "@blackbox_resultsubmit_lines[$bbi]\n";

       $bbi++;

 

       if ($avails_here or $secondary_avails_here or $cookie_domains[0])

       {

              print <<EOF;

                  <tr>

                    <td>

                       <table width="100%">

EOF

       }

 

       if ($avails_here or $secondary_avails_here)

       {

              if (not $landing)

              {

                     print <<EOF;

                          <tr>

                            <td align = center>

                              <font size = $lookandfeel{nextstep_msg_size} color = $lookandfeel{nextstep_msg_color} face = arial,helvetica>

                              <b>$lookandfeel{nextstep_msg_text}</b>

                              </font>

                            </td>

                          </tr>

EOF

              }

              print <<EOF;

                          <tr>

                            <td align = center>

                              <table>

                                <tr>

EOF

              PutNextStepButton();

              if ($cookie_domains[0] and not $landing) {PutReviewButton();}

       }

       elsif ($cookie_domains[0])

       {

              print <<EOF;

                          <tr>

                            <td align = center>

                              <table>

                                <tr>

EOF

              PutReviewButton();

       }

      

       if ($avails_here or $secondary_avails_here or $cookie_domains[0])

       {

              print <<EOF;

                               </tr>

                              </table>

                            </td>

                          </tr>

                        </table>

                      </td>

                    </tr>

EOF

       }

 

       while (@blackbox_resultsubmit_lines[$bbi] !~ /End Result Submit Buttons/) {print "@blackbox_resultsubmit_lines[$bbi]\n"; $bbi++;}     

       print "@blackbox_resultsubmit_lines[$bbi]\n";

       $bbi++;

}

 

 

sub OutputEnd

{

       my $bbi = 0;

       while (@blackbox_end_lines[$bbi]) {print "@blackbox_end_lines[$bbi]\n"; $bbi++;}

}

 

 

sub OutputEndForm

{

       print <<EOF;

                    </form>

EOF

}

 

 

sub SetupQuerystring

{

       # Action = 2 because they can't supply a domain name when using the link

       $searchlink_url = "http://whois.domains.yahoo.com/cgi-bin/domain_search.cgi";

       $searchlink_querystring = "?action=2&property=domains&template=$aForm{template}&promotion_code=$aForm{promotion_code}";

       $blackbox_html =~ s/searchlink_href/$searchlink_url$searchlink_querystring/ig;

}

 

#############################################################################################

 

 

sub BuildSecondaryOutput

{

       # Not ideal, but we call and parse on view_more now, so we get field list built.

       # originally, we didn't call/parse on view_more, 'cause we had hardcoded list

       # of Oingo tld's (and fields in general).  Even generating list of tld's from

       # list of primary tld's doesn't work properly for Oingo results because we

       # might see primary tld's that Oingo doesn't recognize.  If that were the case,

       # the secondary (Oingo) results would contain bogus columns for tld's in the

       # primary list but not recognized by Oingo.  So, there's now a hidden field

       # with the domain name, which the Oingo call can use when it's a view_more.

 

       if (not $aForm{'view_more.x'}) {CallOingo(); ParseOingo();}

 

       if ($something_new)

       {

              if       ($aForm{'view_more.x'})       {BuildOingoOutputViewMore();}

              else                        {BuildOingoOutput();}

       }

}

 

 

sub CallOingo

{

       my $domain = "";

       if ($aForm{'view_more.x'}) {$domain = $aForm{name};} else {$domain = $name;}

 

       my $oingo_cid = "YAHO4210";

       $oingo_uid = "$ENV{REMOTE_ADDR}";

       $oingo_uid =~ s/^\d+\.\d+\.//; # Agreement is to just give 'em last two components of IP

      

       my $URL = 'domain.oingo.com/2.0/dsxml.cgi';

      

#my $URL = "www.nameboy.com/xboy/xsearch.php";

 

       foreach $primary_tld (@tld) {$secondary_tlds .= "&tld=$primary_tld";}

 

       my $contentdata = "uid=$oingo_uid&cid=$oingo_cid&s=$domain&fm=ds4$secondary_tlds";

 

#my $contentdata = "primary=$domain&affid=YAHOOTEST";

 

       my $ua = new LWP::UserAgent;

       $ua->timeout(10);

       $ua->agent("Yahoo! Domain Search" . $ua->agent);

 

       my $req = new HTTP::Request 'GET' => "http://$URL?$contentdata";

       $req->header('Accept' => 'text/html');

 

       # send request

       my $res = $ua->request($req);

 

       # check the outcome

       if ($res->is_success)

       {

              # Everything ok

#             print "Oingo success!<br>";

              CutLogRec1("y");

       }

       else

       {

              # Failed

#             print "Oingo error!<br>";

              CutLogRec1("n");

       }

 

       ($a,$raw_oingo_data) = split /]>/, $res->content;

      

       $raw_oingo_data =~ s/<//g;

       $raw_oingo_data =~ s/\/>//g;

       @raw_oingo_data = split /DOMAINS\s*/, $raw_oingo_data;

}

 

 

sub ParseOingo

{

       # Create array of hashes, one hash per domain result

      

       my $line;

 

       # Skip first entry, which has "oingo_domainsense" and

       # next entry.  We skip that next entry because its

       # results are redundant, having the same domain and

       # some or all of the tld's as our primary results.

      

       # Robyn, on 4/25/01, assured me that no tld in the

       # secondary (Oingo) set of tld's would be in that set

       # but not in the primary (default) set of tld's.

       # This way we avoid displaying a row of secondary

       # results that has domain.tlds we've already seen above

       # in the primary results --- if there were even one

       # tld in the Oingo tld list that wasn't in the primary

       # tld list, we'd need to show its result, and therefore

       # the row that it's in, and thus the redundant results.

       # Robyn was aware of this when giving the above decree.

 

       my $first_oingo_parse = 1;

       $oingo_tld_fields = "";

 

       for ($i = 2; $i < $#raw_oingo_data; $i++)

       {

              $line = $raw_oingo_data[$i];

 

              if ($line =~ /oingo_domainsense/) {next;}

              $line =~ s/^<//;

              $line =~ s/\/>?//;

 

              (@work_line) = split / /, $line;

              my %work_hash;

      

              my $i = 0;

              my $yes_row = 0;

              foreach $key (@work_line)

              {

                     if ($key =~ /=/)

                     {

                            ($name,$value) = split /=/,$key;

                            $value =~ s/"//g;

                            $work_hash{$name} = $value;

                           

                            # If any tld result for row is "not registered," put out row                       

                            if ($i >= $num_oingo_fields_before_tlds and $value =~ /n/)

                            {

                                   $yes_row = 1;

                            }

                           

                            if ($first_oingo_parse)

                            {

                                   push (@oingo_result_fields,$name);

                           

                                   # Determine Oingo tld's dynamically from results.

                                   # Submit all tld's from primary list to Oingo.  Parse

                                   # Oingo results to see which tld's it recognizes.

                                   # Add those tld's to list of Oingo tld fields.

 

                                   if ($i >= $num_oingo_fields_before_tlds) # It's a tld

                                   {$oingo_tld_fields .= $name . ",";}

                            }

                     }

                     $i++;

              }

              if ($first_oingo_parse)

              {

                     $first_oingo_parse = 0;

                     chop $oingo_tld_fields; # Remove last comma

                    

                     # (Re)sequence the Oingo tld fields so that they're in

                     # the same order as the primary ones.

                    

                     my $d_tld, $work_list;

                     foreach $d_tld (@tld)

                     {

                            if ($oingo_tld_fields =~ $d_tld) {$work_list .= $d_tld . ",";}

                     }

                     chop $work_list; # Remove last comma

                     $oingo_tld_fields = $work_list;

                     @oingo_tld_field_array = split /,/, $oingo_tld_fields;

              }

             

              # This uses a "reference" - see Perl manual p. 244.

              # It allows us to have array entries that are hashes,

              # like putting the *address* of the hash in, rather

              # than the hash itself.

 

              if ($yes_row) {push(@oingo_results,\%work_hash);}

       }

 

       $num_oingo_tldfields = $#oingo_result_fields - $num_oingo_fields_before_tlds + 1;

       $num_secondary_cols = $#oingo_result_fields - 1; # One col for domain name, one each for tld's

 

       # More than just com/net/org returned, so show secondary results

 

       if ($#oingo_results > 0) {$something_new = 1;}

      

       # More than just first page's worth returned, so allow view more.

       # $#oingo_results is relative to 0, so if 2 results, this is 1;

       # We need more than 1 (com/net/org result) + $num_secondary_rows_page1 to

       # allow view more, so if $num_secondary_rows_page1 = 3, we need > 4 results.

       # This means $#oingo_results needs to be > 3.

 

       if ($#oingo_results > $num_secondary_rows_page1) {$something_more = 1;}

 

 

       # The following example shows how to access the referenced hash entries

 

       # for ($i = 0; $i <= $#oingo_results; $i++)

       # {

       #       for ($j = 0; $j <= $#oingo_result_fields; $j++)

       #       {

       #             print "$oingo_result_fields[$j] = $oingo_results[$i]{$oingo_result_fields[$j]}<br>";

       #       }

       # }

}

 

 

sub BuildOingoOutput

{

       $secondary_output = "";

       $page_start, $page_end;

 

       $page_start = 0;

       $page_end = $num_secondary_rows_page1 - 1;  

 

       # Go through all secondary domains

       # Update domain list and hiddens

       # But only output rows for those in curr page (1st or more page)

 

       for ($i = 0; $i <= $#oingo_results; $i++)

       {

              $secondary_output2 .= BuildContentRow("$i");

       }

 

       if ($something_more) {$secondary_output3 .= BuildFooterRow();}

}

 

 

sub BuildOingoOutputViewMore

{

       CutLogRec1("v");

       $secondary_output = "";

       $page_start, $page_end;

 

       $num_oingo_tldfields = $#oingo_tldfields + 1;

       $num_secondary_cols = $num_oingo_tldfields + 1;

 

       $page_start = $num_primary_domains + ($num_secondary_rows_page1 * $num_oingo_tldfields);

       $page_end = $aForm{num_domains} - 1;

 

       if (not $max_viewmore_rows

       or $aForm{num_domains} < $page_start + ($max_viewmore_rows * $num_oingo_tldfields))

       {

              $page_end = $aForm{num_domains} - 1;

       }

       else

       {

              $page_end = $page_start + (($max_viewmore_rows - 1) * $num_oingo_tldfields);

       }

 

       $secondary_output1 .= BuildHeaderRowViewMore();

 

       # Go through all secondary domains

       # Update domain list and hiddens

       # But only output rows for those in curr page (1st or more page)

 

       # Note: take $num_primary_domains hiddens to process FIRST "row" (not actually output)

       $secondary_output2 .= BuildContentRowViewMore("0");

 

       # Note: take $num_oingo_tldfields hiddens at a time to build row

       for ($i = $num_primary_domains; $i <= $aForm{num_domains} - $num_primary_domains; $i += $num_primary_domains)

#      for ($i = $num_primary_domains; $i <= $aForm{num_domains} - $num_oingo_tldfields; $i += $num_oingo_tldfields)

       {

              $secondary_output2 .= BuildContentRowViewMore("$i");

       }

}

 

 

sub BuildHeaderRowViewMore

{

       my $i;

       my $row = "";

      

       $bgcolor = $lookandfeel{oddrow_color};

       $color_gender = "even";

       $row .= "                                <tr bgcolor=\"$bgcolor\"><td>&nbsp;</td>";

 

       for ($i = 0; $i <= $#oingo_tldfields; $i++)

       {

              $row .= "<td align=\"center\"><font size = -1 face = arial,helvetica>\.<b>$oingo_tldfields[$i]</b></font></td>";                    

       }

      

       $row .= "</tr>\n";

      

       return "$row";

}

 

 

sub BuildContentRow

{

       my $sub = $_[0];

       my $i;

       my $row   = "";

       my $domain = "";

       my $tld = "";

       my $start_num = $num_oingo_fields_before_tlds;

       my $end_num = $#oingo_result_fields;

 

       $domain .= $oingo_results[$sub]{$oingo_result_fields[0]};      

      

       if ($sub >= $page_start and $sub <= $page_end)

       {

              if       ($color_gender eq "odd")

              {

                     $bgcolor = $lookandfeel{oddrow_color};

                     $color_gender = "even";

              }

              else  

              {

                     $bgcolor = $lookandfeel{evenrow_color};

                     $color_gender = "odd";

              }

              $row .= "                                <tr bgcolor=\"$bgcolor\"><td><font size = -1 face = arial,helvetica>$domain</font></td>";

       }

 

       # Put out a cell for each TLD for a row within curr page.

       # Also update domain list and hiddens whether on curr page or not.

 

       foreach $primary_tld (@tld) # Primary tld in ASI results?

       {

              my $tld_found = 0;

              foreach $asi_tld (@oingo_tld_field_array) # Primary tld in ASI results?

              {

                     if ($primary_tld eq $asi_tld) {$tld_found = 1; last;}

              }

 

              my $work_domain = $domain . "." . $primary_tld;

              my $non_asi_tld_avail = 0;

      

              if       (not $tld_found)

              {

                     if ($sub >= $page_start and $sub <= $page_end)

                     {

                            if (not (IsDelegated("$work_domain","127.0.0.1")))

                            {$non_asi_tld_avail = 1;}

#                           $row .= "<td width=\"1%\" align=\"center\" bgcolor=\"eeeeee\"><img src=\"/Templates/img/1x1.gif\" width=35 height=1 alt=\"\" border=\"0\"><br></td>";

                     }

              }

 

              if       (

                            (not $tld_found and $non_asi_tld_avail)

                             or $oingo_results[$sub]{$primary_tld} =~ /n/

                     ) # Avail

              {

                     if ($sub >= $page_start and $sub <= $page_end)

                     {

                            $row .= "<td width=\"1%\" align=\"center\"><img src=\"/Templates/img/1x1.gif\" width=35 height=1 alt=\"\" border=\"0\"><br><input type = \"checkbox\" name = \"$work_domain\"></font></td>";

                     }

                     $domain_list[$#domain_list+1] = "A" . $work_domain . "NU";

#                    $domain_list[$#domain_list+1] = "A" . $work_domain . "NU" if $tld_found;

                     $secondary_avails_here = 1;

              }

              else

              {

                     if ($sub >= $page_start and $sub <= $page_end)

                     {

                            $row .= "<td width=\"1%\" align=\"center\"><img src=\"/Templates/img/1x1.gif\" width=35 height=1 alt=\"\" border=\"0\"><br><font size = -2 face = arial,helvetica color=black>Taken</font></td>";

                     }

                     $domain_list[$#domain_list+1] = "R" . $work_domain . "NU";

#                    $domain_list[$#domain_list+1] = "R" . $work_domain . "NU" if $tld_found;

              }

             

#             if       ($tld_found) # If not in ASI, will throw off view more, so omit

#             {

                     $hidden_name = "domain" . "$#domain_list";

                     $hidden_domains .= "

                       <input type = \"hidden\" name = \"$hidden_name\" value = \"$domain_list[$#domain_list]\">";

#                }

       }

 

       $num_domains = $#domain_list + 1; # 0 thru last num = last num + 1

      

       if ($sub >= $page_start and $sub <= $page_end)

       {

              $row .= "</tr>\n";

       }

 

       return "$row";

}

 

 

sub BuildContentRowViewMore

{

       my $sub = $_[0];

       my $i;

       my $row   = "";

       my $domain = "";

       my $tld = "";

       my $start_num = 0;

       my $end_num;

#      my $end_num = $#oingo_tldfields;

      

       # First time in, use # of dflt tld's because can be diff from # secondary tld's

       $end_num = $num_primary_domains - 1;

#      if ($sub == 0) {$end_num = $num_primary_domains - 1;} else {$end_num = $#oingo_tldfields;}

 

       $sorted_domain_list[$sub] =~ /^(\w)(.+)\..*(\w)(\w)$/;

       $domain = $2;

 

       if ($sub >= $page_start and $sub <= $page_end)

       {

              if       ($color_gender eq "odd")

              {

                     $bgcolor = $lookandfeel{oddrow_color};

                     $color_gender = "even";

              }

              else  

              {

                     $bgcolor = $lookandfeel{evenrow_color};

                     $color_gender = "odd";

              }

              $row .= "                                <tr bgcolor=\"$bgcolor\"><td><font size = -1 face = arial,helvetica>$domain</font></td>";

       }

 

       # Put out a cell for each TLD for a row within curr page.

       # Also update domain list and hiddens whether on curr page or not.

 

       for ($i = $start_num; $i <= $end_num; $i++)

       {

              # Step from 0 to n-1 thru row's tlds

              my $ind = $i;

 

              # Tld may not be 3 characters

              $sorted_domain_list[$sub + $ind] =~ /^(\w)(.+)\.(.+)(\w)(\w)$/;

#             $sorted_domain_list[$sub + $ind] =~ /^(\w)(.+)\..*(\w)(\w)$/;

              $work_status = $1;

              $domain = $2;

              $curr_tld = $3;

              $work_selected = $5;

#             $work_selected = $4;

              $tld = $oingo_tldfields[$i];                          

              my $work_domain = $domain . "." . $tld;

 

              next if $aForm{oingo_tld_fields} !~ /$curr_tld/;        

 

              if ($work_status =~ /A/) # Avail

              {

                     if ($sub >= $page_start and $sub <= $page_end)

                     {

                            $row .= "<td width=\"1%\" align=\"center\"><img src=\"/Templates/img/1x1.gif\" width=35 height=1 alt=\"\" border=\"0\"><br><input type = \"checkbox\" name = \"$work_domain\"></td>";

                     }

                     $domain_list[$#domain_list+1] = "A" . $work_domain . "NU";

                     $secondary_avails_here = 1;

              }

              else

              {

                     if ($sub >= $page_start and $sub <= $page_end)

                     {

                            $row .= "<td width=\"1%\" align=\"center\"><img src=\"/Templates/img/1x1.gif\" width=35 height=1 alt=\"\" border=\"0\"><br><font size = -2 face = arial,helvetica color=black>Taken</font></td>";

                     }

                     $domain_list[$#domain_list+1] = "R" . $work_domain . "NU";

              }

       }

 

       $num_domains = $#domain_list + 1; # 0 thru last num = last num + 1

      

       if ($sub >= $page_start and $sub <= $page_end)

       {

              $row .= "</tr>\n";

       }

 

       return "$row";

}

 

 

sub BuildFooterRow

{

       my $row   = "";

 

       $row .= "                          <tr bgcolor=\"#ffffff\"><td colspan=$num_secondary_cols align=right><input type=\"image\" name=\"view_more\" src=\"/Templates/img/viewmore.gif\" value=\"$lookandfeel{viewmore_button_text}\" vspace=0 border=0></td></tr>\n";

#      $row .= "                          <tr bgcolor=\"#ffffff\"><td colspan=$num_secondary_cols align=right><input type=\"submit\" name=\"view_more\" value=\"$lookandfeel{viewmore_button_text}\"></td></tr>\n";

      

       return "$row";

}

 

#############################################################################################

 

 

sub Form1

{

       if ($aForm{name} eq "" and $aForm{whois} ne "") {$aForm{name} = $aForm{whois};} # trackstar

 

       &EditForm1Input;

}

 

 

sub EditInput

{

       if ($aForm{name} eq "") {Error("1"); ExitScript();}

 

       $name = $aForm{name};

       $name =~ s/^http:\/\///;

       $name =~ s/www\.//;

       $name =~ s/[^a-zA-Z0-9\-\.]//g;

       $name =~ /^([a-zA-Z0-9\-]+)(\..*)*/; # name.name_rest

       $name = $1;

       $name_rest = $2;

 

       while ($name =~ /^-/ or $name =~ /-$/)

       {

              $name =~ s/^-//g;          # Clean up pre-tld part

              $name =~ s/-$//g;          # Clean up pre-tld part

       }

 

       if (length($name) < 1)               {Error("7"); ExitScript();}

       if (length($name) > 63)                     {Error("4"); ExitScript();}

       if ($name =~ /[^a-zA-Z0-9\-]/)               {Error("5"); ExitScript();}

       if ($name =~ /^\-/ or $name =~ /\-$/)       {Error("6"); ExitScript();}

}

 

 

sub EditForm1Input

{

#       &CutLogRec1;

 

       EditInput();

      

       if ($name_rest eq "\.") {$name_rest = "";}

        $name_rest_save = $name_rest;

        $name_rest = lc($name_rest);

 

       # If name_rest null, check ext; else if in tld list, go on; else use name.com

       if       ($name_rest eq "")

       {

              # edit tld

              # if one selected (not Select TLD or ---------) use it

              # else default to .com

              $ext = $aForm{ext};

              $ext =~ tr/A-Z/a-z/;

              if ($ext =~ /\.xxx/)

              {

                     if       ($default_tlds[0])       {$ext = "\." . $default_tlds[0];}

                     else                        {$ext = "\.com";}

              }

       }

       else

       {

              $tld_not_found = 1;

              for ($i = 0; $i <= $#tld; $i++)

              {

                     if ($name_rest eq "\.$tld[$i]")

                     {

                            $tld_not_found = 0;

                            last;

                     }

              }

#             if ($name_rest eq "\.com" or $name_rest eq "\.net" or $name_rest eq "\.org")

              if       (not $tld_not_found)     {$ext = $name_rest;}

              elsif       ($default_tlds[0])       {$ext = "\." . $default_tlds[0];}

              else                        {$ext = "\.com";}

       }

 

       $prefix = $name;

 

       $name .= $ext;

 

       $domain = $name;

       # we now have domain.tld

 

       for ($i = 0; $i <= $#tld; $i++)

       {

              $domain_list[$i] = $prefix . "\.$tld[$i]";

              if ($ext eq "\.$tld[$i]") {$tld_requested = $i;}

       }

 

       SetPrelimStatus();

       @sorted_domain_list = @domain_list;

}

 

 

sub PutOutResults

{

       BuildHeaderRow();

       BuildPrimaryContentRow();

}

 

 

sub BuildHeaderRow

{

       my $i;

       my $row = "";

      

       $bgcolor = $lookandfeel{oddrow_color};

       $color_gender = "even";

       $row .= "                                <tr bgcolor=\"$bgcolor\"><td>&nbsp;</td>\n";

 

       for ($i = 0; $i <= $#tld; $i++)

       {

              $row .= "                                  <td width=\"1%\" align=\"center\"><img src=\"/Templates/img/1x1.gif\" width=35 height=1 alt=\"\" border=\"0\"><br><font size = -1 face = arial,helvetica>\.<b>$tld[$i]</b></font></td>\n";                 

       }

      

       $row .= "                                </tr>\n";

      

       print "$row";

}

 

 

sub BuildPrimaryContentRow

{

       my $i;

       my $row   = "";

 

       $sorted_page_list[0] =~ /^(\w)(.+)\w(\w)$/;

       $work_domain = $2;

       $work_domain =~ s/(.*)\.(.*)$/$1/;

      

       if       ($color_gender eq "odd")

       {

              $bgcolor = $lookandfeel{oddrow_color};

              $color_gender = "even";

       }

       else  

       {

              $bgcolor = $lookandfeel{evenrow_color};

              $color_gender = "odd";

       }

       $row .= "                                <tr bgcolor=\"$bgcolor\"><td><font size = -1 face = arial,helvetica>$work_domain</font></td>\n";

 

       for ($i = 0; $i < @sorted_page_list; $i++)

       {

              $sorted_page_list[$i] =~ /^(\w)(.+)\w(\w)$/;

              my $status = $1;

              my $domain = $2;

              my $selected = $3;

              my $checked = '';

 

              if       ($status eq "A")

              {

                     $ext =~ /\.(.*)/;       # test below thinks dot in $ext = "any", so

                     $ext_tld = $1;             # omit then re-prepend as "dot"

                     # How can $3 be 'S' if this must be 1st time?  Keep anyway...

                     if       ($selected eq "S" or ($domain =~ /\.$ext_tld/ and not $tld_not_found))

                     {

                            $checked = "checked";

                     }

                     # If no tld was specified in the ext field or as part of the name field,

                     # checkmark all available tld's that are in list of default tld's.

                     elsif       ($aForm{ext} =~ /xxx/ and not $name_rest_save)

                     {

                            foreach $default_tld (@default_tlds)

                            {

                                   if ($domain =~ /\.$default_tld/)

                                   {$checked = "checked"; last;}

                            }

                     }                   

                     $row .= "                                  <td width=\"1%\" align=\"center\"><img src=\"/Templates/img/1x1.gif\" width=35 height=1 alt=\"\" border=\"0\"><br><input type = \"checkbox\" name = \"$domain\" $checked></td>\n";

#                    available("$domain","$3");

              }

              else                       

              {

                     $row .= "                                  <td width=\"1%\" align=\"center\"><img src=\"/Templates/img/1x1.gif\" width=35 height=1 alt=\"\" border=\"0\"><br><font size = -2 face = arial,helvetica color=black>Taken</font></td>\n";

#                    registered("$domain");

              }

       }

 

       print "$row                                </tr>\n";

       return;

}

 

 

sub BuildPrimaryContentRowUserid

{

       my $domainstub = shift;

       my $i;

       my $row   = "";

 

       if       ($color_gender eq "odd")

       {

              $bgcolor = $lookandfeel{oddrow_color};

              $color_gender = "even";

       }

       else  

       {

              $bgcolor = $lookandfeel{evenrow_color};

              $color_gender = "odd";

       }

       $row = "                                <tr bgcolor=\"$bgcolor\"><td><font size = -1 face = arial,helvetica>$domainstub</font></td>\n";

 

       # Add each tld to a domain stub (e.g. myname -> myname.com, myname.net, etc)

       for ($i = 0; $i <= $#tld; $i++)

       {

              $work_domain = $domainstub . "\.$tld[$i]";

              $entry = SetPrelimStatusUserid($work_domain);

              $entry =~ /^(\w)(.+)\w(\w)$/;

              my $status = $1;

              if       ($status eq "A")

              {

                     $row .= "                                  <td width=\"1%\" align=\"center\"><img src=\"/Templates/img/1x1.gif\" width=35 height=1 alt=\"\" border=\"0\"><br><input type = \"checkbox\" name = \"$work_domain\"></td>\n";

              }

              else                       

              {

                     $row .= "                                  <td width=\"1%\" align=\"center\"><img src=\"/Templates/img/1x1.gif\" width=35 height=1 alt=\"\" border=\"0\"><br><font size = -2 face = arial,helvetica color=black>Taken</font></td>\n";

              }

 

              $hidden_name = "domain" . "$#domain_list";

              $hidden_domains .= "

                       <input type = \"hidden\" name = \"$hidden_name\" value = \"$domain_list[$#domain_list]\">";

 

              $num_domains++;

       }

       print "$row                                </tr>\n";

       @sorted_domain_list = @domain_list;

       return;

}

 

 

sub OutputResultsMessage

{

       $sorted_page_list[$tld_requested] =~ /^(\w)(.+)\w(\w)$/;

       my $status = $1;

       my $domain = $2;

 

       if ($tld_not_found)    # Unsupported or garbage tld entered

       {

              if ($name_rest =~ /\.biz/ or $name_rest =~ /\.info/)

              {

                     $lookandfeel{msg1_futuretld_text} =~ s/offer/offer $name_rest/;

                     print <<EOF;

                          <tr>

                            <td colspan = 3><div align="$lookandfeel{msg1_align}">

                              <font size = $lookandfeel{msg1_futuretld_size} face = arial,helvetica color = $lookandfeel{msg1_futuretld_color}>

                              <b>$lookandfeel{msg1_futuretld_text}</b></font></div>

                              <div align="$lookandfeel{msg2_align}">

                           <font size = $lookandfeel{msg2_futuretld_size} face = arial,helvetica color = $lookandfeel{msg2_futuretld_color}>

                              $lookandfeel{msg2_futuretld_text}</font></div>

                            </td>

                          </tr>               

EOF

              }

              else

              {

                     $lookandfeel{msg1_badtld_text} =~ s/specified/specified ($name_rest_save)/;

                     print <<EOF;

                          <tr>

                            <td colspan = 3><div align="$lookandfeel{msg1_align}">

                            <font size = $lookandfeel{msg1_badtld_size} face = arial,helvetica color = $lookandfeel{msg1_badtld_color}>

                              <b>$lookandfeel{msg1_badtld_text}</b></font></div>

                              <div align="$lookandfeel{msg2_align}">

                           <font size = $lookandfeel{msg2_badtld_size} face = arial,helvetica color = $lookandfeel{msg2_badtld_color}>

                              $lookandfeel{msg2_badtld_text}</font></div>

                            </td>

                          </tr>               

EOF

              }

       }

       elsif (! $avails_here)       # None available

       {

              print <<EOF;

                          <tr>

                            <td colspan = 3><div align="$lookandfeel{msg1_align}">

                            <font size = $lookandfeel{msg1_none_size} face = arial,helvetica color = $lookandfeel{msg1_none_color}>

                              <b>$lookandfeel{msg1_none_text}</b></font></div>

                              <div align="$lookandfeel{msg2_align}">

                           <font size = $lookandfeel{msg2_none_size} face = arial,helvetica color = $lookandfeel{msg2_none_color}>

                              $lookandfeel{msg2_none_text}</font></div>

                            </td>

                          </tr>               

EOF

       }

       elsif ($status eq "A")   # Yours is available

       {

              print <<EOF;

                          <tr>

                            <td colspan = 3><div align="$lookandfeel{msg1_align}">

                            <font size = $lookandfeel{msg1_yes_size} face = arial,helvetica color = $lookandfeel{msg1_yes_color}>

                              <b>$lookandfeel{msg1_yes_text}</b></font></div>

                              <div align="$lookandfeel{msg2_align}">

                           <font size = $lookandfeel{msg2_yes_size} face = arial,helvetica color = $lookandfeel{msg2_yes_color}>

                              $lookandfeel{msg2_yes_text}</font></div>

                            </td>

                          </tr>               

EOF

       }

       else       # Yours isn't available, but another *is*

       {

              $lookandfeel{msg2_other_text} =~ s/domain/$domain/; # Replace string "domain" with variable's value

              print <<EOF;

                          <tr>

                            <td colspan = 3><div align="$lookandfeel{msg1_align}">

                            <font size = $lookandfeel{msg1_other_size} face = arial,helvetica color = $lookandfeel{msg1_other_color}>

                              <b>$lookandfeel{msg1_other_text}</b></font></div>

                              <div align="$lookandfeel{msg2_align}">

                           <font size = $lookandfeel{msg2_other_size} face = arial,helvetica color = $lookandfeel{msg2_other_color}>

                              $lookandfeel{msg2_other_text}</font></div>

                            </td>

                          </tr>               

EOF

              $lookandfeel{msg2_other_text} =~ s/$domain/domain/; # Restore string "domain" for next time

       }

}

 

 

sub OutputFormAndMiscHiddens

{

       print "@blackbox_beginform_lines[0]\n";

 

       if ($aForm{'view_more.x'}) {$num_domains = $aForm{num_domains};}

       print <<EOF;

                    <form action = "http://whois.domains.yahoo.com/cgi-bin/domain_search.cgi" method = "POST">

                    <input type = "hidden" name = "action" value = "1">

                  <input type = "hidden" name="name" value = "$aForm{name}">

                  <input type = "hidden" name = "ext" value = "$aForm{ext}">

                    <input type = "hidden" name = "property" value = "domains">

                    <input type = "hidden" name = "num_domains" value = "$num_domains">

                  <input type = "hidden" name = "template" value = "$aForm{template}">

                  <input type = "hidden" name = "promotion_code" value = "$aForm{promotion_code}">

EOF

 

       print "@blackbox_beginform_lines[1]\n";

}

 

 

sub OutputFormAndMiscHiddensSearchbox

{     

       # Used with searchagain box

       print <<EOF;

                        <form action = "http://whois.domains.yahoo.com/cgi-bin/domain_search.cgi" method = "POST">

                        <input type = "hidden" name = "action" value = "$aForm{action}">

                        <input type = "hidden" name = "property" value = "domains">

                      <input type = "hidden" name = "template" value = "$aForm{template}">

                      <input type = "hidden" name = "promotion_code" value = "$aForm{promotion_code}">

EOF

}

 

 

sub PutNextStepButton

{

       if       ($first_time)       {$submit_label = "$lookandfeel{nextstep_button_text_firsttime}";}

       else                 {$submit_label = "$lookandfeel{nextstep_button_text_subsequent}";}

      

       if       ($aForm{'view_more.x'})       {$submit_name = "update_my_list_viewmore";}

       else                        {$submit_name = "update_my_list";}

      

        # Output final tally of num_domains

       print <<EOF;

                                  <td>

                                    <input type = \"hidden\" name = \"num_domains\" value = \"$num_domains\">

                                    <input type = "submit" name = "$submit_name" value = "$submit_label">

                                  </td>

EOF

}

 

 

sub PutReviewButton

{

        # Output final tally of num_domains

       print <<EOF;

                                  <td>

                                    <input type = \"hidden\" name = \"num_domains\" value = \"$num_domains\">

                                    <input type = "submit" name = "review_my_list" value = "$lookandfeel{review_button_text}">

                                  </td>

EOF

}

 

 

sub PutReviewForm

{

       Woops();

 

       # If not update from review page, build sorted_domain_list from hiddens.

       # Review page doesn't have the hiddens.

       if (not $aForm{update_my_list_review} and not $aForm{secure_checkout})

       {

              BuildSortedDomainListFromHiddensWithoutUpdate();

       }

 

       $selected_domains = "";

 

       if (not $aForm{update_my_list} and not $aForm{update_my_list_viewmore})

       {

              BuildHiddensFromSortedDomainList();

       }

 

       # If we're putting out the review page after doing some updating, the server

       # hasn't seen the updated cookie yet.  Thus, ParseCookie won't see up-to-date

       # info.  @cookie_domains has the latest info already, so ParseLocalCookie.

 

       ParseLocalCookie();

 

       # Process review page removals that are not in effect yet.

       # Also, see if any .biz's in cart.

      

       my $i;

       $biz_exists = 0;

      

       for ($i = 0; $i < @cookie_domains; $i++)

       {

              if ($cookie_domains[$i] ne "")           {Selected("$cookie_domains[$i]");}

              if ($cookie_domains[$i] =~ /\.biz$/)       {$biz_exists = 1;}

       }

 

       if (not $biz_exists) {$biz_blurb = "";}

 

       if ($cookie_domains[0]) {ReviewText();}

 

       if (not $cookie_domains[0])

       {

              print "                                <font face=\"Arial, Helvetica\" size=\"-1\"><b>Your list is currently empty.</b></font><br>\n";

       }

}

 

 

sub Woops

{

       if ($woops)

       {

              if       ($woops_count > 1)       {$plural = "es"; $plural_verbiage = "have";}

              else                        {$plural = "";   $plural_verbiage = "has";}

             

              print <<EOF;

              <tr><td colspan = 2>

              <font face="Arial, Helvetica" size="-1"><font color="#CC0000">

              <b>UNABLE TO ADD TO LIST:</b>

              Our secondary availability search shows that the domain name$plural in red below

              $plural_verbiage already been registered.  Search and select another domain name.

              <br><br>

              $woops

              </font></font>

              </td></tr>

              <tr><td>&nbsp;</td></tr>

EOF

       }

}

 

 

sub ReviewText

{

              print <<EOF;

                                <tr>

                                  <td colspan = 3><font size = -1 face = arial,helvetica>

                                   Your list contains the following Web Addresses.  To remove a

                                   Web Address, uncheck the box and click "$lookandfeel{nextstep_button_text_subsequent}."

                                   To place your order, click "$lookandfeel{checkout_button_text}."

                                   </font>

                                 </td>

                               </tr>

                               <tr>

                                 <td>

                                   <form action = "http://whois.domains.yahoo.com/cgi-bin/domain_search.cgi" method = "POST">

                                   <input type = "hidden" name = "action" value = "$aForm{action}">

                                   <input type = "hidden" name = "property" value = "domains">

                                   <input type = "hidden" name = "num_domains" value = "$aForm{num_domains}">

                                 <input type = "hidden" name="name" value = "$aForm{name}">

                                 <input type = "hidden" name = "template" value = "$aForm{template}">

                                  <input type = "hidden" name = "promotion_code" value = "$aForm{promotion_code}">

                                 </td>

                               </tr>

                                $selected_domains

                               <tr>

                                 <td colspan = 3 align = center><font size = -2 face = arial,helvetica color = red>

                                  Please check the spelling of your Web Address(es) before proceeding.

                                   <br><br></font>

                                   $biz_blurb

                                 </td>

                               </tr>

EOF

}

 

 

sub OutputButtonsReview

{

       print <<EOF;

                               <tr>

                                 <td align=center>

                                   <input type = "submit" name = "update_my_list_review" value = "$lookandfeel{nextstep_button_text_subsequent}">

                                 </td>

                                 <td align=left>

                                   <input type = "submit" name = "secure_checkout" value = "$lookandfeel{checkout_button_text}">

                                 </td>

                               </tr>

EOF

 

       print "                              </form>\n";

}

 

 

sub BuildSortedDomainListFromHiddensWithoutUpdate

{

       my $i;

       for ($i = 0; $i < $aForm{num_domains}; $i++)

       {

              $domaini = "domain" . $i;

              $work = $aForm{$domaini};

             

              $work =~ /^(\w)(.+)(\w)(\w)$/;

              $work_status = $1;

              $work_domain = $2;

              $work_lookedup = $3;

              $work_selected = $4;

 

              $sorted_domain_list[$i] =

                     $work_status.$work_domain.$work_lookedup.$work_selected;

       }

}

 

 

sub BuildSortedDomainListFromHiddensWithUpdate

{

       my $i;

       for ($i = 0; $i < $aForm{num_domains}; $i++)

       {

              $domaini = "domain" . $i;

              $work = $aForm{$domaini};

              $work =~ /^(\w)(.+)(\w)(\w)$/;

              $work_status = $1;

              $work_domain = $2;

              $work_lookedup = $3;

              $work_selected = $4;

 

              if ($work_selected eq "S")

              {

                     if       ($aForm{$work_domain} ne "on")

                     {

                            $work_selected = "U";

                            RemoveFromCookie($work_domain);

                     }

                     else  

                     {

                            if       ($i < $num_primary_domains)       {$origin = "P";}

                            else                               {$origin = "S";}

                            AddToCookie($origin);

                     }

              }

 

              $sorted_domain_list[$i] =

                     $work_status.$work_domain.$work_lookedup.$work_selected;

       }

}

 

 

sub BuildHiddensFromSortedDomainList

{

       for ($sorted_domain_list_index = 0; $sorted_domain_list_index < @sorted_domain_list; $sorted_domain_list_index++)

       {

              $sorted_domain_list[$sorted_domain_list_index] =~ /^(\w)(.+)(\w)(\w)$/;

              $work_domain = $2;

              $work_selected = $4;

      

              $hidden_name = "domain" . "$sorted_domain_list_index";

              $hidden_domains .= "

                             <input type = \"hidden\" name = \"$hidden_name\" value = \"$sorted_domain_list[$sorted_domain_list_index]\">";

       }

}

 

 

sub UpdateReview

{

       ParseCookie();

       BuildSortedDomainListFromHiddensWithUpdate();

       CheckForOtherRemovals();

       BuildCookie();

       SetCookie();

       CountDomains();

 

       if       ($aForm{secure_checkout})

       {

              if ($cookie)

              {

                     if ($cart_items > 1) # > 1 domain in list

                     {

                            $lookandfeel{done_url_multi} =~ s/XXXXX/$domains_selected/;

                            print "location: $lookandfeel{done_url_multi}\n\n";

#                           print "location: https://safe.domains.yahoo.com/ordersv2/\n\n";

                            exit 0;

                     }

                     else

                     {

                            $lookandfeel{done_url_single} =~ s/XXXXX/$domains_selected/;

                            $lookandfeel{done_url_single} =~ s/PPPPP/$aForm{promotion_code}/;

                            print "location: $lookandfeel{done_url_single}\n\n";

#                           print "location: http://whois.domains.yahoo.com/cgi-bin/hubpage.cgi?dom=$cookie_domains[$cart_index]&html=$lookandfeel{hubpage_html}\n\n";     

                            exit 0;

                     }

              }

              else       # They've deleted all selections

              {

                     print "Content-type: text/html\n\n";

                     OutputPage();

              }

       }

       elsif       ($aForm{update_my_list_review})

       {

              print "Content-type: text/html\n\n";

              OutputPage();

       }

}

 

 

sub CheckForOtherRemovals

{

       # Domains from old searches can be removed, too, but have no hiddens to go from

       my $i;

       for ($i = 0; $i < @cookie_domains; $i++)

       {

              if       ($aForm{$cookie_domains[$i]} ne "on")

              {

                     RemoveFromCookie($cookie_domains[$i]);

              }

       }

}

 

 

sub CountDomains

{

       $cart_items = 0;

       $cart_index = 0;

       $domains_selected = "";

       for ($i = 0; $i <= $#cookie_domains; $i++)

       {

              if ($cookie_domains[$i] ne "")

              {

                     $domains_selected .= $cookie_domains[$i] . ",";

                     $cart_items++;

                     $cart_index = $i;       # Remember index in case exactly one in cart

              }

       }

       $domains_selected =~ s/\,$//;

}

 

 

sub SetCookie

{

       my @gmt_plus_time_limit = CookieTime("+", "$auth_time_limit");

       my $time_now = time();

       $cookie =~ s/,$//;

       print<<EOF;

Set-Cookie: SN_whois_$yid=$cookie; path=/; expires=@gmt_plus_time_limit; domain=$cookie_auth_domain;

EOF

 

       if ($aForm{promotion_code})

       {

              print<<EOF;

Set-Cookie: SN_whois_promo_$yid=$aForm{promotion_code}; expires=@gmt_plus_time_limit; path=/; domain=$cookie_auth_domain;

EOF

       }

 

}

 

 

sub UpdateAndOutputPage

{

       BuildSortedDomainListFromHiddensWithoutUpdate();

       UpdateDomainlistCookieHiddens();

       RefreshCookie();

       OutputPage();

}

 

 

sub ParseCookie

{

       CookieCutter($ENV{HTTP_COOKIE});

       @cookie_domains = split /,/,$Cookies{"SN_whois_$yid"};

}

 

 

sub ParseLocalCookie

{

       # Server hasn't gotten updated cookie yet, but we need it for displaying curr selecteds

       @cookie_domains = split /,/,$cookie;

}

 

 

sub CookieCutter

{

       my $raw_dough = "@_";

 

       my ($cookie, $key, $value);

 

       undef %Cookies;

 

       # The space after the semi-colon es muy importante

       foreach $cookie (split /; /, $raw_dough)

       {

              ($key, $value) = (split /=/, $cookie);

              $Cookies{ $key } = $value;

       }

}

 

 

# Convert current time into cookie-acceptable format

sub CookieTime

{

       my $operator = shift @_;

       my $seconds = shift @_;

 

       my $time_now = time();

       $time_now = eval "$time_now $operator $seconds" if ($operator);

 

       my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime($time_now);

 

       my $weekday = (qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday))[$wday];

       my $month = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$mon];

       $year += 1900;

 

       return "$weekday, $mday-$month-$year $hour:$min:$sec GMT";

}

 

 

sub CurrentDate

{

       $time_now = time();

       ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time_now);

       $month = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$mon];

       $year += 1900;

 

       if ($hour < 10)       {$hour = '0' . $hour;}

       if ($min < 10)       {$min = '0' . $min;}

       if ($sec < 10)       {$sec = '0' . $sec;}

}

 

 

sub CutLogRec1

{

       my $outcome = $_[0];

       CurrentDate();

 

#      if ($aForm{'view_more.x'}) {$from = "v";} else {$from = "r";}

       open(WHOISLOG,">>dsearchlog1") or die "Can't open dsearchlog1: $!\n";

       print WHOISLOG "$outcome $mday/$month/$year $hour:$min:$sec\n";

#      print WHOISLOG "$outcome $mday/$month/$year $hour:$min:$sec $from\n";

       close WHOISLOG;    

}

 

 

sub CutLogRec2

{

       CurrentDate();

 

#       open(WHOISLOG,">>dwhoislog2") or die "Can't open whoislog2: $!\n";

#      print WHOISLOG "$mday/$month/$year $aForm{wiz1}, $aForm{wiz2}, $aForm{wiz3}\n";

#      close WHOISLOG;    

}

 

 

sub CutLogRec3

{

       my $log_string = $_[0];

 

       CurrentDate();

       $time_out = $hour . ":" . $min . ":" . $sec;

 

#       open(WHOISLOG,">>dwhoislog3") or die "Can't open whoislog3: $!\n";

#      print WHOISLOG "$mday/$month/$year $$ $log_string\n";

#      close WHOISLOG;    

}

 

 

sub CutLogRec

{

#return 0;

      

       my $log_string = $_[0];

 

       CurrentDate();

       $bigtime_out = $time_now;

       $time_out = $hour . ":" . $min . ":" . $sec;

       $elapsed = $bigtime_out - $bigtime_in;

 

       open(WHOISLOG,">>dwhoislog") or die "Can't open dwhoislog: $!\n";

       print WHOISLOG "$$ $bigtime_in $bigtime_out $mday/$month/$year $time_in $time_out $elapsed $log_string\n";

       close WHOISLOG;    

}

 

 

sub SetPrelimStatus

{

       my $i;

       for ($i = 0; $i < @domain_list; $i++)

       {

              $domain_list[$i] =~ /(.+)(\..+)$/;

              if (length($1) < 3)

              {

                     $domain_list[$i] = "R" . $domain_list[$i] . "NU";

                     next;

              }

 

              if (IsDelegated("$domain_list[$i]","127.0.0.1"))

              {

                     $domain_list[$i] = "R" . $domain_list[$i] . "NU";

              }

              else

              {

                     $domain_list[$i] = "A" . $domain_list[$i] . "NU";

              }

 

#             CutLogRec("IsD $temp_domain");

       }

}

 

 

sub SetPrelimStatusUserid

{

       my $domain = shift;

       my $result = '';

      

       if       (length($domain) < 3)                   {$result = "R" . $domain . "NU";}

       elsif       (IsDelegated("$domain","127.0.0.1"))       {$result = "R" . $domain . "NU";}

       else                                      {$result = "A" . $domain . "NU";}

 

       my $index = $#domain_list + 1;

       $domain_list[$index] = $result;

 

       return($result);

}

 

 

sub NotFirstTime

{

       # Build (sorted) domain list from hidden domain list fields

 

       my $i;

       for ($i = 0; $i < $aForm{num_domains}; $i++)

       {

              $sorted_domain_list[$i] = $aForm{"domain$i"};

       }

}

 

 

sub UpdateDomainlistCookieHiddens

{

       #     for whole sorted domain list

       ##       if in page

       #         if avail & no HasWhois yet

       #           do HasWhois

       #           if reg'd

       #             change status to "R"

       #           mark as looked up

       ##         add to page list

       #       add to hiddens

 

       ParseCookie();

       $avails_here = 0;

       $page_list_index = 0;

       for ($sorted_domain_list_index = 0; $sorted_domain_list_index < @sorted_domain_list; $sorted_domain_list_index++)

       {

              $sorted_domain_list[$sorted_domain_list_index] =~ /^(\w)(.+)(\w)(\w)$/;

              $work_status = $1;

              $work_domain = $2;

              $work_lookedup = $3;

              $work_selected = $4;

 

              if ($work_status eq "A" and $work_lookedup eq "N" and $aForm{$work_domain} eq "on")

              {

                     my $available = call_Domains_API('domains',"$work_domain",'search');

                     # return 0 = available

                     # return 1 = not available

                     # return 2,3 = error (3 includes timeout)

 

                     if

                     (

                            ($available != 0 and $available != 3)

                       or       ($available == 3 and HasWhois("$work_domain"))

                     )

#                    if (HasWhois("$work_domain"))

                     {

                            $work_status = "R";

                            $aForm{$work_domain} = ""; # Turn it off so it doesn't -> cookie

                            # Add to list of domains we *thought* were available

                            my $font = "<font face=\"Arial, Helvetica\" size=\"-1\"><font color=\"#CC0000\">";

                            $woops .= "<tr><td><b>$font$work_domain</b></font></font></td></tr>";

                            $woops_count++;

                     }

 

#                    CutLogRec("Has $work_domain");

 

                     $work_lookedup = "Y";

              }

 

              if ($work_status eq "A") {$avails_here = 1;}

 

              if

              (

                     $aForm{$work_domain} eq "on"

              or       ($aForm{update_my_list_viewmore} and $work_selected eq "S")

              )

              {

                     $work_selected = "S";

                     if       ($sorted_domain_list_index < $num_primary_domains)       {$origin = "P";}

                     else                                                    {$origin = "S";}

                     AddToCookie($origin);

              }

#             elsif       ($aForm{update_my_list})

#             {

#                    $work_selected = "U";

#                    RemoveFromCookie($work_domain);

#             }

 

              # Apply any changes to the data

              $sorted_domain_list[$sorted_domain_list_index] =

                     $work_status.$work_domain.$work_lookedup.$work_selected;

              $page_list[$page_list_index] = $sorted_domain_list[$sorted_domain_list_index];

              $page_list_index++;

 

              $hidden_name = "domain" . "$sorted_domain_list_index";

              $hidden_domains .= "

                       <input type = \"hidden\" name = \"$hidden_name\" value = \"$sorted_domain_list[$sorted_domain_list_index]\">";

       }

 

       BuildCookie();

}

 

 

sub AddToCookie

{

       my $origin = $_[0];

       $match_found = 0;

       $cookie = "";

       my $i;

       $lc_work_domain = lc($work_domain);

       for ($i = 0; $i < @cookie_domains; $i++)

       {

              if ($cookie_domains[$i] eq $lc_work_domain) {$match_found = 1; last;}

       }

       if (not $match_found) {$cookie_domains[$i] = $lc_work_domain;}

#      if (not $match_found) {$cookie_domains[$i] = $origin . $lc_work_domain;}

}

 

 

sub RemoveFromCookie

{

       $removal_item = $_[0];

       my $i;

       for ($i = 0; $i < @cookie_domains; $i++)

       {

              if ($cookie_domains[$i] eq $removal_item)

              {

                     $cookie_domains[$i] = "";

                     last;

              }

       }

}

 

 

sub BuildCookie

{

       $cookie = "";

       my $i;

       for ($i = 0; $i < @cookie_domains; $i++)

       {

              if ($cookie_domains[$i] eq "") {next;}

              $cookie .= $cookie_domains[$i] . ",";

       }

}

 

 

sub RefreshCookie

{

       my @gmt_plus_time_limit = CookieTime("+", "$auth_time_limit");

       my $time_now = time();

       $cookie =~ s/,$//;

      

       print<<EOF;

Set-Cookie: SN_whois_$yid=$cookie; expires=@gmt_plus_time_limit; path=/; domain=$cookie_auth_domain;

EOF

 

       if ($aForm{promotion_code})

       {

              print<<EOF;

Set-Cookie: SN_whois_promo_$yid=$aForm{promotion_code}; expires=@gmt_plus_time_limit; path=/; domain=$cookie_auth_domain;

EOF

       }

 

       print "Content-type: text/html\n\n";

}

 

#======================= General Subroutines===========================

 

sub GetFormInput

{

       $debug = '';

       local (@aPairs,$buffer,$name,$value);

       if ($ENV{'REQUEST_METHOD'} eq 'POST')

       {

              read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});

       }

       else

       {

              $buffer = $ENV{'QUERY_STRING'};

       }

       @aPairs = split(/&/,$buffer);

       foreach $pair (@aPairs)

       {

              ($name,$value) = split(/=/,$pair);

 

              $value =~ tr/+/ /;

              $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;

              $aForm{$name} = $value;

       }

}

 

#=======================Error Subroutine===========================

 

sub Error

{

       $error = $_[0];

       $error_exists = 1;

 

       if       ($error == 0 or $error == 1)       {$title = "Welcome";}

       else                               {$title = "Search Error";}

      

       if       ($error == 1)       {$hr = "";}

       else                 {$hr = "<HR>";}     

 

       my $font = "<font face=\"Arial, Helvetica\" size=\"-1\"><font color=\"#CC0000\">";

       my $font2 = "<font face=\"Arial, Helvetica\" size=\"-1\">";

 

       $rwhoisdescription = "

       <tr><td colspan = 3 valign = \"top\"><B>$font$title</FONT></font></B></td></tr>

       <tr><td colspan = 3>$hr</td></tr><tr><td colspan = 3>$font2";

 

       if    ($error == 0) {$msg = "Please use one of the search forms below to find cool Web Addresses.";}

       elsif ($error == 1) {$msg = "Please enter a Web Address to search for.";}

       elsif ($error == 2) {$msg = "Details are only available for .com, .net, .org, and .edu.";}

       elsif ($error == 3) {$msg = "Please fill in at least two wizard fields.";}

       elsif ($error == 4) {$msg = "The Web Address is too long.";}

       elsif ($error == 5) {$msg = "The Web Address contains invalid characters.  You may use".

              " only letters, numbers or dashes (\"-\"). A Web Address may not begin or end".

              " with a dash.";}

       elsif ($error == 6) {$msg = "The Web Address may not begin or end with a \"-\" (dash).";}

       elsif ($error == 7) {$msg = "The Web Address has no valid characters.";}

 

       $rwhoisdescription .= $msg;

       $rwhoisdescription .= "</font></td></tr>";

 

       $error_flag = 1;

      

#      if ($look_and_feel{searchagain_type} =~ /none/) {$look_and_feel{searchagain_type} = "box";}

       OutputPage();

}

 

 

sub registered

{

       local($work_domain = $_[0]);

 

       if ($first_one)       {$display_domain = "<b>$work_domain</b>";} # Bold one they used

       else          {$display_domain = "$work_domain";}

 

       print <<EOF;

                                      <tr>

                                        <td align=center valign=middle>&nbsp;

                                        </td>

                                        <td align=left valign=middle><font face=arial,helvetica size=-1>

                                          &nbsp;&nbsp;$display_domain</font>

                                        </td>

                                        <td align=left valign=middle>

                                          <font face=arial,helvetica size=-2>

                                          <font color=black>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Taken

                                          </font>

                                          </font>

                                        </td>

                                      </tr>

EOF

#      <font color=red>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://???">taken</a></font></font></td>

}

 

 

sub available

{

       local($work_domain = $_[0]);

       local($work_selected = $_[1]);

 

        if ($work_selected eq "S") {$checked = "checked";} else {$checked = "";}

 

       # Bold one they used and make it checked

       if ($first_one)       {$display_domain = "<b>$work_domain</b>"; $checked = "checked";}

       else          {$display_domain = "$work_domain";}

 

       print <<EOF;

                                      <tr>

                                        <td align=center><input type = "checkbox" name = "$work_domain" $checked>

                                        </td>

                                        <td align=left valign=middle><font face=arial,helvetica size=-1>

                                          &nbsp;&nbsp;$display_domain</font>

                                        </td>

                                        <td align=left valign=middle>

                                          <font face=arial,helvetica size=-1>

                                          <font color=\#009999><b>&nbsp;&nbsp;&nbsp;&nbsp;Available</b>

                                          </font>

                                          </font>

                                        </td>

                                      </tr>

EOF

}

 

 

sub Selected

{

       local($work_domain = $_[0]);

 

       $selected_domains .=

        "

                                <tr bgcolor=\"#FFFFFF\">

                                  <td align=center><input type = \"checkbox\" name = \"$work_domain\" checked>

                                  </td>

                                  <td align=left valign=middle>

                                    <font face=arial,helvetica size=2><b>$work_domain</b>

                                    </font>

                                  </td>

                                </tr>

        ";

}

 

 

sub DomainsMemberHeader

{

       my $name = 0;

 

       ($name) = ($ENV{GEO_AUTH_DATA} =~ /member\_name\=([a-z,0-9,\_]+)/i);

}

 

 

sub DoTimeIn

{

       CurrentDate();

       $script_bigtime_in = $time_now;

       $script_time_in = $hour . ":" . $min . ":" . $sec;

}

 

 

sub DoTimeOut

{

 

return 0;

 

       my $form = '';

       my $property = '';

 

       if ($aForm{action} eq '1') {$form = "Sch";} else {$form = "Wiz";}

       if       ($ENV{HTTP_HOST} =~ /^domains\./) {$property = "domains";}

       elsif       ($ENV{HTTP_HOST} =~ /^website\./) {$property = "website";}

       elsif       ($ENV{HTTP_HOST} =~ /^servers\./) {$property = "servers";}

 

       CurrentDate();

       $script_bigtime_out = $time_now;

       $script_time_out = $hour . ":" . $min . ":" . $sec;

       $script_elapsed = $script_bigtime_out - $script_bigtime_in;

 

#       open(WHOISLOG,">>dwhoislog") or die "Can't open dwhoislog: $!\n";

#      print WHOISLOG "$$ $script_bigtime_in $script_bigtime_out $mday/$month/$year $script_time_in $script_time_out $script_elapsed $form $property\n";

#      close WHOISLOG;    

}




Welcome
About Michael
Image Galleries
Info Retrieval
Music
Paraphysics
Poetry
Pyriodic Table
Software
Live Interview
Guestbook
e-mail me

|Welcome| |About Michael| |Image Galleries| |Info Retrieval| |Music| |Paraphysics| |Poetry| |Pyriodic Table| |Software| |Live Interview| |Guestbook|