common.php 936 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. if (!function_exists('get_account_verification_type')) {
  3. /**
  4. * 获取可用的账户验证方式
  5. * 用于:用户找回密码|用户注册
  6. * @return string[] email=电子邮件,mobile=手机短信验证
  7. */
  8. function get_account_verification_type(): array
  9. {
  10. $types = [];
  11. // 电子邮件,检查后台系统邮件配置是否全部填写
  12. $sysMailConfig = get_sys_config('', 'mail');
  13. $configured = true;
  14. foreach ($sysMailConfig as $item) {
  15. if (!$item) {
  16. $configured = false;
  17. }
  18. }
  19. if ($configured) {
  20. $types[] = 'email';
  21. }
  22. // 手机号,检查是否安装短信模块
  23. $sms = \ba\module\Server::getIni(path_transform(root_path() . 'modules/sms/'));
  24. if ($sms && $sms['state'] == 1) {
  25. $types[] = 'mobile';
  26. }
  27. return $types;
  28. }
  29. }