Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Verifies web crawler (search engine) access
  19   *
  20   * Not combined with disabled guest access because attackers might gain guest
  21   * access by modifying browser signature.
  22   *
  23   * @package    core
  24   * @category   check
  25   * @copyright  2020 Brendan Heywood <brendan@catalyst-au.net>
  26   * @copyright  2008 petr Skoda
  27   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  28   */
  29  
  30  namespace core\check\security;
  31  
  32  defined('MOODLE_INTERNAL') || die();
  33  
  34  use core\check\check;
  35  use core\check\result;
  36  
  37  /**
  38   * Verifies web crawler (search engine) access
  39   *
  40   * Not combined with disabled guest access because attackers might gain guest
  41   * access by modifying browser signature.
  42   *
  43   * @copyright  2020 Brendan Heywood <brendan@catalyst-au.net>
  44   * @copyright  2008 petr Skoda
  45   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  46   */
  47  class crawlers extends check {
  48  
  49      /**
  50       * Get the short check name
  51       *
  52       * @return string
  53       */
  54      public function get_name(): string {
  55          return get_string('check_crawlers_name', 'report_security');
  56      }
  57  
  58      /**
  59       * A link to a place to action this
  60       *
  61       * @return action_link|null
  62       */
  63      public function get_action_link(): ?\action_link {
  64          return new \action_link(
  65              new \moodle_url('/admin/settings.php?section=sitepolicies#admin-opentowebcrawlers'),
  66              get_string('sitepolicies', 'admin'));
  67      }
  68  
  69      /**
  70       * Return result
  71       * @return result
  72       */
  73      public function get_result(): result {
  74          global $CFG;
  75          $details = get_string('check_crawlers_details', 'report_security');
  76          if (empty($CFG->opentowebcrawlers)) {
  77              $status = result::OK;
  78              $summary = get_string('check_crawlers_ok', 'report_security');
  79          } else if (!empty($CFG->guestloginbutton)) {
  80              $status = result::INFO;
  81              $summary = get_string('check_crawlers_info', 'report_security');
  82          } else {
  83              $status = result::ERROR;
  84              $summary = get_string('check_crawlers_error', 'report_security');
  85          }
  86          return new result($status, $summary, $details);
  87      }
  88  }
  89