]> git.sur5r.net Git - contagged/blobdiff - inc/functions.php
fall back to english if local language string is missing
[contagged] / inc / functions.php
index 9166d31ca0c5e9f77ead7d923a32e21ce2ae7029..b0c28f67d6fff20ee4c09f4c3a3579d87c0e3252 100644 (file)
@@ -153,7 +153,7 @@ function set_session($user,$pass,$dn){
  * cookies; the string is stored inside the cache dir
  */
 function get_cookie_secret(){
-  $file = dirname(__FILE__).'/cache/.htcookiesecret.php';
+  $file = dirname(__FILE__).'/../cache/.htcookiesecret.php';
   if(@file_exists($file)){
     return md5(trim(file($file)));
   }
@@ -482,5 +482,28 @@ function utf8_encode_array(&$array) {
   }
 }
 
+/**
+ * Returns all the fields used in the template
+ *
+ * Returned fields are already decoded to LDAP internals
+ */
+function get_fields_from_template($tpl){
+    global $smarty;
+    global $FIELDS;
+    $tpl  = $smarty->template_dir.'/'.$tpl;
+    $data = @file_get_contents($tpl);
+    $matches = array();
+    preg_match_all('/\$entry\.(\w+)/',$data,$matches);
+    $matches = array_unique((array) $matches[1]);
+    $return  = array();
+    foreach($matches as $f){
+        if($FIELDS[$f]){
+            $return[] = $FIELDS[$f];
+        }elseif($FIELDS["_$f"]){
+            $return[] = $FIELDS["_$f"];
+        }
+    }
+    return $return;
+}
 
 ?>