function send_mail($to, $template, $params = array()) { $srvEmail = cfg('service/email'); if (trim($srvEmail) == '') { $srvEmail = 'hubbub@' . $_SERVER['HTTP_HOST']; } $headers = array('Content-Type: text/plain; charset="utf-8"', 'From: ' . cfg('service/server') . ' Hubbub Server <' . $srvEmail . '>', 'Return-Path: ' . $srvEmail, 'Message-ID: <' . randomHashId() . '-hubbub@' . $_SERVER['HTTP_HOST'] . '>'); foreach ($params as $k => $v) { ${$k} = $v; } ob_start(); include 'templates/' . $template; $body = ob_get_clean(); ini_set('mail.add_x_header', false); return mail($to, $subject, $body, implode(chr(10), $headers), '-f ' . $srvEmail); }
/** * On-receive event handler * * Gets called when this server (A) receives a trust_sendkey1 message from another server (B). * Usually this means, server (B) wants to establish contact for the first time or it wants * to revoke its existing key. In both cases, the key can only be accepted when this server (A) * contacts server (B) to confirm the origin of the trust_sendkey1 message. * * @param array $data * @param object $msg * @return boolean */ function trust_sendkey1_receive(&$data, &$msg) { $data['mykey'] = trim($data['mykey']); $serverUrl = getDefault($data['author']['server']); if ($serverUrl == '') { $msg->fail('invalid server field in "author" array'); } if ($data['mykey'] == '') { $msg->fail('"mykey" field missing'); } else { // accept the new key (it's not confirmed yet) $server = new HubbubServer($serverUrl, true); $server->ds['s_newkey_out'] = $data['mykey']; $server->ds['s_key_in'] = getDefault($server->ds['s_key_in'], randomHashId()); DB_UpdateField('servers', $server->ds['s_key'], 's_key_in', $server->ds['s_key_in']); logError('notrace', 'received temp outbound key: ' . $data['mykey'] . ' /// ' . dumpArray($server->ds)); // now, get origin confirmation $confirmMsg = new HubbubMessage('trust_sendkey2'); $confirmMsg->author($server->localEntity()); $confirmMsg->owner($server->entity()); $confirmMsg->data['mykey'] = $server->ds['s_key_in']; $responseData = $confirmMsg->sendtourl($server->ds['s_url'], $server->ds['s_newkey_out']); if ($responseData['result'] == 'OK') { /* we need to reload, because the server record might have changed in the meantime */ $server = new HubbubServer($serverUrl, true); // okay, the remote server really sent the original message $server->ds['s_key_out'] = $server->ds['s_newkey_out']; $server->ds['s_status'] = 'OK'; DB_UpdateField('servers', $server->ds['s_key'], 's_key_out', $data['mykey']); $msg->ok(); } else { // this didn't work $server->ds['s_newkey_out'] = ''; $msg->fail('unsuccessful trust_sendkey2: ' . $responseData['reason']); } } return true; }
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] </IfModule> AddHandler php5-script .php'); $_SESSION['installer']['server_base'] = $_REQUEST['serverurl']; $_SESSION['installer']['admin_password'] = $_REQUEST['adminpw']; $_SESSION['installer']['remote_cron_svc'] = $_REQUEST['pingsvc']; $_SESSION['installer']['cfg']['service']['server'] = $_REQUEST['serverurl']; $_SESSION['installer']['cfg']['service']['adminpw'] = $_REQUEST['adminpw']; unset($_SESSION['installer']['cfg']['cron']); $_SESSION['installer']['cfg']['ping']['remote'] = $_REQUEST['pingsvc'] == 'Y'; $_SESSION['installer']['cfg']['ping']['password'] = getDefault($_SESSION['installer']['cfg']['ping']['password'], randomHashId()); $_SESSION['installer']['cfg']['ping']['server'] = getDefault($_SESSION['installer']['cfg']['ping']['server'], 'http://ping.openfu.net'); if($_REQUEST['pingsvc'] == 'Y') { newFile('conf/pingpassword', $_SESSION['installer']['cfg']['ping']['password']); $pingRequest = cqrequest($_SESSION['installer']['cfg']['ping']['server'], array('origin' => 'http://'.$_SESSION['installer']['server_base'].'/cron.php', 'request' => 'activate', 'password' => $_SESSION['installer']['cfg']['ping']['password']), 2); unlink('conf/pingpassword'); if($pingRequest['data']['result'] == 'OK') { $msg .= '<div class="green">✔ Joined remote ping service ('.$_SESSION['installer']['cfg']['ping']['server'].')</div>'; $pingStatus = $pingRequest['data']; $pingStatus['server'] = $pingServer; } else
if(!is_callable('json_encode')) $msg .= '<div class="red">✘ please install JSON support</div>'; $c = $_SESSION['installer']; switch($_REQUEST['part']) { case(0): { $msg .= '<div class="green">✔ Installing...</div>'; break; } case(1): { $cv = array(); include_once('lib/special-io.php'); $_SESSION['installer']['cfg']['service']['salt'] = randomHashId(); $myUserName = trim(shell_exec('whoami')); $myUserName = getDefault($myUserName, 'root'); $tmplFile = '<? $GLOBALS[$cfgCategory] = json_decode(\''.json_format(json_encode($_SESSION['installer']['cfg'])).'\', true); ?>'; $cfgFileName = 'conf/default.php'; if(!file_exists($cfgFileName)) { @chmod('conf', 0777); WriteToFile($cfgFileName, $tmplFile); $cfgWritable = trim(file_get_contents($cfgFileName)) == trim($tmplFile); if(!$_SESSION['installer']['cfg']['ping']['remote']) $cronInfo = l10n('cron.setup').' <pre>* * * * * '.$myUserName.' php -f '.$GLOBALS['APP.BASEDIR'].'/cron.php > /dev/null 2>&1</pre> <a href="ext/installer/cronhelp.php" target="_blank">> More information / help</a><br/>'; if($cfgWritable) $msg .= '<div class="green">✔ Config file written</div>
<? $params['ia_recovery'] = randomHashId(); DB_UpdateDataset('idaccounts', $params); $subject = 'Recover Your Hubbub Password'; ?>Dear Hubbub user, you (or someone using your email address) requested that your Hubbub password on server <?php echo cfg('service/server'); ?> be reset. Please click on the following link to change it: <?php echo actionUrl('reset', 'signin', array('i' => $params['ia_recovery']), true); ?> If you did not request a reset, simply ignore this message. The request was made from the following IP address: <?php echo $_SERVER['REMOTE_HOST']; ?>
function msg_trust_sendkey1() { // make a trust_sendkey1 message $msg = new HubbubMessage('trust_sendkey1'); $msg->to($this->entity()); $msg->data['author'] = $this->localEntity(); $this->save(); // make new key if there is none $this->ds['s_key_in'] = getDefault($this->ds['s_key_in'], randomHashId()); if ($this->ds['s_url'] != '') { DB_UpdateField('servers', $this->ds['s_key'], 's_key_in', $this->ds['s_key_in']); } $msg->data['mykey'] = $this->ds['s_key_in']; // we need to save at this point because the other server will try to make a trust_sendkey2-request in the meantime // send message to other server $responseData = $msg->sendToUrl($this->ds['s_url']); if ($responseData['result'] == 'OK') { $this->ds['s_status'] = 'OK'; $ret = result_ok(); } else { $this->ds['s_status'] = 'fail'; $this->ds['s_key_in'] = ''; logError('notrace', '[OUT] trust_sendkey1 failed, server ' . $this->ds['s_url'] . ' says: ' . getDefault($responseData['reason'], $responseData['result'])); $ret = result_fail('trust_sendkey1 failed: ' . getDefault($responseData['reason'], $responseData['result'])); } return $ret; }