if(x($dfrn_url)) {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1",
- intval($_SESSION['uid']),
+ intval(get_uid()),
dbesc($dfrn_url)
);
$r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `name`, `photo`, `site-pubkey`,
`request`, `confirm`, `notify`, `poll`, `aes_allow`)
VALUES ( %d, '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', %d)",
- intval($_SESSION['uid']),
+ intval(get_uid()),
datetime_convert(),
dbesc($dfrn_url),
$parms['fn'],
// invalid/bogus request
- notice( t("Unrecoverable protocol error.") . EOL );
+ notice( t('Unrecoverable protocol error.') . EOL );
goaway($a->get_baseurl());
return; // NOTREACHED
}
// in $a->argv[1] and we should have their complete info in $a->profile.
if(! (is_array($a->profile) && count($a->profile))) {
- notice(t("Profile unavailable.") . EOL);
+ notice( t('Profile unavailable.') . EOL);
return;
}
return;
}
- // Is this an email-style DFRN locator?
+ // Canonicalise email-style profile locator
- if(strstr($url,'@')) {
- $username = substr($url,0,strpos($url,'@'));
- $hostname = substr($url,strpos($url,'@') + 1);
- require_once('Scrape.php');
-
-
- $parms = scrape_meta('https://' . $url);
- if((x($parms,'dfrn-template')) && strstr($parms['dfrn-template'],'%s')) {
- $url = sprintf($parms['dfrn-template'],$username);
- }
- else {
- $parms = scrape_meta('http://' . $url);
- if((x($parms,'dfrn-template')) && strstr($parms['dfrn-template'],'%s')) {
- $url = sprintf($parms['dfrn-template'],$username);
- }
- else {
- $url = '';
- }
- }
-
- }
+ $url = webfinger($url);
if(! strlen($url)) {
- notice(t("Unable to resolve your name at the provided location.") . EOL);
+ notice( t("Unable to resolve your name at the provided location.") . EOL);
return;
}
);
}
else {
-
+ if(! validate_url($url)) {
+ notice( t('Invalid profile URL.') . EOL);
+ goaway($a->get_baseurl() . '/' . $a->cmd);
+ return; // NOTREACHED
+ }
+
+ if(! allowed_url($url)) {
+ notice( t('Disallowed profile URL.') . EOL);
+ goaway($a->get_baseurl() . '/' . $a->cmd);
+ return; // NOTREACHED
+ }
+
+
require_once('Scrape.php');
$parms = scrape_dfrn($url);
if(! count($parms)) {
notice( t('Profile location is not valid or does not contain profile information.') . EOL );
- killme();
+ goaway($a->get_baseurl() . '/' . $a->cmd);
}
else {
if(! x($parms,'fn'))
// find the contact record we just created
if($r) {
$r = q("SELECT `id` FROM `contact`
- WHERE `uid` = '%s' AND `url` = '%s' AND `issued-id` = '%s' LIMIT 1",
+ WHERE `uid` = %d AND `url` = '%s' AND `issued-id` = '%s' LIMIT 1",
intval($uid),
$parms['url'],
$parms['issued-id']
}
if($r === false) {
- notice( 'Failed to update contact record.' . EOL );
+ notice( t('Failed to update contact record.') . EOL );
return;
}
intval($uid),
intval($contact_record['id']),
((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0),
- dbesc(trim($_POST['dfrn-request-message'])),
+ dbesc(notags(trim($_POST['dfrn-request-message']))),
dbesc($hash),
dbesc(datetime_convert())
);
// This notice will only be seen by the requestor if the requestor and requestee are on the same server.
if(! $failed)
- notice( t("Your introduction has been sent.") . EOL );
+ notice( t('Your introduction has been sent.') . EOL );
// "Homecoming" - send the requestor back to their site to record the introduction.
- $dfrn_url = bin2hex($a->get_baseurl() . "/profile/$nickname");
+ $dfrn_url = bin2hex($a->get_baseurl() . '/profile/' . $nickname);
$aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
goaway($parms['dfrn-request'] . "?dfrn_url=$dfrn_url" . '&confirm_key=' . $hash . (($aes_allow) ? "&aes_allow=1" : ""));
$dfrn_url = notags(trim(hex2bin($_GET['dfrn_url'])));
$aes_allow = (((x($_GET,'aes_allow')) && ($_GET['aes_allow'] == 1)) ? 1 : 0);
$confirm_key = (x($_GET,'confirm_key') ? $_GET['confirm_key'] : "");
- $o .= file_get_contents("view/dfrn_req_confirm.tpl");
+ $o .= load_view_file("view/dfrn_req_confirm.tpl");
$o = replace_macros($o,array(
'$dfrn_url' => $dfrn_url,
'$aes_allow' => (($aes_allow) ? '<input type="hidden" name="aes_allow" value="1" />' : "" ),
if(count($r)) {
if($r[0]['notify-flags'] & NOTIFY_INTRO) {
- $email_tpl = file_get_contents('view/request_notify_eml.tpl');
+ $email_tpl = load_view_file('view/request_notify_eml.tpl');
$email = replace_macros($email_tpl, array(
'$requestor' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')),
'$url' => stripslashes($r[0]['url']),
'$siteurl' => $a->get_baseurl(),
'$sitename' => $a->config['sitename']
));
- $res = mail($r[0]['email'],t("Introduction received at ") . $a->config['sitename'],$email,t('From: Administrator@') . $_SERVER[SERVER_NAME] );
+ $res = mail($r[0]['email'],
+ t("Introduction received at ") . $a->config['sitename'],
+ $email,
+ 'From: ' . t('Administrator') . '@' . $_SERVER[SERVER_NAME] );
// This is a redundant notification - no point throwing errors if it fails.
}
}
// Normal web request. Display our user's introduction form.
- $o = file_get_contents("view/dfrn_request.tpl");
+ $o = load_view_file("view/dfrn_request.tpl");
$o = replace_macros($o,array('$nickname' => $a->argv[1]));
return $o;
}