summaryrefslogtreecommitdiff
path: root/inc
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
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')
-rw-r--r--inc/HTTPClient.php2
-rw-r--r--inc/confutils.php31
-rw-r--r--inc/io.php2
3 files changed, 32 insertions, 3 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php
index 71844b847..1184aebee 100644
--- a/inc/HTTPClient.php
+++ b/inc/HTTPClient.php
@@ -32,7 +32,7 @@ class DokuHTTPClient extends HTTPClient {
$this->proxy_host = $conf['proxy']['host'];
$this->proxy_port = $conf['proxy']['port'];
$this->proxy_user = $conf['proxy']['user'];
- $this->proxy_pass = $conf['proxy']['pass'];
+ $this->proxy_pass = conf_decodeString($conf['proxy']['pass']);
$this->proxy_ssl = $conf['proxy']['ssl'];
}
}
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 :
diff --git a/inc/io.php b/inc/io.php
index 1c0e86104..2eb94db0c 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -424,7 +424,7 @@ function io_mkdir_ftp($dir){
return false;
}
- if(!@ftp_login($conn, $conf['ftp']['user'], $conf['ftp']['pass'])){
+ if(!@ftp_login($conn, $conf['ftp']['user'], conf_decodeString($conf['ftp']['pass']))){
msg("FTP login failed",-1);
return false;
}