本文整理汇总了PHP中Validation::alphaNumeric方法的典型用法代码示例。如果您正苦于以下问题:PHP Validation::alphaNumeric方法的具体用法?PHP Validation::alphaNumeric怎么用?PHP Validation::alphaNumeric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validation
的用法示例。
在下文中一共展示了Validation::alphaNumeric方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
function login()
{
$authorized = false;
$error = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (strlen($_POST['userid']) > 0) {
$validation = new Validation();
if ($message = $validation->userid($_POST['userid'], 'ユーザー名')) {
$error[] = $message;
} else {
$userid = $_POST['userid'];
}
$_POST['password'] = trim($_POST['password']);
if ($message = $validation->alphaNumeric($_POST['password'], 'パスワード')) {
$error[] = $message;
} else {
$password = md5($_POST['password']);
}
if (count($error) <= 0) {
$connection = new Connection();
$query = sprintf("SELECT id,userid,password,realname,user_group,authority FROM %suser WHERE userid = '%s'", DB_PREFIX, $connection->quote($userid));
$data = $connection->fetchOne($query);
$connection->close();
if (count($data) > 0 && $data['userid'] === $userid && $data['password'] === $password) {
$authorized = true;
} else {
$error[] = 'ユーザー名もしくはパスワードが<br />異なります。';
}
}
} else {
$error[] = 'ユーザー名を入力してください。';
}
} elseif (isset($_SESSION['status'])) {
if ($_SESSION['status'] == 'idle') {
$error[] = '自動的にログアウトしました。<br />ログインしなおしてください。';
} elseif ($_SESSION['status'] == 'expire') {
$error[] = 'ログインの有効期限が切れました。<br />ログインしなおしてください。';
}
session_unregister('status');
}
if ($authorized === true && count($error) <= 0) {
session_regenerate_id();
$_SESSION['logintime'] = time();
$_SESSION['accesstime'] = $_SESSION['logintime'];
$_SESSION['authorized'] = md5(__FILE__ . $_SESSION['logintime']);
$_SESSION['userid'] = $data['userid'];
$_SESSION['realname'] = $data['realname'];
$_SESSION['group'] = $data['user_group'];
$_SESSION['authority'] = $data['authority'];
if (isset($_SESSION['referer'])) {
header('Location: ' . $_SESSION['referer']);
session_unregister('referer');
} else {
header('Location: index.php');
}
exit;
} else {
return $error;
}
}
示例2: testAlphaNumericPassedAsArray
function testAlphaNumericPassedAsArray()
{
$this->assertTrue(Validation::alphaNumeric(array('check' => 'frferrf')));
$this->assertTrue(Validation::alphaNumeric(array('check' => '12234')));
$this->assertTrue(Validation::alphaNumeric(array('check' => '1w2e2r3t4y')));
$this->assertTrue(Validation::alphaNumeric(array('check' => '0')));
$this->assertFalse(Validation::alphaNumeric(array('check' => '12 234')));
$this->assertFalse(Validation::alphaNumeric(array('check' => 'dfd 234')));
$this->assertFalse(Validation::alphaNumeric(array('check' => "\n")));
$this->assertFalse(Validation::alphaNumeric(array('check' => "\t")));
$this->assertFalse(Validation::alphaNumeric(array('check' => "\r")));
$this->assertFalse(Validation::alphaNumeric(array('check' => ' ')));
$this->assertFalse(Validation::alphaNumeric(array('check' => '')));
}
示例3: name
/**
* Checa o nome do remetente de acordo com
* as regras do PagSeguro
*
* @param string $check The value to check.
* @return boolean
*/
public static function name($check)
{
if (!self::genericValidate($check, 50)) {
return false;
}
$parts = explode(' ', $check);
if (count($parts) < 2) {
return false;
}
foreach ($parts as $part) {
if (!Validation::alphaNumeric($part)) {
return false;
}
}
return self::success();
}
示例4: testAlphaNumeric
/**
* testAlphaNumeric method
*
* @return void
*/
public function testAlphaNumeric()
{
$this->assertTrue(Validation::alphaNumeric('frferrf'));
$this->assertTrue(Validation::alphaNumeric('12234'));
$this->assertTrue(Validation::alphaNumeric('1w2e2r3t4y'));
$this->assertTrue(Validation::alphaNumeric('0'));
$this->assertTrue(Validation::alphaNumeric('abçďĕʑʘπй'));
$this->assertTrue(Validation::alphaNumeric('ˇˆๆゞ'));
$this->assertTrue(Validation::alphaNumeric('אกあアꀀ豈'));
$this->assertTrue(Validation::alphaNumeric('Džᾈᾨ'));
$this->assertTrue(Validation::alphaNumeric('ÆΔΩЖÇ'));
$this->assertFalse(Validation::alphaNumeric('12 234'));
$this->assertFalse(Validation::alphaNumeric('dfd 234'));
$this->assertFalse(Validation::alphaNumeric("0\n"));
$this->assertFalse(Validation::alphaNumeric("\n"));
$this->assertFalse(Validation::alphaNumeric("\t"));
$this->assertFalse(Validation::alphaNumeric("\r"));
$this->assertFalse(Validation::alphaNumeric(' '));
$this->assertFalse(Validation::alphaNumeric(''));
}
示例5: trim
}
if ($string = Validation::length('userid', 'ユーザーID', 100)) {
$error[] = $string;
}
}
if (count($error) <= 0 && is_array($table) && in_array(DB_PREFIX . 'user', $table)) {
$count = $connection->fetchCount(DB_PREFIX . 'user', "WHERE userid = '" . $connection->quote($_POST['userid']) . "'", 'id');
if ($count > 0) {
$error[] = 'そのユーザーIDはすでに存在します。<br />別のユーザーIDを入力してください。';
}
}
$_POST['password'] = trim($_POST['password']);
if (strlen($_POST['password']) <= 0) {
$error[] = 'パスワードを入力してください。';
} else {
if ($string = Validation::alphaNumeric('password', 'パスワード')) {
$error[] = $string;
}
if ($string = Validation::length('password', 'パスワード', 4, 32)) {
$error[] = $string;
}
}
if (strlen($_POST['realname']) <= 0) {
$error[] = '名前を入力してください。';
} elseif ($string = Validation::length('realname', '名前', 100)) {
$error[] = $string;
}
if (strlen($_POST['user_groupname']) <= 0) {
$error[] = 'グループ名を入力してください。';
} else {
if ($string = Validation::length('user_groupname', 'グループ名', 100)) {
示例6: trim
}
if ($string = Validation::length($_POST['userid'], 'ユーザーID', 100)) {
$error[] = $string;
}
}
if (count($error) <= 0 && is_array($table) && in_array(DB_PREFIX . 'user', $table)) {
$count = $connection->fetchCount(DB_PREFIX . 'user', "WHERE userid = '" . $connection->quote($_POST['userid']) . "'", 'id');
if ($count > 0) {
$error[] = 'そのユーザーIDはすでに存在します。<br />別のユーザーIDを入力してください。';
}
}
$_POST['password'] = trim($_POST['password']);
if (strlen($_POST['password']) <= 0) {
$error[] = 'パスワードを入力してください。';
} else {
if ($string = Validation::alphaNumeric($_POST['password'], 'パスワード')) {
$error[] = $string;
}
if ($string = Validation::length($_POST['password'], 'パスワード', 4, 32)) {
$error[] = $string;
}
}
if (strlen($_POST['realname']) <= 0) {
$error[] = '名前を入力してください。';
} elseif ($string = Validation::length($_POST['realname'], '名前', 100)) {
$error[] = $string;
}
if (strlen($_POST['user_groupname']) <= 0) {
$error[] = 'グループ名を入力してください。';
} else {
if ($string = Validation::length($_POST['user_groupname'], 'グループ名', 100)) {
示例7: formatAlphaNumeric
/**
* formatAlphaNumeric
* jpn: AdditionalValidationPatternsBehavior用にemptyのときはtrue
*
*/
public function formatAlphaNumeric(Model $model, $field)
{
$value = array_shift($field);
if (!Validation::notEmpty($value)) {
return true;
}
return Validation::alphaNumeric($value);
}