inc/auth.inc.php
changeset 4 55ed92aa7cf5
parent 1 58094faf794d
child 6 9fcac40c1b0e
equal deleted inserted replaced
3:64525a2eb098 4:55ed92aa7cf5
    37 }
    37 }
    38 
    38 
    39 // Check if the session hasnt expired yet.
    39 // Check if the session hasnt expired yet.
    40 if ((isset($_SESSION["userid"])) && ($_SESSION["lastmod"] != "") && ((time() - $_SESSION["lastmod"]) > $EXPIRE))
    40 if ((isset($_SESSION["userid"])) && ($_SESSION["lastmod"] != "") && ((time() - $_SESSION["lastmod"]) > $EXPIRE))
    41 {
    41 {
    42 	logout("Session expired, please login again.");
    42 	logout( _('Session expired, please login again.') );
    43 }
    43 }
    44 
    44 
    45 // If the session hasn't expired yet, give our session a fresh new timestamp.
    45 // If the session hasn't expired yet, give our session a fresh new timestamp.
    46 $_SESSION["lastmod"] = time();
    46 $_SESSION["lastmod"] = time();
    47 
    47 
    64         	}
    64         	}
    65     	}
    65     	}
    66     	else
    66     	else
    67     	{
    67     	{
    68         	//Authentication failed, retry.
    68         	//Authentication failed, retry.
    69 	        auth("Authentication failed!");
    69 	        auth( _('Authentication failed!') );
    70 	}
    70 	}
    71 }
    71 }
    72 else
    72 else
    73 {
    73 {
    74 	//No username and password set, show auth form (again).
    74 	//No username and password set, show auth form (again).
    81 
    81 
    82 function auth($msg="")
    82 function auth($msg="")
    83 {
    83 {
    84 	include_once('inc/header.inc.php');
    84 	include_once('inc/header.inc.php');
    85 	?>
    85 	?>
    86 	<H2>PowerAdmin for PowerDNS</H2><H3>Please login:</H3>
    86 	<H2><? echo _('PowerAdmin for PowerDNS'); ?></H2><H3><? echo _('Please login'); ?>:</H3>
    87 	<?
    87 	<?
    88 	if($msg)
    88 	if($msg)
    89 	{
    89 	{
    90 		print "<font class=\"warning\">$msg</font>\n";
    90 		print "<font class=\"warning\">$msg</font>\n";
    91 
    91 
    92 	}
    92 	}
    93 	?>
    93 	?>
    94 	<FORM METHOD="post" ACTION="<?= $_SERVER["PHP_SELF"] ?>">
    94 	<FORM METHOD="post" ACTION="<?= $_SERVER["PHP_SELF"] ?>">
    95 	<TABLE BORDER="0">
    95 	<TABLE BORDER="0">
    96 	<TR><TD STYLE="background-color: #FCC229;">Login:</TD><TD STYLE="background-color: #FCC229;"><INPUT TYPE="text" CLASS="input" NAME="username"></TD></TR>
    96 	<TR><TD STYLE="background-color: #FCC229;"><? echo _('Login'); ?>:</TD><TD STYLE="background-color: #FCC229;"><INPUT TYPE="text" CLASS="input" NAME="username"></TD></TR>
    97 	<TR><TD STYLE="background-color: #FCC229;">Password:</TD><TD STYLE="background-color: #FCC229;"><INPUT TYPE="password" CLASS="input" NAME="password"></TD></TR>
    97 	<TR><TD STYLE="background-color: #FCC229;"><? echo _('Password'); ?>:</TD><TD STYLE="background-color: #FCC229;"><INPUT TYPE="password" CLASS="input" NAME="password"></TD></TR>
    98 	<TR><TD STYLE="background-color: #FCC229;">&nbsp;</TD><TD STYLE="background-color: #FCC229;"><INPUT TYPE="submit" NAME="authenticate" CLASS="button" VALUE=" Login "></TD></TR>
    98 	<TR><TD STYLE="background-color: #FCC229;">&nbsp;</TD><TD STYLE="background-color: #FCC229;"><INPUT TYPE="submit" NAME="authenticate" CLASS="button" VALUE=" <? echo _('Login'); ?> "></TD></TR>
    99 	</TABLE>
    99 	</TABLE>
   100 	<?
   100 	<?
   101 	include_once('inc/footer.inc.php');
   101 	include_once('inc/footer.inc.php');
   102 	exit;
   102 	exit;
   103 }
   103 }