allow obfuscated settings
This commit is contained in:
parent
e1ad25ef02
commit
825c546991
|
@ -778,4 +778,47 @@ function formatLDAPTimestamp($time) {
|
|||
' ' . substr($time, 8, 2) . ':' . substr($time, 10, 2) . ':' . substr($time, 12, 2) . ' GMT';
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple function to obfuscate strings.
|
||||
*
|
||||
* @param String $text text to obfuscate
|
||||
*/
|
||||
function obfuscateText($text) {
|
||||
if (($text == null) || ($text == '')) {
|
||||
return $text;
|
||||
}
|
||||
return str_rot13(base64_encode('LAM_OBFUSCATE:'.$text));
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple function to deobfuscate strings.
|
||||
*
|
||||
* @param String $text text to deobfuscate
|
||||
*/
|
||||
function deobfuscateText($text) {
|
||||
if (($text == null) || ($text == '')) {
|
||||
return $text;
|
||||
}
|
||||
return str_replace('LAM_OBFUSCATE:', '', base64_decode(str_rot13($text)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given text is obfuscated.
|
||||
*
|
||||
* @param String $text text to check
|
||||
* @return boolean obfuscated or not
|
||||
*/
|
||||
function isObfuscatedText($text) {
|
||||
if (($text == null) || ($text == '')) {
|
||||
return false;
|
||||
}
|
||||
$deob = base64_decode(str_rot13($text));
|
||||
if (strpos($deob, 'LAM_OBFUSCATE:') === 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -349,6 +349,8 @@ class htmlInputField extends htmlElement {
|
|||
private $isPassword = false;
|
||||
/** enabled or disabled */
|
||||
private $isEnabled = true;
|
||||
/** indicates that the value should be saved in obfuscated form */
|
||||
private $obfuscate = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -357,6 +359,9 @@ class htmlInputField extends htmlElement {
|
|||
* @param String $fieldValue value of input field (optional)
|
||||
*/
|
||||
function __construct($fieldName, $fieldValue = null, $fieldSize = null) {
|
||||
if (isObfuscatedText($fieldValue)) {
|
||||
$fieldValue = deobfuscateText($fieldValue);
|
||||
}
|
||||
$this->fieldName = htmlspecialchars($fieldName);
|
||||
$this->fieldValue = htmlspecialchars($fieldValue);
|
||||
if ($fieldSize != null) {
|
||||
|
@ -377,7 +382,12 @@ class htmlInputField extends htmlElement {
|
|||
*/
|
||||
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
|
||||
if (isset($values[$this->fieldName])) {
|
||||
$this->fieldValue = $values[$this->fieldName][0];
|
||||
if (isObfuscatedText($values[$this->fieldName][0])) {
|
||||
$this->fieldValue = deobfuscateText($values[$this->fieldName][0]);
|
||||
}
|
||||
else {
|
||||
$this->fieldValue = $values[$this->fieldName][0];
|
||||
}
|
||||
}
|
||||
// print input field
|
||||
$name = ' name="' . $this->fieldName . '"';
|
||||
|
@ -401,7 +411,12 @@ class htmlInputField extends htmlElement {
|
|||
$disabled = ' disabled';
|
||||
}
|
||||
echo '<input type="' . $inputType . '"' . $name . $value . $maxLength . $size . $fieldTabIndex . $disabled . '>';
|
||||
return array($this->fieldName => 'text');
|
||||
if ($this->obfuscate) {
|
||||
return array($this->fieldName => 'text_obfuscated');
|
||||
}
|
||||
else {
|
||||
return array($this->fieldName => 'text');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -440,6 +455,15 @@ class htmlInputField extends htmlElement {
|
|||
$this->isEnabled = $isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies if the value should be saved in obfuscated form (e.g. self service profile).
|
||||
*
|
||||
* @param boolean $obfuscate obfuscate value
|
||||
*/
|
||||
public function setObfuscate($obfuscate) {
|
||||
$this->obfuscate = $obfuscate;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue