File "htaccess_auth.php"

Full Path: /home/analogde/www/JAVA/system/authentication/htaccess_auth.php
File size: 1.95 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2003-2004 Tobias Bender (tobias@phpXplorer.org)
*  All rights reserved
*
*  This script is part of the phpXplorer project. The phpXplorer project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*  A copy is found in the textfile GPL.txt distributed with these scripts.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

$PXP_user = isset($HTTP_SERVER_VARS['REMOTE_USER']) ? $HTTP_SERVER_VARS['REMOTE_USER'] : $HTTP_SERVER_VARS['REDIRECT_REMOTE_USER'];
$PXP_user_roles = Array();

$PXP_users = Array();
$PXP_roles = Array();

# parse htpasswd file and fill $PXP_users array with all usernames

if(file_exists($PXP_dir . "/.htpasswd")){

	$lines = file($PXP_dir . "/.htpasswd");

	foreach($lines as $index => $line){
		$parts = explode(":", trim($line));
		array_push($PXP_users, trim($parts[0]));
	}
}

# parse htgroups file and fill $PXP_users array with all usernames and $PXP_user_roles with the roles of the current user

if(file_exists($PXP_dir . "/.htgroups")){

	$lines = file($PXP_dir . "/.htgroups");

	foreach($lines as $index => $line){
		$parts = explode(":", trim($line));
		$arrAuthUsers = explode(" ", trim($parts[1]));
	
		array_push($PXP_roles, trim($parts[0]));
	
		if(in_array($PXP_user, $arrAuthUsers))
			array_push($PXP_user_roles, trim($parts[0]));
	}
}

?>