#!/usr/bin/perl
use strict;
use lib "/var/www/agora/lib";

if (0 == 1) {
  print "Content-type: text/html\n\n";
  print "Server is temporarily unavailable for maintenance<p>";
  exit 0;
}

use CGI;
use Agora::Agora;
use Agora::DBMagora;
use Agora::DEFINITIONS qw(%CONST);


# Avoiding Denial of Service Attacks
use CGI::Carp 'fatalsToBrowser';
$CGI::POST_MAX = $CONST{'DEFAULT_MAX_CGI_INPUT_SIZE'};


$ENV{'QUERY_STRING'} = '' if !$ENV{'QUERY_STRING'};
my @query_string = split(/\+/, $ENV{'QUERY_STRING'});

my $r            = {};
   $r->{QUERY}   = new CGI;
   $r->{QSTRING} = [split(/\+/, $ENV{'QUERY_STRING'})];
   $r->{URL}     = $r->{QUERY}->url;
   $r->{DB}      = new DBMagora($CONST{'DEFAULT_DATABASE_DSN'},
                                $CONST{'DEFAULT_DATABASE_LOGIN'},
                                $CONST{'DEFAULT_DATABASE_PASSWD'});


# This CGI script should only be used for debugging.
# Remove the script from the server when you want to disable debugging.

#$r->{DEBUG}->{console} = 1; # enable debug to console
$r->{DEBUG}->{syslog} = 1;  # enable debug to syslog

#$r->{DEBUG}->{level} = 1;   # minimum level of debug messages (with a level selector)

# enabled tags of debug messages (with a tag selector)
my @debug_tags;
#push @debug_tags, ('vector');

my %h = map { $_ => 1 } @debug_tags; $r->{DEBUG}->{tags} = \%h;


Agora::login($r);

##############################################################
# End of file.
