Location: PHPKode > projects > phlyMail Lite > phlymail/shared/lib/init.frontend.php
<?php
/**
 * shared/lib/init.frontend.php -> Initialise all bells and whistles to ring
 * @package phlyMail Nahariya 4.0+
 * @subpackage Core system
 * @copyright 2002-2010 phlyLabs, Berlin (http://phlylabs.de)
 * @version 4.1.8 2010-08-20
 */
// Only valid within phlyMail
if (!defined('_IN_PHM_')) die();
define('SESS_NAME', session_name());
define('SESS_ID', preg_replace('![^-,a-zA-Z0-9]!', '', session_id())); // Allow up to 6bits per character session IDs
define('CRLF', "\r\n");
define('LF', "\n");
require_once($_PM_['path']['lib'].'/functions.php');
require_once($_PM_['path']['lib'].'/basemethods.php');
require_once($_PM_['path']['lib'].'/uctc.php');
# // This allows Zend Framework inclusion
# @set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__));
// Global Choices, overloading core settings
if (file_exists($_PM_['path']['conf'].'/global.choices.ini.php')) {
    $_PM_ = merge_PM($_PM_, parse_ini_file($_PM_['path']['conf'].'/global.choices.ini.php', true));
}
$_PM_['core']['file_umask'] = octdec($_PM_['core']['file_umask']);
$_PM_['core']['dir_umask']  = octdec($_PM_['core']['dir_umask']);
// Handling special proxy calls here. Very often used for SSL calls thorugh an SSL proxy used for all instances of a hoster
if (isset($_PM_['proxy']['prepend_path']) && $_PM_['proxy']['prepend_path']
        && (isset($_SERVER[$_PM_['proxy']['server_param']]) && $_SERVER[$_PM_['proxy']['server_param']] == $_PM_['proxy']['server_value'])) {
    define('PHP_SELF', (isset($_SERVER['SCRIPT_NAME']) && $_SERVER['SCRIPT_NAME'])
            ? str_replace('//', '/', $_PM_['proxy']['prepend_path'].'/'.$_SERVER['SCRIPT_NAME'])
            : str_replace('//', '/', $_PM_['proxy']['prepend_path'].'/'.$_SERVER['PHP_SELF']));
} else {
    define('PHP_SELF', (isset($_SERVER['SCRIPT_NAME']) && $_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $_SERVER['PHP_SELF']);
}
require_once($_PM_['path']['driver'].'/'.$_PM_['core']['database'].'/driver.php');
$DB = new driver($_PM_['path']['conf'].'/driver.'.$_PM_['core']['database'].'.ini.php'
        ,(isset($_PM_['core']['accountpass_security']) && $_PM_['core']['accountpass_security'] == 'cleartext' ? false : true));
if (isset($_SESSION['phM_uid'])) require_once($_PM_['path']['lib'].'/user.choices.php');
require_once($_PM_['path']['message'].'/'.$_PM_['core']['language'].'.php');
require_once($_PM_['path']['lib'].'/fxl_template.inc.php');
require_once($_PM_['path']['lib'].'/idna_convert.class.php');
// Timezone
if (isset($_PM_['core']['timezone'])) {
    define('PHM_TIMEZONE', $_PM_['core']['timezone']);
    date_default_timezone_set($_PM_['core']['timezone']);
} elseif (isset($WP_msg['tz'])) {
    define('PHM_TIMEZONE', $WP_msg['tz']);
    date_default_timezone_set($WP_msg['tz']);
} else {
    define('PHM_TIMEZONE', date_default_timezone_get());
}
// Theme related
$fallbackTheme = 'Yokohama';
if (!isset($_PM_['core']['theme_name']) || !@file_exists($_PM_['path']['theme'].'/'.$_PM_['core']['theme_name'].'/choices.ini.php')) {
    $_PM_['core']['theme_name'] = $fallbackTheme;
}
$WP_theme = parse_ini_file($_PM_['path']['theme'].'/'.$_PM_['core']['theme_name'].'/choices.ini.php');
if ($WP_theme['engine'] != trim(file_get_contents($_PM_['path']['conf'].'/theme.engine'))) {
    $_PM_['core']['theme_name'] = $fallbackTheme;
    $WP_theme = parse_ini_file($_PM_['path']['theme'].'/'.$_PM_['core']['theme_name'].'/choices.ini.php');
}
$_PM_['path']['theme_dir'] = $_PM_['path']['theme'];
$_PM_['path']['theme'] .= '/'.$_PM_['core']['theme_name'];
$_PM_['path']['tplcache'] = $_PM_['path']['storage'].'/tplcache/';
$_PM_['path']['themecache'] = $_PM_['path']['storage'].'/tplcache/'.$_PM_['core']['theme_name'].'_';
// End Theme handling

// Tie session to IP, if told so
if (isset($_PM_['auth']['tie_session_ip']) && $_PM_['auth']['tie_session_ip'] && !defined('PHM_NO_SESSION')) {
    if (isset($_SESSION['phM_remote_ip'])) {
        if ($_SESSION['phM_remote_ip'] != getenv('REMOTE_ADDR')) {
            // Redirect the visitor with the wrong IP to the login screen
            header('Location: '.PHP_SELF);
            exit;
        }
    } else $_SESSION['phM_remote_ip'] = getenv('REMOTE_ADDR');
}
// Session cookie check
if (isset($_PM_['auth']['session_cookie']) && $_PM_['auth']['session_cookie'] && !defined('PHM_NO_SESSION')) {
    if (isset($_SESSION['phM_cookie'])
            && (!isset($_COOKIE['phlyMail_Session']) || $_SESSION['phM_cookie'] != $_COOKIE['phlyMail_Session'])) {
        // If no session cookie found or session cookie invalid
        header('Location: '.PHP_SELF);
        exit;
    }
}
// SMS active?
if (isset($_PM_['core']['sms_active'])) {
    if ($_PM_['core']['sms_active']) $_PM_['core']['sms_active'] = 1;
} elseif (isset($_PM_['core']['sms_default_active'])) {
    if ($_PM_['core']['sms_default_active']) $_PM_['core']['sms_active'] = 1;
} else {
    $_PM_['core']['sms_active'] = 0;
}
// Use gzip
if (isset($_PM_['core']['gzip_frontend']) && $_PM_['core']['gzip_frontend']) ob_start('ob_gzhandler');
?>
Return current item: phlyMail Lite