示例#1
0
function diaspora_dispatch($importer, $msg)
{
    $ret = 0;
    if (!array_key_exists('system', $importer)) {
        $importer['system'] = false;
    }
    $enabled = intval(get_config('system', 'diaspora_enabled'));
    if (!$enabled) {
        logger('mod-diaspora: disabled');
        return;
    }
    $allowed = get_pconfig($importer['channel_id'], 'system', 'diaspora_allowed');
    if ($allowed === false) {
        $allowed = 1;
    }
    if (!intval($allowed)) {
        logger('mod-diaspora: disallowed for channel ' . $importer['channel_name']);
        return;
    }
    // php doesn't like dashes in variable names
    $msg['message'] = str_replace(array('<activity_streams-photo>', '</activity_streams-photo>'), array('<asphoto>', '</asphoto>'), $msg['message']);
    $parsed_xml = parse_xml_string($msg['message'], false);
    $xmlbase = $parsed_xml->post;
    //	logger('diaspora_dispatch: ' . print_r($xmlbase,true), LOGGER_DATA);
    if ($xmlbase->request) {
        $ret = diaspora_request($importer, $xmlbase->request);
    } elseif ($xmlbase->status_message) {
        $ret = diaspora_post($importer, $xmlbase->status_message, $msg);
    } elseif ($xmlbase->profile) {
        $ret = diaspora_profile($importer, $xmlbase->profile, $msg);
    } elseif ($xmlbase->comment) {
        $ret = diaspora_comment($importer, $xmlbase->comment, $msg);
    } elseif ($xmlbase->like) {
        $ret = diaspora_like($importer, $xmlbase->like, $msg);
    } elseif ($xmlbase->asphoto) {
        $ret = diaspora_asphoto($importer, $xmlbase->asphoto, $msg);
    } elseif ($xmlbase->reshare) {
        $ret = diaspora_reshare($importer, $xmlbase->reshare, $msg);
    } elseif ($xmlbase->retraction) {
        $ret = diaspora_retraction($importer, $xmlbase->retraction, $msg);
    } elseif ($xmlbase->signed_retraction) {
        $ret = diaspora_signed_retraction($importer, $xmlbase->signed_retraction, $msg);
    } elseif ($xmlbase->relayable_retraction) {
        $ret = diaspora_signed_retraction($importer, $xmlbase->relayable_retraction, $msg);
    } elseif ($xmlbase->photo) {
        $ret = diaspora_photo($importer, $xmlbase->photo, $msg);
    } elseif ($xmlbase->conversation) {
        $ret = diaspora_conversation($importer, $xmlbase->conversation, $msg);
    } elseif ($xmlbase->message) {
        $ret = diaspora_message($importer, $xmlbase->message, $msg);
    } else {
        logger('diaspora_dispatch: unknown message type: ' . print_r($xmlbase, true));
    }
    return $ret;
}
示例#2
0
function diaspora_dispatch($importer, $msg, $attempt = 1)
{
    $ret = 0;
    $enabled = intval(get_config('system', 'diaspora_enabled'));
    if (!$enabled) {
        logger('mod-diaspora: disabled');
        return;
    }
    // php doesn't like dashes in variable names
    $msg['message'] = str_replace(array('<activity_streams-photo>', '</activity_streams-photo>'), array('<asphoto>', '</asphoto>'), $msg['message']);
    $parsed_xml = parse_xml_string($msg['message'], false);
    $xmlbase = $parsed_xml->post;
    logger('diaspora_dispatch: ' . print_r($xmlbase, true), LOGGER_DEBUG);
    if ($xmlbase->request) {
        $ret = diaspora_request($importer, $xmlbase->request);
    } elseif ($xmlbase->status_message) {
        $ret = diaspora_post($importer, $xmlbase->status_message, $msg);
    } elseif ($xmlbase->profile) {
        $ret = diaspora_profile($importer, $xmlbase->profile, $msg);
    } elseif ($xmlbase->comment) {
        $ret = diaspora_comment($importer, $xmlbase->comment, $msg);
    } elseif ($xmlbase->like) {
        $ret = diaspora_like($importer, $xmlbase->like, $msg);
    } elseif ($xmlbase->asphoto) {
        $ret = diaspora_asphoto($importer, $xmlbase->asphoto, $msg);
    } elseif ($xmlbase->reshare) {
        $ret = diaspora_reshare($importer, $xmlbase->reshare, $msg);
    } elseif ($xmlbase->retraction) {
        $ret = diaspora_retraction($importer, $xmlbase->retraction, $msg);
    } elseif ($xmlbase->signed_retraction) {
        $ret = diaspora_signed_retraction($importer, $xmlbase->signed_retraction, $msg);
    } elseif ($xmlbase->relayable_retraction) {
        $ret = diaspora_signed_retraction($importer, $xmlbase->relayable_retraction, $msg);
    } elseif ($xmlbase->photo) {
        $ret = diaspora_photo($importer, $xmlbase->photo, $msg, $attempt);
    } elseif ($xmlbase->conversation) {
        $ret = diaspora_conversation($importer, $xmlbase->conversation, $msg);
    } elseif ($xmlbase->message) {
        $ret = diaspora_message($importer, $xmlbase->message, $msg);
    } elseif ($xmlbase->participation) {
        $ret = diaspora_participation($importer, $xmlbase->participation);
    } else {
        logger('diaspora_dispatch: unknown message type: ' . print_r($xmlbase, true));
    }
    return $ret;
}
示例#3
0
function diaspora_dispatch($importer, $msg)
{
    $ret = 0;
    if (!array_key_exists('system', $importer)) {
        $importer['system'] = false;
    }
    $host = substr($msg['author'], strpos($msg['author'], '@') + 1);
    $ssl = array_key_exists('HTTPS', $_SERVER) && strtolower($_SERVER['HTTPS']) === 'on' ? true : false;
    $url = ($ssl ? 'https://' : 'http://') . $host;
    q("update site set site_dead = 0, site_update = '%s' where site_type = %d and site_url = '%s'", dbesc(datetime_convert()), intval(SITE_TYPE_NOTZOT), dbesc($url));
    $allowed = get_pconfig($importer['channel_id'], 'system', 'diaspora_allowed');
    if (!intval($allowed)) {
        logger('mod-diaspora: disallowed for channel ' . $importer['channel_name']);
        return;
    }
    // php doesn't like dashes in variable names
    // I doubt we need this any more. The Cubbi.es activity stream photo thing died in 2011
    $msg['message'] = str_replace(array('<activity_streams-photo>', '</activity_streams-photo>'), array('<asphoto>', '</asphoto>'), $msg['message']);
    //	$parsed_xml = parse_xml_string($msg['message'],false);
    $parsed_xml = xml2array($msg['message'], false, 0, 'tag');
    if ($parsed_xml) {
        if (array_key_exists('xml', $parsed_xml) && array_key_exists('post', $parsed_xml['xml'])) {
            $xmlbase = $parsed_xml['xml']['post'];
        } else {
            $xmlbase = $parsed_xml;
        }
    }
    //	logger('diaspora_dispatch: ' . print_r($xmlbase,true), LOGGER_DATA);
    if ($xmlbase['request']) {
        $ret = diaspora_request($importer, $xmlbase['request']);
    }
    if ($xmlbase['contact']) {
        $ret = diaspora_request($importer, $xmlbase['contact']);
    } elseif ($xmlbase['status_message']) {
        $ret = diaspora_post($importer, $xmlbase['status_message'], $msg);
    } elseif ($xmlbase['profile']) {
        $ret = diaspora_profile($importer, $xmlbase['profile'], $msg);
    } elseif ($xmlbase['comment']) {
        $ret = diaspora_comment($importer, $xmlbase['comment'], $msg);
    } elseif ($xmlbase['like']) {
        $ret = diaspora_like($importer, $xmlbase['like'], $msg);
    } elseif ($xmlbase['asphoto']) {
        $ret = diaspora_asphoto($importer, $xmlbase['asphoto'], $msg);
    } elseif ($xmlbase['reshare']) {
        $ret = diaspora_reshare($importer, $xmlbase['reshare'], $msg);
    } elseif ($xmlbase['retraction']) {
        $ret = diaspora_retraction($importer, $xmlbase['retraction'], $msg);
    } elseif ($xmlbase['signed_retraction']) {
        $ret = diaspora_retraction($importer, $xmlbase['signed_retraction'], $msg);
    } elseif ($xmlbase['relayable_retraction']) {
        $ret = diaspora_retraction($importer, $xmlbase['relayable_retraction'], $msg);
    } elseif ($xmlbase['photo']) {
        $ret = diaspora_photo($importer, $xmlbase['photo'], $msg);
    } elseif ($xmlbase['conversation']) {
        $ret = diaspora_conversation($importer, $xmlbase['conversation'], $msg);
    } elseif ($xmlbase['message']) {
        $ret = diaspora_message($importer, $xmlbase['message'], $msg);
    } elseif ($xmlbase['participation']) {
        $ret = diaspora_participation($importer, $xmlbase['participation'], $msg);
    } elseif ($xmlbase['account_deletion']) {
        $ret = diaspora_account_deletion($importer, $xmlbase['account_deletion'], $msg);
    } elseif ($xmlbase['poll_participation']) {
        $ret = diaspora_poll_participation($importer, $xmlbase['poll_participation'], $msg);
    } else {
        logger('diaspora_dispatch: unknown message type: ' . print_r($xmlbase, true));
    }
    return $ret;
}
示例#4
0
function diaspora_dispatch($importer, $msg)
{
    $ret = 0;
    if (!array_key_exists('system', $importer)) {
        $importer['system'] = false;
    }
    $host = substr($msg['author'], strpos($msg['author'], '@') + 1);
    $ssl = array_key_exists('HTTPS', $_SERVER) && strtolower($_SERVER['HTTPS']) === 'on' ? true : false;
    $url = ($ssl ? 'https://' : 'http://') . $host;
    q("update site set site_dead = 0, site_update = '%s' where site_type = %d and site_url = '%s'", dbesc(datetime_convert()), intval(SITE_TYPE_NOTZOT), dbesc($url));
    $allowed = get_pconfig($importer['channel_id'], 'system', 'diaspora_allowed');
    if (!intval($allowed)) {
        logger('mod-diaspora: disallowed for channel ' . $importer['channel_name']);
        return;
    }
    // php doesn't like dashes in variable names
    $msg['message'] = str_replace(array('<activity_streams-photo>', '</activity_streams-photo>'), array('<asphoto>', '</asphoto>'), $msg['message']);
    $parsed_xml = parse_xml_string($msg['message'], false);
    $xmlbase = $parsed_xml->post;
    //	logger('diaspora_dispatch: ' . print_r($xmlbase,true), LOGGER_DATA);
    if ($xmlbase->request) {
        $ret = diaspora_request($importer, $xmlbase->request);
    } elseif ($xmlbase->status_message) {
        $ret = diaspora_post($importer, $xmlbase->status_message, $msg);
    } elseif ($xmlbase->profile) {
        $ret = diaspora_profile($importer, $xmlbase->profile, $msg);
    } elseif ($xmlbase->comment) {
        $ret = diaspora_comment($importer, $xmlbase->comment, $msg);
    } elseif ($xmlbase->like) {
        $ret = diaspora_like($importer, $xmlbase->like, $msg);
    } elseif ($xmlbase->asphoto) {
        $ret = diaspora_asphoto($importer, $xmlbase->asphoto, $msg);
    } elseif ($xmlbase->reshare) {
        $ret = diaspora_reshare($importer, $xmlbase->reshare, $msg);
    } elseif ($xmlbase->retraction) {
        $ret = diaspora_retraction($importer, $xmlbase->retraction, $msg);
    } elseif ($xmlbase->signed_retraction) {
        $ret = diaspora_signed_retraction($importer, $xmlbase->signed_retraction, $msg);
    } elseif ($xmlbase->relayable_retraction) {
        $ret = diaspora_signed_retraction($importer, $xmlbase->relayable_retraction, $msg);
    } elseif ($xmlbase->photo) {
        $ret = diaspora_photo($importer, $xmlbase->photo, $msg);
    } elseif ($xmlbase->conversation) {
        $ret = diaspora_conversation($importer, $xmlbase->conversation, $msg);
    } elseif ($xmlbase->message) {
        $ret = diaspora_message($importer, $xmlbase->message, $msg);
    } else {
        logger('diaspora_dispatch: unknown message type: ' . print_r($xmlbase, true));
    }
    return $ret;
}