function abconfirm() { // the global address book connects here to find out if this // server really sent a request modifying ab AB entry $result = array(); $entityUrl = $_REQUEST['entity_url']; $checksum = $_REQUEST['checksum']; $thisEntity = new HubbubEntity(array('url' => $entityUrl)); if(sizeof($thisEntity->ds) == 0) { $result['error'] = 'invalid entity'; } else { $nvIdentifier = 'abreq/'.$thisEntity->ds['_key']; $reqInfo = h2_nv_retrieve($nvIdentifier, 'sys'); if($reqInfo['checksum'] != $checksum) { $result['error'] = 'invalid checksum'; } else { // remove the "pending" entry from the NV store h2_nv_store($nvIdentifier, null, 'sys'); // confirm to the address book that we did indeed make this request $result['result'] = 'OK'; } } print(json_encode($result)); }
function RemoteRegister($res, $entityDS, $active = 'yes') { $abData = h2_nv_retrieve('abdata'); $abData['active'] = $active; $abData['receipt'] = $res['receipt']; $abData['updated'] = time(); $abData['entry'] = $entityDS; h2_nv_store('abdata', $abData); }
function ABNewEntry($entityDS, $commentText) { $entityDS['comment'] = $commentText; $entityDS['email'] = md5($this->user->ds['u_email']); $entityInfo = json_encode($entityDS); // this is important: we need to prepare the endpoint API to give out // the confirmation before we send the request to the AB, because the AB // may hold the request until it's completed ITS confirmation request // back to us! h2_nv_store('abreq/'.$entityDS['_key'], array( 'abrequest' => 'pending', 'checksum' => md5($entityInfo))); // now, make the request to add our info to the AB $result = cqrequest('http://hubbub.at/ab', array( 'mode' => 'new', 'entity' => $entityInfo, 'callback' => actionUrl('abconfirm', 'endpoint', array(), true))); return($result['data']); }
$btype = 'fail'; $lastPingText = 'Waiting for ping from '.$pingServer.'...'; } if(cfg('ping/remote') && cfg('ping/server') != '') { $pingStatus = h2_nv_retrieve('ping/status'); if($pingStatus['server'] != $pingServer) { $pingRequest = cqrequest($pingServer, array('origin' => 'http://'.cfg('service/server').'/cron.php', 'request' => 'activate', 'password' => cfg('ping/password')), 2); if($pingRequest['data']['result'] == 'OK') { $btype = 'win'; $lastPingText = 'Connection with ping server established, waiting for ping from '.$pingServer.'...'; $pingStatus = $pingRequest['data']; $pingStatus['server'] = $pingServer; h2_nv_store('ping/status', $pingStatus); @unlink('log/cron.last.log'); } else { $btype = 'fail'; $reason = $pingRequest['data']['reason']; $lastPingText = 'Could not establish connection with ping server. Reason: '.getDefault($reason, 'server not found'); } } } ?><div class="banner <?php echo $btype; ?> "> <?php