选择语言 :

 Core_HttpIO::auto_add_ajax_control_allow_origin

自动添加HTML5的AJAX跨越支持

null Core_HttpIO::auto_add_ajax_control_allow_origin( )
File: ./core/classes/httpio.class.php
protected static function auto_add_ajax_control_allow_origin()
{
    $ajax_cross_domain = Core::config('ajax_cross_domain');

    if (false!==$ajax_cross_domain)
    {
        if ('none'==$ajax_cross_domain)return ;

        $info = parse_url($_SERVER['HTTP_REFERER']);
        $host = $info['host'];

        $add_allow_origin = false;

        if (is_array($ajax_cross_domain))
        {
            foreach ($ajax_cross_domain as $item)
            {
                if (strpos($item, '*')!==false)
                {
                    $preg = '#^'. str_replace('\\*', '*', preg_quote($item)) .'#$i';
                    if (preg_match($preg, $host))
                    {
                        $add_allow_origin = true;
                        break;
                    }
                }
                elseif ($host==$item)
                {
                    $add_allow_origin = true;
                    break;
                }
            }
        }
        elseif ($ajax_cross_domain)
        {
            if ($_SERVER['HTTP_HOST']!=$host && HttpIO::get_primary_domain($_SERVER['HTTP_HOST']) == HttpIO::get_primary_domain($host))
            {
                $add_allow_origin = true;
            }
        }

        if ($add_allow_origin)
        {
            header('Access-Control-Allow-Origin: '. HttpIO::PROTOCOL . $host . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']?($_SERVER['SERVER_PORT']==443?'':':'.$_SERVER['SERVER_PORT']):($_SERVER['SERVER_PORT']==80?'':':'.$_SERVER['SERVER_PORT'])) . '/');
        }
    }
}