コード例 #1
0
function get_conf()
{
    if (!defined('TEST_ENVIRONMENT_RUNNING')) {
        define('TEST_ENVIRONMENT_RUNNING', true);
    }
    if (!file_exists(MAX_PATH . '/var/' . OX_getHostName() . '.conf.php')) {
        if (folder_is_writable(MAX_PATH . '/var')) {
            copy(MAX_PATH . '/etc/sim.conf.php', MAX_PATH . '/var/' . OX_getHostName() . '.conf.php');
        }
    }
    require_once MAX_PATH . '/init-delivery-parse.php';
    $conf = parseIniFile();
    // this is purely because its not used (yet)
    $conf['request']['context'] = '';
    return $conf;
}
コード例 #2
0
<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
if (!function_exists('parseIniFile')) {
    function parseIniFile($iIniFile)
    {
        $a = array();
        $aMatches = array();
        $s = '\\s*([[:alnum:]_\\- \\*]+?)\\s*';
        preg_match_all('#^\\s*((\\[' . $s . '\\])|(("?)' . $s . '\\5\\s*=\\s*("?)(.*?)\\7))\\s*(;[^\\n]*?)?$#ms', file_get_contents($iIniFile), $aMatches, PREG_SET_ORDER);
        foreach ($aMatches as $aMatch) {
            if (empty($aMatch[2])) {
                $a[$aMatch[6]] = $aMatch[8];
            }
        }
        return $a;
    }
}
$lang = parseIniFile(sprintf("%s/helppage.ini", dirname(__FILE__)));
// --------------------------------------------------------------------
/* End of file groupware_lang.php */
/* Location: ./application/language/en/groupware_lang.php */
コード例 #3
0
ファイル: constants.php プロジェクト: akirsch/revive-adserver
/**
 * The environmental constants initialisation function for Revive Adserver.
 */
function setupConstants()
{
    // Define this version of Revive Adserver's constants
    define('VERSION', '3.2.2-dev');
    define('PRODUCT_NAME', 'Revive Adserver');
    define('PRODUCT_URL', 'www.revive-adserver.com');
    define('PRODUCT_DOCSURL', 'http://documentation.revive-adserver.com');
    // Deprecated constants for backwards compatibility. Please use the ones above
    define('OA_VERSION', VERSION);
    define('OX_PRODUCT_DOCSURL', PRODUCT_DOCSURL);
    define('RV_INSTALLATION_STATUS_NOTINSTALLED', -1);
    define('RV_INSTALLATION_STATUS_UPGRADING', 0);
    define('RV_INSTALLATION_STATUS_INSTALLED', 1);
    define('OA_AD_DIRECT_ENABLED', false);
    // Campaign types
    define('OX_CAMPAIGN_TYPE_REMNANT', 1);
    define('OX_CAMPAIGN_TYPE_CONTRACT_NORMAL', 2);
    define('OX_CAMPAIGN_TYPE_OVERRIDE', 3);
    define('OX_CAMPAIGN_TYPE_ECPM', 4);
    define('OX_CAMPAIGN_TYPE_CONTRACT_ECPM', 5);
    // Database connection constants
    define('MAX_DSN_ARRAY', 0);
    define('MAX_DSN_STRING', 1);
    $GLOBALS['_OA']['CONNECTIONS'] = array();
    // Error codes to use with MAX::raiseError()
    // Start at -100 in order not to conflict with PEAR::DB error codes
    define('MAX_ERROR_INVALIDARGS', -101);
    // Wrong args to function
    define('MAX_ERROR_INVALIDCONFIG', -102);
    // Something wrong with the config
    define('MAX_ERROR_NODATA', -103);
    // No data available
    define('MAX_ERROR_NOCLASS', -104);
    // No class exists
    define('MAX_ERROR_NOMETHOD', -105);
    // No method exists
    define('MAX_ERROR_NOAFFECTEDROWS', -106);
    // No rows where affected by update/insert/delete
    define('MAX_ERROR_NOTSUPPORTED', -107);
    // Limit queries on unsuppored databases
    define('MAX_ERROR_INVALIDCALL', -108);
    // Overload getter/setter failure
    define('MAX_ERROR_INVALIDAUTH', -109);
    define('MAX_ERROR_EMAILFAILURE', -110);
    define('MAX_ERROR_DBFAILURE', -111);
    define('MAX_ERROR_DBTRANSACTIONFAILURE', -112);
    define('MAX_ERROR_BANNEDUSER', -113);
    define('MAX_ERROR_NOFILE', -114);
    define('MAX_ERROR_INVALIDFILEPERMS', -115);
    define('MAX_ERROR_INVALIDSESSION', -116);
    define('MAX_ERROR_INVALIDPOST', -117);
    define('MAX_ERROR_INVALIDTRANSLATION', -118);
    define('MAX_ERROR_FILEUNWRITABLE', -119);
    define('MAX_ERROR_INVALIDMETHODPERMS', -120);
    define('MAX_ERROR_INVALIDREQUEST', -121);
    define('MAX_ERROR_INVALIDTYPE', -122);
    define('MAX_ERROR_INVALIDOPERATIONINT', -123);
    define('MAX_ERROR_INVALIDBANNERSIZE', -124);
    define('MAX_ERROR_INVALIDBANNERTYPE', -125);
    define('MAX_ERROR_ALREADYLINKED', -126);
    define('MAX_ERROR_EXISTINGCAMPAIGNFORDATES', -127);
    define('MAX_ERROR_EMAILNODATES', -128);
    // Ad/Zone association link types
    define('MAX_AD_ZONE_LINK_DIRECT', 0);
    define('MAX_AD_ZONE_LINK_NORMAL', 1);
    define('MAX_AD_ZONE_LINK_CATEGORY', 2);
    // URL construction constants
    define('MAX_URL_ADMIN', 0);
    define('MAX_URL_IMAGE', 1);
    define('MAX_URL_DEL_SCRIPT', 2);
    define('MAX_URL_DEL_SCRIPT_SSL', 3);
    define('MAX_URL_DEL_IMG', 4);
    define('MAX_URL_DEL_IMG_SSL', 5);
    // Connection action type constants
    define('MAX_CONNECTION_AD_IMPRESSION', 0);
    define('MAX_CONNECTION_AD_CLICK', 1);
    define('MAX_CONNECTION_AD_ARRIVAL', 2);
    define('MAX_CONNECTION_MANUAL', 4);
    // Campaign deactivation reasons
    // Values must be x^2, as used as binary flags
    define('OX_CAMPAIGN_DISABLED_IMPRESSIONS', 2);
    define('OX_CAMPAIGN_DISABLED_CLICKS', 4);
    define('OX_CAMPAIGN_DISABLED_CONVERSIONS', 8);
    define('OX_CAMPAIGN_DISABLED_DATE', 16);
    // Time contstants
    define('SECONDS_PER_WEEK', 604800);
    define('MINUTES_PER_WEEK', 10080);
    define('SECONDS_PER_DAY', 86400);
    define('SECONDS_PER_HOUR', 3600);
    define('MINUTES_PER_DAY', 1440);
    // Connection status types. Only the default conversion
    // status (MAX_CONNECTION_STATUS_APPROVED) is defined (4), which
    // is a conversion type that is approved by default.
    // Note also that only ignore, pending and approved
    // are used as possible starting values (ie. in the
    // campaigns_trackers table.
    define('MAX_CONNECTION_STATUS_IGNORE', 1);
    define('MAX_CONNECTION_STATUS_PENDING', 2);
    define('MAX_CONNECTION_STATUS_ONHOLD', 3);
    define('MAX_CONNECTION_STATUS_APPROVED', 4);
    define('MAX_CONNECTION_STATUS_DISAPPROVED', 5);
    define('MAX_CONNECTION_STATUS_DUPLICATE', 6);
    // Connection action type constants
    define('MAX_CONNECTION_TYPE_SALE', 1);
    define('MAX_CONNECTION_TYPE_LEAD', 2);
    define('MAX_CONNECTION_TYPE_SIGNUP', 3);
    // Financial constants
    define('MAX_FINANCE_CPM', 1);
    define('MAX_FINANCE_CPC', 2);
    define('MAX_FINANCE_CPA', 3);
    define('MAX_FINANCE_MT', 4);
    // Monthly Tennancy
    define('MAX_FINANCE_RS', 5);
    // % Revenue split     (zone-only)
    define('MAX_FINANCE_BV', 6);
    // % Basket value      (zone-only)
    define('MAX_FINANCE_AI', 7);
    // Amount per item     (zone-only)
    define('MAX_FINANCE_ANYVAR', 8);
    // % of any variable   (zone-only)
    define('MAX_FINANCE_VARSUM', 9);
    // % of a variable sum (zone-only)
    $GLOBALS['_MAX']['STATUSES'] = array(MAX_CONNECTION_STATUS_IGNORE => 'strStatusIgnore', MAX_CONNECTION_STATUS_PENDING => 'strStatusPending', MAX_CONNECTION_STATUS_ONHOLD => 'strStatusOnHold', MAX_CONNECTION_STATUS_APPROVED => 'strStatusApproved', MAX_CONNECTION_STATUS_DISAPPROVED => 'strStatusDisapproved', MAX_CONNECTION_STATUS_DUPLICATE => 'strStatusDuplicate');
    $GLOBALS['_MAX']['CONN_TYPES'] = array(MAX_CONNECTION_TYPE_SALE => 'strConnTypeSale', MAX_CONNECTION_TYPE_LEAD => 'strConnTypeLead', MAX_CONNECTION_TYPE_SIGNUP => 'strConnTypeSignUp');
    // IP Address used to determine which (if any) MaxMind databases are installed
    define('MAX_MIND_TEST_IP', '24.24.24.24');
    // Maximum random number
    define('MAX_RAND', mt_getrandmax());
    define('MAX_RAND_INV', 1 / MAX_RAND);
    // Maintenance Engine Constants: Number of days to keep old maintenance
    // data, before pruning, where a fixed retention value is appriopriate
    define('OA_MAINTENANCE_FIXED_PRUNING', 30);
    define('MAX_LIMITATION_EQUAL', 0);
    define('MAX_LIMITATION_NOT_EQUAL', 1);
    define('MAX_LIMITATION_BITWISE', 2);
    // Define the week to start on Sunday (0) so that the PEAR::Date and
    // PEAR::Date_Calc classes agree on what day is the start of the week
    define('DATE_CALC_BEGIN_WEEKDAY', 0);
    // Do not overload DataObjects as it allows us to work with 4.3.10
    define('DB_DATAOBJECT_NO_OVERLOAD', true);
    // Ensure that the initialisation has not been run before
    if (!isset($GLOBALS['_MAX']['CONF'])) {
        // Define the installation base path if not defined
        // since local mode will pre-define this value
        if (!defined('MAX_PATH')) {
            define('MAX_PATH', dirname(__FILE__));
        }
        if (!defined('OX_PATH')) {
            define('OX_PATH', MAX_PATH);
        }
        if (!defined('RV_PATH')) {
            define('RV_PATH', MAX_PATH);
        }
        if (!defined('LIB_PATH')) {
            define('LIB_PATH', MAX_PATH . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'OX');
        }
        define('IS_WINDOWS', DIRECTORY_SEPARATOR === '\\');
        // Setup the include path
        setupIncludePath();
        // Parse the configuration file
        $GLOBALS['_MAX']['CONF'] = parseIniFile();
        // Define the cache file location path (required trailing slash)
        define('MAX_CACHE', MAX_PATH . '/var/cache/');
        // Set the URL access mechanism
        if (!empty($GLOBALS['_MAX']['CONF']['openads']['requireSSL'])) {
            $GLOBALS['_MAX']['HTTP'] = 'https://';
        } else {
            if (isset($_SERVER['SERVER_PORT'])) {
                if (isset($GLOBALS['_MAX']['CONF']['openads']['sslPort']) && $_SERVER['SERVER_PORT'] == $GLOBALS['_MAX']['CONF']['openads']['sslPort']) {
                    $GLOBALS['_MAX']['HTTP'] = 'https://';
                } else {
                    $GLOBALS['_MAX']['HTTP'] = 'http://';
                }
            }
        }
        // Set the True Type Font path
        if (isset($GLOBALS['_MAX']['CONF']['graphs']['ttfDirectory'])) {
            define('IMAGE_CANVAS_SYSTEM_FONT_PATH', $GLOBALS['_MAX']['CONF']['graphs']['ttfDirectory']);
        }
        // Set the dbms type
        if (isset($GLOBALS['_MAX']['CONF']['database']) && $GLOBALS['_MAX']['CONF']['database']['type'] == 'mysql') {
            define('phpAds_dbmsname', 'MySQL');
        } else {
            if (isset($GLOBALS['_MAX']['CONF']['database']) && $GLOBALS['_MAX']['CONF']['database']['type'] == 'pgsql') {
                define('phpAds_dbmsname', 'Postgres');
            }
        }
    }
}
コード例 #4
0
ファイル: vars.php プロジェクト: aiurlano/mAdserve-Fork
/**
 * Setup common variables
 */
function setupConfigVariables()
{
    $GLOBALS['_MAX']['CONF'] = parseIniFile();
}
コード例 #5
0
ファイル: ver.php プロジェクト: rgocal/Renovate_Rom
<?php

function parseIniFile($iIniFile)
{
    $aResult = $aMatches = array();
    $a =& $aResult;
    $s = '\\s*([[:alnum:]_\\- \\*]+?)\\s*';
    preg_match_all('#^\\s*((\\[' . $s . '\\])|(("?)' . $s . '\\5\\s*=\\s*("?)(.*?)\\7))\\s*(;[^\\n]*?)?$#ms', @file_get_contents($iIniFile), $aMatches, PREG_SET_ORDER);
    foreach ($aMatches as $aMatch) {
        if (empty($aMatch[2])) {
            $a[$aMatch[6]] = $aMatch[8];
        } else {
            $a =& $aResult[$aMatch[3]];
        }
    }
    return $aResult;
}
$ini = parseIniFile('ver.ini');
$u['ver'] = $ini['ver']['ver'];
$u['log'] = $ini['ver']['log'];
if (!file_exists("RenoCon.apk")) {
    $u['ver'] = "0.0.0";
}
echo json_encode($u);
コード例 #6
0
 /**
  * A method for writing out the OpenX configuration .conf.php file(s),
  * including any changes that have been made to the configuration in the
  * current object.
  *
  * Configuration files are prefixed with the host name being used to access
  * Openads, so that multiple OpenX installations can be run from a single
  * code base, if the correct virtual hosts are configured.
  *
  * @param string $configPath The directory to save the config file(s) in.
  *                           Default is Max's /var directory.
  * @param string $configFile The configuration file name (eg. "geotargeting").
  *                           Default is no name (ie. the main Max
  *                           configuration file).
  * @param boolean $reParse   If the config file should be parsed again
  *                           after writing (default is true).
  *
  * @return boolean True when the configuration file(s) was (were)
  *                 correctly written out, false otherwise.
  */
 function writeConfigChange($configPath = null, $configFile = null, $reParse = true)
 {
     if (is_null($configPath)) {
         $configPath = MAX_PATH . '/var';
     }
     if (!is_null($configFile)) {
         $configFile = '.' . $configFile;
     }
     if (defined('TEST_ENVIRONMENT_RUNNING') && empty($GLOBALS['override_TEST_ENVIRONMENT_RUNNING'])) {
         // Special case! The test environment is running, so just write the
         // configuration to the test configuration file...
         $testConfigFile = $configPath . '/test.conf.php';
         $result = $this->writeConfigArrayToFile($testConfigFile, $this->aConf);
         if (!$result) {
             return false;
         }
         // Re-parse the config file?
         if ($reParse) {
             $GLOBALS['_MAX']['CONF'] = @parse_ini_file($testConfigFile, true);
             $this->aConf = $GLOBALS['_MAX']['CONF'];
             // Set the global $conf value -- normally set by the init
             // script -- to be the same as $GLOBALS['_MAX']['CONF']
             global $conf;
             $conf = $GLOBALS['_MAX']['CONF'];
         }
         return true;
     }
     // What were the old host names used for the installation?
     $aConf = $GLOBALS['_MAX']['CONF'];
     $url = @parse_url('http://' . $aConf['webpath']['admin']);
     $oldAdminHost = $url['host'];
     $url = @parse_url('http://' . $aConf['webpath']['delivery']);
     $oldDeliveryHost = $url['host'];
     $url = @parse_url('http://' . $aConf['webpath']['deliverySSL']);
     $oldDeliverySslHost = $url['host'];
     // What are the new host names used for the installation?
     $url = @parse_url('http://' . $this->aConf['webpath']['admin']);
     $newAdminHost = $url['host'];
     $url = @parse_url('http://' . $this->aConf['webpath']['delivery']);
     $newDeliveryHost = $url['host'];
     $url = @parse_url('http://' . $this->aConf['webpath']['deliverySSL']);
     $newDeliverySslHost = $url['host'];
     // Prepare config arrays
     $adminConfig = $deliverySslConfig = array('realConfig' => $newDeliveryHost);
     $adminConfigChanged = false;
     $mainConfig = array();
     // Has the use changed from a single host to a multi-host setup?
     if ($newDeliveryHost != $oldDeliveryHost && ($oldDeliveryHost = $oldAdminHost)) {
         $adminConfigChanged = true;
     }
     // Collect any values from existing wrapper config files
     if (!$adminConfigChanged && $newDeliveryHost != $oldAdminHost && file_exists($configPath . '/' . $oldAdminHost . '.conf.php')) {
         $adminConfig = @parse_ini_file($configPath . '/' . $oldAdminHost . '.conf.php', true);
         // (re)set the realConfig for the admin conf file
         if (isset($adminConfig['realConfig'])) {
             $adminConfig['realConfig'] = $newDeliveryHost;
         } else {
             // Have to do this array_merge because just setting $adminConfig['realConfig'] puts the value in to the wrong place in the wrapper config file
             $adminConfig = array_merge(array('realConfig' => $newDeliveryHost), $adminConfig);
         }
     }
     if (file_exists($configPath . '/' . $oldDeliveryHost . $configFile . '.conf.php')) {
         $mainConfig = @parse_ini_file($configPath . '/' . $oldDeliveryHost . $configFile . '.conf.php', true);
     } else {
         // No config file exists, use the aConf array
         $mainConfig = $this->aConf;
     }
     // Clear any persisting realConfig value in the primary config file
     // (in case we are changing URL paths?)
     unset($mainConfig['realConfig']);
     // Iterate over the changes to be written out, check if a value is being
     // overridden in the UI wrapper config file, ensure that it gets changed
     // _there_, additionally, write only changes/new items to the delivery
     // config file, not the in-memory merged array
     foreach ($this->aConf as $section => $sectionArray) {
         // Compare the value to be written against that in memory
         // (merged admin/delivery configs)
         if (is_array($aConf[$section])) {
             $sectionDiff = array_diff_assoc($this->aConf[$section], $aConf[$section]);
             foreach ($sectionDiff as $configKey => $configValue) {
                 if (isset($adminConfig[$section][$configKey])) {
                     // This setting exists in the wrapper config file,
                     // change its value there
                     $adminConfig[$section][$configKey] = $configValue;
                     $adminConfigChanged = true;
                 } else {
                     // This setting doesn't exist in the wrapper config
                     // file, change it in the delivery config file only
                     $mainConfig[$section][$configKey] = $configValue;
                 }
             }
         } else {
             // This section didn't/doesnt exist in the in-memory array,
             // assume it is a new section and write to the delivery conf
             // file
             $mainConfig[$section] = $this->aConf[$section];
         }
         // Check if any of the in-memory items have been removed from the
         // $this->aConf array, and remove them from the appropriate file if
         // necessary
         if (is_array($aConf[$section]) && is_array($this->aConf[$section])) {
             $reverseDiff = array_diff(array_keys($aConf[$section]), array_keys($this->aConf[$section]));
             foreach ($reverseDiff as $deletedSectionKey) {
                 if (isset($adminConfig[$section][$deletedSectionKey])) {
                     // This setting exists in the wrapper config file,
                     // remove it from there
                     unset($adminConfig[$section][$deletedSectionKey]);
                     if (count($adminConfig[$section]) == 0) {
                         unset($adminConfig[$section]);
                     }
                     $adminConfigChanged = true;
                 } else {
                     // This setting doesn't exist in the wrapper config
                     // file, remove it from the delivery config file only
                     unset($mainConfig[$section][$deletedSectionKey]);
                     if (count($mainConfig[$section]) == 0) {
                         unset($mainConfig[$section]);
                     }
                 }
             }
         }
     }
     // Write out the new main configuration file
     $mainConfigFile = $configPath . '/' . $newDeliveryHost . $configFile . '.conf.php';
     if (!$this->writeConfigArrayToFile($mainConfigFile, $mainConfig)) {
         return false;
     }
     // Check if a different host name is used for the admin
     if ($newAdminHost != $newDeliveryHost) {
         // Write out the new "fake" configuration file
         $file = $configPath . '/' . $newAdminHost . $configFile . '.conf.php';
         // Only write out the wrapper config files if a) it doesn't exist already, or b) the value changed was in the wrapper file already
         if (!file_exists($file) || $adminConfigChanged) {
             if (!$this->writeConfigArrayToFile($file, $adminConfig)) {
                 return false;
             }
         }
     }
     // Check if a different host name is used for the delivery SSL
     if ($newDeliverySslHost != $newDeliveryHost) {
         // Write out the new "fake" configuration file
         $file = $configPath . '/' . $newDeliverySslHost . $configFile . '.conf.php';
         if (!file_exists($file)) {
             if (!$this->writeConfigArrayToFile($file, $deliverySslConfig)) {
                 return false;
             }
         }
     }
     // Always touch the INSTALLED file
     if (!file_exists(MAX_PATH . '/var/INSTALLED') && !touch(MAX_PATH . '/var/INSTALLED')) {
         return false;
     }
     // Do any old configuration files need to be deleted?
     if (!is_null($oldAdminHost) && $newAdminHost != $oldAdminHost) {
         $file = $configPath . '/' . $oldAdminHost . $configFile . '.conf.php';
         if ($file != $mainConfigFile) {
             @unlink($file);
         }
     }
     if (!is_null($oldDeliveryHost) && $newDeliveryHost != $oldDeliveryHost && $oldDeliveryHost != $newAdminHost) {
         $file = $configPath . '/' . $oldDeliveryHost . $configFile . '.conf.php';
         if ($file != $mainConfigFile) {
             @unlink($file);
         }
     }
     if (!is_null($oldDeliverySslHost) && $newDeliverySslHost != $oldDeliverySslHost && $oldDeliverySslHost != $newAdminHost) {
         $file = $configPath . '/' . $oldDeliverySslHost . $configFile . '.conf.php';
         if ($file != $mainConfigFile) {
             @unlink($file);
         }
     }
     // If the main (delivery) conf file changed or if there are any un-accounted for
     // config files in the var directory, don't write a default.conf.php file
     $aOtherConfigFiles = $this->findOtherConfigFiles($configPath, $configFile);
     if ($oldDeliveryHost != $newDeliveryHost || empty($aOtherConfigFiles)) {
         $file = $configPath . '/default' . $configFile . '.conf.php';
         $aConfig = array('realConfig' => $newDeliveryHost);
         if (!$this->writeConfigArrayToFile($file, $aConfig)) {
             OA::debug('Unable to write default.conf.php file (check file/folder permissions', PEAR_LOG_DEBUG);
         }
     } else {
         OA::debug('Did not create a default.conf.php file due to the presence of:' . implode(', ', $aOtherConfigFiles), PEAR_LOG_DEBUG);
     }
     // Re-parse the config file?
     if ($reParse) {
         if (!is_null($configFile)) {
             // The code above will have prefixed a '.' to the configFile value, strip it off before passing along
             $configFile = substr($configFile, 1);
         }
         $GLOBALS['_MAX']['CONF'] = parseIniFile($configPath, $configFile);
         $this->aConf = $GLOBALS['_MAX']['CONF'];
         // Set the global $conf value -- normally set by the init
         // script -- to be the same as $GLOBALS['_MAX']['CONF']
         global $conf;
         $conf = $GLOBALS['_MAX']['CONF'];
     }
     return true;
 }
コード例 #7
0
ファイル: init-parse.php プロジェクト: villos/tree_admin
/**
 * The general (non-delivery engine) function to parse the configuration .ini file
 *
 * @param string $configPath The directory to load the config file from.
 *                           Default is Max's /var directory.
 * @param string $configFile The configuration file name (eg. "geotargeting").
 *                           Default is no name (ie. the main Max
 *                           configuration file).
 * @param boolean $sections  Process sections, as per parse_ini_file().
 * @param string  $type      The config file type value (eg. ".php"). Allows BC
 *                           support for old ".ini" files.
 *
 * @return mixed The array resulting from the call to parse_ini_file(), with
 *               the appropriate .php file for the installation.
 */
function parseIniFile($configPath = null, $configFile = null, $sections = true, $type = '.php')
{
    // Set up the configuration .ini file path location
    if (is_null($configPath)) {
        $configPath = MAX_PATH . '/var';
    }
    // Set up the configuration .ini file type name
    if (!is_null($configFile)) {
        $configFile = '.' . $configFile;
    }
    // Is this a web, or a cli call?
    if (is_null($configFile) && !isset($_SERVER['SERVER_NAME'])) {
        if (!isset($GLOBALS['argv'][1]) && !file_exists($configPath . '/default' . $configFile . '.conf' . $type)) {
            echo MAX_PRODUCT_NAME . " was called via the command line, but had no host as a parameter.\n";
            exit(1);
        }
        $host = trim($GLOBALS['argv'][1]);
    } else {
        $host = OX_getHostName();
    }
    // Is the system running the test environment?
    if (is_null($configFile) && defined('TEST_ENVIRONMENT_RUNNING')) {
        // Does the test environment config exist?
        $testFilePath = $configPath . '/test.conf' . $type;
        if (file_exists($testFilePath)) {
            return @parse_ini_file($testFilePath, $sections);
        } else {
            // Define a value so that we know the testing environment is not
            // configured, so that the TestRenner class knows not to run any
            // tests, and return an empty config
            define('TEST_ENVIRONMENT_NO_CONFIG', true);
            return array();
        }
    }
    // Is the .ini file for the hostname being used directly accessible?
    if (file_exists($configPath . '/' . $host . $configFile . '.conf' . $type)) {
        // Parse the configuration file
        $conf = @parse_ini_file($configPath . '/' . $host . $configFile . '.conf' . $type, $sections);
        // Is this a real config file?
        if (!isset($conf['realConfig'])) {
            // Yes, return the parsed configuration file
            return $conf;
        }
        // Parse and return the real configuration .ini file
        if (file_exists($configPath . '/' . $conf['realConfig'] . $configFile . '.conf' . $type)) {
            $realConfig = @parse_ini_file(MAX_PATH . '/var/' . $conf['realConfig'] . '.conf' . $type, true);
            $mergedConf = mergeConfigFiles($realConfig, $conf);
            // if not multiple levels of configs
            if (!isset($mergedConf['realConfig'])) {
                return $mergedConf;
            }
        }
    } elseif ($configFile === '.plugin') {
        // For plugins, if no configuration file is found, return the sane default values
        $pluginType = basename($configPath);
        $defaultConfig = MAX_PATH . '/plugins/' . $pluginType . '/default.plugin.conf' . $type;
        if (file_exists($defaultConfig)) {
            return parse_ini_file($defaultConfig, $sections);
        } else {
            echo MAX_PRODUCT_NAME . " could not read the default configuration file for the {$pluginType} plugin";
            exit(1);
        }
    }
    // Check for a default.conf.php file...
    if (file_exists($configPath . '/default' . $configFile . '.conf' . $type)) {
        // Parse the configuration file
        $conf = @parse_ini_file($configPath . '/default' . $configFile . '.conf' . $type, $sections);
        // Is this a real config file?
        if (!isset($conf['realConfig'])) {
            // Yes, return the parsed configuration file
            return $conf;
        }
        // Parse and return the real configuration .ini file
        if (file_exists($configPath . '/' . $conf['realConfig'] . $configFile . '.conf' . $type)) {
            $realConfig = @parse_ini_file(MAX_PATH . '/var/' . $conf['realConfig'] . '.conf' . $type, true);
            $mergedConf = mergeConfigFiles($realConfig, $conf);
            // if not multiple levels of configs
            if (!isset($mergedConf['realConfig'])) {
                return $mergedConf;
            }
        }
    }
    // Got all this way, and no configuration file yet found - maybe
    // the user is upgrading from an old version where the config
    // files have a .ini prefix instead of .php...
    global $installing;
    if ($installing) {
        // ah but MMM might be installed, check for the ini file
        if (file_exists($configPath . '/' . $host . $configFile . '.conf.ini')) {
            return parseIniFile($configPath, $configFile, $sections, '.ini');
        }
        if (!$configFile) {
            // OpenX hasn't been installed, so use the distribution .ini file
            // this deals with letting a PAN install get into the ugprader
            return @parse_ini_file(MAX_PATH . '/etc/dist.conf.php', $sections);
        }
        //return parseIniFile($configPath, $configFile, $sections, '.ini');
    }
    // Check to ensure OpenX hasn't been installed
    if (file_exists(MAX_PATH . '/var/INSTALLED')) {
        // ah but MMM might be installed, check for the ini file
        if (file_exists($configPath . '/' . $host . $configFile . '.conf.ini')) {
            return parseIniFile($configPath, $configFile, $sections, '.ini');
        }
        echo MAX_PRODUCT_NAME . " has been installed, but no configuration file " . $configPath . '/' . $host . $configFile . '.conf.php' . " was found.\n";
        exit(1);
    }
    // OpenX hasn't been installed, so use the distribution .ini file
    return @parse_ini_file(MAX_PATH . '/etc/dist.conf.php', $sections);
}