<?
//
// Read the list of permitted login hosts from the LOGIN_HOST_FILE
//
// Use $numHosts to return the number of hosts found and $loginHostNames and 
// $loginHostAddresses to return a list of the host names + IP addresses
//
// If no LOGIN_HOST_FILE exists, then $numHosts will return 0
//
// Copyright, Exolution GmbH / Michael Kerrisk, Sep 2000
// http://www.exolution.com/wapsh   mailto:wapsh@exolution.de
//
// This software is Open Source licensed under the terms of the Trolltech QPL
// version 1.0.  See http://www.exolution.de/wapsh for further information.
//
// ---------------------------------------------------------------------
//
define(LOGIN_HOST_FILE, "loginhosts");

function getLoginHosts(&$numHosts, &$loginHostNames, &$loginHostAddresses) {
    $numHosts = 0;
    $fp = @fopen(LOGIN_HOST_FILE, "r");
    if ($fp) {
	while (!feof($fp)) {
	    $line = fgets($fp, 200);
	    $line = trim(ereg_replace("#.*", "", $line));

	    if (strlen($line) == 0) continue;
	    
	    $parts = explode(" ", $line);
	    $loginHostNames[$numHosts] = $parts[0];
	    $loginHostAddresses[$numHosts] = (sizeof($parts) < 2) ? $parts[0] : 
					$parts[1];
     	    $numHosts++;
	}
	fclose($fp);
    } // if 
} // getLoginHosts
?>
