Code:
#!/usr/bin/perl -w use strict;
use lib '.';
use GMail qw/:all/;
use GMail::Auth;
GMail::init('.');
$SIG{__DIE__} = \&GMail::fatal;
$| = 1;
main();
sub main {
# Load all template specific files.
my $t = GMail->template_set();
$CFG->load_template_set($t);
# If this site is disabled display the disabled page
if (!$CFG->{enabled}) {
return GMail->print_page('disabled.htm');
}
# Check to see if they are allowed to use the service
if (!GMail::Auth->allow_access()) {
require GMail::NoAuth;
return GMail::NoAuth->print_page($CFG->{templates}->{auth_error}, { error => ref($GMail::Auth::error) ? $GMail::Auth::error : \$GMail::Auth::error });
}
# Authenticate the user.
$GMail::Auth::error ||= ''; # -w warnings, ugg
my $ret = $PLG->dispatch('GMail::Auth::authenticate', sub { GMail::Auth->authenticate() });
unless ($ret) {
require GMail::NoAuth;
return GMail::NoAuth->auth_failed({ error => $GMail::Auth::error });
}
return $ret if $ret == EXIT;
# Find out which template set we are on.
$t = GMail->template_set();
$CFG->load_template_set($t);
GMail->print_page('foo.htm', { foo => "bar" });
}
Adrian