Esempio n. 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);
	}
Esempio n. 2
0
function tmpl_friendlist($list, $rowCallback2 = '')
{
    ?>
<table width="100%"><?php 
    foreach ($list as $ds) {
        ?>
<tr class="drow_<?php 
        echo $ds['_key'];
        ?>
">
      <td colspan="10"><div style="width: 100%; border-top: 1px solid #aaa;"></div></td>
    </tr class="drow_<?php 
        echo $ds['_key'];
        ?>
"><tr>
      <td valign="top" width="60"><img src="<?php 
        echo getDefault($ds['pic'], 'img/anonymous.png');
        ?>
" width="48" style="max-height: 48px"/></td>
      <td valign="top" width="50%">
        <div><?php 
        echo HubbubEntity::link($ds);
        ?>
</div>
        <div class="smalltext"><?php 
        echo htmlspecialchars($ds['url']);
        ?>
</div>
      </td>
			<td valign="top">
				<?
				if($rowCallback2 != '') $rowCallback2($ds);
				?>
			</td>
    </tr><?php 
    }
    ?>
</table><?php 
}
Esempio n. 3
0
echo l10n('friend.notfound');
?>
    </div><? 
  }
  else
  {
    ?><div class="win" style="padding-bottom: 8px;">
      <?php 
echo l10n('friend.searchresults');
?>
:
    </div><table><?
    
    foreach($results as $item)
    {
      $ent = new HubbubEntity($item);
      ?><tr>
        <td width="64" valign="top"><img src="img/anonymous.png" width="48"/></td>
        <td valign="top" width="250">
          <b><?php 
echo $item['name'];
?>
</b>
          <div id="srvstat_<?php 
echo md5($item['server']);
?>
">
          <?
          if(!$item['server_trusted'])
          {
            ?>contacting server...
Esempio n. 4
0
<?

  $u1name = 'HTT_'.substr(md5(time().rand(1, 100000)), 0, 5);
  $u2name = 'HTT_'.substr(md5(time().rand(1, 100000)), 0, 5);

  tsection('Entities');
  
  $this->friends->contactServer($_SERVER['HTTP_HOST']);
  
  $erec1 = array('server' => $_SERVER['HTTP_HOST'], 'user' => $u1name, 'url' => $_SERVER['HTTP_HOST'].'/'.$u1name);
  $ne1 = new HubbubEntity();
  $ne1->create($erec1, true);
  $erec2 = array('server' => $_SERVER['HTTP_HOST'], 'user' => $u2name, 'url' => $_SERVER['HTTP_HOST'].'/'.$u2name);
  $ne2 = new HubbubEntity();
  $ne2->create($erec2, true);
  $ne1key = $ne1->ds['_key'];
  $ne2key = $ne2->ds['_key'];
  tlog($ne1->ds['_key'] > 0, 'HubbubEntity::create('.$u1name.')', 'OK', 'failed, no key assigned'); 
  tlog($ne2->ds['_key'] > 0, 'HubbubEntity::create('.$u2name.')', 'OK', 'failed, no key assigned'); 

  $u1 = array('u_name' => $u1name, 'u_entity' => $ne1->ds['_key']);
  DB_UpdateDataset('users', $u1);
  $u2 = array('u_name' => $u2name, 'u_entity' => $ne2->ds['_key']);
  DB_UpdateDataset('users', $u2);
  tlog($u1['u_key'] > 0, 'HubbubUser::create('.$u1['u_key'].')', 'OK', 'failed, no key assigned'); 
  tlog($u2['u_key'] > 0, 'HubbubUser::create('.$u2['u_key'].')', 'OK', 'failed, no key assigned'); 

  tsection('Message Basic');

  $p = new HubbubMessage('friend_request');  
  tlog($p->data['msgid'] != '', 'HubbubMessage::create(friend_request '.$p->data['msgid'].')', 'OK', 'msgid failure');
Esempio n. 5
0
		
		if($this->user->getUsername() == '')
      $this->form->add('string', 'username', array('default' => $defaultUsername, 'validate' => 'notempty', 'filter' => 'safe'));
    else
      $this->form->add('readonly', 'username');
      
    $this->form
      ->add('string', 'u_name', array('default' => $defaultName, 'validate' => 'notempty'))
		  ->add('dropdown', 'u_l10n', array('options' => array('en' => 'English', 'de' => 'Deutsch')))
      ->add('submit', 'saveprofile');
		
		if($this->form->submitted)
		{
			if($this->form->getData())
			{
			  if($this->user->getUsername() == '' && !HubbubEntity::isNameAvailable($this->form->ds['username']))
			  {
				  $this->form->errors['username'] = l10n('username.notavailable');
			  }
				else
				{
					$this->model->setUsername($this->form->ds['username']);
				}
				if(sizeof($this->form->errors) == 0)
				{
	        $this->user->ds['u_name'] = trim(strip_tags($this->form->ds['u_name']));
	        $this->user->ds['u_l10n'] = trim(strip_tags($this->form->ds['u_l10n']));
	        $this->user->save();
	        redirect(actionUrl('index', 'home'));
				}
			}			
Esempio n. 6
0
<h3>Creating and finding</h3>
<?
  
	$newUserId = 'HTT_'.substr(md5(time()), 0, 5);
	$erec = array('server' => $_SERVER['HTTP_HOST'], 'user' => $newUserId, 'url' => $_SERVER['HTTP_HOST'].'/'.$newUserId);
	$ne = new HubbubEntity();
	?><div>Test Entity: <?php 
echo json_encode($erec);
?>
</div><?
	$ne->create($erec, true);
  tlog($ne->ds['_key'] > 0, 'HubbubEntity::create()', 'created', 'failed, no key assigned'); 

  $found = HubbubEntity::findEntityGlobal(array('server' => $erec['server'], 'user' => $erec['user']));
  tlog($found['_key'] > 0, 'HubbubEntity::findEntityGlobal(server, user)', 'found', 'not found'); 
  tlog($found['_key'] == $ne->ds['_key'], 'HubbubEntity::findEntityGlobal(server, user) key value', 'correct', 'not valid'); 	
	
  tlog(!HubbubEntity::isNameAvailable($erec['user']), 'HubbubEntity::isNameAvailable(user)', 'OK', 'name not found'); 
	
?>
Esempio n. 7
0
 function sanitizeFields()
 {
     $this->ownerKey = $this->ownerEntity->key();
     $this->authorKey = $this->authorEntity->key();
     $this->data['author'] = HubbubEntity::ds2arrayShort($this->authorEntity->ds);
     $this->data['owner'] = HubbubEntity::ds2arrayShort($this->ownerEntity->ds);
     $this->data['created'] = getDefault($this->data['created'], time());
     $this->data['changed'] = getDefault($this->data['changed'], $this->data['created']);
     $this->data['msgid'] = getDefault($this->data['msgid'], $this->newMsgId());
 }
Esempio n. 8
0
function dyn_type_foreign_post(&$data, &$ds, &$flags)
{
  /* are there any comments? */
  if($ds['m_created'] < time() - 60*30) return;
	$comments = MsgModel::getComments($ds['m_key']);
	/* define the standard actions for this post */
	$metaElements = array();//array(ageToString($ds['m_created']));
	/* insert entries from the cmd array in $flags (these come from plugins) */
	if(is_array($flags['cmd'])) foreach($flags['cmd'] as $cmd) $metaElements[] = $cmd;
	/* admin users get to see an "inspect" button */
  if(object('user')->isAdmin()) $metaElements[] = '<a target="_blank" href="'.actionUrl('inspect', 'test', array('id' => $ds['m_key'])).'">Inspect</a>';
  $metaElements[] = 'not published yet';
  $text = h2_post_excerpt($data['text'], $ds['m_key']);
  /* onward to the actual display of the message: */
  ?><div class="post disabled" id="post_<?php 
echo $ds['m_key'];
?>
">
  	  <div class="postimg"><img src="img/anonymous.png" width="64"/></div>
		  <div class="postcontent">
			  <div>
    			<? if($ds['m_author'] != $ds['m_owner']) print(HubbubEntity::linkFromId($ds['m_author']).' ► '); ?>
  			  <?php 
echo HubbubEntity::linkFromId($ds['m_owner']);
?>
			    <?php 
echo $text;
?>
			  </div>
			  <div class="postmeta"><?php 
echo implode(' · ', $metaElements);
?>
</div>
      </div>
			<div class="post_actions" id="post_<?php 
echo $ds['m_key'];
?>
_actions"></div>
      <div id="post_<?php 
echo $ds['m_key'];
?>
_temp" style="display:none"></div>
		</div><?
}