Location: PHPKode > projects > FreeRealty > FR-3.0-0.rc10/common30.sample.php
<?php
// $Id: common30.sample.php,v 2.8 2007/11/08 15:50:26 pat Exp $ 
//common include file for versions 3.0 and up
/** \file 
 * \brief Sample main configuration file.
 *
 * This file can be used by copying or renaming it to common.php. 
 * Most configuration has been moved to the database. This should make the 
 * db connection, pull configuration options from the db. Admin users can 
 * change the configuration through the admin interface.
 */
 


//mysql database setup
$server = "localhost";
$db = "freerealty"; /**< Database name */
$table_prefix=""; /**< Defaults to no prefix. This allows you to use the same 
		   *database for more than one installation, especially helpful
		   *on a shared host */
$user = "fr"; /**< Database user name */ 
$password = "fr"; /**< Database password */
define("temp_dir", "/tmp", "yes"); //Where is the temporary directory - 
			//we can't really do this as a variable
/**** Try to connect to the server ****/
$setup_link = mysql_connect($server, $user, $password);
if (!$setup_link)
	die ("Couldn't connect to MySQL server. Check your configuration in common.php");
if (!mysql_select_db ($db, $setup_link))
	die("Unable to open $db: ".mysql_error().". Check that the database exists and is correct");

/** Get the initial configuration data from the database */
if (!isset($baseurl))
{
 $sql = "select config_key, config_value from ".$table_prefix."configuration where config_key = 'baseurl' or config_key = 'install_path' or config_key = 'includes' "; 
 //echo "$sql";
 $results = mysql_query($sql, $setup_link);
 if (!$results) {
	 die("Database does not appear to be configured
		 Check docs for configuration instructions");
 }
 while ($a_results = mysql_fetch_array($results) )
 {
	$key = "$a_results[0]";
	$value = "$a_results[1]";	
	$$key = "$value";
 //	echo "<br /> $key : $value";
 }
}
/** Contributed by Martin Purcell
  * Tweaks by Patrick Fleming. This function reads through the includes 
  * directory automatically pulling in files that end in php  */

function GetIncludes($dir) //Trimmed the function a 'little' and changed it to
			   // more match my coding style
{
 $hdl = opendir($dir);    
 while (false !== ($dirEntry = readdir($hdl))) 
 {
	 if (substr("$dirEntry", 0,1) != "." && substr("$dirEntry", -4,4) == ".php")
   {
    $listing[] = $dirEntry;
   }
 }
 closedir($hdl);

  if (sizeof($listing) > 0) 
 {
  foreach($listing as $blah) 
  {
   if (!is_dir($dir."/".$blah)) 
   {
    $data[] = $dir."/".$blah;
   }
  }
 }
 return $data;
}
/** The last part of using the includes directory, finalizes pulling in this 
  * directory */
$inc = GetIncludes($includes); //replaced empty () with $includes
foreach($inc as $line)
 include_once($line);
//End testing function by Martin Purcell
?>
Return current item: FreeRealty