ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilRobotSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
25{
26 private bool $open_robots = false;
28 private static ?self $instance = null;
29
33 private function __construct()
34 {
35 global $DIC;
36
37 $this->settings = $DIC->settings();
38 $this->read();
39 }
40
44 public static function getInstance(): ?\ilRobotSettings
45 {
46 if (!self::$instance instanceof ilRobotSettings) {
47 self::$instance = new self();
48 }
49 return self::$instance;
50 }
51
55 public function robotSupportEnabled(): bool
56 {
57 return $this->open_robots;
58 }
59
64 private function read(): void
65 {
66 $this->open_robots = (bool) $this->settings->get('open_google', null);
67 }
68
73 public function checkRewrite(): bool
74 {
75 if (!function_exists('apache_lookup_uri')) {
76 return true;
77 }
78
79 $url = ILIAS_HTTP_PATH . '/goto_' . CLIENT_ID . '_root_1.html';
80 $status_info = @apache_lookup_uri($url);
81
82 // fallback for php as cgi (and available remote fopen)
83 if ($status_info === false && ini_get('allow_url_fopen')) {
84 // fopen respects HTTP error codes
85 $fp = @fopen($url, 'r');
86 if ($fp) {
87 fclose($fp);
88 return true;
89 }
90 return false;
91 }
92
93 return $status_info->status == 200;
94 }
95}
robotSupportEnabled()
Check if client is open for robots.
checkRewrite()
Indirect Check of allow override @access public.
read()
Read settings @access private.
__construct()
Private constructor => use getInstance.
static getInstance()
get singleton instance
ILIAS Setting Class.
const CLIENT_ID
Definition: constants.php:41
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68