1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
package essai;
use FindBin;
use lib "$FindBin::Bin/../lib";
use CGI qw/:standard/;
use CGI::Session;
use Infoblox;
require "common.pm";
#########################################################################
####### Récupère les paramètres de configuration du portail ######
#########################################################################
GetPortalParameters();
#########################################################################
####### Récupère le POST du login et du password ######
#########################################################################
my $UserLogin = param('login');
my $UserPassword = param('pwd');
if ($UserLogin && $UserPassword ) {
eval {
#########################################################################
####### Authentifie le user sur l'Infoblox ######
#########################################################################
my $SESSION;
$SESSION = Infoblox::Session->new ( 'master' => $Parametres{Master} , 'username' => $UserLogin, 'password' => $UserPassword );
if ($SESSION->status_detail() ne 'Operation succeeded') {
$url = "../index.html";
print "Location: $url\n\n";
exit;
}
#########################################################################
####### Fabrique la session ######
#########################################################################
$CGISession = new CGI::Session("driver:File", undef, {Directory => 'session'} );
my $sess_id = $CGISession->id();
$CGISession->expire('+20m');
$CGISession->param('User', $UserLogin);
$CGISession->param('Password', $UserPassword);
$CGISession->param('Logged', 'ok');
$CGISession->param('SuperUser', $power);
$CGISession->param('Host', $Parametres{Host});
$CGISession->param('Cname', $Parametres{Cname});
$CGISession->param('A', $Parametres{A});
$CGISession->param('Txt', $Parametres{Txt});
$CGISession->param('Mx', $Parametres{Mx});
$CGISession->param('View', $Parametres{ViewForListing});
#########################################################################
####### Récupère les droits granulaires si la fonction est enable ######
#########################################################################
$CGISession->flush();
print 'Set-Cookie: CGISESSIONID=' . $sess_id ."\n";
if (int(rand(5)) == 2) {
$filez = "session/*";
while ($file = glob($filez)) {
@stat=stat $file;
$hour = (time()-$stat[9]) / (60*60);
unlink $file if ($hour > 4);
}
}
if ($UserLogin eq $Parametres{AdminAccount}) {
print "Content-type: text/html\n\n";
print "<HTML><BODY><HEAD>\n";
print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=parameters.cgi\">\n";
print "<\/HEAD><\/BODY><\/HTML>\n";
exit;
} else {
print "Content-type: text/html\n\n";
print "<HTML><BODY><HEAD>\n";
print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=list.cgi\">\n";
print "<\/HEAD><\/BODY><\/HTML>\n";
exit;
}
}; |
Partager