Code

Updated gosaServerDeamon
[gosa.git] / gosa-core / include / class_gosaSupportDaemon.inc
index 14f84f7c80c33d49429093305865911d1926709a..2eba2f8eb82f6937b7ccc5bd7c56be35140b8c3b 100644 (file)
@@ -39,10 +39,11 @@ class gosaSupportDaemon
   public function connect()
   {
     $this->o_sock = new Socket_Client($this->s_host,$this->i_port,TRUE,$this->f_timeout);
-    $this->o_sock->setEncryptionKey($this->s_encryption_key); 
     if($this->o_sock->connected()){ 
+      $this->o_sock->setEncryptionKey($this->s_encryption_key); 
       $this->is_connected = TRUE;
     }else{
+      $this->error = $this->o_sock->get_error();
       $this->is_connected = FALSE;
     }
   }
@@ -99,12 +100,17 @@ class gosaSupportDaemon
       $this->o_sock->write($xml_msg);
       $str = trim($this->o_sock->read());
       $entries = $this->xml_to_array($str);
-      if(!isset($entries['XML'])){
-        $this->set_error("Couldn't parse xml.");
+
+      if(!array_key_exists("XML",$entries)){
+        $this->set_error("!!!Couldn't parse xml.");
         $this->disconnect();
         return;
       }else{
-        $ret = array_values($entries['XML']); 
+        if(!is_array($entries['XML'])) {
+          $ret = array();
+        }else{
+          $ret = $entries['XML']; 
+        }
       }
       return($ret);
     }
@@ -244,7 +250,7 @@ class gosaSupportDaemon
             $start_level++;
           }
           $php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
-          eval($php_stmt);
+          @eval($php_stmt);
         }
       }
     }
@@ -259,6 +265,8 @@ class gosaSupportDaemon
    */
   public function update_entry($id,$entry)
   {
+    $this->b_error = FALSE;
+    $this->s_error = "";
     if(!is_numeric($id)){
       trigger_error("Requires an integer value as ID parameter.");
       return;
@@ -274,9 +282,6 @@ class gosaSupportDaemon
       $attr.="<".strtolower($name).">".$entry."</".strtolower($name).">\n";
     }
 
-    $this->b_error = FALSE;
-    $this->s_error = "";
-
     $xml_msg = "<xml> 
                   <header>gosa_update_status_jobdb_entry</header>
                   <where>
@@ -288,7 +293,6 @@ class gosaSupportDaemon
                 </xml>";
     $this->connect();
     if($this->is_connected){
-      echo $xml_msg;
       $this->o_sock->write($xml_msg);
       $str      = trim($this->o_sock->read());
       $entries = $this->xml_to_array($str);