xrd cannot be called before db is open to get language

This commit is contained in:
Mike Macgirvin 2010-10-04 04:22:34 -07:00
parent b8a9581acb
commit 941b2331f1
3 changed files with 24 additions and 30 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
$tpl = load_view_file('view/xrd_host.tpl'); $tpl = file_get_contents('view/xrd_host.tpl');
echo str_replace('$domain',$this->hostname,$tpl); echo str_replace('$domain',$this->hostname,$tpl);
session_write_close(); session_write_close();
exit(); exit();

View File

@ -718,7 +718,7 @@ function consume_feed($xml,$importer,$contact, &$hub) {
); );
// who is the last child now? // who is the last child now?
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d
ORDER BY `edited` DESC LIMIT 1", ORDER BY `created` DESC LIMIT 1",
dbesc($item['parent-uri']), dbesc($item['parent-uri']),
intval($importer['uid']) intval($importer['uid'])
); );

View File

@ -54,11 +54,25 @@ function dfrn_notify_post(&$a) {
if(! count($r)) { if(! count($r)) {
xml_status(3); xml_status(3);
return; //NOTREACHED //NOTREACHED
} }
$importer = $r[0]; $importer = $r[0];
if($importer['readonly']) {
// We aren't receiving stuff from this person. But we will quietly ignore them
// rather than a blatant "go away" message.
xml_status(0);
//NOTREACHED
}
// Consume notification feed. This may differ from consuming a public feed in several ways
// - might contain email
// - might contain remote followup to our message
// - in which case we need to accept it and then notify other conversants
// - we may need to send various email notifications
$feed = new SimplePie(); $feed = new SimplePie();
$feed->set_raw_data($data); $feed->set_raw_data($data);
$feed->enable_order_by_date(false); $feed->enable_order_by_date(false);
@ -69,13 +83,6 @@ function dfrn_notify_post(&$a) {
$rawmail = $feed->get_feed_tags( NAMESPACE_DFRN, 'mail' ); $rawmail = $feed->get_feed_tags( NAMESPACE_DFRN, 'mail' );
if(isset($rawmail[0]['child'][NAMESPACE_DFRN])) { if(isset($rawmail[0]['child'][NAMESPACE_DFRN])) {
if($importer['readonly']) {
// We aren't receiving email from this person. But we will quietly ignore them
// rather than a blatant "go away" message.
xml_status(0);
return; //NOTREACHED
}
$ismail = true; $ismail = true;
$base = $rawmail[0]['child'][NAMESPACE_DFRN]; $base = $rawmail[0]['child'][NAMESPACE_DFRN];
@ -118,15 +125,9 @@ function dfrn_notify_post(&$a) {
$email_tpl, 'From: ' . t('Administrator') . '@' . $a->get_hostname() ); $email_tpl, 'From: ' . t('Administrator') . '@' . $a->get_hostname() );
} }
xml_status(0); xml_status(0);
return; // NOTREACHED // NOTREACHED
} }
if($importer['readonly']) {
xml_status(0);
return; // NOTREACHED
}
foreach($feed->get_items() as $item) { foreach($feed->get_items() as $item) {
$deleted = false; $deleted = false;
@ -175,7 +176,7 @@ function dfrn_notify_post(&$a) {
); );
// who is the last child now? // who is the last child now?
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d
ORDER BY `edited` DESC LIMIT 1", ORDER BY `created` DESC LIMIT 1",
dbesc($item['parent-uri']), dbesc($item['parent-uri']),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -198,7 +199,6 @@ function dfrn_notify_post(&$a) {
$parent_uri = $rawthread[0]['attribs']['']['ref']; $parent_uri = $rawthread[0]['attribs']['']['ref'];
} }
if($is_reply) { if($is_reply) {
if($feed->get_item_quantity() == 1) { if($feed->get_item_quantity() == 1) {
// remote reply to our post. Import and then notify everybody else. // remote reply to our post. Import and then notify everybody else.
@ -259,7 +259,7 @@ function dfrn_notify_post(&$a) {
} }
} }
xml_status(0); xml_status(0);
return; // NOTREACHED
} }
else { else {
@ -357,13 +357,11 @@ function dfrn_notify_post(&$a) {
$datarray['contact-id'] = $importer['id']; $datarray['contact-id'] = $importer['id'];
$r = item_store($datarray); $r = item_store($datarray);
continue; continue;
} }
} }
xml_status(0); xml_status(0);
killme(); // NOTREACHED
} }
@ -416,8 +414,6 @@ function dfrn_notify_content(&$a) {
break; // NOTREACHED break; // NOTREACHED
} }
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1"); $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1");
if(! count($r)) if(! count($r))
@ -439,10 +435,8 @@ function dfrn_notify_content(&$a) {
$challenge = bin2hex($challenge); $challenge = bin2hex($challenge);
$encrypted_id = bin2hex($encrypted_id); $encrypted_id = bin2hex($encrypted_id);
echo '<?xml version="1.0" encoding="UTF-8"?><dfrn_notify><status>' .$status . '</status><dfrn_version>2.0</dfrn_version><dfrn_id>' . $encrypted_id . '</dfrn_id>' . '<challenge>' . $challenge . '</challenge></dfrn_notify>' . "\r\n" ; echo '<?xml version="1.0" encoding="UTF-8"?><dfrn_notify><status>' . $status . '</status><dfrn_version>2.0</dfrn_version><dfrn_id>' . $encrypted_id . '</dfrn_id><challenge>' . $challenge . '</challenge></dfrn_notify>' . "\r\n" ;
session_write_close(); killme();
exit;
} }
} }