magicblack / maccms10

苹果cms官网,苹果cmsv10,maccmsv10,麦克cms,开源cms,内容管理系统,视频分享程序,分集剧情程序,网址导航程序,文章程序,漫画程序,图片程序
Other
2.27k stars 782 forks source link

套完cdn的bug #1176

Closed xiaoqiu1600604528 closed 1 week ago

xiaoqiu1600604528 commented 3 months ago

在套完conflare的cdn后,用户在登录注册ip在后台看到的为cdn的IP,请问官方该怎么办

magicblack commented 1 week ago

升级到最新版本了吗~

最新版本是支持CF的: 参考 ./application/common.php

function mac_get_client_ip()
{
    static $final;
    if (!is_null($final)) {
        return $final;
    }
    $ips = [];
    if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
        $ips[] = $_SERVER['HTTP_CF_CONNECTING_IP'];
    }
    if (!empty($_SERVER['HTTP_ALI_CDN_REAL_IP'])) {
        $ips[] = $_SERVER['HTTP_ALI_CDN_REAL_IP'];
    }
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        $ips[] = $_SERVER['HTTP_CLIENT_IP'];
    }
    if (!empty($_SERVER['HTTP_PROXY_USER'])) {
        $ips[] = $_SERVER['HTTP_PROXY_USER'];
    }
    $real_ip = getenv('HTTP_X_REAL_IP');
    if (!empty($real_ip)) {
        $ips[] = $real_ip;
    }
    if (!empty($_SERVER['REMOTE_ADDR'])) {
        $ips[] = $_SERVER['REMOTE_ADDR'];
    }
    // 选第一个最合法的,或最后一个正常的IP
    foreach ($ips as $ip) {
        $verifyResult = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE);
        if (!$verifyResult){
            continue;
        }
        $verifyResult && $final = $ip;
    }
    empty($final) && $final = '0.0.0.0';
    return $final;
}