<?php

@( (bool)FALSE === strpos( $_SERVER['REQUEST_URI'], basename( __FILE__ ) ) ) OR exit( '!! ACCESS DENIED !!' );
error_reporting( _E_VALUE );

/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Core Constants for version 188_8 RC2                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003-2004 Kiril Threndor                               |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: Kiril Threndor < mpnx@dev.illearth.net >                     |
// +----------------------------------------------------------------------+

/**
 * This file sets the MPN core constants. You do not need to modify anything
 * in this file unless instructed to do so by a MPN developer.
 *
 * @package myPHPNuke_Core
 * @category Constants
 * @version $Id: core_Constants.php,v 1.5.2.20 2004/08/22 14:33:48 kirilt Exp $
 *
 * @author Kiril Threndor <support@mpn.illearth.net>
 * @copyright Copyright (C) 2003 Eric Haddix
 * @license http://www.gnu.org/copyleft/gpl.html GPL 2.0
 * @support http://myphpnuke.com/
 */

// Define MPN Version

define( '_MPN_VERSION_' , '1.8.8_8rc2' );

// Define Install Root

define( '__ROOT__' , realpath( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR );

// Define Current Script Loaded

define( '__REQSCR__', basename( $_SERVER['PHP_SELF'], '.php' ) );

/**
 * Get User Configurable Constants
 */

@( include_once __ROOT__ . 'core_UserConstants.php' );

/**
 * Define Sites Root URI
 */

defineRootURI();

/**
 * Define Locale Specific Current Timestamp Constant
 */

$time_adjust = ( 3600 * $serv_offset );

define( '_MPN_TIMESTAMP' , ( time() + $time_adjust ) );

// MAX UPLOAD FILE SIZE

$tmpfs = @ini_get( 'upload_max_filesize' );

if ( ! empty( $tmpfs ) && $tmpfs != '' )
{
    define( '__MAX_UPLD_FILESIZE__', (int)$tmpfs * 1000000 );
}
else
{
    define( '__MAX_UPLD_FILESIZE__', 2 * 1000000 ); // 2(M) is the php.ini default upload size restriction.
}

unset( $tmpfs );

// DEFINE SAFEMODE ENVIRONMENT

$safe_mode = @get_cfg_var( 'safe_mode' );

if ( empty( $safe_mode ) || $safe_mode == '' ) { $safe_mode = @ini_get( 'safe_mode' ); }

define( '__SAFEMODE__', ( ( ! empty( $safe_mode ) && $safe_mode != '' ) && ( strcasecmp( $safe_mode, 'on' ) || strcasecmp( $safe_mode, 'true' ) || $safe_mode == 1 ) ) );

unset( $safe_mode );



/**
 * Absolute Linking
 */

    // Themes

    define( '_URI_THEMES_ROOT', _MPN_ROOT_URI . 'themes/' );

        define( '_URI_THEMES_NN4', _URI_THEMES_ROOT . 'NN4/' );

    // CSS

    define( '_URI_CSS_ROOT', _MPN_ROOT_URI . 'themes/css/' );

        define( '_URI_CSS_PAGE', _URI_CSS_ROOT . 'pages/' ); // Page style sheets

        define( '_URI_CSS_LAYOUT', _URI_CSS_ROOT . 'layout/' ); // Layout style sheets

    // Images Root

    define( '_URI_IMG_ROOT', _MPN_ROOT_URI . 'images/' );

    define( '_URI_IMG_REL_ROOT', './images/' );

/**
 * Relative Linking
 */

    // Default Themes

    define( '_DP_THEME_PAR' , __ROOT__ . 'themes' . DIRECTORY_SEPARATOR ); // theme root

        define( '_DP_THEME_PAR_CSS' , _DP_THEME_PAR . 'css' . DIRECTORY_SEPARATOR ); // css root

        define( '_DP_THEME_PAR_NN4' , _DP_THEME_PAR . 'NN4' . DIRECTORY_SEPARATOR ); // nn4 root

    // Classes

    define( '_DP_CLASS_PAR' , __ROOT__ . 'classes' . DIRECTORY_SEPARATOR );

        define( '_DP_CLASS_SUB' , _DP_CLASS_PAR . 'subs' . DIRECTORY_SEPARATOR );

            define( '_DP_CLASS_PAR_SUB_SAN' , _DP_CLASS_SUB . 'sanitizer' . DIRECTORY_SEPARATOR );
            define( '_DP_CLASS_PAR_SUB_NPP' , _DP_CLASS_SUB . 'npp' . DIRECTORY_SEPARATOR );
            define( '_DP_CLASS_PAR_SUB_UPLD' , _DP_CLASS_SUB . 'uploads' . DIRECTORY_SEPARATOR );

        define( '_DP_CLASS_IMGMANI_', _DP_CLASS_PAR . 'imagemani' . DIRECTORY_SEPARATOR );

    // Cache

    define( '_DP_CACHE_PAR' , __ROOT__ . 'cache' . DIRECTORY_SEPARATOR );

        define( '_DP_CACHE_GAL_', _DP_CACHE_PAR . 'gallery' . DIRECTORY_SEPARATOR );

    // Uploads

    define( '_DP_UPLOAD_PAR', __ROOT__ . 'uploads' . DIRECTORY_SEPARATOR );

      define( '_DP_MAIL_ATTACH' , _DP_UPLOAD_PAR . 'mail' . DIRECTORY_SEPARATOR );

      define( '_DP_UPLOAD_GAL_' , _DP_UPLOAD_PAR . 'gallery' . DIRECTORY_SEPARATOR );

/**
 * Nested Page Project
 */

    $allowed_shares = array
    (
        'odp' => array(   'access' => 'npp_ODP.php'
                        , 'root'   => 'odp' . DIRECTORY_SEPARATOR
                        , 'child'  => 'core_ODP_NestedPage.subclass.php'
                        , 'name'   => 'OpenDirectory'
                      )
    );

    define( '_MPN_SITE_SHARES', serialize( $allowed_shares ) );


unset( $time_adjust, $allowed_shares );

/**
 * Bullet Proof Determination Of Root And Host
 *
 * If A Valid Host Cannot Be Determined, Exit with Error
 *
 * @param string ( $nuke_url -> config value of sites base URI )
 *
 * @return bool ( True On Success, False On Fail )
 */

function defineRootURI()
{
    // Return If Already Defined

    if ( defined( '_MPN_ROOT_URI' ) && defined( '_MPN_HOST' ) && defined( '_MPN_COOKIE_HOST' ) )
    {
        return (bool)TRUE;
    }

    // Determine Host Name For Cookie Setting

    if ( isset( $_SERVER['HTTP_HOST'] ) )
    {
        $mpn_host = $_SERVER['HTTP_HOST'];
    }
    else if ( isset( $_SERVER['SERVER_NAME'] ) )
    {
        $mpn_host = $_SERVER['SERVER_NAME'];
    }
    else
    {
        $mpn_host = $_SERVER['SERVER_ADDR'];
    }

    // Set The Absolute URI And Host For the Root If All The Above Checks Didn't Fail

    if ( empty( $mpn_host ) )
    {
        return (bool)FALSE;
    }
    else
    {
        $tmp = explode( ':', $mpn_host );
        $scheme = strtolower( substr( $_SERVER['SERVER_PROTOCOL'], 0, strpos( $_SERVER['SERVER_PROTOCOL'], '/' ) ) );
        $path = substr( $_SERVER['SCRIPT_NAME'], 1, strrpos( $_SERVER['SCRIPT_NAME'], '/' ) );

        if ( isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) )
        {
            if ( (bool)FALSE !== strpos( $_SERVER['REQUEST_URI'], $mpn_host ) )
            {
                $start = strpos( $_SERVER['REQUEST_URI'], '://' ) + 3;
                $end = strpos( $_SERVER['REQUEST_URI'], '/', $start );
                $mpn_host = substr( $_SERVER['REQUEST_URI'], $start, $end );
            }
            else
            {
                $mpn_host = $_SERVER['HTTP_X_FORWARDED_HOST'];
           }
        }

        if ( $_SERVER['SERVER_PORT'] == 80 && sizeof( $tmp ) === 1 )
        {
            $derived_url =  $scheme . '://' . $mpn_host . '/' . $path;
        }
        else
        {
            $mpn_host = ( sizeof( $tmp ) > 1 ) ? ( $tmp[0] ) : ( $mpn_host );
            $derived_url =  $scheme . '://' . $mpn_host . ':' . $_SERVER['SERVER_PORT'] . '/' . $path;
        }
    }

    // Define Absolute URI Constant

    define( '_MPN_ROOT_URI', $derived_url );

    // Top Level Domain Check

    $chkdomain = explode( '.', $mpn_host );

    switch( sizeof( $chkdomain ) )
    {
        case 1:
            $host_domain = '.' . $chkdomain[0];
        break;

        case 2:
            $host_domain = '.' . $chkdomain[0] . '.' . $chkdomain[1];
        break;

        case 3:
            $host_domain = ( $chkdomain[0] == 'www' )
                         ? ( '.' . $chkdomain[1] . '.' . $chkdomain[2] )
                         : ( $mpn_host );
        break;

        DEFAULT:
            $host_domain = $mpn_host;
        break;

    } // End Switch

    // Define The Host Name

    define( '_MPN_HOST', $mpn_host );
    define( '_MPN_COOKIE_HOST', $host_domain );

    return (bool)TRUE;

} // End Method defineRoot

?>