Esempio n. 1
1
 public function setOptions($options)
 {
     //        if(count($diff = array_diff(array_keys($options), array_keys($this->options)))>0) {
     //            throw new Exception('Unknown options: ' . implode(',', $diff));
     //        }
     $this->options = Insight_Util::array_merge($this->options, $options);
 }
Esempio n. 2
1
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;
            }
        }
    }
}
Esempio n. 3
1
 protected function _encodeVariable($Variable, $ObjectDepth = 1, $ArrayDepth = 1, $MaxDepth = 1)
 {
     /*        
             if($Variable===self::UNDEFINED) {
                 $var = array('type'=>'constant', 'constant'=>'undefined');
                 if($this->options['includeLanguageMeta']) {
                     $var['lang.type'] = 'undefined';
                 }
                 return $var;
             } else
     */
     if (is_null($Variable)) {
         $var = array('type' => 'constant', 'constant' => 'null');
         if ($this->getOption('includeLanguageMeta')) {
             $var['lang.type'] = 'null';
         }
     } else {
         if (is_bool($Variable)) {
             $var = array('type' => 'constant', 'constant' => $Variable ? 'true' : 'false');
             if ($this->getOption('includeLanguageMeta')) {
                 $var['lang.type'] = 'boolean';
             }
         } else {
             if (is_int($Variable)) {
                 $var = array('type' => 'text', 'text' => (string) $Variable);
                 if ($this->getOption('includeLanguageMeta')) {
                     $var['lang.type'] = 'integer';
                 }
             } else {
                 if (is_float($Variable)) {
                     $var = array('type' => 'text', 'text' => (string) $Variable);
                     if ($this->getOption('includeLanguageMeta')) {
                         $var['lang.type'] = 'float';
                     }
                 } else {
                     if (is_object($Variable)) {
                         $sub = $this->_encodeInstance($Variable, $ObjectDepth, $ArrayDepth, $MaxDepth);
                         $var = array('type' => 'reference', 'reference' => $sub['value']);
                         if (isset($sub['meta'])) {
                             $var = Insight_Util::array_merge($var, $sub['meta']);
                         }
                     } else {
                         if (is_array($Variable)) {
                             if (isset($Variable[self::SKIP])) {
                                 unset($Variable[self::SKIP]);
                                 return $Variable;
                             }
                             $sub = null;
                             // Check if we have an indexed array (list) or an associative array (map)
                             if (Insight_Util::is_list($Variable)) {
                                 $sub = $this->_encodeArray($Variable, $ObjectDepth, $ArrayDepth, $MaxDepth);
                                 $var = array('type' => 'array', 'array' => $sub['value']);
                             } else {
                                 if ($this->getOption('treatArrayMapAsDictionary')) {
                                     $sub = $this->_encodeAssociativeArray($Variable, $ObjectDepth, $ArrayDepth, $MaxDepth);
                                     $var = array('type' => 'dictionary', 'dictionary' => isset($sub['value']) ? $sub['value'] : false);
                                 } else {
                                     $sub = $this->_encodeAssociativeArray($Variable, $ObjectDepth, $ArrayDepth, $MaxDepth);
                                     $var = array('type' => 'map', 'map' => isset($sub['value']) ? $sub['value'] : false);
                                 }
                             }
                             if (isset($sub['meta'])) {
                                 $var = Insight_Util::array_merge($var, $sub['meta']);
                             }
                             if ($this->getOption('includeLanguageMeta')) {
                                 $var['lang.type'] = 'array';
                             }
                         } else {
                             if (is_resource($Variable)) {
                                 // TODO: Try and get more info about resource
                                 $var = array('type' => 'text', 'text' => (string) $Variable);
                                 if ($this->getOption('includeLanguageMeta')) {
                                     $var['lang.type'] = 'resource';
                                 }
                             } else {
                                 if (is_string($Variable)) {
                                     $var = array('type' => 'text');
                                     // TODO: Add info about encoding
                                     if (Insight_Util::is_utf8($Variable)) {
                                         $var['text'] = $Variable;
                                     } else {
                                         $var['text'] = utf8_encode($Variable);
                                     }
                                     $maxLength = $this->getOption('maxStringLength');
                                     $lengthNoLimit = $this->getOption('lengthNoLimit');
                                     if ($maxLength >= 0 && strlen($var['text']) >= $maxLength && $lengthNoLimit !== true) {
                                         $var['encoder.trimmed'] = true;
                                         $var['encoder.trimmed.partial'] = true;
                                         $var['encoder.notice'] = 'Max String Length (' . $maxLength . ') ' . (strlen($var['text']) - $maxLength) . ' more';
                                         $var['text'] = substr($var['text'], 0, $maxLength);
                                     }
                                     if ($this->getOption('includeLanguageMeta')) {
                                         $var['lang.type'] = 'string';
                                     }
                                 } else {
                                     $var = array('type' => 'text', 'text' => (string) $Variable);
                                     if ($this->getOption('includeLanguageMeta')) {
                                         $var['lang.type'] = 'unknown';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $var;
 }
Esempio n. 4
1
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * ***** END LICENSE BLOCK *****
 * 
 * @copyright   Copyright (C) 2010 Christoph Dorn
 * @author      Christoph Dorn <*****@*****.**>
 * @license     http://www.opensource.org/licenses/bsd-license.php
 * @package     FirePHP
 */
$GLOBALS['INSIGHT_AUTOLOAD'] = false;
if (!isset($GLOBALS['INSIGHT_ADDITIONAL_CONFIG'])) {
    $GLOBALS['INSIGHT_ADDITIONAL_CONFIG'] = array();
}
$GLOBALS['INSIGHT_ADDITIONAL_CONFIG'] = Insight_Util::array_merge($GLOBALS['INSIGHT_ADDITIONAL_CONFIG'], array('implements' => array('cadorn.org/insight/@meta/config/0' => array('plugins' => array('engine' => array('api' => 'FirePHP/Plugin/Engine'), 'firephp' => array('api' => 'FirePHP/Plugin/FirePHP'))))));
// NOTE: We must load this class manually as the exported class is only named 'FirePHP' which will not work with the autoloader
FirePHP__autoload('FirePHPCore_FirePHP.class');
Insight_Helper::setSenderLibrary('cadorn.org/github/firephp-libs/packages/insight@' . FirePHP::VERSION);
class FirePHP_Insight extends FirePHP
{
    /**
     * Flag to indicate if upgrade message for client extension was logged
     * 
     * @var boolean
     */
    protected static $upgradeClientMessageLogged = false;
    /**
     * Set the configuration file path
     * 
     * @param string $file The config file path
Esempio n. 5
0
 public function getPackageInfo()
 {
     $info = array('links' => array('quick' => array()));
     if (isset($this->config['name'])) {
         $info['name'] = $this->config['name'];
     }
     if (isset($this->config['description'])) {
         $info['description'] = $this->config['description'];
     }
     if (isset($this->config['homepage'])) {
         $info['links']['quick']['Homepage'] = $this->config['homepage'];
     }
     if (isset($this->config['bugs'])) {
         $info['links']['quick']['Bugs'] = $this->config['bugs'];
     }
     if (isset($this->config['implements'][self::PACKAGE_META_URI])) {
         $info = Insight_Util::array_merge($info, $this->config['implements'][self::PACKAGE_META_URI]);
     }
     return $info;
 }
Esempio n. 6
-1
 public function __call($name, $arguments)
 {
     if (self::$blocks > 0) {
         return Insight_Helper::getNullMessage();
     }
     if ($this->apiOnce) {
         if (!method_exists($this->apiOnce, $name)) {
             throw new Exception('Method "' . $name . '" does not exist in class: ' . get_class($this->apiOnce));
         }
         $api = $this->apiOnce;
         $this->apiOnce = false;
         $oldmsg = $api->setMessage($this);
         $retval = call_user_func_array(array($api, $name), $arguments);
         $api->setMessage($oldmsg);
         return $retval;
     } else {
         if ($this->api && method_exists($this->api, $name)) {
             $oldmsg = $this->api->setMessage($this);
             $retval = call_user_func_array(array($this->api, $name), $arguments);
             $this->api->setMessage($oldmsg);
             return $retval;
         }
     }
     if ($name == 'once') {
         $message = clone $this;
         $message->once = $arguments[0];
         return $message;
     } else {
         if ($name == 'to') {
             $message = clone $this;
             $message->to = $arguments[0];
             return $message;
         } else {
             if ($name == 'is') {
                 if (is_bool($arguments[0])) {
                     return $arguments[0];
                 }
                 throw new Exception('non-boolean is() comparison not supported');
             } else {
                 if ($name == 'api') {
                     $message = clone $this;
                     $api = $arguments[0];
                     if (is_string($api)) {
                         $api = $this->helper->getApi($api);
                     }
                     if (isset($arguments[1]) && $arguments[1] === true) {
                         $message->apiOnce = $api;
                     } else {
                         $message->api = $api;
                     }
                     if (method_exists($api, 'setRequest')) {
                         $api->setRequest($this->helper->getRequest());
                     }
                     return $message;
                 } else {
                     if ($name == 'meta') {
                         $message = clone $this;
                         foreach ($arguments[0] as $name => $value) {
                             if ($value === null) {
                                 unset($message->meta[$name]);
                             } else {
                                 if (isset($message->meta[$name])) {
                                     $message->meta[$name] = Insight_Util::array_merge($message->meta[$name], $value);
                                 } else {
                                     $message->meta[$name] = $value;
                                 }
                             }
                         }
                         return $message;
                     } else {
                         if ($name == 'open') {
                             return $this;
                         } else {
                             if ($name == 'close') {
                                 return $this;
                             }
                         }
                     }
                 }
             }
         }
     }
     throw new Exception("Unknown method: " . $name);
 }