Code

Ensure we either call the plugins constructor or manually set the initTime variable...
[gosa.git] / gosa-core / include / class_jsonRPC.inc
index 247f05411bd07fd1255bec9b35d1c61ab17516ba..d9084f61c0913dba6c4bbcefb8668f69ddc754dd 100644 (file)
@@ -21,6 +21,10 @@ class jsonRPC {
         $user   =  $this->config->get_cfg_value('core','gosaRpcUser');
         $passwd =  $this->config->get_cfg_value('core','gosaRpcPassword');
 
+        DEBUG (DEBUG_RPC, __LINE__, __FUNCTION__, __FILE__,bold($url), "Initiated RPC "); 
+        DEBUG (DEBUG_RPC, __LINE__, __FUNCTION__, __FILE__,bold($user), "RPC user: "); 
+        DEBUG (DEBUG_RPC, __LINE__, __FUNCTION__, __FILE__,bold($passwd),"RPC password: "); 
+
         // Init Curl handler
         $this->curlHandler = curl_init($url);
 
@@ -30,12 +34,12 @@ class jsonRPC {
         curl_setopt($this->curlHandler, CURLOPT_COOKIEFILE, 'cookiefile.txt'); 
         curl_setopt($this->curlHandler, CURLOPT_POST , TRUE);
         curl_setopt($this->curlHandler, CURLOPT_RETURNTRANSFER , TRUE);
+        curl_setopt($this->curlHandler, CURLOPT_SSL_VERIFYPEER, TRUE);
         curl_setopt($this->curlHandler, CURLOPT_HTTPHEADER , array('Content-Type: application/json'));
 
         // Try to login 
         $this->login($user, $passwd);
        
-        DEBUG (DEBUG_RPC, __LINE__, __FUNCTION__, __FILE__,"RPC Login ".$this->get_error() , "Login"); 
     }
         
 
@@ -72,7 +76,16 @@ class jsonRPC {
              $this->__login();
         }
 
+        // Start request
+        DEBUG (DEBUG_RPC, __LINE__, __FUNCTION__, __FILE__,"{$method}", "Calling: "); 
         $response = $this->request($method,$params);
+        if($this->success()){
+            DEBUG (DEBUG_RPC, __LINE__, __FUNCTION__, __FILE__,
+                (is_array($response['result']))?$response['result']:bold($response['result']), "Result: "); 
+        }else{
+            DEBUG (DEBUG_RPC, __LINE__, __FUNCTION__, __FILE__,bold($this->get_error())."<br>".$response, "Result (FAILED): "); 
+        }
+
         return($response['result']);
     }
 
@@ -112,59 +125,59 @@ class jsonRPC {
     public static function getHttpStatusCodeMessage($code)
     {
         $codes  = array(
-                '100' =>_('Continue'),
-                '101' =>_('Switching Protocols'),
-                '102' =>_('Processing'),
-                '200' =>_('OK'),
-                '201' =>_('Created'),
-                '202' =>_('Accepted'),
-                '203' =>_('Non-Authoritative Information'),
-                '204' =>_('No Content'),
-                '205' =>_('Reset Content'),
-                '206' =>_('Partial Content'),
-                '207' =>_('Multi-Status'),
-                '300' =>_('Multiple Choice'),
-                '301' =>_('Moved Permanently'),
-                '302' =>_('Found'),
-                '303' =>_('See Other'),
-                '304' =>_('Not Modified'),
-                '305' =>_('Use Proxy'),
-                '306' =>_('(reserviert)'),
-                '307' =>_('Temporary Redirect'),
-                '400' =>_('Bad Request'),
-                '401' =>_('Unauthorized'),
-                '402' =>_('Payment Required'),
-                '403' =>_('Forbidden'),
-                '404' =>_('Not Found'),
-                '405' =>_('Method Not Allowed'),
-                '406' =>_('Not Acceptable'),
-                '407' =>_('Proxy Authentication Required'),
-                '408' =>_('Request Time-out'),
-                '409' =>_('Conflict'),
-                '410' =>_('Gone'),
-                '411' =>_('Length Required'),
-                '412' =>_('Precondition Failed'),
-                '413' =>_('Request Entity Too Large'),
-                '414' =>_('Request-URI Too Long'),
-                '415' =>_('Unsupported Media Type'),
-                '416' =>_('Requested range not satisfiable'),
-                '417' =>_('Expectation Failed'),
-                '421' =>_('There are too many connections from your internet address'),
-                '422' =>_('Unprocessable Entity'),
-                '423' =>_('Locked'),
-                '424' =>_('Failed Dependency'),
-                '425' =>_('Unordered Collection'),
-                '426' =>_('Upgrade Required'),
-                '500' =>_('Internal Server Error'),
-                '501' =>_('Not Implemented'),
-                '502' =>_('Bad Gateway'),
-                '503' =>_('Service Unavailable'),
-                '504' =>_('Gateway Time-out'),
-                '505' =>_('HTTP Version not supported'),
-                '506' =>_('Variant Also Negotiates'),
-                '507' =>_('Insufficient Storage'),
-                '509' =>_('Bandwidth Limit Exceeded'),
-                '510' =>_('Not Extended'));
+                '100' =>  'Continue',
+                '101' =>  'Switching Protocols',
+                '102' =>  'Processing',
+                '200' =>  'OK',
+                '201' =>  'Created',
+                '202' =>  'Accepted',
+                '203' =>  'Non-Authoritative Information',
+                '204' =>  'No Content',
+                '205' =>  'Reset Content',
+                '206' =>  'Partial Content',
+                '207' =>  'Multi-Status',
+                '300' =>  'Multiple Choice',
+                '301' =>  'Moved Permanently',
+                '302' =>  'Found',
+                '303' =>  'See Other',
+                '304' =>  'Not Modified',
+                '305' =>  'Use Proxy',
+                '306' =>  'reserved',
+                '307' =>  'Temporary Redirect',
+                '400' =>  'Bad Request',
+                '401' =>  'Unauthorized',
+                '402' =>  'Payment Required',
+                '403' =>  'Forbidden',
+                '404' =>  'Not Found',
+                '405' =>  'Method Not Allowed',
+                '406' =>  'Not Acceptable',
+                '407' =>  'Proxy Authentication Required',
+                '408' =>  'Request Time-out',
+                '409' =>  'Conflict',
+                '410' =>  'Gone',
+                '411' =>  'Length Required',
+                '412' =>  'Precondition Failed',
+                '413' =>  'Request Entity Too Large',
+                '414' =>  'Request-URI Too Long',
+                '415' =>  'Unsupported Media Type',
+                '416' =>  'Requested range not satisfiable',
+                '417' =>  'Expectation Failed',
+                '421' =>  'There are too many connections from your internet address',
+                '422' =>  'Unprocessable Entity',
+                '423' =>  'Locked',
+                '424' =>  'Failed Dependency',
+                '425' =>  'Unordered Collection',
+                '426' =>  'Upgrade Required',
+                '500' =>  'Internal Server Error',
+                '501' =>  'Not Implemented',
+                '502' =>  'Bad Gateway',
+                '503' =>  'Service Unavailable',
+                '504' =>  'Gateway Time-out',
+                '505' =>  'HTTP Version not supported',
+                '506' =>  'Variant Also Negotiates',
+                '507' =>  'Insufficient Storage',
+                '509' =>  'Bandwidth Limit Exceeded',
+                '510' =>  'Not Extended');
         return((isset($codes[$code]))? $codes[$code] : sprintf(_("Unknown HTTP status code '%s'!"), $code));
     }
 }