*/ class LSformRule_gpg_pub_key extends LSformRule { /** * Validate SSH public key value * * @param string $value The value to validate * @param array $options Validation options * @param LSformElement &$formElement The related formElement object * * @return boolean true if the value is valide, false if not */ public static function validate($value, $options, &$formElement) { if (!function_exists('gnupg_init')) { LSerror :: addErrorCode('LSformRule_gpg_pub_key_01'); return false; } // @phpstan-ignore-next-line $res = gnupg_init(["home_dir" => LS_TMP_DIR_PATH]); $info = gnupg_import($res, $value); // @phpstan-ignore-next-line return is_array($info) && ($info['imported'] + $info['unchanged']) == 1 && $info['fingerprint']; } } /* * Error Codes */ LSerror :: defineError('LSformRule_gpg_pub_key_01', ___("LSformRule_gpg_pub_key: PHP GnuPG extension is missing, can't validate value.") );