ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilRobotSettings.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
33 {
34  private $open_robots = false;
35  private $settings = null;
36 
37  private static $instance = null;
45  private function __construct()
46  {
47  global $DIC;
48 
49  $ilSetting = $DIC['ilSetting'];
50 
51  $this->settings = $ilSetting;
52  $this->read();
53  }
54 
63  public static function _getInstance()
64  {
65  if (isset(self::$instance) and self::$instance) {
66  return self::$instance;
67  } else {
68  return self::$instance = new ilRobotSettings();
69  }
70  }
71 
78  public function robotSupportEnabled()
79  {
80  return (bool) $this->open_robots;
81  }
82 
89  private function read()
90  {
91  $this->open_robots = (bool) $this->settings->get('open_google', false);
92  }
93 
94 
101  public function checkRewrite()
102  {
103  if (!function_exists('apache_lookup_uri')) {
104  return true;
105  }
106 
107  $url = ILIAS_HTTP_PATH . '/goto_' . CLIENT_ID . '_root_1.html';
108  $status_info = @apache_lookup_uri($url);
109 
110  // fallback for php as cgi (and available remote fopen)
111  if ($status_info === false && ini_get('allow_url_fopen')) {
112  // fopen respects HTTP error codes
113  $fp = @fopen($url, 'r');
114  if ($fp) {
115  fclose($fp);
116  return true;
117  }
118  return false;
119  }
120 
121  return $status_info->status == 200;
122  }
123 }
settings()
Definition: settings.php:2
checkRewrite()
Indirect Check of allow override.
global $DIC
Definition: saml.php:7
static _getInstance()
Get instance.
robotSupportEnabled()
Check if client is open for robots.
global $ilSetting
Definition: privfeed.php:17
$url
__construct()
Private constructor => use getInstance.
read()
Read settings.