当前位置: 首页>>代码示例>>PHP>>正文


PHP http_status_exit函数代码示例

本文整理汇总了PHP中http_status_exit函数的典型用法代码示例。如果您正苦于以下问题:PHP http_status_exit函数的具体用法?PHP http_status_exit怎么用?PHP http_status_exit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了http_status_exit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post_post

function post_post(&$a)
{
    $bulk_delivery = false;
    if ($a->argc == 1) {
        $bulk_delivery = true;
    } else {
        $nickname = $a->argv[2];
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' \n\t\t\t\tAND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($nickname));
        if (!count($r)) {
            http_status_exit(500);
        }
        $importer = $r[0];
    }
    $xml = file_get_contents('php://input');
    logger('mod-post: new zot: ' . $xml, LOGGER_DATA);
    if (!$xml) {
        http_status_exit(500);
    }
    $msg = zot_decode($importer, $xml);
    logger('mod-post: decoded msg: ' . print_r($msg, true), LOGGER_DATA);
    if (!is_array($msg)) {
        http_status_exit(500);
    }
    $ret = 0;
    $ret = zot_incoming($bulk_delivery, $importer, $msg);
    http_status_exit($ret ? $ret : 200);
    // NOTREACHED
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:28,代码来源:post.php

示例2: _well_known_init

function _well_known_init(&$a)
{
    if (argc() > 1) {
        $arr = array('server' => $_SERVER, 'request' => $_REQUEST);
        call_hooks('well_known', $arr);
        switch (argv(1)) {
            case 'zot-info':
                $a->argc -= 1;
                array_shift($a->argv);
                $a->argv[0] = 'zfinger';
                require_once 'mod/zfinger.php';
                zfinger_init($a);
                break;
            case 'webfinger':
                $a->argc -= 1;
                array_shift($a->argv);
                $a->argv[0] = 'wfinger';
                require_once 'mod/wfinger.php';
                wfinger_init($a);
                break;
            case 'host-meta':
                $a->argc -= 1;
                array_shift($a->argv);
                $a->argv[0] = 'hostxrd';
                require_once 'mod/hostxrd.php';
                hostxrd_init($a);
                break;
            default:
                break;
        }
    }
    http_status_exit(404);
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:33,代码来源:_well_known.php

示例3: init

 function init()
 {
     if (argc() != 3 || !in_array(argv(1), ['post', 'status_message', 'reshare'])) {
         http_status_exit(404, 'Not found');
     }
     $guid = argv(2);
     // Fetch the item
     $item = q("SELECT * from item where mid = '%s' and item_private = 0 and mid = parent_mid limit 1", dbesc($guid));
     if (!$item) {
         http_status_exit(404, 'Not found');
     }
     xchan_query($item);
     $item = fetch_post_tags($item, true);
     $channel = channelx_by_hash($item[0]['author_xchan']);
     if (!$channel) {
         $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($item[0]['author_xchan']));
         if ($r) {
             $url = $r[0]['xchan_url'];
             if (strpos($url, z_root()) === false) {
                 $m = parse_url($url);
                 goaway($m['scheme'] . '://' . $m['host'] . ($m['port'] ? ':' . $m['port'] : '') . '/fetch/' . argv(1) . '/' . argv(2));
             }
         }
         http_status_exit(404, 'Not found');
     }
     $status = diaspora_build_status($item[0], $channel);
     header("Content-type: application/magic-envelope+xml; charset=utf-8");
     echo diaspora_magic_env($channel, $status);
     killme();
 }
开发者ID:phellmes,项目名称:hubzilla-addons,代码行数:30,代码来源:Mod_Fetch.php

示例4: p_init

function p_init(&$a)
{
    if (argc() < 2) {
        http_status_exit(401);
    }
    $mid = str_replace('.xml', '', argv(1));
    $r = q("select * from item where mid = '%s' and item_wall = 1 and item_private = 0 limit 1", dbesc($mid));
    if (!$r || !perm_is_allowed($r[0]['uid'], '', 'view_stream')) {
        http_status_exit(404);
    }
    $c = q("select * from channel where channel_id = %d limit 1", intval($r[0]['uid']));
    if (!$c) {
        http_status_exit(404);
    }
    $myaddr = $c[0]['channel_address'] . '@' . App::get_hostname();
    $item = $r[0];
    $title = $item['title'];
    $body = bb2diaspora_itembody($item);
    $created = datetime_convert('UTC', 'UTC', $item['created'], 'Y-m-d H:i:s \\U\\T\\C');
    $tpl = get_markup_template('diaspora_post.tpl', 'addon/diaspora');
    $msg = replace_macros($tpl, array('$body' => xmlify($body), '$guid' => $item['mid'], '$handle' => xmlify($myaddr), '$public' => 'true', '$created' => $created, '$provider' => $item['app'] ? $item['app'] : t('$projectname')));
    header('Content-type: text/xml');
    echo $msg;
    killme();
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:25,代码来源:p.php

示例5: _well_known_init

function _well_known_init(&$a)
{
    if (argc() > 1) {
        $arr = array('server' => $_SERVER, 'request' => $_REQUEST);
        call_hooks('well_known', $arr);
        if (!check_siteallowed($_SERVER['REMOTE_ADDR'])) {
            logger('well_known: site not allowed. ' . $_SERVER['REMOTE_ADDR']);
            killme();
        }
        // from php.net re: REMOTE_HOST:
        //     Note: Your web server must be configured to create this variable. For example in Apache
        // you'll need HostnameLookups On inside httpd.conf for it to exist. See also gethostbyaddr().
        if (get_config('system', 'siteallowed_remote_host') && !check_siteallowed($_SERVER['REMOTE_HOST'])) {
            logger('well_known: site not allowed. ' . $_SERVER['REMOTE_HOST']);
            killme();
        }
        switch (argv(1)) {
            case 'zot-info':
                $a->argc -= 1;
                array_shift($a->argv);
                $a->argv[0] = 'zfinger';
                require_once 'mod/zfinger.php';
                zfinger_init($a);
                break;
            case 'webfinger':
                $a->argc -= 1;
                array_shift($a->argv);
                $a->argv[0] = 'wfinger';
                require_once 'mod/wfinger.php';
                wfinger_init($a);
                break;
            case 'host-meta':
                $a->argc -= 1;
                array_shift($a->argv);
                $a->argv[0] = 'hostxrd';
                require_once 'mod/hostxrd.php';
                hostxrd_init($a);
                break;
            default:
                // look in $WEBROOT/well_known for the requested file in case it is
                // something a site requires and for which we do not have a module
                // @fixme - we may need to determine the content-type and stick it in the header
                // for now this can be done with a php script masquerading as the requested file
                $wk_file = str_replace('.well-known', 'well_known', $a->cmd);
                if (file_exists($wk_file)) {
                    echo file_get_contents($wk_file);
                    killme();
                } elseif (file_exists($wk_file . '.php')) {
                    require_once $wk_file . '.php';
                }
                break;
        }
    }
    http_status_exit(404);
}
开发者ID:Gillesq,项目名称:hubzilla,代码行数:55,代码来源:_well_known.php

示例6: _well_known_init

function _well_known_init(&$a)
{
    if ($a->argc > 1) {
        switch ($a->argv[1]) {
            case "host-meta":
                hostxrd_init($a);
                break;
        }
    }
    http_status_exit(404);
    killme();
}
开发者ID:jzacman,项目名称:friendica,代码行数:12,代码来源:_well_known.php

示例7: _well_known_init

function _well_known_init(&$a)
{
    if (argc() > 1) {
        $arr = array('server' => $_SERVER, 'request' => $_REQUEST);
        call_hooks('well_known', $arr);
        if (!check_siteallowed($_SERVER['REMOTE_ADDR'])) {
            logger('well_known: site not allowed. ' . $_SERVER['REMOTE_ADDR']);
            killme();
        }
        // from php.net re: REMOTE_HOST:
        //     Note: Your web server must be configured to create this variable. For example in Apache
        // you'll need HostnameLookups On inside httpd.conf for it to exist. See also gethostbyaddr().
        if (get_config('system', 'siteallowed_remote_host') && !check_siteallowed($_SERVER['REMOTE_HOST'])) {
            logger('well_known: site not allowed. ' . $_SERVER['REMOTE_HOST']);
            killme();
        }
        switch (argv(1)) {
            case 'zot-info':
                $a->argc -= 1;
                array_shift($a->argv);
                $a->argv[0] = 'zfinger';
                require_once 'mod/zfinger.php';
                zfinger_init($a);
                break;
            case 'webfinger':
                $a->argc -= 1;
                array_shift($a->argv);
                $a->argv[0] = 'wfinger';
                require_once 'mod/wfinger.php';
                wfinger_init($a);
                break;
            case 'host-meta':
                $a->argc -= 1;
                array_shift($a->argv);
                $a->argv[0] = 'hostxrd';
                require_once 'mod/hostxrd.php';
                hostxrd_init($a);
                break;
            default:
                if (file_exists($a->cmd)) {
                    echo file_get_contents($a->cmd);
                    killme();
                } elseif (file_exists($a->cmd . '.php')) {
                    require_once $a->cmd . '.php';
                }
                break;
        }
    }
    http_status_exit(404);
}
开发者ID:royalterra,项目名称:hubzilla,代码行数:50,代码来源:_well_known.php

示例8: init

 function init()
 {
     logger('oep: ' . print_r($_REQUEST, true), LOGGER_DEBUG, LOG_INFO);
     $html = argc() > 1 && argv(1) === 'html' ? true : false;
     if ($_REQUEST['url']) {
         $_REQUEST['url'] = strip_zids($_REQUEST['url']);
         $url = $_REQUEST['url'];
     }
     if (!$url) {
         http_status_exit(404, 'Not found');
     }
     $maxwidth = $_REQUEST['maxwidth'];
     $maxheight = $_REQUEST['maxheight'];
     $format = $_REQUEST['format'];
     if ($format && $format !== 'json') {
         http_status_exit(501, 'Not implemented');
     }
     if (fnmatch('*/photos/*/album/*', $url)) {
         $arr = $this->oep_album_reply($_REQUEST);
     } elseif (fnmatch('*/photos/*/image/*', $url)) {
         $arr = $this->oep_photo_reply($_REQUEST);
     } elseif (fnmatch('*/photos*', $url)) {
         $arr = $this->oep_phototop_reply($_REQUEST);
     } elseif (fnmatch('*/display/*', $url)) {
         $arr = $this->oep_display_reply($_REQUEST);
     } elseif (fnmatch('*/channel/*mid=*', $url)) {
         $arr = $this->oep_mid_reply($_REQUEST);
     } elseif (fnmatch('*/channel*', $url)) {
         $arr = $this->oep_profile_reply($_REQUEST);
     } elseif (fnmatch('*/profile/*', $url)) {
         $arr = $this->oep_profile_reply($_REQUEST);
     }
     if ($arr) {
         if ($html) {
             if ($arr['type'] === 'rich') {
                 header('Content-Type: text/html');
                 echo $arr['html'];
             }
         } else {
             header('Content-Type: application/json+oembed');
             echo json_encode($arr);
         }
         killme();
     }
     http_status_exit(404, 'Not found');
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:46,代码来源:Oep.php

示例9: receive_post

function receive_post(&$a)
{
    $public = false;
    logger('diaspora_receive: ' . print_r($a->argv, true), LOGGER_DEBUG);
    if (argc() == 2 && argv(1) === 'public') {
        $public = true;
    } else {
        if (argc() != 3 || argv(1) !== 'users') {
            http_status_exit(500);
        }
        $guid = argv(2);
        $hn = str_replace('.', '', $a->get_hostname());
        if (($x = strpos($guid, $hn)) > 0) {
            $guid = substr($guid, 0, $x);
        }
        // Diaspora sites *may* provide a truncated guid.
        $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_guid like '%s' AND channel_removed = 0 LIMIT 1", dbesc($guid . '%'));
        if (!$r) {
            http_status_exit(500);
        }
        $importer = $r[0];
    }
    // It is an application/x-www-form-urlencoded that has been urlencoded twice.
    logger('mod-diaspora: receiving post', LOGGER_DEBUG);
    $xml = urldecode($_POST['xml']);
    logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
    if (!$xml) {
        http_status_exit(500);
    }
    logger('mod-diaspora: message is okay', LOGGER_DEBUG);
    $msg = diaspora_decode($importer, $xml);
    logger('mod-diaspora: decoded', LOGGER_DEBUG);
    logger('mod-diaspora: decoded msg: ' . print_r($msg, true), LOGGER_DATA);
    if (!is_array($msg)) {
        http_status_exit(500);
    }
    logger('mod-diaspora: dispatching', LOGGER_DEBUG);
    $ret = 0;
    if ($public) {
        diaspora_dispatch_public($msg);
    } else {
        $ret = diaspora_dispatch($importer, $msg);
    }
    http_status_exit($ret ? $ret : 200);
    // NOTREACHED
}
开发者ID:git-marijus,项目名称:hubzilla-addons,代码行数:46,代码来源:receive.php

示例10: receive_post

function receive_post(&$a)
{
    $enabled = intval(get_config('system', 'diaspora_enabled'));
    if (!$enabled) {
        logger('mod-diaspora: disabled');
        http_status_exit(500);
    }
    $public = false;
    if (argc() == 2 && argv(1) === 'public') {
        $public = true;
    } else {
        if (argc() != 3 || argv(1) !== 'users') {
            http_status_exit(500);
        }
        $guid = argv(2);
        // Diaspora sites *may* provide a truncated guid.
        $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_guid like '%s' AND NOT (channel_pageflags & %d )>0 LIMIT 1", dbesc($guid . '%'), intval(PAGE_REMOVED));
        if (!$r) {
            http_status_exit(500);
        }
        $importer = $r[0];
    }
    // It is an application/x-www-form-urlencoded that has been urlencoded twice.
    logger('mod-diaspora: receiving post', LOGGER_DEBUG);
    $xml = urldecode($_POST['xml']);
    logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
    if (!$xml) {
        http_status_exit(500);
    }
    logger('mod-diaspora: message is okay', LOGGER_DEBUG);
    $msg = diaspora_decode($importer, $xml);
    logger('mod-diaspora: decoded', LOGGER_DEBUG);
    logger('mod-diaspora: decoded msg: ' . print_r($msg, true), LOGGER_DATA);
    if (!is_array($msg)) {
        http_status_exit(500);
    }
    logger('mod-diaspora: dispatching', LOGGER_DEBUG);
    $ret = 0;
    if ($public) {
        diaspora_dispatch_public($msg);
    } else {
        $ret = diaspora_dispatch($importer, $msg);
    }
    http_status_exit($ret ? $ret : 200);
    // NOTREACHED
}
开发者ID:redmatrix,项目名称:red,代码行数:46,代码来源:receive.php

示例11: receive_post

function receive_post(&$a)
{
    $enabled = intval(get_config('system', 'diaspora_enabled'));
    if (!$enabled) {
        logger('mod-diaspora: disabled');
        http_status_exit(500);
    }
    $public = false;
    if ($a->argc == 2 && $a->argv[1] === 'public') {
        $public = true;
    } else {
        if ($a->argc != 3 || $a->argv[1] !== 'users') {
            http_status_exit(500);
        }
        $guid = $a->argv[2];
        $r = q("SELECT * FROM `user` WHERE `guid` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($guid));
        if (!count($r)) {
            http_status_exit(500);
        }
        $importer = $r[0];
    }
    // It is an application/x-www-form-urlencoded
    logger('mod-diaspora: receiving post', LOGGER_DEBUG);
    $xml = urldecode($_POST['xml']);
    logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
    if (!$xml) {
        http_status_exit(500);
    }
    logger('mod-diaspora: message is okay', LOGGER_DEBUG);
    $msg = diaspora_decode($importer, $xml);
    logger('mod-diaspora: decoded', LOGGER_DEBUG);
    logger('mod-diaspora: decoded msg: ' . print_r($msg, true), LOGGER_DATA);
    if (!is_array($msg)) {
        http_status_exit(500);
    }
    logger('mod-diaspora: dispatching', LOGGER_DEBUG);
    $ret = 0;
    if ($public) {
        diaspora_dispatch_public($msg);
    } else {
        $ret = diaspora_dispatch($importer, $msg);
    }
    http_status_exit($ret ? $ret : 200);
    // NOTREACHED
}
开发者ID:jzacman,项目名称:friendica,代码行数:45,代码来源:receive.php

示例12: _well_known_init

function _well_known_init(&$a)
{
    if ($a->argc > 1) {
        switch ($a->argv[1]) {
            case "host-meta":
                hostxrd_init($a);
                break;
            case "x-social-relay":
                wk_social_relay($a);
                break;
            case "nodeinfo":
                nodeinfo_wellknown($a);
                break;
        }
    }
    http_status_exit(404);
    killme();
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:18,代码来源:_well_known.php

示例13: statistics_json_init

function statistics_json_init(&$a)
{
    if (!get_config("system", "nodeinfo")) {
        http_status_exit(404);
        killme();
    }
    $statistics = array("name" => $a->config["sitename"], "network" => FRIENDICA_PLATFORM, "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION, "registrations_open" => $a->config['register_policy'] != 0, "total_users" => get_config('nodeinfo', 'total_users'), "active_users_halfyear" => get_config('nodeinfo', 'active_users_halfyear'), "active_users_monthly" => get_config('nodeinfo', 'active_users_monthly'), "local_posts" => get_config('nodeinfo', 'local_posts'));
    $statistics["services"] = array();
    $statistics["services"]["appnet"] = plugin_enabled("appnet");
    $statistics["services"]["blogger"] = plugin_enabled("blogger");
    $statistics["services"]["buffer"] = plugin_enabled("buffer");
    $statistics["services"]["dreamwidth"] = plugin_enabled("dwpost");
    $statistics["services"]["facebook"] = plugin_enabled("fbpost");
    $statistics["services"]["gnusocial"] = plugin_enabled("statusnet");
    $statistics["services"]["googleplus"] = plugin_enabled("gpluspost");
    $statistics["services"]["libertree"] = plugin_enabled("libertree");
    $statistics["services"]["livejournal"] = plugin_enabled("ljpost");
    $statistics["services"]["pumpio"] = plugin_enabled("pumpio");
    $statistics["services"]["twitter"] = plugin_enabled("twitter");
    $statistics["services"]["tumblr"] = plugin_enabled("tumblr");
    $statistics["services"]["wordpress"] = plugin_enabled("wppost");
    $statistics["appnet"] = $statistics["services"]["appnet"];
    $statistics["blogger"] = $statistics["services"]["blogger"];
    $statistics["buffer"] = $statistics["services"]["buffer"];
    $statistics["dreamwidth"] = $statistics["services"]["dreamwidth"];
    $statistics["facebook"] = $statistics["services"]["facebook"];
    $statistics["gnusocial"] = $statistics["services"]["gnusocial"];
    $statistics["googleplus"] = $statistics["services"]["googleplus"];
    $statistics["libertree"] = $statistics["services"]["libertree"];
    $statistics["livejournal"] = $statistics["services"]["livejournal"];
    $statistics["pumpio"] = $statistics["services"]["pumpio"];
    $statistics["twitter"] = $statistics["services"]["twitter"];
    $statistics["tumblr"] = $statistics["services"]["tumblr"];
    $statistics["wordpress"] = $statistics["services"]["wordpress"];
    header("Content-Type: application/json");
    echo json_encode($statistics, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
    logger("statistics_init: printed " . print_r($statistics, true), LOGGER_DATA);
    killme();
}
开发者ID:vinzv,项目名称:friendica,代码行数:39,代码来源:statistics_json.php

示例14: poco

function poco($a, $extended = false)
{
    $system_mode = false;
    if (observer_prohibited()) {
        logger('mod_poco: block_public');
        http_status_exit(401);
    }
    $observer = App::get_observer();
    if (argc() > 1) {
        $user = notags(trim(argv(1)));
    }
    if (!x($user)) {
        $c = q("select * from pconfig where cat = 'system' and k = 'suggestme' and v = '1'");
        if (!$c) {
            logger('mod_poco: system mode. No candidates.', LOGGER_DEBUG);
            http_status_exit(404);
        }
        $system_mode = true;
    }
    $format = $_REQUEST['format'] ? $_REQUEST['format'] : 'json';
    $justme = false;
    if (argc() > 2 && argv(2) === '@me') {
        $justme = true;
    }
    if (argc() > 3) {
        if (argv(3) === '@all') {
            $justme = false;
        } elseif (argv(3) === '@self') {
            $justme = true;
        }
    }
    if (argc() > 4 && intval(argv(4)) && $justme == false) {
        $cid = intval(argv(4));
    }
    if (!$system_mode) {
        $r = q("SELECT channel_id from channel where channel_address = '%s' limit 1", dbesc($user));
        if (!$r) {
            logger('mod_poco: user mode. Account not found. ' . $user);
            http_status_exit(404);
        }
        $channel_id = $r[0]['channel_id'];
        $ohash = $observer ? $observer['xchan_hash'] : '';
        if (!perm_is_allowed($channel_id, $ohash, 'view_contacts')) {
            logger('mod_poco: user mode. Permission denied for ' . $ohash . ' user: ' . $user);
            http_status_exit(401);
        }
    }
    if ($justme) {
        $sql_extra = " and abook_self = 1 ";
    } else {
        $sql_extra = " and abook_self = 0 ";
    }
    if ($cid) {
        $sql_extra = sprintf(" and abook_id = %d and abook_hidden = 0 ", intval($cid));
    }
    if ($system_mode) {
        $r = q("SELECT count(*) as `total` from abook where abook_self = 1 \n\t\t\tand abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') ");
    } else {
        $r = q("SELECT count(*) as `total` from abook where abook_channel = %d \n\t\t\t{$sql_extra} ", intval($channel_id));
        $rooms = q("select * from menu_item where ( mitem_flags & " . intval(MENU_ITEM_CHATROOM) . " )>0 and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d", intval($channel_id));
    }
    if ($r) {
        $totalResults = intval($r[0]['total']);
    } else {
        $totalResults = 0;
    }
    $startIndex = intval($_GET['startIndex']);
    if (!$startIndex) {
        $startIndex = 0;
    }
    $itemsPerPage = x($_GET, 'count') && intval($_GET['count']) ? intval($_GET['count']) : $totalResults;
    if ($system_mode) {
        $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_self = 1 \n\t\t\tand abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') \n\t\t\tlimit %d offset %d ", intval($itemsPerPage), intval($startIndex));
    } else {
        $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d \n\t\t\t{$sql_extra} LIMIT %d OFFSET %d", intval($channel_id), intval($itemsPerPage), intval($startIndex));
    }
    $ret = array();
    if (x($_GET, 'sorted')) {
        $ret['sorted'] = 'false';
    }
    if (x($_GET, 'filtered')) {
        $ret['filtered'] = 'false';
    }
    if (x($_GET, 'updatedSince')) {
        $ret['updateSince'] = 'false';
    }
    $ret['startIndex'] = (string) $startIndex;
    $ret['itemsPerPage'] = (string) $itemsPerPage;
    $ret['totalResults'] = (string) $totalResults;
    if ($rooms) {
        $ret['chatrooms'] = array();
        foreach ($rooms as $room) {
            $ret['chatrooms'][] = array('url' => $room['mitem_link'], 'desc' => $room['mitem_desc']);
        }
    }
    $ret['entry'] = array();
    $fields_ret = array('id' => false, 'guid' => false, 'guid_sig' => false, 'hash' => false, 'displayName' => false, 'urls' => false, 'preferredUsername' => false, 'photos' => false, 'rating' => false);
    if (!x($_GET, 'fields') || $_GET['fields'] === '@all') {
        foreach ($fields_ret as $k => $v) {
            $fields_ret[$k] = true;
//.........这里部分代码省略.........
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:101,代码来源:socgraph.php

示例15: salmon_post

function salmon_post(&$a)
{
    $xml = file_get_contents('php://input');
    logger('mod-salmon: new salmon ' . $xml, LOGGER_DATA);
    $nick = $a->argc > 1 ? notags(trim($a->argv[1])) : '';
    $mentions = $a->argc > 2 && $a->argv[2] === 'mention' ? true : false;
    $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($nick));
    if (!count($r)) {
        http_status_exit(500);
    }
    $importer = $r[0];
    // parse the xml
    $dom = simplexml_load_string($xml, 'SimpleXMLElement', 0, NAMESPACE_SALMON_ME);
    // figure out where in the DOM tree our data is hiding
    if ($dom->provenance->data) {
        $base = $dom->provenance;
    } elseif ($dom->env->data) {
        $base = $dom->env;
    } elseif ($dom->data) {
        $base = $dom;
    }
    if (!$base) {
        logger('mod-salmon: unable to locate salmon data in xml ');
        http_status_exit(400);
    }
    // Stash the signature away for now. We have to find their key or it won't be good for anything.
    $signature = base64url_decode($base->sig);
    // unpack the  data
    // strip whitespace so our data element will return to one big base64 blob
    $data = str_replace(array(" ", "\t", "\r", "\n"), array("", "", "", ""), $base->data);
    // stash away some other stuff for later
    $type = $base->data[0]->attributes()->type[0];
    $keyhash = $base->sig[0]->attributes()->keyhash[0];
    $encoding = $base->encoding;
    $alg = $base->alg;
    // Salmon magic signatures have evolved and there is no way of knowing ahead of time which
    // flavour we have. We'll try and verify it regardless.
    $stnet_signed_data = $data;
    $signed_data = $data . '.' . base64url_encode($type) . '.' . base64url_encode($encoding) . '.' . base64url_encode($alg);
    $compliant_format = str_replace('=', '', $signed_data);
    // decode the data
    $data = base64url_decode($data);
    $author = ostatus_salmon_author($data, $importer);
    $author_link = $author["author-link"];
    if (!$author_link) {
        logger('mod-salmon: Could not retrieve author URI.');
        http_status_exit(400);
    }
    // Once we have the author URI, go to the web and try to find their public key
    logger('mod-salmon: Fetching key for ' . $author_link);
    $key = get_salmon_key($author_link, $keyhash);
    if (!$key) {
        logger('mod-salmon: Could not retrieve author key.');
        http_status_exit(400);
    }
    $key_info = explode('.', $key);
    $m = base64url_decode($key_info[1]);
    $e = base64url_decode($key_info[2]);
    logger('mod-salmon: key details: ' . print_r($key_info, true), LOGGER_DEBUG);
    $pubkey = metopem($m, $e);
    // We should have everything we need now. Let's see if it verifies.
    $verify = rsa_verify($compliant_format, $signature, $pubkey);
    if (!$verify) {
        logger('mod-salmon: message did not verify using protocol. Trying padding hack.');
        $verify = rsa_verify($signed_data, $signature, $pubkey);
    }
    if (!$verify) {
        logger('mod-salmon: message did not verify using padding. Trying old statusnet hack.');
        $verify = rsa_verify($stnet_signed_data, $signature, $pubkey);
    }
    if (!$verify) {
        logger('mod-salmon: Message did not verify. Discarding.');
        http_status_exit(400);
    }
    logger('mod-salmon: Message verified.');
    /*
     *
     * If we reached this point, the message is good. Now let's figure out if the author is allowed to send us stuff.
     *
     */
    $r = q("SELECT * FROM `contact` WHERE `network` IN ('%s', '%s')\n\t\t\t\t\t\tAND (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s')\n\t\t\t\t\t\tAND `uid` = %d LIMIT 1", dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN), dbesc(normalise_link($author_link)), dbesc($author_link), dbesc(normalise_link($author_link)), intval($importer['uid']));
    if (!count($r)) {
        logger('mod-salmon: Author unknown to us.');
        if (get_pconfig($importer['uid'], 'system', 'ostatus_autofriend')) {
            $result = new_contact($importer['uid'], $author_link);
            if ($result['success']) {
                $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s') \n\t\t\t\t\tAND `uid` = %d LIMIT 1", dbesc(NETWORK_OSTATUS), dbesc($author_link), dbesc($author_link), intval($importer['uid']));
            }
        }
    }
    // Have we ignored the person?
    // If so we can not accept this post.
    //if((count($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
    if (count($r) && $r[0]['blocked']) {
        logger('mod-salmon: Ignoring this author.');
        http_status_exit(202);
        // NOTREACHED
    }
    // Placeholder for hub discovery.
    $hub = '';
//.........这里部分代码省略.........
开发者ID:ZerGabriel,项目名称:friendica,代码行数:101,代码来源:salmon.php


注:本文中的http_status_exit函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。