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

PHP setup_get_remote_url函数代码示例

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

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



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

示例1: initialise_fullme

/**
 * Initialises $FULLME and friends. Private function. Should only be called from
 * setup.php.
 */
function initialise_fullme()
{
    global $CFG, $FULLME, $ME, $SCRIPT, $FULLSCRIPT;
    // Detect common config error.
    if (substr($CFG->wwwroot, -1) == '/') {
        print_error('wwwrootslash', 'error');
    }
    if (CLI_SCRIPT) {
        initialise_fullme_cli();
        return;
    }
    $rurl = setup_get_remote_url();
    $wwwroot = parse_url($CFG->wwwroot . '/');
    if (empty($rurl['host'])) {
        // missing host in request header, probably not a real browser, let's ignore them
    } else {
        if (!empty($CFG->reverseproxy)) {
            // $CFG->reverseproxy specifies if reverse proxy server used
            // Used in load balancing scenarios.
            // Do not abuse this to try to solve lan/wan access problems!!!!!
        } else {
            if ($rurl['host'] !== $wwwroot['host'] or !empty($wwwroot['port']) and $rurl['port'] != $wwwroot['port']) {
                // Explain the problem and redirect them to the right URL
                if (!defined('NO_MOODLE_COOKIES')) {
                    define('NO_MOODLE_COOKIES', true);
                }
                // The login/token.php script should call the correct url/port.
                if (defined('REQUIRE_CORRECT_ACCESS') && REQUIRE_CORRECT_ACCESS) {
                    $wwwrootport = empty($wwwroot['port']) ? '' : $wwwroot['port'];
                    $calledurl = $rurl['host'];
                    if (!empty($rurl['port'])) {
                        $calledurl .= ':' . $rurl['port'];
                    }
                    $correcturl = $wwwroot['host'];
                    if (!empty($wwwrootport)) {
                        $correcturl .= ':' . $wwwrootport;
                    }
                    throw new moodle_exception('requirecorrectaccess', 'error', '', null, 'You called ' . $calledurl . ', you should have called ' . $correcturl);
                }
                redirect($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3);
            }
        }
    }
    // Check that URL is under $CFG->wwwroot.
    if (strpos($rurl['path'], $wwwroot['path']) === 0) {
        $SCRIPT = substr($rurl['path'], strlen($wwwroot['path']) - 1);
    } else {
        // Probably some weird external script
        $SCRIPT = $FULLSCRIPT = $FULLME = $ME = null;
        return;
    }
    // $CFG->sslproxy specifies if external SSL appliance is used
    // (That is, the Moodle server uses http, with an external box translating everything to https).
    if (empty($CFG->sslproxy)) {
        if ($rurl['scheme'] === 'http' and $wwwroot['scheme'] === 'https') {
            print_error('sslonlyaccess', 'error');
        }
    } else {
        if ($wwwroot['scheme'] !== 'https') {
            throw new coding_exception('Must use https address in wwwroot when ssl proxy enabled!');
        }
        $rurl['scheme'] = 'https';
        // make moodle believe it runs on https, squid or something else it doing it
    }
    // hopefully this will stop all those "clever" admins trying to set up moodle
    // with two different addresses in intranet and Internet
    if (!empty($CFG->reverseproxy) && $rurl['host'] === $wwwroot['host']) {
        print_error('reverseproxyabused', 'error');
    }
    $hostandport = $rurl['scheme'] . '://' . $wwwroot['host'];
    if (!empty($wwwroot['port'])) {
        $hostandport .= ':' . $wwwroot['port'];
    }
    $FULLSCRIPT = $hostandport . $rurl['path'];
    $FULLME = $hostandport . $rurl['fullpath'];
    $ME = $rurl['fullpath'];
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:81,代码来源:setuplib.php


示例2: initialise_fullme

/**
 * Initialises $FULLME and friends. Private function. Should only be called from
 * setup.php.
 */
function initialise_fullme()
{
    global $CFG, $FULLME, $ME, $SCRIPT, $FULLSCRIPT;
    // Detect common config error.
    if (substr($CFG->wwwroot, -1) == '/') {
        print_error('wwwrootslash', 'error');
    }
    if (CLI_SCRIPT) {
        initialise_fullme_cli();
        return;
    }
    $wwwroot = parse_url($CFG->wwwroot);
    if (!isset($wwwroot['path'])) {
        $wwwroot['path'] = '';
    }
    $wwwroot['path'] .= '/';
    $rurl = setup_get_remote_url();
    // Check that URL is under $CFG->wwwroot.
    if (strpos($rurl['path'], $wwwroot['path']) === 0) {
        $SCRIPT = substr($rurl['path'], strlen($wwwroot['path']) - 1);
    } else {
        // Probably some weird external script
        $SCRIPT = $FULLSCRIPT = $FULLME = $ME = null;
        return;
    }
    // $CFG->sslproxy specifies if external SSL appliance is used
    // (That is, the Moodle server uses http, with an external box translating everything to https).
    if (empty($CFG->sslproxy)) {
        if ($rurl['scheme'] == 'http' and $wwwroot['scheme'] == 'https') {
            print_error('sslonlyaccess', 'error');
        }
    }
    // $CFG->reverseproxy specifies if reverse proxy server used.
    // Used in load balancing scenarios.
    // Do not abuse this to try to solve lan/wan access problems!!!!!
    if (empty($CFG->reverseproxy)) {
        if ($rurl['host'] != $wwwroot['host'] or !empty($wwwroot['port']) and $rurl['port'] != $wwwroot['port']) {
            print_error('wwwrootmismatch', 'error', '', $CFG->wwwroot);
        }
    }
    // hopefully this will stop all those "clever" admins trying to set up moodle
    // with two different addresses in intranet and Internet
    if (!empty($CFG->reverseproxy) && $rurl['host'] == $wwwroot['host']) {
        print_error('reverseproxyabused', 'error');
    }
    $hostandport = $rurl['scheme'] . '://' . $wwwroot['host'];
    if (!empty($wwwroot['port'])) {
        $hostandport .= ':' . $wwwroot['port'];
    }
    $FULLSCRIPT = $hostandport . $rurl['path'];
    $FULLME = $hostandport . $rurl['fullpath'];
    $ME = $rurl['fullpath'];
    $rurl['path'] = $rurl['fullpath'];
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:58,代码来源:setuplib.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
php png失真的原因及解决办法发布时间:2022-02-12
下一篇:
PHP setup_gateways_monitor函数代码示例发布时间: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