diff --git a/include/functions.inc b/include/functions.inc
index e46df87dc7a07c11b7368d555570b5ee383e7344..cebbb4a3f9c3e82321775d45d97a90c015869d42 100644 (file)
--- a/include/functions.inc
+++ b/include/functions.inc
}
-function prepare4mailbody($string)
-{
- $string = html_entity_decode($string);
-
- $from = array(
- "/%/",
- "/ /",
- "/\n/",
- "/\r/",
- "/!/",
- "/#/",
- "/\*/",
- "/\//",
- "/</",
- "/>/",
- "/\?/",
- "/\&/",
- "/\(/",
- "/\)/",
- "/\"/");
-
- $to = array(
- "%25",
- "%20",
- "%0A",
- "%0D",
- "%21",
- "%23",
- "%2A",
- "%2F",
- "%3C",
- "%3E",
- "%3F",
- "%38",
- "%28",
- "%29",
- "%22");
-
- $string = preg_replace($from,$to,$string);
-
- return($string);
-}
function mac2company($mac)
}
+/* Add a given objectClass to an attrs entry */
+function add_objectClass($classes, &$attrs)
+{
+ if (is_array($classes)){
+ $list= $classes;
+ } else {
+ $list= array($classes);
+ }
+
+ foreach ($list as $class){
+ $attrs['objectClass'][]= $class;
+ }
+}
+
+
+/* Removes a given objectClass from the attrs entry */
+function remove_objectClass($classes, &$attrs)
+{
+ if (isset($attrs['objectClass'])){
+ /* Array? */
+ if (is_array($classes)){
+ $list= $classes;
+ } else {
+ $list= array($classes);
+ }
+
+ $tmp= array();
+ foreach ($attrs['objectClass'] as $oc) {
+ foreach ($list as $class){
+ if ($oc != $class){
+ $tmp[]= $oc;
+ }
+ }
+ }
+ $attrs['objectClass']= $tmp;
+ }
+}
+
+
+function cred_encrypt($input, $password) {
+
+ $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
+ $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);
+
+ return bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $password, $input, MCRYPT_MODE_ECB, $iv));
+}
+
+
+function cred_decrypt($input,$password) {
+ $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
+ $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);
+
+ return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $password, pack("H*", $input), MCRYPT_MODE_ECB, $iv);
+}
+
+
/* Returns contents of the given POST variable and check magic quotes settings */
function get_post($name)
{