当前位置: 首页>>代码示例>>PHP>>正文


PHP PMA_langDetect函数代码示例

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


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

示例1: PMA_langCheck

/**
 * trys to find the language to use
 *
 * @uses    $GLOBALS['cfg']['lang']
 * @uses    $GLOBALS['cfg']['DefaultLang']
 * @uses    $GLOBALS['lang_failed_cfg']
 * @uses    $GLOBALS['lang_failed_cookie']
 * @uses    $GLOBALS['lang_failed_request']
 * @uses    $_REQUEST['lang']
 * @uses    $_COOKIE['pma_lang']
 * @uses    $_SERVER['HTTP_ACCEPT_LANGUAGE']
 * @uses    $_SERVER['HTTP_USER_AGENT']
 * @uses    PMA_langSet()
 * @uses    PMA_langDetect()
 * @uses    explode()
 * @return  bool    success if valid lang is found, otherwise false
 */
function PMA_langCheck()
{
    // check forced language
    if (!empty($GLOBALS['cfg']['Lang'])) {
        if (PMA_langSet($GLOBALS['cfg']['Lang'])) {
            return true;
        } else {
            $GLOBALS['lang_failed_cfg'] = $GLOBALS['cfg']['Lang'];
        }
    }
    // Don't use REQUEST in following code as it might be confused by cookies with same name
    // check user requested language (POST)
    if (!empty($_POST['lang'])) {
        if (PMA_langSet($_POST['lang'])) {
            return true;
        } else {
            $GLOBALS['lang_failed_request'] = $_POST['lang'];
        }
    }
    // check user requested language (GET)
    if (!empty($_GET['lang'])) {
        if (PMA_langSet($_GET['lang'])) {
            return true;
        } else {
            $GLOBALS['lang_failed_request'] = $_GET['lang'];
        }
    }
    // check previous set language
    if (!empty($_COOKIE['pma_lang'])) {
        if (PMA_langSet($_COOKIE['pma_lang'])) {
            return true;
        } else {
            $GLOBALS['lang_failed_cookie'] = $_COOKIE['pma_lang'];
        }
    }
    // try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE variable
    if (PMA_getenv('HTTP_ACCEPT_LANGUAGE')) {
        foreach (explode(',', PMA_getenv('HTTP_ACCEPT_LANGUAGE')) as $lang) {
            if (PMA_langDetect($lang, 1)) {
                return true;
            }
        }
    }
    // try to findout user's language by checking its HTTP_USER_AGENT variable
    if (PMA_langDetect(PMA_getenv('HTTP_USER_AGENT'), 2)) {
        return true;
    }
    // Didn't catch any valid lang : we use the default settings
    if (PMA_langSet($GLOBALS['cfg']['DefaultLang'])) {
        return true;
    }
    return false;
}
开发者ID:robmat,项目名称:samplebator,代码行数:70,代码来源:select_lang.lib.php

示例2: PMA_langCheck

/**
 * Tries to find the language to use
 *
 * @return bool  success if valid lang is found, otherwise false
 */
function PMA_langCheck()
{
    // check forced language
    if (!empty($GLOBALS['cfg']['Lang'])) {
        if (PMA_langSet($GLOBALS['cfg']['Lang'])) {
            return true;
        } else {
            $GLOBALS['lang_failed_cfg'] = $GLOBALS['cfg']['Lang'];
        }
    }
    // Don't use REQUEST in following code as it might be confused by cookies
    // with same name. Check user requested language (POST)
    if (!empty($_POST['lang'])) {
        if (PMA_langSet($_POST['lang'])) {
            return true;
        } elseif (!is_string($_POST['lang'])) {
            /* Faked request, don't care on localisation */
            $GLOBALS['lang_failed_request'] = 'Yes';
        } else {
            $GLOBALS['lang_failed_request'] = $_POST['lang'];
        }
    }
    // check user requested language (GET)
    if (!empty($_GET['lang'])) {
        if (PMA_langSet($_GET['lang'])) {
            return true;
        } elseif (!is_string($_GET['lang'])) {
            /* Faked request, don't care on localisation */
            $GLOBALS['lang_failed_request'] = 'Yes';
        } else {
            $GLOBALS['lang_failed_request'] = $_GET['lang'];
        }
    }
    // check previous set language
    if (!empty($_COOKIE['pma_lang'])) {
        if (PMA_langSet($_COOKIE['pma_lang'])) {
            return true;
        } elseif (!is_string($_COOKIE['pma_lang'])) {
            /* Faked request, don't care on localisation */
            $GLOBALS['lang_failed_cookie'] = 'Yes';
        } else {
            $GLOBALS['lang_failed_cookie'] = $_COOKIE['pma_lang'];
        }
    }
    // try to find out user's language by checking its HTTP_ACCEPT_LANGUAGE variable;
    // prevent XSS
    $accepted_languages = PMA_getenv('HTTP_ACCEPT_LANGUAGE');
    if ($accepted_languages && false === strpos($accepted_languages, '<')) {
        foreach (explode(',', $accepted_languages) as $lang) {
            if (PMA_langDetect($lang, 1)) {
                return true;
            }
        }
    }
    unset($accepted_languages);
    // try to find out user's language by checking its HTTP_USER_AGENT variable
    if (PMA_langDetect(PMA_getenv('HTTP_USER_AGENT'), 2)) {
        return true;
    }
    // Didn't catch any valid lang : we use the default settings
    if (PMA_langSet($GLOBALS['cfg']['DefaultLang'])) {
        return true;
    }
    return false;
}
开发者ID:yszar,项目名称:linuxwp,代码行数:70,代码来源:select_lang.lib.php

示例3: explode

if (!empty($lang) && empty($available_languages[$lang])) {
    $lang = '';
}
// Language is not defined yet :
// 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE
//    variable
if (empty($lang) && !empty($HTTP_ACCEPT_LANGUAGE)) {
    $accepted = explode(',', $HTTP_ACCEPT_LANGUAGE);
    $acceptedCnt = count($accepted);
    for ($i = 0; $i < $acceptedCnt && empty($lang); $i++) {
        PMA_langDetect($accepted[$i], 1);
    }
}
// 2. try to findout user's language by checking its HTTP_USER_AGENT variable
if (empty($lang) && !empty($HTTP_USER_AGENT)) {
    PMA_langDetect($HTTP_USER_AGENT, 2);
}
// 3. Didn't catch any valid lang : we use the default settings
if (empty($lang)) {
    $lang = $cfg['DefaultLang'];
}
// 4. Checks whether charset recoding should be allowed or not
$allow_recoding = FALSE;
// Default fallback value
if (!isset($convcharset) || empty($convcharset)) {
    if (isset($_COOKIE['pma_charset'])) {
        $convcharset = $_COOKIE['pma_charset'];
    } else {
        $convcharset = $cfg['DefaultCharset'];
    }
}
开发者ID:mike503,项目名称:phpmyadmin,代码行数:31,代码来源:select_lang.lib.php


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