| version 1.1, 2005/12/17 17:16:32 |
version 1.2, 2005/12/17 18:14:37 |
|
|
| <?php |
<?php |
| |
|
| $fm_imap_options = array( |
$fm_imap_options = array( |
| 'host' => 'localhost', |
'host' => 'localhost', |
| 'port' => 143, |
'port' => 143, |
| 'baseDSN' => '', |
'baseDSN' => '/imap/notls', |
| 'timeout' => 20 |
'timeout' => 5 |
| ); |
); |
| |
|
| if (!extension_loaded('imap')) { |
if (!extension_loaded('imap')) { |
| die('Cannot use IMAP authentication, IMAP extension not loaded!'); |
die('Cannot use IMAP authentication, IMAP extension not loaded!'); |
| } |
} |
| |
|
| $dsn = '{'.$fm_imap_options['host'].':'.$fm_imap_options['port'].$fm_imap_options['baseDSN'].'}'; |
session_start(); |
| |
|
| |
$logged = false; |
| |
$dsn = '{'.$fm_imap_options['host'].':'.$fm_imap_options['port'].$fm_imap_options['baseDSN'].'}'; |
| $username = $_REQUEST['username']; |
$username = $_REQUEST['username']; |
| $password = $_REQUEST['password']; |
$password = $_REQUEST['password']; |
| |
|
| |
if ($_SESSION['timestamp'] > time() - 90) { |
| |
$logged = true; |
| |
} |
| |
|
| if (strlen($username) > 0 && strlen($password) > 0) { /* {{{ */ |
if (strlen($username) > 0 && strlen($password) > 0) { /* {{{ */ |
| /* Check server */ |
|
| |
/* |
| |
* Check server |
| |
*/ |
| $fp = @fsockopen ($fm_imap_options['host'], $fm_imap_options['port'], |
$fp = @fsockopen ($fm_imap_options['host'], $fm_imap_options['port'], |
| $errno, $errstr, $fm_imap_options['timeout']); |
$errno, $errstr, $fm_imap_options['timeout']); |
| if (is_resource($fp)) { |
if (is_resource($fp)) { |
| Line 27 if (strlen($username) > 0 && strlen($pas |
|
| Line 37 if (strlen($username) > 0 && strlen($pas |
|
| die($message); |
die($message); |
| } |
} |
| |
|
| /* Check username & password */ |
/* |
| $conn = @imap_open($dsn, $username, $password, OP_HALFOPEN); |
* Check username & password |
| |
*/ |
| |
$conn = imap_open($dsn, $username, $password); |
| if (is_resource($conn)) { |
if (is_resource($conn)) { |
| @imap_close($conn); |
@imap_close($conn); |
| // create some sesion variables |
$logged = true; |
| } else { |
} else { |
| echo '<center><h1>Bad username or password</h1></center>'; |
echo '<center><h1>Bad username or password</h1></center>'; |
| exit; |
exit; |
| } |
} |
| } /* }}} */ |
} /* }}} */ |
| |
|
| /* Modeline for ViM {{{ |
|
| * vim: set ts=4: |
if (function_exists('fm_header')) { |
| * vim600: fdm=marker fdl=0 fdc=0: |
fm_header(); |
| * }}} */ |
} |
| |
|
| |
if (! $logged) { |
| |
|
| ?> |
?> |
| <?php if (function_exists('fm_header')) fm_header(); ?> |
|
| |
|
| <span class="fm-login"> |
<span class="fm-login"> |
| <table border="0" align="center" cellpadding="0" cellspacing="5" class="fm-login"> |
<table border="0" align="center" cellpadding="0" cellspacing="5" class="fm-login"> |
| Line 67 if (strlen($username) > 0 && strlen($pas |
|
| Line 80 if (strlen($username) > 0 && strlen($pas |
|
| </table> |
</table> |
| </span> |
</span> |
| |
|
| <?php if (function_exists('fm_footer')) fm_footer(); ?> |
<?php |
| <?php exit; ?> |
|
| |
} |
| |
|
| |
if (function_exists('fm_footer')) { |
| |
fm_footer(); |
| |
} |
| |
|
| |
if (! $logged) { |
| |
exit; |
| |
} |
| |
|
| |
$_SESSION['timestamp'] = time(); |
| |
|
| |
/* Modeline for ViM {{{ |
| |
* vim: set ts=4: |
| |
* vim600: fdm=marker fdl=0 fdc=0: |
| |
* }}} */ |
| |
|
| |
?> |