#!/usr/bin/perl #---------------------------------------------------------------- # # Script Name: index.cgi # # Author : michael budash, mbudash@sonic.net # # Date : 06/28/2001 # # Purpose : modify admin.he.net via screen-scrape to shield # user from the fact that it's hurricane at all, # as well as to limit what they can do. # #---------------------------------------------------------------- use strict; use CGI qw/:standard/; use LWP::UserAgent; $|++; print header(); # the hurricane support host my $adminhost = 'admin.he.net'; # build any header and footer html my $header = makeheader(); my $footer = makefooter(); # we *always* need to send this fake cookie to hurricane my $h = new HTTP::Headers Cookie => 'cookie=1'; # create the request object my $req = new HTTP::Request ('POST', 'http://' . $adminhost . '/index.cgi', $h); $req->content_type('application/x-www-form-urlencoded'); # build the socket's post content from *all* params passed to this script my $qs; foreach (param()) { $qs .= "$_=" . CGI::escape(param($_)) . '&'; } chop $qs; $req->content($qs); # create the user agent object my $ua = new LWP::UserAgent; # perform the request my $res = $ua->request($req); if (!($res->is_success)) { print "Sorry - could not connect!"; exit; } # capture the returned content my $content = $res->content; # debug - show the post content passed to hurricane #$content =~ s//$&$qs\n\n

\n/; # remove any link or form action references to hurricane $content =~ s{https?://$adminhost/?}{}sg; # slice and dice the main page; if (param('menu') eq 'main' || !param('menu') || (param('form_result') eq 'true' && param('menu') eq 'add_mbox')) { # remove any straggler 'MAILBOX: xxxx' and clear the param that made it happen $content =~ s/MAILBOX:\s+\w+//s; param('mbox', ''); # remove top table and replace with just account's domain name and link $content =~ s{\n.+?/a>)\n.+?().+?/table>\n}{\n

$1$2
}is; # remove next 2 tables altogether $content =~ s{}{}is; $content =~ s{}{}is; # remove certain menu options # add any extra links my $extralinks = makeextralinks(); $content =~ s/
\n/$&
$extralinks/; foreach ('Change To Credit Card Billing', 'Edit Contact Information', 'Edit DNS', 'Edit Virtual Host Options', 'Mail Invoice', 'View Service Record', 'View Statement') { $content =~ s/
\n//; } } my $default_mailbox; # modify the 'configure default mailbox' link on the 'view_mailboxes' page # to include an additional 'default_mailbox' param to be used by Net::Telnet if (param('menu') eq 'view_mailboxes') { $content =~ /
(\S+@\S+)\s+.+?\(default mailbox\)/s;
  $default_mailbox = $1;
  $content =~ s/(menu=configure_default_mbox&)/$1default_mailbox=$default_mailbox&/s;
}

# slice and dice the 'configure_default_mbox' page
if (param('menu') eq 'configure_default_mbox') {
  # connect to server, see if ~/.forward exists
  use Net::Telnet ();
  $default_mailbox = param('default_mailbox');
  my $server = substr($default_mailbox, 0, 4);
  chop($server) if ($server =~ /0$/);
  my $t = new Net::Telnet (Timeout => 10,
                        Prompt => '/' . $server . ':~\$ $/');
  $t->errmode("return");
  my ($telnet_error, $exists);
  if (!defined($t->open("$server.he.net"))) {
    $telnet_error = "Net::Telnet error: " . $t->errmsg;
  }
  elsif (!defined($t->login(param('account'), param('auth')))) {
    $telnet_error = "Net::Telnet error: " . $t->errmsg;
  }
  else {
    $exists = (($t->cmd("ls .forward"))[0] =~ /No such/) ? 0 : 1;
  }
  # first time thru. set checkbox: 'checked' if ~/.forward already exists,
  #  else unchecked; also add hidden form field containing default_mailbox param.
  if (param('form_result') ne 'true') {
    my $checked = $exists ? ' checked' : '';
    $content =~ s/(type="checkbox").+?>/$1$checked>/s;
    $content =~ s/<\/form>/\n/si;
    if ($telnet_error) {
      $content =~ s{will take effect.+?\n}{$&
$telnet_error
}s; } } # submit hit. if checked, create ~/.forward (if doesn't already exist); else delete it (if exists) else { if (param('form_wildcard')) { if (!$exists) { $t->cmd("echo \"" . param('default_mailbox') . "\" > .forward"); } } elsif ($exists) { $t->cmd("rm .forward"); } } } # add certain of the params to all links $content =~ s/index\.cgi\?.+?"/addparams($&)/ge; $content =~ s/index\.cgi/$ENV{SCRIPT_NAME}/sg; # remove hurricane copyright $content =~ s{
Copyright © 1994 - 2001 Hurricane Electric. All Rights Reserved.
}{}; # add any header and footer $content =~ s{}{$&\n$header}is; $content =~ s{}{$footer\n$&}is; # finally! - push the page back to the browser print $content; exit; #---------------------------------------------------------------- sub addparams { my $link = shift; my $value; foreach (param()) { $value = CGI::escape(param($_)); unless (/^form_/ || $link =~ /$_=/) { unless ($_ eq 'mbox' && param('menu') eq 'main') { $link =~ s/index\.cgi\?/$&$_=$value&/; } } } return $link; } #--------------------------------------------------------------------------------------- sub makeheader { my $header = qq|
 

CDLA hosting 

Domain Registration and Hosting


1 714-630-4441

.

 

      Home       Product and Pricing         Site-Wizard         Support       Contact   Why CDLA
|; return $header; } #--------------------------------------------------------------------------------------- sub makefooter { my $footer = qq|

Website-Wizard DEMO  I  About Us    I   Pricing   I  Contact   I    Support   I    Domain Questions

©
2000 CDLA Domain Registration and Hosting Service
Tel: +1 714-630-4441
|; return $footer; } #--------------------------------------------------------------------------------------- sub makeextralinks { my $extralinks = qq| FAQ
Support |; return $extralinks; }