ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilRPCServerSettings.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 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
24
34define("RPC_SERVER_PATH", "/RPC2");
35define("RPC_SERVER_ALIVE", true);
36
38{
39 private static $instance = null;
40
41
42 public $rpc_host = '';
43 public $rpc_port = '';
44
45 public $log = null;
46 public $db = null;
47 public $err = null;
48
49 public $settings_obj = null;
50
51
56 private function __construct()
57 {
58 global $ilLog,$ilDB,$ilError,$ilias;
59
60 $this->log =&$ilLog;
61 $this->db =&$ilDB;
62 $this->err =&$ilError;
63 $this->ilias =&$ilias;
64 }
65
70 public static function getInstance()
71 {
72 if (self::$instance) {
73 return self::$instance;
74 }
75 return self::$instance = new ilRPCServerSettings();
76 }
77
82 public function isEnabled()
83 {
84 return strlen($this->getHost()) and strlen($this->getPort());
85 }
86
87 public function getServerUrl()
88 {
89 return 'http://' . $this->getHost() . ':' . $this->getPort() . '/' . RPC_SERVER_PATH;
90 }
91
92
93 public function getHost()
94 {
95 if (strlen($this->rpc_host)) {
96 return $this->rpc_host;
97 }
98 return $this->rpc_host = $this->ilias->getSetting('rpc_server_host');
99 }
100 public function setHost($a_host)
101 {
102 $this->rpc_host = $a_host;
103 }
104 public function getPort()
105 {
106 if (strlen($this->rpc_port)) {
107 return $this->rpc_port;
108 }
109 return $this->rpc_port = $this->ilias->getSetting('rpc_server_port');
110 }
111 public function setPort($a_port)
112 {
113 $this->rpc_port = $a_port;
114 }
115 public function getPath()
116 {
117 return RPC_SERVER_PATH;
118 }
119
120 public function update()
121 {
122 $this->ilias->setSetting('rpc_server_host', $this->getHost());
123 $this->ilias->setSetting('rpc_server_port', $this->getPort());
124
125 return true;
126 }
127
128 public function pingServer()
129 {
130 include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
131
132 try {
133 ilRpcClientFactory::factory('RPCebug')->ping();
134 return true;
135 } catch (Exception $e) {
136 $ilLog->write(__METHOD__ . ': ' . $e->getMessage());
137 return false;
138 }
139 }
140}
An exception for terminatinating execution or to throw for unit testing.
const RPC_SERVER_PATH
isEnabled()
Returns true if server ip and port are set.
static getInstance()
Get singelton instance.
__construct()
Singleton contructor.
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB