Code

Updated socket client
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 28 Jan 2008 07:57:01 +0000 (07:57 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 28 Jan 2008 07:57:01 +0000 (07:57 +0000)
- Only try to encrypt if encryption is enabled.
Removed some echos
-From plugin.inc

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8612 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_plugin.inc
gosa-core/include/class_socketClient.inc

index 8eec579c440ece59c05ab39906138cf558687d76..06336cd2e231b19302ff5051666c03444a612edc 100644 (file)
@@ -314,9 +314,6 @@ class plugin
           $data = "";  
         }
         $this->$val= $data;
-        //echo "<font color='blue'>".$val."</font><br>";
-      }else{
-        //echo "<font color='red'>".$val."</font><br>";
       }
     }
   }
@@ -972,14 +969,11 @@ class plugin
               $tmp = $source[$var][$i];
             }
             $this->$var = $tmp;
-#            echo $var."=".$tmp."<br>";
           }else{
             $this->$var = $source[$var][0];
-#            echo $var."=".$source[$var][0]."<br>";
           }
         }else{
           $this->$var= $source[$var];
-#          echo $var."=".$source[$var]."<br>";
         }
       }
     }
@@ -1514,12 +1508,12 @@ class plugin
     if(isset($this->base) && isset($this->config->idepartments[$this->base])){
       $deps[$this->base] = $this->config->idepartments[$this->base];
     }else{
-      echo "No default base found. ".$this->base."<br> ";
+      trigger_error("No default base found in class ".get_class($this).". ".$this->base);
     }
-
     return($deps);
   }
 
+
   /* This function modifies object acls too, if an object is moved.
    *  $old_dn   specifies the actually used dn
    *  $new_dn   specifies the destiantion dn
@@ -1597,14 +1591,10 @@ class plugin
        /* Acls for this object must be adjusted */
        if($found){
 
-          if($output_changes){
-            echo "<font color='green'>".
-                  _("Changing ACL dn")."&nbsp;:&nbsp;<br>&nbsp;-"._("from")."&nbsp;<b>&nbsp;".
-                  $old_dn.
-                  "</b><br>&nbsp;-"._("to")."&nbsp;<b>".
-                  $new_dn.
-                  "</b></font><br>";
-          }
+          $debug_info=  _("Changing ACL dn")."&nbsp;:&nbsp;<br>&nbsp;-"._("from")."&nbsp;<b>&nbsp;".
+                  $old_dn."</b><br>&nbsp;-"._("to")."&nbsp;<b>".$new_dn."</b><br>";
+          @DEBUG (DEBUG_ACL, __LINE__, __FUNCTION__, __FILE__,$debug_info,"ACL");
+
           $update[$attrs['dn']] =array();
           foreach($acls as $acl){
             $update[$attrs['dn']]['gosaAclEntry'][] = $acl;
index fd71b01f09fb8bd2efc3c6b8cd52b32972074fb7..2812e26880eab4dd50b5455bc3d2eb204d4b7348 100644 (file)
@@ -11,6 +11,7 @@ class Socket_Client
   private $handle      = NULL;
   private $bytes_read = 0;
   private $error = "";
+  private $b_encrypt = FALSE;
 
   /* Crypto information */
   private $td= NULL;
@@ -36,31 +37,37 @@ class Socket_Client
     if(!function_exists("mcrypt_get_iv_size")){
       $this->error = _("The mcrypt module was not found. Please install php5-mcrypt.");
       $this->ckey = "";
-      return FALSE ;
+      $this->b_encrypt = FALSE;
     }
 
     if ($this->connected()){
       $this->ckey = substr(md5($key), 0, $this->ks);
-      return TRUE;
+      $this->b_encrypt = TRUE;
     }
 
-    return FALSE;
+    return($this->b_encrypt);
   }
 
 
   private function encrypt($data)
   {
-    mcrypt_generic_init($this->td, $this->ckey, $this->iv);
-    return base64_encode(mcrypt_generic($this->td, $data));
+    if($this->b_encrypt){
+      mcrypt_generic_init($this->td, $this->ckey, $this->iv);
+      $data = base64_encode(mcrypt_generic($this->td, $data));
+    }
+    return($data);
   }
 
 
   private function decrypt($data)
   {
     /* decrypt data */
-    $data = base64_decode($data);
-    mcrypt_generic_init($this->td, $this->ckey, $this->iv);
-    return mdecrypt_generic($this->td, $data);
+    if($this->b_encrypt){
+      $data = base64_decode($data);
+      mcrypt_generic_init($this->td, $this->ckey, $this->iv);
+      $data = mdecrypt_generic($this->td, $data);
+    }
+    return($data);
   }