Location: PHPKode > scripts > GenieGate Membership protection software > web/admin/doconf.php
<?php
/**
 * $Id: doconf.php,v 1.2 2007/10/17 10:16:50 joe Exp $
 *
 * This file is responsible for locating and setting up GenieGate. It needs to
 * locate the libraries and ini file. 
 *
 * We need to be absolutely clear about one thing, the ~/geniegate files should
 * NEVER be accessed in a web browser, you SHOULD NOT BE ABLE TO BROWSE THEM,
 * they need to be kept safely OUTSIDE OF WEB SPACE ENTIRELY. Not even during
 * setup. (We don't even recommend protecting them with passwords, they should 
 * be kept off the web site entirely whenever possible)
 *
 * GenieGate makes it easy to do this because it defaults to your HOME
 * directory, unfortunately many people are under the belief that the HOME
 * directory refers to their web root, this is NOT THE CASE. By "HOME" we
 * literally mean your home directory, (typically '/' when you login with ftp)
 *
 * This is very important. Many (if not most) PHP/CGI scripts actually get this 
 * wrong, chances are, you've probably installed them before. 
 *
 *
 * It tries it in 3 ways:
 * 
 * A. GENIEGATE_HOME is defined. If nothing else works, do this:
 *      define('GENIEGATE_HOME','/path/OUTSIDE/OF/THE/WEB/geniegate')
 *
 * B. The environment variable GENIEGATE_HOME is defined.
 *      In an .htaccess file: SetEnv GENIEGATE_HOME /path/OUTSIDE/WEB/SPACE/geniegate
 *      (or however your particular web server sets environment variables)
 *        
 * C. The users HOME directory is searched for ~/geniegate
 *
 *      Simply do nothing at all, just edit your ~/geniegate/conf/geniegate.ini
 *
 *
 */


/** 
* If it cannot find the libraries on it's own, you can set this. (But do read
* the above warning, make sure you understand it)
*/
//define('GENIEGATE_HOME','/your/path/to/geniegate');

function geniegate_bomb_conf($err){
	echo '<html><head></head><body><h1>Problem</h1>';
	echo '<p>GenieGate is unable to locate initial configuration.</p>';
	echo '<p><a href="setup.php">Try running setup</a></p>';
	echo "<p>If you've already done this, you might edit doconf.php</a></p>";
	die("Unable to run, $err");
}

function findConf(){ 
	if(! defined("GENIEGATE_HOME")){
		$home = getenv('GENIEGATE_HOME');
		if(! $home){
			$user = fileowner($_SERVER['SCRIPT_FILENAME']);
			if(! $user){
				geniegate_bomb_conf('File has no owner??');
			}
			$inf = posix_getpwuid($user);
			$home = $inf['dir'] . "/geniegate";
			if(! is_dir($home)){
				geniegate_bomb_conf("I can't find my ~/geniegate directory");
			}
		}
		define('GENIEGATE_HOME',$home);
	}
	if(! defined('GENIEGATE_HOME')){
		geniegate_bomb_conf("Some how, GENIEGATE_HOME wasn't defined");
	}
	$file = GENIEGATE_HOME . '/conf.php'; // provides genieGateLoadConf()
	if(! file_exists($file)){
		die("Missing $file");
	}
	require_once($file);
	return(genieGateLoadConf(GENIEGATE_HOME . '/conf/geniegate.ini'));
  }
?>
Return current item: GenieGate Membership protection software