summaryrefslogtreecommitdiff
path: root/inc/confutils.php
diff options
context:
space:
mode:
authorChris Smith <chris.eureka@jalakai.co.uk>2009-01-19 17:48:09 +0100
committerChris Smith <chris.eureka@jalakai.co.uk>2009-01-19 17:48:09 +0100
commit3994772a3d7c09e3152591d2e20e85b389acc4ac (patch)
tree1219f2b5749834b53542e3f3befbc1a4907cd1aa /inc/confutils.php
parent32ee58308d5bb11c322ca6bfc3b56e66364230af (diff)
downloadrpg-3994772a3d7c09e3152591d2e20e85b389acc4ac.tar.gz
rpg-3994772a3d7c09e3152591d2e20e85b389acc4ac.tar.bz2
FS#1517, obscure passwords in config files
This patch extends the config 'password' class to support a "_code" parameter darcs-hash:20090119164809-f07c6-c136b559772610539bccb9e9c0191f6a973216ad.gz
Diffstat (limited to 'inc/confutils.php')
-rw-r--r--inc/confutils.php31
1 files changed, 30 insertions, 1 deletions
diff --git a/inc/confutils.php b/inc/confutils.php
index 5b48e97dd..2099ba949 100644
--- a/inc/confutils.php
+++ b/inc/confutils.php
@@ -238,5 +238,34 @@ function useHeading($linktype) {
return (!empty($useHeading[$linktype]));
}
-
+/**
+ * obscure config data so information isn't plain text
+ *
+ * @param string $str data to be encoded
+ * @param string $code encoding method, values: plain, base64, uuencode.
+ * @return string the encoded value
+ */
+function conf_encodeString($str,$code) {
+ switch ($code) {
+ case 'base64' : return '<b>'.base64_encode($str);
+ case 'uuencode' : return '<u>'.convert_uuencode($str);
+ case 'plain':
+ default:
+ return $str;
+ }
+}
+/**
+ * return obscured data as plain text
+ *
+ * @param string $str encoded data
+ * @return string plain text
+ */
+function conf_decodeString($str) {
+ switch (substr($str,0,3)) {
+ case '<b>' : return base64_decode(substr($str,3));
+ case '<u>' : return convert_uudecode(substr($str,3));
+ default: // not encode (or unknown)
+ return $str;
+ }
+}
//Setup VIM: ex: et ts=2 enc=utf-8 :