示例#1
0
	function CheckNewUrl($newUrl)
	{
    require_once('lib/hubbub2_loadurl.php');
    // let's see if there is a valid entity record at this url
		$ne = hubbub2_loadurl($newUrl);
		if(sizeof($ne) == 0)
		{
      $result = array('result' => 'fail', 'reason' => 'entity_not_found');
		}
		else if($ne['user'] == '' || $ne['server'] == '')
		{
			$result = array('result' => 'fail', 'reason' => 'invalid_entity');
		}
		else 
		{
			$userEntity = HubbubEntity::ds2array($GLOBALS['obj']['user']->selfEntity());
			$localEntity = HubbubEntity::findEntity($ne);
			$result = array('entity' => $ne, 'match' => $localEntity);
			if(sizeof($localEntity) == 0 || $localEntity['user'] != $userEntity['user'])
			{
				$result['result'] = 'fail';
				$result['reason'] = 'entity_mismatch';
			}
			else 
			{
				$result['result'] = 'OK';
			}
		}
		return($result);
	}
示例#2
0
	function loadUrl($url)
	{
		$result = array();
		require_once('lib/hubbub2_loadurl.php');
    $result = hubbub2_loadurl($url);
    if(sizeof($result) == 0 || $result['user'] == '' || $result['server'] == '')
    {
    	$result['result'] = 'fail';
    	$result['reason'] = 'entity_not_found';
    }
    else
    {
      $result['result'] = 'OK';
    }
    return($result);
	}
示例#3
0
  tlog($p->signature == md5($toServer->outboundKey().$p->payload), 'HubbubMessage::signForServer('.$p->ownerEntity->ds['server'].')', 'OK ('.$p->signature.')', 'invalid signature');
  tlog($p->validateSignature(), 'HubbubMessage->validateSignature(valid)', 'OK', 'failure');
	$p->signature = md5($p->signature);
	$GLOBALS['nolog'] = true; // disable logging, because we'll trigger an error here
	tlog(!$p->validateSignature(), 'HubbubMessage->validateSignature(invalid)', 'OK', 'failure');
  $GLOBALS['nolog'] = false;
  $p->signForServer($toServer);
  $r = new HubbubMessage();
	$r->receive($p->payload, $p->signature);
  tlog($r->validateSignature(), 'HubbubMessage->receive() signature', 'OK', 'failure ('.$p->expectedSignature.')');

  tsection('Friends');
  
	$url = $ne2->ds['url'];
  require_once('lib/hubbub2_loadurl.php');
  $er = hubbub2_loadurl($url);
  tlog(!(sizeof($er) == 0 || $er['user'] == '' || $er['server'] == ''), 'hubbub2_loadurl('.$url.')', 'OK ('.$er['user'].'@'.$er['server'].')', 'failure');
  $res = $p->sendToUrl($er['server']);  
  tlog($res['result'] == 'OK', 'HubbubMessage->sendToUrl('.$url.') Message '.$p->data['msgid'], 'OK ('.json_encode($res).')', 'fail ('.$res['reason'].')');
  $con1 = new HubbubConnection($p->authorEntity->key(), $p->ownerEntity->key());
  $con2 = new HubbubConnection($p->ownerEntity->key(), $p->authorEntity->key());
  tlog($con1->ds['c_status'] == 'req.sent', 'HubbubConnection status '.$u1name.':'.$con1->ds['c_from'].' to '.$u2name.':'.$con1->ds['c_to'].' == req.sent', 'OK', 'fail ('.$con1->ds['c_status'].')');
  tlog($con2->ds['c_status'] == 'req.rcv', 'HubbubConnection status '.$u2name.':'.$con2->ds['c_from'].' to '.$u1name.':'.$con2->ds['c_to'].' == req.rcv', 'OK', 'fail ('.json_encode($con2->ds).')');
	
	// if everything went right, there should be a friend request waiting for user u1
	$frRcvList = $this->friends->getFriends('req.rcv', $u2['u_entity']);
	foreach($frRcvList as $frc) if($frc['c_to'] == $ne1->ds['_key']) $frqReceived = true;
  tlog($frqReceived, 'FriendsModel: friend_request in "pending" list', 'OK', 'fail ('.dumpArray($frRcvList).')');		
	
	// now, confirm it
  $fp = new HubbubMessage('friend_request');