Esempio n. 1
0
File: My.php Progetto: kevan/MyPHP
function MySetGetAlphaNumeric($ParameterName, $MinLength = 0, $MaxLength = 0)
{
    if ($MinLength === 0 && $MaxLength === 0) {
        if (isset($_GET[$ParameterName]) && $_GET[$ParameterName] !== '' && ctype_alnum($_GET[$ParameterName])) {
            return MySetValue($ParameterName, $_GET[$ParameterName]);
        }
    } else {
        if (isset($_GET[$ParameterName]) && $_GET[$ParameterName] !== '' && ctype_alnum($_GET[$ParameterName]) && strlen($_GET[$ParameterName]) >= $MinLength && strlen($_GET[$ParameterName]) <= $MaxLength) {
            return MySetValue($ParameterName, $_GET[$ParameterName]);
        }
    }
    return false;
}
Esempio n. 2
0
function MyCheckParameter($ParameterName, $DefaultValue = null)
{
    if (isset($_POST[$ParameterName])) {
        MySetValue($ParameterName, $_POST[$ParameterName]);
        return;
    }
    if (isset($_GET[$ParameterName])) {
        MySetValue($ParameterName, $_GET[$ParameterName]);
        return;
    }
    if (isset($DefaultValue)) {
        MySetValue($ParameterName, $DefaultValue);
        return;
    }
    MyResult('1027', $data = '', $tips = '请求缺少' . $ParameterName . '参数', $description = '请求需要的' . $ParameterName . '参数可使用POST、GET方式传递');
}