ILIAS  release_8 Revision v8.24
class.ilRobotSettings.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
22{
23 private bool $open_robots = false;
25 private static ?self $instance = null;
26
30 private function __construct()
31 {
32 global $DIC;
33
34 $this->settings = $DIC->settings();
35 $this->read();
36 }
37
41 public static function getInstance(): ?\ilRobotSettings
42 {
43 if (!self::$instance instanceof ilRobotSettings) {
44 self::$instance = new self();
45 }
46 return self::$instance;
47 }
48
52 public function robotSupportEnabled(): bool
53 {
54 return $this->open_robots;
55 }
56
61 private function read(): void
62 {
63 $this->open_robots = (bool) $this->settings->get('open_google', null);
64 }
65
70 public function checkRewrite(): bool
71 {
72 if (!function_exists('apache_lookup_uri')) {
73 return true;
74 }
75
76 $url = ILIAS_HTTP_PATH . '/goto_' . CLIENT_ID . '_root_1.html';
77 $status_info = @apache_lookup_uri($url);
78
79 // fallback for php as cgi (and available remote fopen)
80 if ($status_info === false && ini_get('allow_url_fopen')) {
81 // fopen respects HTTP error codes
82 $fp = @fopen($url, 'r');
83 if ($fp) {
84 fclose($fp);
85 return true;
86 }
87 return false;
88 }
89
90 return $status_info->status == 200;
91 }
92}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CLIENT_ID
Definition: constants.php:41
global $DIC
Definition: feed.php:28
$url