Location: PHPKode > scripts > File Exchange Protocol > file-exchange-protocol/test/server_example.php
<?php
/***************************************************************************
 *   Copyright (C) 2007 by Cesar D. Rodas                                  *
 *   hide@address.com                                                     *
 *                                                                         *
 *   Permission is hereby granted, free of charge, to any person obtaining *
 *   a copy of this software and associated documentation files (the       *
 *   "Software"), to deal in the Software without restriction, including   *
 *   without limitation the rights to use, copy, modify, merge, publish,   *
 *   distribute, sublicense, and/or sell copies of the Software, and to    *
 *   permit persons to whom the Software is furnished to do so, subject to *
 *   the following conditions:                                             *
 *                                                                         *
 *   The above copyright notice and this permission notice shall be        *
 *   included in all copies or substantial portions of the Software.       *
 *                                                                         *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
 ***************************************************************************/
 
/**
 *	File Exchange Protocol
 *	
 *	This is a PHP class based on Amazon S3 like transference protocol.
 *	The Idea is to develope a fexible, plataform indepente, file transfer
 *	that works over HTTP(s). Basically for exchange files between servers.
 *
 *	@package File Exchange Protocol
 *	@version 1.0
 *	@author Cesar D. Rodas
 *	@license BSD License
 */
require("FEP_server.php");

/**
 *	Creating a FEP server, and pasing as a paramenter
 *	the callback function that will check the users
 *	permissionss.
 */
$server = new FEP_server('auth');
/* 
 *	Working directory, PHP should be the owner of this folder or at read write permission
 *	If this property is not set, by default it is pwd();
 */
$server->setWorkingDir('./repository');
/* start server, handle queries */
$server->start();
 
/**
 *	Authentication.
 *
 *	Authentication is handled by an User defined function that must
 *	return True or false. 
 *	By this way a better permission system could be handle and saved
 *	into a database for exampl.e
 *
 *	If this function is not written, every users, will be able to 
 *	do everything.
 *
 *	@param string $user Username that request the action
 *	@param string $password Byref, Here we should write the password of the username
 *	@param string $action The action that he wants to do over $path.
 *	@param string $path
 */
function auth($user, &$password, $action, $path) {
	/* in this example, user cesar, with password rasec could do everything*/
	if ($user == "cesar") {
		$password="rasec";
		return true; 
	}
	return false;
}

?>
Return current item: File Exchange Protocol