PHP Classes

File: config.inc.php

Recommend this page to a friend!
  Classes of Danny Tucker   EZ Framework   config.inc.php   Download  
File: config.inc.php
Role: Configuration script
Content type: text/plain
Description: Config File
Class: EZ Framework
Framework providing several types of functionality
Author: By
Last change: cleaned up some code not required for this version of the classes
Date: 18 years ago
Size: 6,486 bytes
 

Contents

Class file image Download
<?php
// The classes are autoloaded but only work in php5+
// so if you use php4 I have all the classes included on this page
// not very effeciant but whatever upgrade then

// If you are using php4 but not using all the classes you will need to modifiy
// "if($is_php4)" area right above the do not edit below this line comment
$is_php4 = false;

if(
eregi( "config.inc.php", $_SERVER['PHP_SELF'] ) )
    die(
"This File Cannot Be Viewed Directly");
## ---------------------------------------------------------------------------------##
## ------------------------------ Auto Switch Profile ------------------------------##
## ---------------------------------------------------------------------------------##
# Use part of the localhost document root path that the live server wont have in it
# This will auto switch which database connection profile to use
$unique_local = 'c:/wamp';

## ---------------------------------------------------------------------------------##
## ---------------------- Database/Site Path Configuration -------------------------##
## ---------------------------------------------------------------------------------##

if( eregi( $unique_local, $_SERVER['DOCUMENT_ROOT'] ) )
   
$profile = 0;
else
   
$profile = 1;

switch(
$profile )
{
   
# Localhost
   
case 0:
       
define('DB_HOST', 'localhost'); // Database Host
       
define('DB_USER', ''); // Database User Name
       
define('DB_PASSWORD', ''); // Database User Password
       
define('DB_NAME', ''); // Database Name
       
        # Site Paths
       
define('PATH_ROOT',$_SERVER['DOCUMENT_ROOT']);
       
       
// If main files reside on root level site_sub_path should be blank ''
       
$site_sub_path = '/sites/mysite/';
       
       
// Add path to each folder you want to have a set path to
       
define('PATH_SITE', PATH_ROOT.$site_sub_path);
       
define('PATH_INCLUDE', PATH_SITE.'include/');
       
define('PATH_INC_CLASS',PATH_INCLUDE.'class/');
       
define('PATH_IMAGE', PATH_SITE.'images/');
       
define('PATH_CSS', PATH_SITE.'css/');
    break;
   
# Live Site
   
case 1:
       
define('DB_HOST', 'localhost'); //D atabase Host
       
define('DB_USER', ''); // Database User Name
       
define('DB_PASSWORD', ''); // Database User Password
       
define('DB_NAME', ''); // Database Name
       
        # Site Paths
       
define('PATH_ROOT',$_SERVER['DOCUMENT_ROOT']);
       
       
// If main files reside on root level site_sub_path should be blank ''
       
$site_sub_path = '';
       
       
// Add path to each folder you want to have a set path to
       
define('PATH_SITE', PATH_ROOT.$site_sub_path);
       
define('PATH_INCLUDE', PATH_SITE.'include/');
       
define('PATH_INC_CLASS',PATH_INCLUDE.'class/');
       
define('PATH_IMAGE', PATH_SITE.'images/');
    break;
}

// Website Name, not required but comes in handy to use if not using config values saved in a database or flat file
define('SITE_NAME', 'YOUR SITE NAME');

// 1 = On, 0 = Off
// Requires coresponding table under $_T['CONFIG']
$database_config = 0;


## ---------------------------------------------------------------------------------##
## ---------------------------- Table Declorations ---------------------------------##
## ---------------------------------------------------------------------------------##
// List all table defined names and actual names in the database to link to

// Table prefix to use if any, if none leave blank
$table_prefix = '';
global
$_T;
// Table reference name => real table name
$_T = array
(
   
'USER' => $table_prefix . 'user',
   
'CONFIG' => $table_prefix . 'config',
   
'SESSION' => $table_prefix . 'session'
);

## ---------------------------------------------------------------------------------##
## -------------------------------- Authentication ---------------------------------##
## ---------------------------------------------------------------------------------##
/*
    Notes:
    $_CONFIG is linked to $_T['CONFIG']
    $_AUTH['USER'] is linked to $_T['USER']
    $_AUTH['SESSION'] is linked to $_T['SESSION']
*/

// Table columns needed for Authentication
// and config if you use the db config
$_CONFIG['NAME'] = 'config_name';
$_CONFIG['VALUE'] = 'config_value';
$_AUTH['USER']['login'] = 'user_login';
$_AUTH['USER']['password'] = 'user_password';
$_AUTH['USER']['id'] = 'user_id';
$_AUTH['SESSION']['user_id']= 'user_id';
$_AUTH['SESSION']['id'] = 'session_id';
$_AUTH['SESSION']['ip'] = 'session_ip';
$_AUTH['SESSION']['begin'] = 'session_begin';
$_AUTH['SESSION']['end'] = 'session_end';
$_AUTH['SESSION']['total'] = 'session_total';


if(
$is_php4)
{
    require_once (
PATH_INC_CLASS . 'sql' . '.php' );
    require_once (
PATH_INC_CLASS . 'auth' . '.php' );
    require_once (
PATH_INC_CLASS . 'form_handle' . '.php' );
    require_once (
PATH_INC_CLASS . 'pagination' . '.php' );
    require_once (
PATH_INC_CLASS . 'file_handle' . '.php' );
    require_once (
PATH_INC_CLASS . 'image_handle' . '.php' );
    require_once (
PATH_INC_CLASS . 'email' . '.php' );
    require_once (
PATH_INC_CLASS . 'sorting' . '.php' );
}


## ---------------------------------------------------------------------------------##
## ------------------------ DO NOT EDIT BELOW THIS LINE ----------------------------##
## ---------------------------------------------------------------------------------##
define('ID_SESSION_NAME', 'session_auth');

function
__autoload( $class_name )
{
   require_once (
PATH_INC_CLASS . $class_name . '.php' );
}

//Get config settings from database
// Default database connection object
$sql = new sql(DB_HOST, DB_NAME, DB_USER, DB_PASSWORD);

if(
$database_config === 1 )
{
    global
$config;
   
$config = array();
   
$sql->go( "SELECT * FROM {$_T['CONFIG']}", 'config' );
   
$row = $sql->fetchAll( 'config' );
    foreach(
$row as $row )
    {
       
define( strtoupper( $row['config_name']), $row['config_value'] );
       
$config[$row['config_name']] = $row['config_value'];
    }
   
$sql->clearResult('config');
}
#Create defined table names and values
foreach( $_T as $t_key => $t_value )
{
   
define( 'T_'.$t_key, $t_value );
}

#Start the session @=supress errors if fails to start
@session_start();

//Unset these variables as they are no longer needed
if(isset($site_sub_path)) unset($site_sub_path);
if(isset(
$unique_local)) unset($unique_local);
if(isset(
$session_var)) unset($session_var);
if(isset(
$profile)) unset($profile);
if(isset(
$t_count)) unset($t_count);
if(isset(
$x)) unset($x);
if(isset(
$use_db_config)) unset($use_db_config);
?>