Exemplo n.º 1
0
function hubbub2_loadurl($url)
{
    $content = HubbubEndpoint::request($url);
    $html = trim($content['body']);
    $entity = array();
    // case 1, this is a json array
    if (substr($html, 0, 1) == '{') {
        $entity = json_decode($html);
    } else {
        if (stristr($html, '<!-- hubbub2:{') != '') {
            CutSegment('<!-- hubbub2:{', $html);
            $seg = '{' . trim(CutSegment('-->', $html));
            $entity = json_decode($seg, true);
        }
    }
    return $entity;
}
Exemplo n.º 2
0
<?

  $results = array();

  $url = HubbubEndpoint::urlUnify($_REQUEST['q']);
  $url_res = $this->model->loadUrl($url);

  $GLOBALS['group.options'] = array('<option value="0">Select...</option>');
  foreach($this->model->getMyGroups() as $grp)
  $GLOBALS['group.options'][] = '<option value="'.$grp['lg_key'].'">'.$grp['lg_name'].'</option>';
  
  if($url_res['result'] == 'OK')
  {
    if($url_res['url'] == '') $url_res['url'] = $url; else $url_res['url'] = HubbubEndpoint::urlUnify($url_res['url']);
    if(trim($url_res['server']) != '' && trim($url_res['user']) != '') 
    {
      $server = new HubbubServer($url_res['server']);
      if(!$server->isTrusted()) $server->msg_trust_sendkey1();
      $url_res['server_trusted'] = $server->isTrusted();
      $results[] = $url_res;
    }
  }
  
  if(sizeof($results) == 0)
  {
    ?><div class="fail">
      <?php 
echo l10n('friend.notfound');
?>
    </div><? 
  }
Exemplo n.º 3
0
 /**
  * sends the current message to a server URL
  * @param string $url
  * @return 
  */
 function sendToUrl($url, $forceKey = null)
 {
     if (trim($url) == '') {
         logError('', 'Message[' . $this->type . ']::sendToUrl(empty)');
         return array('result' => 'fail', 'reason' => 'Server URL cannot be empty');
     }
     $this->sanitizeDataset();
     $this->toServer = new HubbubServer($url, true);
     if (!$this->toServer->isTrusted() && !strStartsWith($this->type, 'trust')) {
         $r = $this->toServer->msg_trust_sendkey1();
         if ($r['result'] != 'OK') {
             return $r;
         } else {
             return array('result' => 'fail', 'reason' => 'waiting for server key');
         }
     }
     $this->executeHandler('before_sendtourl', array('url' => $url));
     $this->payload = json_encode($this->data);
     if ($this->toServer->outboundKey() != '' || $forceKey != null) {
         $this->signForServer($this->toServer, $forceKey);
     }
     $result = HubbubEndpoint::request($url, array('hubbub_msg' => $this->payload, 'hubbub_sig' => $this->signature));
     $this->responseData = $result['data'];
     $this->executeHandler('after_sendtourl', array('url' => $url, 'result' => $result));
     h2_audit_log('msg/send', array('to' => array($url), 'text' => $this->data['text'], 'result' => $result['result']), $this->data['msgid']);
     return $result['data'];
 }