File "checkFilePermissions.php"

Full Path: /home/analogde/www/JAVA/system/checkFilePermissions.php
File size: 2.62 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!
***************************************************************/

function checkFilePermissions($fileName, $isFile = true){
	GLOBAL $PXP_user, $byPathMembers;
	GLOBAL $PXP_user_rightsOpen_byName, $PXP_user_rightsOpen_byTypekey;
	GLOBAL $PXP_user_rightsEdit_byName, $PXP_user_rightsEdit_byTypekey;
	GLOBAL $PXP_rightsOpen_byPath_invert, $PXP_rightsOpen_byPath;
	GLOBAL $PXP_rightsEdit_byPath_invert, $PXP_rightsEdit_byPath;
	
	$allowOpen = true;
	$allowEdit = true;

	if($isFile){
		$extKey = getTypeKeyByExtension($fileName);
	}else{
		if(strpos($fileName, ".") === FALSE){
			$extKey = "folder";
		}else{
			$extKey = getTypeKeyByExtension($fileName);
		}
	}
	
	if($PXP_user != "root"){

		if(in_array($extKey, $PXP_user_rightsOpen_byTypekey) or in_array($fileName, $PXP_user_rightsOpen_byName))
			$allowOpen = false;

		if(in_array($extKey, $PXP_user_rightsEdit_byTypekey) or in_array($fileName, $PXP_user_rightsEdit_byName))
			$allowEdit = false;
		
		if($allowOpen or $allowEdit){

			foreach($byPathMembers as $member){

				if($PXP_rightsOpen_byPath_invert[$member]){# alles verboten dann erlauben
					$allowOpen = in_array($fileName, $PXP_rightsOpen_byPath[$member]);
				}else{# alles erlaubt dann verbieten 
					$allowOpen = !in_array($fileName, $PXP_rightsOpen_byPath[$member]);
				}

				if($allowEdit){
			
					if($PXP_rightsEdit_byPath_invert[$member]){
						$allowEdit = in_array($fileName, $PXP_rightsEdit_byPath[$member]);
					}else{
						$allowEdit = !in_array($fileName, $PXP_rightsEdit_byPath[$member]);
					}
				}
			}
		}
	}
	
	if(!$isFile and $extKey == "")
		$extKey = "folder";
	
	return Array("extKey" => $extKey, "allowOpen" => $allowOpen, "allowEdit" => $allowEdit);
}
?>