Permissions.php 991 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Grav\Plugin\Problems;
  3. use Grav\Plugin\Problems\Base\Problem;
  4. /**
  5. * Class Permissions
  6. * @package Grav\Plugin\Problems
  7. */
  8. class Permissions extends Problem
  9. {
  10. public function __construct()
  11. {
  12. $this->id = 'Permissions Setup';
  13. $this->class = get_class($this);
  14. $this->order = -1;
  15. $this->level = Problem::LEVEL_WARNING;
  16. $this->status = false;
  17. $this->help = 'https://learn.getgrav.org/troubleshooting/permissions';
  18. }
  19. /**
  20. * @return $this
  21. */
  22. public function process()
  23. {
  24. umask($umask = umask(022));
  25. $msg = 'Your default file umask is <strong>%s</strong> which %s';
  26. if (($umask & 2) !== 2) {
  27. $this->msg = sprintf($msg, decoct($umask), 'is potentially dangerous');
  28. $this->status = false;
  29. } else {
  30. $this->msg = sprintf($msg, decoct($umask), 'looks good!');
  31. $this->status = true;
  32. }
  33. return $this;
  34. }
  35. }