Location: PHPKode > projects > ZZ/OSS Installer > zic-1.1.0dev1/installer/inc/init.php
<?php
    /*
    Copyright (C) 2001-2004 ZZOSS GbR, http://www.zzoss.com

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser 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
    */
    
    /**
    @version $Id: init.php,v 1.10 2004/04/06 14:45:17 ordnas Exp $
    @copyright Copyright &copy; 2001-2004 ZZ/OSS GbR, http://www.zzoss.com
    @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
    */
    
    // set default mode of framework
    if(!defined('ZI_INIT_MODE')){
        define('ZI_INIT_MODE', 'full');
    }
    
    // define parameters
	$zi_phpversion_required = '4.3.0';
    $zi_phpversions_excluded = array();
    /*
	$zi_phpversions_excluded = array(
									'4.2.3' => 'PHP 4.2.3 has the posted array bug, causing a mailfunctioning installer.<br/>'.
												'See for more information: <a href="http://bugs.php.net/bug.php?id=19353">'.
												'http://bugs.php.net/bug.php?id=19353</a>'
								);
    */
	if(strlen($zi_phpversion_required)){
	  	// check, if we provide the required version at minimum
	  	if(version_compare(phpversion(),$zi_phpversion_required) < 0){  
				die(  
					'The installer requires PHP >= '.$zi_phpversion_required.
					', you are running PHP '.phpversion().'. Please upgrade.'
				);  
		} elseif(is_array($zi_phpversions_excluded) && array_key_exists(phpversion(), $zi_phpversions_excluded)){
		  	// check if our version is excluded
				die(  
					'You are running PHP '.phpversion().' which is not supported<br/>'.
					'due to the following reason:<br/>'.
					'<b>'.$zi_phpversions_excluded[phpversion()].'</b>'
				);  
		}
	} else {
		die('Compatible PHP version not defined.');  
	}  
    
    //print_r($_REQUEST);
    
    // Handle magic quotes.
    set_magic_quotes_runtime(0);

    if(get_magic_quotes_gpc()){
       function zi_stripslashes_recursive($element)
       {
           if (is_array($element)){
               return array_map("zi_stripslashes_recursive", $element);
           } else{
               return stripslashes($element);
           }
       }
       
       // Add slashes to all incoming GET/POST/COOKIE data.
       $_REQUEST    = array_map("zi_stripslashes_recursive", $_REQUEST);
       $_GET    = array_map("zi_stripslashes_recursive", $_GET);
       $_POST  = array_map("zi_stripslashes_recursive", $_POST);
       $_COOKIE = array_map("zi_stripslashes_recursive", $_COOKIE);
    }
      
    // Debugging
    define('ZI_DEBUG', false);
    define('ZZOSS_PACKAGE_DEBUG', false);
    define('ZZOSS_CONFIG_DEBUG', false);
    
    // Set the include path.
    ini_set('include_path', '.'.PATH_SEPARATOR.'lib');
    
    if(ZI_INIT_MODE == 'RE'){
        define('ZZOSS_INSTALLER_REGISTRY_DEBUG', false);
    } else {
        define('ZZOSS_INSTALLER_REGISTRY_DEBUG', false);
        
        require_once 'PEAR.php';
        
        require_once 'ZZOSS_Error/Error.php';
        
        $options['production'] = false;
        
        $error =& new ZZOSS_Error($options);
        $error->setIdent('zic');
        
        if($options['production']){
            $error->setBehaviour(E_WARNING, ZZOSS_ERROR_B_EXIT + ZZOSS_ERROR_B_CLIENT + ZZOSS_ERROR_B_LOG);
            $error->setBehaviour(E_NOTICE, ZZOSS_ERROR_B_CONTINUE);
            $error->setBehaviour(E_USER_ERROR, ZZOSS_ERROR_B_EXIT + ZZOSS_ERROR_B_CLIENT + ZZOSS_ERROR_B_LOG);
            $error->setBehaviour(E_USER_WARNING, ZZOSS_ERROR_B_EXIT + ZZOSS_ERROR_B_CLIENT + ZZOSS_ERROR_B_LOG);
            $error->setBehaviour(E_USER_NOTICE, ZZOSS_ERROR_B_EXIT + ZZOSS_ERROR_B_CLIENT + ZZOSS_ERROR_B_LOG);
        } else {
            $error->setBehaviour(E_WARNING, ZZOSS_ERROR_B_DEV + ZZOSS_ERROR_B_EXIT);
            $error->setBehaviour(E_NOTICE, ZZOSS_ERROR_B_DEV + ZZOSS_ERROR_B_EXIT);
            $error->setBehaviour(E_USER_ERROR, ZZOSS_ERROR_B_DEV + ZZOSS_ERROR_B_EXIT);
            $error->setBehaviour(E_USER_WARNING, ZZOSS_ERROR_B_DEV + ZZOSS_ERROR_B_EXIT);
            $error->setBehaviour(E_USER_NOTICE, ZZOSS_ERROR_B_DEV + ZZOSS_ERROR_B_EXIT);
        }
        
        //$error->setLog('C:\WINDOWS\Temp\zzoss_error.log', ZZOSS_ERROR_ROTATE_MONTHLY);
        //$error->setRecipients('hide@address.com');
    }
    
    // Default values for reserved variables that are used frequently.
    $zi_auth = NULL;
    $zi_registry = NULL;
    $zi_hide = array();
    $zi_hide['profile'] = false;
    $chdir = '';
    if(!isset($_REQUEST['mode'])){
        $_REQUEST['mode'] = '';
    }
    
    
    // get general configuration
    require_once 'inc/config.php';
    
    // The root directory where the installer resides.
    require_once 'ZZOSS_Installer/Setup.php';
    $zi_setup = new ZZOSS_InstallerSetup($GLOBALS['ZI']['data']);
    
    // Pass init params to global config array.
    $GLOBALS['ZI']['data_dir'] = $zi_setup->getDataDir();
    $GLOBALS['ZI']['init_file'] = $zi_setup->getInitFile();
    // Get the path to data directory.
    $GLOBALS['ZI']['installer_data_dir'] = $zi_setup->getInstallerDataDir();
    $GLOBALS['ZI']['installer_data_dir_dev'] = $GLOBALS['ZI']['installer_data_dir'].'dev'.DIRECTORY_SEPARATOR;

    // Check if path to data dir has been defined.
    if(!$zi_setup->isInitiated()){
        if(
            strpos(basename(getenv('SCRIPT_FILENAME')), 'setup') === false &&
            strpos(basename(getenv('SCRIPT_FILENAME')), 'about.php') === false){
            // Seems like the installer has not yet been installed, hence
            // we trigger the installation process and first ask for the
            // data directory.
            header('Location: setup.php?mode=setup');
            exit;
        }
    } else {
        if(basename(getenv('SCRIPT_FILENAME')) == 'setup.php') {
            // Someone tries to call the setup allthough it's already done.
            //echo basename(getenv('SCRIPT_FILENAME'));
            header('Location: index.php');
            exit;
        }
        
        // Increases the max. allowed time to run a script
        @set_time_limit(0);
        
        require_once 'inc/registry.php';
        if(ZI_DEBUG){
            ZZOSS_Debug::log('Application: ', var_export($zi_registry->getApplication(), true), __FILE__, __LINE__);
        }
        // check if we can grant access
        require_once 'inc/authentication.php';
    }
    
    // routines to process form input
    require_once 'inc/form.php';
    
    if(isset($_REQUEST['nav_parent'])){
        $_SESSION['nav_parent'] = $_REQUEST['nav_parent'];
    }
    
    if(isset($_REQUEST['nav_child'])){
        $_SESSION['nav_child'] = $_REQUEST['nav_child'];
    }
?>
Return current item: ZZ/OSS Installer