function blog_check_url($url)
{
    $url = durlencode(trim($url));
    if (preg_match("/^(https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\\/\\//i", $url)) {
        $return = '<a href="' . $url . '" target="_blank">';
    } else {
        $return = '<a href="' . (!empty($GLOBALS['_G']['siteurl']) ? $GLOBALS['_G']['siteurl'] : 'http://') . $url . '" target="_blank">';
    }
    return $return;
}
Exemple #2
0
function output_json($arr)
{
    if (empty($arr)) {
        return '[]';
    }
    if (floatvaldec(PHP_VERSION) >= 5.4) {
        return json_encode($arr, JSON_UNESCAPED_UNICODE);
    }
    $json = json_encode(durlencode($arr));
    return urldecode($json);
}
function dreferer($default = '')
{
    global $_G;
    $default = empty($default) && $_ENV['curapp'] ? $_ENV['curapp'] . '.php' : '';
    $_G['referer'] = !empty($_GET['referer']) ? $_GET['referer'] : $_SERVER['HTTP_REFERER'];
    $_G['referer'] = substr($_G['referer'], -1) == '?' ? substr($_G['referer'], 0, -1) : $_G['referer'];
    if (strpos($_G['referer'], 'member.php?mod=logging')) {
        $_G['referer'] = $default;
    }
    $reurl = parse_url($_G['referer']);
    if (!$reurl || isset($reurl['scheme']) && !in_array(strtolower($reurl['scheme']), array('http', 'https'))) {
        $_G['referer'] = '';
    }
    if (!empty($reurl['host']) && !in_array($reurl['host'], array($_SERVER['HTTP_HOST'], 'www.' . $_SERVER['HTTP_HOST'])) && !in_array($_SERVER['HTTP_HOST'], array($reurl['host'], 'www.' . $reurl['host']))) {
        if (!in_array($reurl['host'], $_G['setting']['domain']['app']) && !isset($_G['setting']['domain']['list'][$reurl['host']])) {
            $domainroot = substr($reurl['host'], strpos($reurl['host'], '.') + 1);
            if (empty($_G['setting']['domain']['root']) || is_array($_G['setting']['domain']['root']) && !in_array($domainroot, $_G['setting']['domain']['root'])) {
                $_G['referer'] = $_G['setting']['domain']['defaultindex'] ? $_G['setting']['domain']['defaultindex'] : 'index.php';
            }
        }
    } elseif (empty($reurl['host'])) {
        $_G['referer'] = $_G['siteurl'] . './' . $_G['referer'];
    }
    $_G['referer'] = durlencode($_G['referer']);
    return $_G['referer'];
}
/**
* 刷新重定向
*/
function dreferer($default = '')
{
    global $_G;
    $default = empty($default) && $_ENV['curapp'] ? $_ENV['curapp'] . '.php' : '';
    $_G['referer'] = !empty($_GET['referer']) ? $_GET['referer'] : $_SERVER['HTTP_REFERER'];
    $_G['referer'] = substr($_G['referer'], -1) == '?' ? substr($_G['referer'], 0, -1) : $_G['referer'];
    if (strpos($_G['referer'], 'member.php?mod=logging')) {
        $_G['referer'] = $default;
    }
    $reurl = parse_url($_G['referer']);
    /**
     * 判断host是否相同,不同时做进一步的校验
     * 当解析到的host与HTTP_HOST,相同的,不管是不是加www均给予放行
     */
    if (!empty($reurl['host']) && !in_array($reurl['host'], array($_SERVER['HTTP_HOST'], 'www.' . $_SERVER['HTTP_HOST'])) && !in_array($_SERVER['HTTP_HOST'], array($reurl['host'], 'www.' . $reurl['host']))) {
        //校验是否在应用域名或版块域名配置中
        if (!in_array($reurl['host'], $_G['setting']['domain']['app']) && !isset($_G['setting']['domain']['list'][$reurl['host']])) {
            $domainroot = substr($reurl['host'], strpos($reurl['host'], '.') + 1);
            //是否为子域名,如果不为子域名则跳到index.php
            if (empty($_G['setting']['domain']['root']) || is_array($_G['setting']['domain']['root']) && !in_array($domainroot, $_G['setting']['domain']['root'])) {
                $_G['referer'] = $_G['setting']['domain']['defaultindex'] ? $_G['setting']['domain']['defaultindex'] : 'index.php';
            }
        }
    } elseif (empty($reurl['host'])) {
        $_G['referer'] = $_G['siteurl'] . './' . $_G['referer'];
    }
    $_G['referer'] = durlencode($_G['referer']);
    return $_G['referer'];
}