ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
34 define("RPC_SERVER_PATH","/RPC2");
35 define("RPC_SERVER_ALIVE",true);
36 
38 {
39  private static $instance = null;
40 
41 
42  var $rpc_host = '';
43  var $rpc_port = '';
44 
45  var $log = null;
46  var $db = null;
47  var $err = null;
48 
49  var $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  {
74  return self::$instance;
75  }
76  return self::$instance = new ilRPCServerSettings();
77  }
78 
83  public function isEnabled()
84  {
85  return strlen($this->getHost()) and strlen($this->getPort());
86  }
87 
88  public function getServerUrl()
89  {
90  return 'http://'.$this->getHost().':'.$this->getPort().'/'.RPC_SERVER_PATH;
91  }
92 
93 
94  function getHost()
95  {
96  if(strlen($this->rpc_host))
97  {
98  return $this->rpc_host;
99  }
100  return $this->rpc_host = $this->ilias->getSetting('rpc_server_host');
101  }
102  function setHost($a_host)
103  {
104  $this->rpc_host = $a_host;
105  }
106  function getPort()
107  {
108  if(strlen($this->rpc_port))
109  {
110  return $this->rpc_port;
111  }
112  return $this->rpc_port = $this->ilias->getSetting('rpc_server_port');
113  }
114  function setPort($a_port)
115  {
116  $this->rpc_port = $a_port;
117  }
118  function getPath()
119  {
120  return RPC_SERVER_PATH;
121  }
122 
123  function update()
124  {
125  $this->ilias->setSetting('rpc_server_host',$this->getHost());
126  $this->ilias->setSetting('rpc_server_port',$this->getPort());
127 
128  return true;
129  }
130 
131  function pingServer()
132  {
133  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
134 
135  try
136  {
137  ilRpcClientFactory::factory('RPCebug')->ping();
138  return true;
139  }
140  catch(Exception $e)
141  {
142  $ilLog->write(__METHOD__.': '.$e->getMessage());
143  return false;
144  }
145  }
146 }
147 ?>