* Copyright (c) 2005 Platon Group, http://platon.sk/ * Licensed under terms of GNU General Public License. * All rights reserved. * * Changelog: * 2005-12-17 - created * */ /* $Platon: $ */ $fm_imap_options = array( 'host' => 'localhost', 'port' => 143, 'baseDSN' => '/imap/notls', 'timeout' => 5, 'session' => 900 /* 15 minutes */ ); /* * phpWebFileManager initialization * * Config file is read from init.inc.php file. */ $fm_init_file = dirname(__FILE__) . (strlen(dirname(__FILE__)) > 0 ? '/' : '') . '../init.inc.php'; if (! @file_exists($fm_init_file)) { exit; } require_once $fm_init_file; require_once $PN_PathPrefix . 'functions.inc.php'; if (!extension_loaded('imap')) { die('Cannot use IMAP authentication, IMAP extension not loaded!'); } session_start(); $logged = false; $dsn = '{'.$fm_imap_options['host'].':'.$fm_imap_options['port'].$fm_imap_options['baseDSN'].'}'; $username = $_REQUEST['username']; $password = $_REQUEST['password']; if ($_SESSION['timestamp'] > time() - $fm_imap_options['session']) { $logged = true; } if (strlen($username) > 0 && strlen($password) > 0) { /* {{{ */ /* * Check server */ $fp = @fsockopen ($fm_imap_options['host'], $fm_imap_options['port'], $errno, $errstr, $fm_imap_options['timeout']); if (is_resource($fp)) { @fclose($fp); } else { $message = "Error connecting to IMAP server " . $fm_imap_options['host'].':'.$fm_imap_options['port']; die($message); } /* * Check username & password */ $conn = @imap_open($dsn, $username, $password); if (is_resource($conn)) { @imap_close($conn); $logged = true; } else { echo '

Bad username or password

'; exit; } } /* }}} */ if (! $logged) { if (function_exists('fm_header')) { fm_header(); } ?>