コード例 #1
1
ファイル: Helper.php プロジェクト: janym/angular-yii
function Insight_Helper__main()
{
    spl_autoload_register('Insight_Helper::autoload');
    $additionalConfig = isset($GLOBALS['INSIGHT_ADDITIONAL_CONFIG']) ? $GLOBALS['INSIGHT_ADDITIONAL_CONFIG'] : false;
    $insightConfigPath = getenv('INSIGHT_CONFIG_PATH');
    if (defined('INSIGHT_CONFIG_PATH')) {
        $insightConfigPath = constant('INSIGHT_CONFIG_PATH');
    }
    $options = array();
    if (isset($GLOBALS['INSIGHT_FORCE_ENABLE'])) {
        $options['forceEnable'] = $GLOBALS['INSIGHT_FORCE_ENABLE'] === true ? true : false;
    }
    if ($insightConfigPath) {
        $insightConfigPath = explode(',', $insightConfigPath);
        if (sizeof($insightConfigPath) == 2) {
            $additionalConfig = Insight_Util::array_merge($additionalConfig ? $additionalConfig : array(), array('implements' => array('cadorn.org/insight/@meta/config/0' => array('credentialsPath' => $insightConfigPath[1]))));
        }
        $insightConfigPath = $insightConfigPath[0];
        if (defined('INSIGHT_IPS')) {
            Insight_Helper::debug('INSIGHT_IPS constant ignored as INSIGHT_CONFIG_PATH is defined');
            trigger_error('INSIGHT_IPS constant ignored as INSIGHT_CONFIG_PATH is defined', E_USER_WARNING);
        }
        if (defined('INSIGHT_AUTHKEYS')) {
            Insight_Helper::debug('INSIGHT_AUTHKEYS constant ignored as INSIGHT_CONFIG_PATH is defined');
            trigger_error('INSIGHT_AUTHKEYS constant ignored as INSIGHT_CONFIG_PATH is defined', E_USER_WARNING);
        }
        if (defined('INSIGHT_PATHS')) {
            Insight_Helper::debug('INSIGHT_PATHS constant ignored as INSIGHT_CONFIG_PATH is defined');
            trigger_error('INSIGHT_PATHS constant ignored as INSIGHT_CONFIG_PATH is defined', E_USER_WARNING);
        }
        if (defined('INSIGHT_SERVER_PATH')) {
            Insight_Helper::debug('INSIGHT_SERVER_PATH constant ignored as INSIGHT_CONFIG_PATH is defined');
            trigger_error('INSIGHT_SERVER_PATH constant ignored as INSIGHT_CONFIG_PATH is defined', E_USER_WARNING);
        }
        Insight_Helper::init($insightConfigPath, $additionalConfig, $options);
    } else {
        if (!$insightConfigPath && php_sapi_name() == 'cli') {
            $paths = array();
            if (defined('INSIGHT_PATHS')) {
                foreach (explode(',', constant('INSIGHT_PATHS')) as $path) {
                    $paths[$path] = 'allow';
                }
            }
            $config = array('package.json' => array('uid' => 'localhost', 'implements' => array('cadorn.org/insight/@meta/config/0' => array('paths' => $paths))), 'credentials.json' => array('cadorn.org/insight/@meta/config/0' => array('allow' => array('ips' => array('*'), 'authkeys' => array('*')))));
            Insight_Helper::init($config, $additionalConfig, $options);
        } else {
            if (defined('INSIGHT_IPS') || defined('INSIGHT_AUTHKEYS') || defined('INSIGHT_PATHS') || defined('INSIGHT_SERVER_PATH')) {
                if (!defined('INSIGHT_IPS') || !defined('INSIGHT_AUTHKEYS') || !defined('INSIGHT_PATHS') || !defined('INSIGHT_SERVER_PATH')) {
                    Insight_Helper::debug('INSIGHT_IPS, INSIGHT_AUTHKEYS, INSIGHT_PATHS and INSIGHT_SERVER_PATH constants must be defined if not using INSIGHT_CONFIG_PATH');
                    throw new Exception('INSIGHT_IPS, INSIGHT_AUTHKEYS, INSIGHT_PATHS and INSIGHT_SERVER_PATH constants must be defined if not using INSIGHT_CONFIG_PATH');
                }
                $paths = array();
                foreach (explode(',', constant('INSIGHT_PATHS')) as $path) {
                    $paths[$path] = 'allow';
                }
                $config = array('package.json' => array('uid' => $_SERVER['HTTP_HOST'], 'implements' => array('cadorn.org/insight/@meta/config/0' => array('server' => array('path' => constant('INSIGHT_SERVER_PATH')), 'paths' => $paths))), 'credentials.json' => array('cadorn.org/insight/@meta/config/0' => array('allow' => array('ips' => explode(',', constant('INSIGHT_IPS')), 'authkeys' => explode(',', constant('INSIGHT_AUTHKEYS'))))));
                Insight_Helper::init($config, $additionalConfig, $options);
            } else {
                Insight_Helper::debug('INSIGHT_CONFIG_PATH constant or environment variable or INSIGHT_IPS, INSIGHT_AUTHKEYS, INSIGHT_PATHS and INSIGHT_SERVER_PATH constants not set!');
                return false;
            }
        }
    }
}
コード例 #2
0
ファイル: Insight.php プロジェクト: janym/angular-yii
 /**
  * Set the configuration file path
  * 
  * @param string $file The config file path
  * @return boolean FALSE if file not found TRUE otherwise
  */
 public function setConfig($file)
 {
     if (!file_exists($file)) {
         return false;
     }
     if (Insight_Helper::isInitialized()) {
         throw new Exception('FirePHP::setConfig() already set');
     }
     Insight_Helper::init($file, $GLOBALS['INSIGHT_ADDITIONAL_CONFIG']);
 }