Location: PHPKode > projects > mailqui > mailqui/login.php
<?php
/**
 * The contents of this file are subject to the Guara. You may not use
 * this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.gnu.org/licenses/gpl.html
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * mailqui Login Page
 *
 * @version Revision: 4 - 02/11/2006
 * @author Andreas Hansen <hide@address.com>, IdeiaLivre - Software Livre como Estrategia
 * @package login
 *
 **/

/** Include Config file, that have some important functions and startup session **/
include( "config.inc.php" );

if ( $_REQUEST["action"] == "login" ) {
	if ( !file_exists( "mailqui.ini" ) ) {
		if ( $_REQUEST["user"] == "admin" AND $_REQUEST["pass"] == "admin" ) {
			redirect( ROOT_URL . "/mailqui.php?action=firstLogin&" . session_id() );
		} else {
			redirect( ROOT_URL );
		}
	} else {
		switch ( $config->get ( 'Method', 'authentication' ) ) {
			case "POP3":
				require("lib/auth/POP3/popAuth.inc.php");
				$authentication = new POPAuth( $_REQUEST["user"], $_REQUEST["pass"], $config->get( 'Server', 'auth_pop3' ) );
				break;
		}
		// If user is authenticated
		if( $authentication->validate() ) {
			// Then, authorizate user through global CanLogin parameter
			$canlogin = explode ( ",", $config->get ( 'CanLogin', 'authentication' ) );
			foreach ( $canlogin as $user ) {
				if ( trim($user) == $_REQUEST["user"] ) $userGranted = true;
			}
			if ( $userGranted == true ) {
				$_SESSION["username"] = $_REQUEST["user"];
				redirect( ROOT_URL . "/mailqui.php?" . session_id() );
			} else {
				redirect( ROOT_URL . "/login.php?lr=loginNAuthorized" );
			}
		} else {
			redirect( ROOT_URL . "/login.php?lr=loginError" );
		}
	}
} elseif ( $_REQUEST["action"] == "logout" ) {
	session_destroy();
	redirect( ROOT_URL );
} else {
?>
<html>
<head>
	<title>mailqui :: mail queue control</title>
	<style type="text/css" media="all">
		<!--
		@import "<?php echo ROOT_URL; ?>/output/css/style.css";
		-->
	</style>
</head>
<body onLoad="document.mailquiForm.user.focus();">
<form action="login.php" name="mailquiForm" method="post">
<?php if ( $_REQUEST['lr'] ) { ?>
	<div style="margin: 0 auto; width: 300px; padding:0; margin-top: 170px; text-align: center; padding: 10px; color: #FF410C; font-weight: bold;">
		<?php echo getLanguageString( $_REQUEST['lr'] ); ?>
	</div>
<?php } elseif ( !file_exists( "mailqui.ini" ) ) { ?>
	<div style="margin: 0 auto; width: 300px; padding:0; margin-top: 170px; text-align: center; padding: 10px;">
		<?php echo getLanguageString( "firstLogin" ); ?>
	</div>
<?php } ?>

<div style="margin:0 auto;padding:0;margin-top: <?php if ( $_REQUEST['lr'] OR  !file_exists( "mailqui.ini" ) ) { ?>5<?php } else { ?>200<?php } ?>px; width: 300px; padding: 10px; border: 1px solid #D6D6D6;">
	<table align="center">
	<tr>
		<td><img src="<?php echo ROOT_URL; ?>/output/img/mailqui.png" border="0"></td>
		<td style="font-size: 16px; font-weight: bold; color: #DE991B;">mailqui :: mail queue control</td>
	</tr>
	</table><br />
	<table align="center">
	<tr>
		<td><?php echo getLanguageString( 'username' ); ?>:</td>
		<td><input type="text" name="user"></td>
	</tr>
	<tr>
		<td><?php echo getLanguageString( 'password' ); ?>:</td>
		<td><input type="password" name="pass"></td>
	</tr>
	<tr height="3px"><td colspan="2"></td></tr>
	<tr><td align="center" colspan="2"><input type="submit" value="login" onClick="document.mailquiForm.action.value='login';"></td></tr>
	</table>
</div>
<?php
}
?>
	<input type="hidden" name="action" value="">
</form>
</body>
</html> 
Return current item: mailqui