Esempio n. 1
0
 public static function get($resourceName)
 {
     /*{{{*/
     $resourceName = strtolower($resourceName);
     if (false == self::has($resourceName)) {
         if ($resourceName == 'debug') {
             $res = XDebuggerFactory::create();
         } else {
             $res = new $resourceName();
         }
         self::$_arr[$resourceName] = $res;
     } else {
         $res = self::$_arr[$resourceName];
     }
     return $res;
 }
Esempio n. 2
0
 public function call($module, $method, $args, $options)
 {
     /*{{{*/
     //error_log("$module $method \n", 3, '/tmp/call.log');
     //echo 'remote! '.$module.' | '.$method.'<br>';
     //echo 'in REMOTE!<br>';
     $this->setTimeOut($options);
     $urlInfo = $this->pickUpRemoteServer();
     $request = $this->parseUrl($urlInfo) . "?service={$module}&do={$method}";
     //error_log(print_r($args, true), 3, '/tmp/a');
     //error_log(print_r($options, true), 3, '/tmp/a');
     //$data = 'data='.rawurlencode(serialize($args)).'&options='.rawurlencode(serialize($this->prepareTransInfo($options)));
     $files = $this->filterFiles($args);
     $data = array('data' => rawurlencode(igbinary_serialize(array('args' => $args, 'options' => $this->prepareTransInfo($options)))));
     //error_log($data."\n\n", 3, '/tmp/a');
     //error_log("\n===".strlen($data)."===\n", 3, '/tmp/a');
     $beginTime = $this->microtime_float();
     $revdata = $this->request($request, $urlInfo['domain'], $data, $files);
     $endTime = $this->microtime_float();
     if ($this->_clientUtil->getConfig('DEBUG_ENABLE')) {
         echo $revdata;
     }
     if ($revdata) {
         if ($this->_clientUtil->getConfig('DEBUG_ENABLE')) {
             echo $revdata;
         }
         $result = $this->myUnserialize($revdata);
     } else {
         $result = array();
         $result['errno'] = -3;
         $result['data'] = array();
         $result['node'] = $urlInfo['domain'];
         $result['errmsg'] = "{$module} {$method} " . serialize($args) . " " . serialize($options);
         $result['consume'] = (int) round(($endTime - $beginTime) * 1000, 1);
     }
     if (XDebuggerFactory::isValidDebugRequest() && isset($result['xdebugger'])) {
         BeanFinder::get('debug')->addChildrenNodeList($result['xdebugger']);
         BeanFinder::get('debug')->end();
     }
     $info['consume'] = (int) round(($endTime - $beginTime) * 1000, 1);
     $info['len'] = strlen($revdata);
     $info['rconsume'] = $result['consume'];
     $info['remote_addr'] = $this->trans['remote_addr'];
     $info['time'] = date('[d/M/Y:H:i:s O]', time());
     $info['method'] = $urlInfo['host'] . '::' . $module . '::' . $method;
     $info['errno'] = isset($result['errno']) ? $result['errno'] : 0;
     $info['args'] = $args;
     $this->log($info);
     return $result;
 }