• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP http_status_exit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: nodeinfo_init

function nodeinfo_init(&$a)
{
    if (!get_config("system", "nodeinfo")) {
        http_status_exit(404);
        killme();
    }
    if ($a->argc != 2 or $a->argv[1] != "1.0") {
        http_status_exit(404);
        killme();
    }
    $smtp = (function_exists("imap_open") and !get_config("system", "imap_disabled") and !get_config("system", "dfrn_only"));
    $nodeinfo = array();
    $nodeinfo["version"] = "1.0";
    $nodeinfo["software"] = array("name" => "friendica", "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION);
    $nodeinfo["protocols"] = array();
    $nodeinfo["protocols"]["inbound"] = array();
    $nodeinfo["protocols"]["outbound"] = array();
    if (get_config("system", "diaspora_enabled")) {
        $nodeinfo["protocols"]["inbound"][] = "diaspora";
        $nodeinfo["protocols"]["outbound"][] = "diaspora";
    }
    $nodeinfo["protocols"]["inbound"][] = "friendica";
    $nodeinfo["protocols"]["outbound"][] = "friendica";
    if (!get_config("system", "ostatus_disabled")) {
        $nodeinfo["protocols"]["inbound"][] = "gnusocial";
        $nodeinfo["protocols"]["outbound"][] = "gnusocial";
    }
    $nodeinfo["services"] = array();
    $nodeinfo["services"]["inbound"] = array();
    $nodeinfo["services"]["outbound"] = array();
    $nodeinfo["openRegistrations"] = $a->config['register_policy'] != 0;
    $nodeinfo["usage"] = array();
    $nodeinfo["usage"]["users"] = array("total" => (int) get_config("nodeinfo", "total_users"), "activeHalfyear" => (int) get_config("nodeinfo", "active_users_halfyear"), "activeMonth" => (int) get_config("nodeinfo", "active_users_monthly"));
    $nodeinfo["usage"]["localPosts"] = (int) get_config("nodeinfo", "local_posts");
    $nodeinfo["usage"]["localComments"] = (int) get_config("nodeinfo", "local_comments");
    $nodeinfo["metadata"] = array("nodeName" => $a->config["sitename"]);
    if (nodeinfo_plugin_enabled("appnet")) {
        $nodeinfo["services"]["inbound"][] = "appnet";
    }
    if (nodeinfo_plugin_enabled("appnet") or nodeinfo_plugin_enabled("buffer")) {
        $nodeinfo["services"]["outbound"][] = "appnet";
    }
    if (nodeinfo_plugin_enabled("blogger")) {
        $nodeinfo["services"]["outbound"][] = "blogger";
    }
    if (nodeinfo_plugin_enabled("dwpost")) {
        $nodeinfo["services"]["outbound"][] = "dreamwidth";
    }
    if (nodeinfo_plugin_enabled("fbpost") or nodeinfo_plugin_enabled("buffer")) {
        $nodeinfo["services"]["outbound"][] = "facebook";
    }
    if (nodeinfo_plugin_enabled("statusnet")) {
        $nodeinfo["services"]["inbound"][] = "gnusocial";
        $nodeinfo["services"]["outbound"][] = "gnusocial";
    }
    if (nodeinfo_plugin_enabled("gpluspost") or nodeinfo_plugin_enabled("buffer")) {
        $nodeinfo["services"]["outbound"][] = "google";
    }
    if (nodeinfo_plugin_enabled("ijpost")) {
        $nodeinfo["services"]["outbound"][] = "insanejournal";
    }
    if (nodeinfo_plugin_enabled("libertree")) {
        $nodeinfo["services"]["outbound"][] = "libertree";
    }
    if (nodeinfo_plugin_enabled("buffer")) {
        $nodeinfo["services"]["outbound"][] = "linkedin";
    }
    if (nodeinfo_plugin_enabled("ljpost")) {
        $nodeinfo["services"]["outbound"][] = "livejournal";
    }
    if (nodeinfo_plugin_enabled("buffer")) {
        $nodeinfo["services"]["outbound"][] = "pinterest";
    }
    if (nodeinfo_plugin_enabled("posterous")) {
        $nodeinfo["services"]["outbound"][] = "posterous";
    }
    if (nodeinfo_plugin_enabled("pumpio")) {
        $nodeinfo["services"]["inbound"][] = "pumpio";
        $nodeinfo["services"]["outbound"][] = "pumpio";
    }
    // redmatrix
    if ($smtp) {
        $nodeinfo["services"]["outbound"][] = "smtp";
    }
    if (nodeinfo_plugin_enabled("tumblr")) {
        $nodeinfo["services"]["outbound"][] = "tumblr";
    }
    if (nodeinfo_plugin_enabled("twitter") or nodeinfo_plugin_enabled("buffer")) {
        $nodeinfo["services"]["outbound"][] = "twitter";
    }
    if (nodeinfo_plugin_enabled("wppost")) {
        $nodeinfo["services"]["outbound"][] = "wordpress";
    }
    $nodeinfo["metadata"]["protocols"] = $nodeinfo["protocols"];
    $nodeinfo["metadata"]["protocols"]["outbound"][] = "atom1.0";
    $nodeinfo["metadata"]["protocols"]["inbound"][] = "atom1.0";
    $nodeinfo["metadata"]["protocols"]["inbound"][] = "rss2.0";
    $nodeinfo["metadata"]["services"] = $nodeinfo["services"];
    if (nodeinfo_plugin_enabled("twitter")) {
        $nodeinfo["metadata"]["services"]["inbound"][] = "twitter";
//.........这里部分代码省略.........
开发者ID:ZerGabriel,项目名称:friendica,代码行数:101,代码来源:nodeinfo.php


示例17: pubsubhubbub_init

function pubsubhubbub_init(&$a)
{
    // PuSH subscription must be considered "public" so just block it
    // if public access isn't enabled.
    if (get_config('system', 'block_public')) {
        http_status_exit(403);
    }
    // Subscription request from subscriber
    // https://pubsubhubbub.googlecode.com/git/pubsubhubbub-core-0.4.html#anchor4
    // Example from GNU Social:
    // [hub_mode] => subscribe
    // [hub_callback] => http://status.local/main/push/callback/1
    // [hub_verify] => sync
    // [hub_verify_token] => af11...
    // [hub_secret] => af11...
    // [hub_topic] => http://friendica.local/dfrn_poll/sazius
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $hub_mode = push_post_var('hub_mode');
        $hub_callback = push_post_var('hub_callback');
        $hub_verify = push_post_var('hub_verify');
        $hub_verify_token = push_post_var('hub_verify_token');
        $hub_secret = push_post_var('hub_secret');
        $hub_topic = push_post_var('hub_topic');
        // check for valid hub_mode
        if ($hub_mode === 'subscribe') {
            $subscribe = 1;
        } else {
            if ($hub_mode === 'unsubscribe') {
                $subscribe = 0;
            } else {
                logger("pubsubhubbub: invalid hub_mode={$hub_mode}, ignoring.");
                http_status_exit(404);
            }
        }
        logger("pubsubhubbub: {$hub_mode} request from " . $_SERVER['REMOTE_ADDR']);
        // get the nick name from the topic, a bit hacky but needed
        $nick = substr(strrchr($hub_topic, "/"), 1);
        if (!$nick) {
            logger('pubsubhubbub: bad hub_topic=$hub_topic, ignoring.');
            http_status_exit(404);
        }
        // fetch user from database given the nickname
        $owner = channelx_by_nick($nick);
        if (!$owner) {
            logger('pubsubhubbub: local account not found: ' . $nick);
            http_status_exit(404);
        }
        if (!perm_is_allowed($owner['channel_id'], '', 'view_stream')) {
            logger('pubsubhubbub: local channel ' . $nick . 'has chosen to hide wall, ignoring.');
            http_status_exit(403);
        }
        // sanity check that topic URLs are the same
        if (!link_compare($hub_topic, z_root() . '/feed/' . $nick)) {
            logger('pubsubhubbub: not a valid hub topic ' . $hub_topic);
            http_status_exit(404);
        }
        // do subscriber verification according to the PuSH protocol
        $hub_challenge = random_string(40);
        $params = 'hub.mode=' . ($subscribe == 1 ? 'subscribe' : 'unsubscribe') . '&hub.topic=' . urlencode($hub_topic) . '&hub.challenge=' . $hub_challenge . '&hub.lease_seconds=604800' . '&hub.verify_token=' . $hub_verify_token;
        // lease time is hard coded to one week (in seconds)
        // we don't actually enforce the lease time because GNU
        // Social/StatusNet doesn't honour it (yet)
        $x = z_fetch_url($hub_callback . "?" . $params);
        if (!$x['success']) {
            logger("pubsubhubbub: subscriber verification at {$hub_callback} " . "returned {$ret}, ignoring.");
            http_status_exit(404);
        }
        // check that the correct hub_challenge code was echoed back
        if (trim($x['body']) !== $hub_challenge) {
            logger("pubsubhubbub: subscriber did not echo back " . "hub.challenge, ignoring.");
            logger("\"{$hub_challenge}\" != \"" . trim($x['body']) . "\"");
            http_status_exit(404);
        }
        // fetch the old subscription if it exists
        $orig = q("SELECT * FROM `push_subscriber` WHERE `callback_url` = '%s'", dbesc($hub_callback));
        // delete old subscription if it exists
        q("DELETE FROM push_subscriber WHERE callback_url = '%s' and topic = '%s'", dbesc($hub_callback), dbesc($hub_topic));
        if ($subscribe) {
            $last_update = datetime_convert('UTC', 'UTC', 'now', 'Y-m-d H:i:s');
            // if we are just updating an old subscription, keep the
            // old values for last_update
            if ($orig) {
                $last_update = $orig[0]['last_update'];
            }
            // subscribe means adding the row to the table
            q("INSERT INTO push_subscriber ( callback_url, topic, last_update, secret) values ('%s', '%s', '%s', '%s') ", dbesc($hub_callback), dbesc($hub_topic), dbesc($last_update), dbesc($hub_secret));
            logger("pubsubhubbub: successfully subscribed [{$hub_callback}].");
        } else {
            logger("pubsubhubbub: successfully unsubscribed [{$hub_callback}].");
            // we do nothing here, since the row was already deleted
        }
        http_status_exit(202);
    }
    killme();
}
开发者ID:phellmes,项目名称:hubzilla-addons,代码行数:95,代码来源:pubsubhubbub.php


示例18: dfrn_poll_init


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP httpallpost函数代码示例发布时间:2022-05-15
下一篇:
PHP http_status函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap