source: pro-bachkim-filespace/sourcecode/api.violet.vn/www/lib/common/sfFullnameValidator.class.php @ 179

Last change on this file since 179 was 19, checked in by dungnv, 11 years ago
File size: 2.2 KB
Line 
1<?php
2
3class sfFullnameValidator extends sfStringValidator
4{
5  public function execute(&$fullname, &$error)
6  {
7    if (!parent::execute($fullname, $error)) return false;
8
9    $specical_char = '1234567890,.<>/?;:\'"`~!@#$%^&*()-_=+\\|[]{}';
10    for ($i = 0; $i < strlen($specical_char); $i++) {
11      $pos = stripos($fullname, $specical_char[$i]);
12      if ($pos !== false) {$error = 'Please do not enter special char'; return false;}
13    }
14
15    $fullname = mb_convert_case($fullname, MB_CASE_TITLE, "UTF-8");
16    $names = explode(' ', $fullname);
17    $count = count($names);
18    if($count < 2) {$error = 'Please enter exact your fullname'; return false;}
19
20    $cousin = $names[0];
21    $surnames = array(
22    "Bui", "Dam", "Dao", "Duong", "Do", "Doan", "Dang", "Dinh",
23    "Ha", "Ho", "Hoang", "Huynh", "Kieu", "Khong", "Le", "Luu",
24    "Luong", "Ly", "Nguyen", "Ngo", "Ta", "Thai", "Tran", "Trinh",
25    "Ton", "Tong", "Truong", "Pham", "Vo", "Vu", "Vuong");
26    if (in_array($cousin, $surnames)) {$error = 'Please enter in Vietnamese'; return false;}
27
28    $surnamesVietcode = array(
29    //---- VNI code ---
30    "BuÞi", "ÑaÞm", "ÑaÞo", "DöÎng", "Ñoã", "ÑoaÞn", "Ñaëng", "Ñinh",
31    "HaÞ", "HoaÞng", "HuyÞnh", "Kieàu", "KhoÃ¥ng", "Leâ", "Löu",           // thiếu "Hoà" (Hồ)
32    "LöÎng", "Lyù", "Nguyeãn", "Ngoâ", "Taï", "Thaùi", "Traàn", "Trònh",
33    "Toân", "TröÎng", "Phaïm", "Voõ", "Vuõ", "VöÎng",                     // thiếu "Toáng" (Tống)
34    //---- TCVN3 code ----
35    "Bïi", "§Μm", "§Μo", "D­¬Ng", "§Ç", "§Oµn", "§Æng", "§Inh",
36    "®Μm", "®Μo", "®Ç", "®Oµn", "®Æng", "®Inh",
37    "Hµ", "HÃ¥", "Hoµng", "Huúnh", "Kiòu", "KhÊng", "Lª", "L­U",
38    "L­¬Ng", "NguyÃŽn", "Ng«", "T¹", "Thži", "Trçn", "Trßnh",              // thiếu "LÜ" (LÜ)
39    "T«N", "Tr­¬Ng", "Ph¹M", "Vâ", "V­¬Ng");                              // thiếu "TÚng" (Tống) và "Vò" (VÅ©)
40    if (in_array($cousin, $surnamesVietcode)) {$error = 'Please disable the Viet Typing program and input again'; return false;}
41
42    for ($i = 0; $i < $count; $i++){
43      if ($names[$i] == '') continue;
44      if ($i == 0) $fullname = $names[$i] ;
45      else $fullname .= ' '.$names[$i];
46    }
47
48    return true;
49  }
50}
Note: See TracBrowser for help on using the repository browser.