Location: PHPKode > projects > FiForms Framework > FiForms/FiForms-includes/FiForms_global.inc.php
<?php
/**
*******************************************************************************

    FiForms -- A collection of PHP classes designed 
    to facilitate rapid development of web-database software

    Copyright (C) 2003-2008  Daniel McFeeters

    This library 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.

    This library 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.

    You should have received a copy of the GNU General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


    The original author of this library can be contacted at the following 
    address:

    Daniel McFeeters
    182 Baker Rd.
    Faubush, KY 42544-6526
    email:databases [at] fiforms [dot] org
    http://www.fiforms.org/


Project Started May 4, 2003
*******************************************************************************
FiForms_global.inc.php

 * Global Defaults File
 * 
 * This file sets the default FiForms configuration. 
 * 
 * DO NOT MODIFY THIS FILE to configure FiForms:
 * place your configuration in localconfig.php instead.
 * 

*******************************************************************************
**/

require_once("FiForms_fillVars.inc.php");    // fillVars function
require_once("FiForms_selectValue.inc.php"); // selectValue function
require_once("appconfig.inc.php");           // FiFormsAppConfig Class

/* ?><code><?php */


//***************** DATABASE SETTINGS *********************

function FIFORMS_SET_APP_PATH()
{
  global $FIFORMS_CONFIG;

    if(array_key_exists('app',$_GET) && !array_key_exists('APP_NAME',$FIFORMS_CONFIG))
    {
        if(!preg_match('/^[a-zA-Z0-9_]+$/',$_GET['app']))
        {
            die('Error in App Name');
        }
        $FIFORMS_CONFIG['APP_NAME'] = $_GET['app'];
    }
    if(is_array($FIFORMS_CONFIG['AVAILABLE_APPS']) && array_key_exists('APP_NAME',$FIFORMS_CONFIG) && in_array($FIFORMS_CONFIG['APP_NAME'],$FIFORMS_CONFIG['AVAILABLE_APPS']))
    {
        $FIFORMS_CONFIG['XML_PATH'] = $FIFORMS_CONFIG['APP_BASE'].$FIFORMS_CONFIG['APP_NAME']."/forms/";
        $FIFORMS_CONFIG['MENU_PATH'] = $FIFORMS_CONFIG['APP_BASE'].$FIFORMS_CONFIG['APP_NAME']."/menus/";
        $FIFORMS_CONFIG['RPT_PATH'] = $FIFORMS_CONFIG['APP_BASE'].$FIFORMS_CONFIG['APP_NAME']."/reports/";
    }
    if(array_key_exists('APP_NAME',$FIFORMS_CONFIG))
    {
        $appconfig = $FIFORMS_CONFIG['SCRIPT_PATH']."/app/".$FIFORMS_CONFIG['APP_NAME']."/appconfig.php";
        if(file_exists($appconfig))
        {
            include_once($appconfig);
        }
        else
        {
            $appconfig = $FIFORMS_CONFIG['APP_BASE'].$FIFORMS_CONFIG['APP_NAME']."/appconfig.php";
            if(file_exists($appconfig))
            {
                include_once($appconfig);
            }
        } // if appconfig
    } // if APP_NAME


    // get the template from the configuration, otherwise use default template.

    $templateFile = $FIFORMS_CONFIG['SCRIPT_PATH'].
                    "themes/".
                    $FIFORMS_CONFIG['ICON_SET']."/htmltemplate.php";

    if(file_exists($templateFile))
    {
        include_once($templateFile);
    }
    else
    {
         //$templateFile = "htmltemplate.php";
    }
include_once($GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH']."themes/".$FIFORMS_CONFIG['ICON_SET']."/iconset.php");

} // function FIFORMS_SET_APP_PATH

function FIFORMS_DETECT_SERVER()
{
    return ("http".($_SERVER['SERVER_PORT'] == 443 ? "s" : "").
            "://".$_SERVER["SERVER_NAME"].
        ($_SERVER['SERVER_PORT'] != 80 && 
                $_SERVER['SERVER_PORT'] != 443  ? 
                ":".$_SERVER['SERVER_PORT'] : ""));
}
function FIFORMS_DETECT_URI()
{
    //echo ($_SERVER['DOCUMENT_ROOT']."<br />");
    //die($GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH']);
    if(strpos($GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH'],$_SERVER['DOCUMENT_ROOT']) === 0)
    {
        return (str_ireplace($_SERVER['DOCUMENT_ROOT'],$GLOBALS['FIFORMS_CONFIG']['SERVER_ADDRESS']."/",$GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH']));
    }
    else
    {
        return($GLOBALS['FIFORMS_CONFIG']['SERVER_ADDRESS'].dirname($_SERVER['REQUEST_URI']).'/');
    }
}

function FIFORMS_REGISTER_XML($xmlfile)
{
        $cfg = new FiFormAppConfig();
        $cfg->load($xmlfile);
        $appname = $cfg->getName();
        if(!$appname)
        {
            return false;
        }
        $appinfo['appversion'] = $cfg->getVersion();
        $appinfo['xmlversion'] = $cfg->getXMLVersion();
        if(array_search($appinfo['xmlversion'],$GLOBALS['FIFORMS_CONFIG']['SUPPORTED_XML_VERSIONS']) === FALSE)
        {
            echo 'This application is not supported by this version of FiForms.<br />';
            echo 'The application requires XML version: '.$appinfo['xmlversion'].'<br />';
            echo 'You are current running FiForms version: '.$GLOBALS['FIFORMS_CONFIG']['VERSION'].' which supports XML versions ';
            foreach($GLOBALS['FIFORMS_CONFIG']['SUPPORTED_XML_VERSIONS'] as $ver)
            {
                echo "$ver, ";
            }
            echo '<br />You may have a problem with your application, or you may need to upgrade to a later version of FiForms. Click the back button on your browser to return.';
            die();
        }
        $GLOBALS['FIFORMS_CONFIG']['AVAILABLE_APPS'][] = $appname;
        $GLOBALS['FIFORMS_CONFIG']['AVAILABLE_APP_INFO'][$appname] = array();
        $appinfo = &$GLOBALS['FIFORMS_CONFIG']['AVAILABLE_APP_INFO'][$appname];
        $appinfo['apptitle'] = $cfg->getTitle();
        $appinfo['appsummary'] = $cfg->getSummary();
        $appinfo['appdatabase'] = $cfg->getDB();
        $GLOBALS['FIFORMS_CONFIG']['DEFAULT_DATABASE'] = $appinfo['appdatabase'];
}

function set_config_default($key,$value)
{
    if(!array_key_exists($key,$GLOBALS['FIFORMS_CONFIG']))
    {
        $GLOBALS['FIFORMS_CONFIG'][$key] = $value;
    }
}

if(!isset($FIFORMS_CONFIG) || !is_array($FIFORMS_CONFIG))
{
    $FIFORMS_CONFIG = array();
}

if(!array_key_exists('OS',$FIFORMS_CONFIG))
{
    if(substr($_ENV['PATH'],0,1) == "/")
    {
        set_config_default('OS',"Linux");
    }
    else
    {
        set_config_default('OS',"Windows");
    }
}
    set_config_default('VERSION',"1.1.0");
    set_config_default('SCRIPT_PATH', str_replace("\\","/",dirname(dirname(__FILE__)))."/scripts/");
    set_config_default('APP_BASE', str_replace("\\","/",dirname(dirname(__FILE__))."/apps/"));
    set_config_default('INCLUDE_PATH', str_replace("\\","/",dirname(__FILE__))."/");
    set_config_default('AUTH_MODULE', $FIFORMS_CONFIG['INCLUDE_PATH']."FiForms_BasicAuth.inc.php");
    set_config_default('TEMP_PATH', $FIFORMS_CONFIG['SCRIPT_PATH']."temp/");
    if($FIFORMS_CONFIG['OS'] == "Linux")
    {
        set_config_default('XSLTPROC', "xsltproc");
        set_config_default('XMLLINT', "xmllint");
    }
    else
    {
        // For Windows:
        set_config_default('XSLTPROC', $FIFORMS_CONFIG['APP_BASE']."/bin/libxml2/xsltproc.exe");
        set_config_default('XMLLINT', $FIFORMS_CONFIG['APP_BASE']."/bin/libxml2/xmllint.exe");
    }
    if($FIFORMS_CONFIG['OS'] == "Linux")
    {
        set_config_default('UNZIP', "unzip");
    }
    else
    {
    // For Windows:
        set_config_default('UNZIP', $FIFORMS_CONFIG['APP_BASE']."/bin/unzip/unzip.exe");
    }
    set_config_default('MYSQLDUMP',"mysqldump");
    set_config_default('SERVER_ADDRESS',FIFORMS_DETECT_SERVER());
    set_config_default('URI',FIFORMS_DETECT_URI());
    set_config_default('DEFAULT_SERVER',"localhost");
    set_config_default('DEFAULT_USER',"");
    set_config_default('DEFAULT_PASSWORD',"");
    set_config_default('DEFAULT_DATABASE',"");
    set_config_default('MYSQL_VERSION',5.0);
    set_config_default('PHP_XSLT',FALSE);
    set_config_default('FIFORMS_ENCRYPT_KEY',"");
    set_config_default('UPDATEPW_HASH',"!");
    set_config_default('UPDATE_HOST',"none"); // one of "any", "localhost", or "none"
    set_config_default('ALLOW_USER_QUERIES',FALSE);
    set_config_default('ALLOWED_SERVERS',",localhost");
    set_config_default('DEFAULT_LIMIT',20);
    set_config_default('ICON_SET',"topblue-gif");
    set_config_default('DEFAULT_HEADER',"");
    set_config_default('QUERY_DEBUGGING',FALSE);
    set_config_default('SHOW_DEFINITION',FALSE);
    set_config_default('USE_XHTML',FALSE);
    set_config_default('CONNECT_EARLY',FALSE);
    set_config_default('AUTH_REALM',"FiForms");
    set_config_default('XML_VERSION', '1.1');
    set_config_default('MENU_POPUPS', 'new');
    set_config_default('MENU_XMLNS', TRUE);
    set_config_default('SUPPORTED_XML_VERSIONS', array());
    set_config_default('PHPMYADMIN_URI',$FIFORMS_CONFIG['SERVER_ADDRESS']."/phpMyAdmin/");
    $FIFORMS_CONFIG['SUPPORTED_XML_VERSIONS'][] = '1.0';
    $FIFORMS_CONFIG['SUPPORTED_XML_VERSIONS'][] = '1.1';
    set_config_default('USE_COMBINED',false);
    include_once($FIFORMS_CONFIG['APP_BASE'].'applications.php');
    FIFORMS_SET_APP_PATH();


/* ?></code><?php */


?>
Return current item: FiForms Framework