Пример #1
0
 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
0
 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
0
 /**
  * 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
0
 /**
  * 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
0
     }
     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
0
     }
     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)) {
 /**
  * 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);
 }