| 1: | <?php | 
| 2: |  | 
| 3: |  | 
| 4: |  | 
| 5: |  | 
| 6: |  | 
| 7: |  | 
| 8: | namespace Aurora\System\Utils; | 
| 9: |  | 
| 10: |  | 
| 11: |  | 
| 12: |  | 
| 13: |  | 
| 14: |  | 
| 15: | class Validate | 
| 16: | { | 
| 17: |  | 
| 18: |  | 
| 19: |  | 
| 20: |  | 
| 21: | public static function GetError($sFuncName) | 
| 22: | { | 
| 23: | switch ($sFuncName) { | 
| 24: | case 'Port': | 
| 25: | return 'Required valid port.'; | 
| 26: | case 'IsEmpty': | 
| 27: | return 'Required fields cannot be empty.'; | 
| 28: | } | 
| 29: |  | 
| 30: | return 'Error'; | 
| 31: | } | 
| 32: |  | 
| 33: |  | 
| 34: |  | 
| 35: |  | 
| 36: |  | 
| 37: | public static function IsValidLogin($mValue) | 
| 38: | { | 
| 39: | return preg_match('/^[a-zA-Z0-9@\-_\.]+$/', $mValue); | 
| 40: | } | 
| 41: |  | 
| 42: |  | 
| 43: |  | 
| 44: |  | 
| 45: |  | 
| 46: | public static function IsEmpty($mValue) | 
| 47: | { | 
| 48: | return !is_string($mValue) || 0 === strlen($mValue); | 
| 49: | } | 
| 50: |  | 
| 51: |  | 
| 52: |  | 
| 53: |  | 
| 54: |  | 
| 55: | public static function Port($mValue) | 
| 56: | { | 
| 57: | $bResult = false; | 
| 58: | if (0 < strlen((string) $mValue) && is_numeric($mValue)) { | 
| 59: | $iPort = (int) $mValue; | 
| 60: | if (0 < $iPort && $iPort < 65355) { | 
| 61: | $bResult = true; | 
| 62: | } | 
| 63: | } | 
| 64: | return $bResult; | 
| 65: | } | 
| 66: |  | 
| 67: |  | 
| 68: |  | 
| 69: |  | 
| 70: |  | 
| 71: | public static function IsValidPassword($mValue) | 
| 72: | { | 
| 73: | $bResult = true; | 
| 74: | $oSettings = & \Aurora\System\Api::GetSettings(); | 
| 75: | $iPasswordMinLength = $oSettings->PasswordMinLength; | 
| 76: | $bPasswordMustBeComplex = $oSettings->PasswordMustBeComplex; | 
| 77: |  | 
| 78: | if (strlen($mValue) < $iPasswordMinLength) { | 
| 79: | $bResult = false; | 
| 80: | } elseif ($bPasswordMustBeComplex && (!preg_match('([0-9])', $mValue) || !preg_match('([!,%,&,@,#,$,^,*,?,_,~])', $mValue))) { | 
| 81: | $bResult = false; | 
| 82: | } | 
| 83: |  | 
| 84: | return $bResult; | 
| 85: | } | 
| 86: | } | 
| 87: |  |