####################################################################### # htmlgen.pm # # These routines generate the HTML for the GnuDIP # Web interface. # # See COPYING for licensing information. # ####################################################################### # Perl modules use strict; # global variables use vars qw($conf); use vars qw($pref $userinfo $remote_ip); use vars qw($reqparm $thiscgi $thishost $thisurl); use vars qw($htmlgen_header $htmlgen_trailer); # GnuDIP common subroutines use gdiplib; use gdipcgi_cmn; use gdipmailchk; # variables global to this file # - may be included in all pages my ($title, $head, $headtxt, $topline, $trailerline, $bodytxt, $body, $bodyend, $html_dir); ####################################################################### # initialise global variables ####################################################################### sub htmlgen_init { # title $title = "GnuDIP Web Interface"; $headtxt = tst(qq* $title*); $head = tst(qq* $headtxt *); # HTML to insert after if (! defined $htmlgen_header or ! defined $$conf{'persistance'} or $$conf{'persistance'} ne 'YES') { my $headerfile = $$conf{'header_file'}; $headerfile = '' if !defined($headerfile); $htmlgen_header = ''; if ($headerfile and open(HEADER,"$headerfile")) { while (my $line =
) { $htmlgen_header .= $line; }; close HEADER; } } # HTML to insert before if (! defined $htmlgen_trailer or ! defined $$conf{'persistance'} or $$conf{'persistance'} ne 'YES') { my $trailerfile = $$conf{'trailer_file'}; $trailerfile = '' if !defined($trailerfile); $htmlgen_trailer = ''; if ($trailerfile and open(TRAILER,"$trailerfile")) { while (my $line = ) { $htmlgen_trailer .= $line; }; close TRAILER; } } # offset to HTML directory $html_dir = $$conf{'html_dir'}; $html_dir = '../html' if !$html_dir; # stuff for top of each page $topline = $htmlgen_header . tst(qq*
GnuDIP Logo

$title

Help
*); # for starting and ending HTML body $bodytxt = "body bgcolor=\"FFFFFF\""; $body = "<$bodytxt>"; $bodyend = $htmlgen_trailer . ''; } ####################################################################### # login ####################################################################### sub pg_login { header(); tpr(qq* $headtxt <$bodytxt onload="sethidden()"> $topline

Login

*); if ($$pref{'SHOW_DOMAINLIST'} eq 'YES') { html_domain('','domain'); } else { tpr(qq* *); } tpr(qq*
Username/Hostname
Domain
Password
*); if ($$pref{'SEND_URL'} eq 'YES') { if (!$$conf{'URL_sendURL'}) { tpr(qq* *); } else { tpr(qq* *); } } if ($$pref{'ADD_SELF'} eq 'YES') { if (!$$conf{'URL_self_signup'}) { tpr(qq* *); } else { tpr(qq* *); } } tpr(qq*
Forgotten Password
Self Register
$htmlgen_trailer *); exit; } ####################################################################### # forgotten password ####################################################################### sub pg_sendURL { # ensure initialized default_empty('sendURL_username'); header(); tpr(qq* $headtxt $body $topline

Forgotten Password

Enter your username and domain
A Quick Login URL will be sent to the E-mail address on record
*); if ($$pref{'SHOW_DOMAINLIST'} eq 'YES') { html_domain('','domain'); } else { tpr(qq* *); } tpr(qq*
Username/Hostname
Domain
*); # ensure not a robot mchk_html(); tpr(qq*
$bodyend *); exit; } ####################################################################### # Quick Login URL E-mail sent ####################################################################### sub pg_sentURL { my $email = shift; pg_msg(qq* Quick Login URL E-mail Sent *,qq* An E-mail has been sent to the E-mail address on record for this host, containing a Quick Login URL (i.e., www address).
When you receive the E-mail, connect to the URL in your browser to login. *); } ####################################################################### # self signup ####################################################################### sub pg_self { pg_error("no_addself") if $$pref{'ADD_SELF'} ne 'YES'; header(); tpr(qq* $head $body $topline

Self Registration

*); tpr(qq* *); tpr(qq*
Username/Hostname
Domain
E-Mail Address
Password
Password Again
*); # ensure not a robot mchk_html(); tpr(qq*
 
$bodyend *); exit; } ####################################################################### # self signup E-mail sent ####################################################################### sub pg_selfemail { my $email = shift; pg_msg(qq* Self Registration E-mail Sent *,qq* An E-mail has been sent to $email, containing a URL (i.e., www address).
When you receive the E-mail, connect to the URL in your browser to complete the self registration process. *); } ####################################################################### # self signup done ####################################################################### sub pg_didself { pg_msg(qq* Registration Successful *,qq* Your registration was successful.
Please return to the login page. *); } ####################################################################### # E-mail update E-mail sent ####################################################################### sub pg_newemail { my $email = shift; pg_msg(qq* E-mail Update E-mail Sent *,qq* An E-mail has been sent to $email, containing a URL (i.e., www address).
When you receive the E-mail, connect to the URL in your browser to complete the E-mail address update process. *); } ####################################################################### # E-mail update done ####################################################################### sub pg_didemail { pg_msg(qq* E-mail Address Update Successful *,qq* Your E-mail address update was successful. *); } ####################################################################### # no forward URL set ####################################################################### sub pg_noforwardurl { pg_msg(qq* Auto Update Successful but Forward URL Not Set *,qq* Your username and password were verified and your hostname now points to your new IP $remote_ip.

However you have not set a URL to forward to.
Please set a Forward URL in your GnuDIP settings. *); } ####################################################################### # AutoURL test succeeded ####################################################################### sub pg_goodautourl { pg_msg(qq* AutoURL Test Succeeded *,qq* Your username and password were verified and your hostname now points to your new IP $remote_ip.

Set this page as your default page and from now on it will automatically forward you to your Forward URL under the settings menu. *); } ####################################################################### # user options ####################################################################### sub pg_options { # ensure initialized default_empty('localaddr'); default_empty('user_pattern'); default_empty('errormsg'); header(); tpr(qq* $head $body *); if ($$pref{'DELETE_SELF'} eq 'YES' and !$$conf{'URL_delthisuser'}) { tpr(qq* *); } tpr(qq* $topline *); my $updateaddr = $remote_ip; if ($$userinfo{'level'} eq 'USER') { tpr(qq*

Hostname $$userinfo{'username'}.$$userinfo{'domain'} Currently Points to $$userinfo{'currentip'}
(Updated at $$userinfo{'updated'})

The computer that connected to GnuDIP has IP address $remote_ip

*); if ($$reqparm{'localaddr'} eq 'nojavascript') { tpr(qq* GnuDIP cannot determine if $remote_ip is the IP address of your computer.
Javascript is not enabled in your browser. *); } elsif ($$reqparm{'localaddr'} eq 'nojava') { tpr(qq* GnuDIP cannot determine if $remote_ip is the IP address of your computer.
Java is not enabled in your browser. *); } elsif ($$reqparm{'localaddr'} eq 'javaerror') { writelog('Error occured in Java applet:'); writelog(" message: $$reqparm{'errormsg'}"); tpr(qq* GnuDIP cannot determine if $remote_ip is the IP address of your computer.
The Java applet for doing this has failed with the following message:

$$reqparm{'errormsg'}
*); } elsif (validdotquad($$reqparm{'localaddr'})) { $updateaddr = $$reqparm{'localaddr'}; tpr(qq* The computer your browser is running on has IP address $updateaddr *); } elsif ($$reqparm{'localaddr'}) { writelog('Error occured in Java applet:'); writelog(" invalid IP address: $$reqparm{'localaddr'}"); tpr(qq* GnuDIP cannot determine if $remote_ip is the IP address of your computer.
The Java applet for doing this has failed. It returned an invalid IP address. *); } else { tpr(qq* Browser based IP address detection was not done *); } tpr(qq*
*); } tpr(qq*

User Options

*); if ($$reqparm{'updatehost'}) { tpr(qq*
Update done for $$userinfo{'username'}.$$userinfo{'domain'}

*); } elsif ($$reqparm{'offline'}) { tpr(qq*

Offline done for $$userinfo{'username'}.$$userinfo{'domain'}

*); } tpr(qq*

*); html_user(); $$reqparm{'updateaddr'} = $updateaddr if ! defined $$reqparm{'updateaddr'}; tpr(qq*
*); if ($$userinfo{'level'} eq "USER") { tpr(qq* *); } tpr(qq* *); if ($$userinfo{'level'} eq 'USER' and $$pref{'REQUIRE_EMAIL'} eq 'YES') { tpr(qq* *); } if ($$userinfo{'level'} eq 'USER' and $$pref{'ALLOW_AUTO_URL'} eq 'YES') { tpr(qq* *); } if ($$userinfo{'level'} eq 'ADMIN') { tpr(qq* *); } if ($$pref{'DELETE_SELF'} eq 'YES') { tpr(qq* *); } tpr(qq*
Update $$userinfo{'username'}.$$userinfo{'domain'}
to
Offline $$userinfo{'username'}.$$userinfo{'domain'}
Change Settings
Change E-mail Address
Set Auto URL
Add User
Manage Users
  User Pattern:
   
\*-zero or more characters
?-one character
Add Domain
Manage Domains
Administrative Settings
 
Delete Current User *); if (!$$conf{'URL_delthisuser'}) { tpr(qq* *); } else { # sign the self delete information my $checkval = md5_base64( $$userinfo{'username'} . '.' . $$userinfo{'domain'} . '.' . $$pref{'SERVER_KEY'} ); # the URL must have a question mark and any other # parameters already in it my $url = $$conf{'URL_delthisuser'}; $url .= 'user=' . $$userinfo{'username'}; $url .= '&domn=' . $$userinfo{'domain'}; $url .= '&sign=' . uri_escape($checkval); tpr(qq*
Delete
*); } tpr(qq*
*); # button for setting Quick Login my $detect; my $quick = "$thisurl?"; if ($updateaddr eq $$reqparm{'localaddr'}) { $quick .= 'login=ipdetect'; $detect = 'yes'; } else { $quick .= 'login=enc'; $detect = 'no'; } $quick .= "&username=$$userinfo{'username'}" . "&password=$$userinfo{'password'}"; if ($$userinfo{'level'} eq 'USER') { $quick .= "&domain=$$userinfo{'domain'}"; } tpr(qq*
*); html_user(); tpr(qq*
$bodyend *); exit; } ####################################################################### # user settings ####################################################################### sub pg_usersettings { pg_cmn_edituser($userinfo); } ####################################################################### # current user deleted ####################################################################### sub pg_usergone { pg_msg(qq* Current User Deleted *,qq* The current user has been deleted.
Please go back to the previous Login page. *); } ####################################################################### # set quick login ####################################################################### sub pg_setquick { # "&" has to become "&" in HTML my $quick = $$reqparm{'quick'}; $quick =~ s/\&/\&/g; header(); tpr(qq* $head $body $topline

Set Quick Login URL

Create a new Favorite or Bookmark now

Or in Windows create a Shortcut
Right click on this link:

GnuDIP Quick Login

The Favorite, Bookmark or Shortcut will do Quick Login. *); if ($$reqparm{'detect'} eq 'no') { tpr(q*

This URL will not do IP address detection.
Either Javascript or Java is not enabled in your browser.
*); } tpr(qq*

$bodyend *); exit; } ####################################################################### # Quick Login IP detection ####################################################################### sub pg_ipdetect { header(); tpr(qq* $headtxt <$bodytxt onload=\"winload()\">