summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorStephen Beaver <sbeaver@netgate.com>2015-12-28 14:31:51 -0500
committerStephen Beaver <sbeaver@netgate.com>2015-12-28 14:33:26 -0500
commit5ea90990e6ebcdbeb78fadf8b88aedef66428c66 (patch)
treee3437d140c9e44224273c86f614bef8019c0576e /src/usr
parentf1b7a0b1bc66ead820f5d8301ad7e9b2199cfb2c (diff)
downloadpfsense-5ea90990e6ebcdbeb78fadf8b88aedef66428c66.zip
pfsense-5ea90990e6ebcdbeb78fadf8b88aedef66428c66.tar.gz
Experimental: Fixed #5693
Added new functionality to PHP classes, and used it ONLY in system_advanced_notifications.php -> smtp password
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/local/www/classes/Form/Input.class.php16
-rw-r--r--src/usr/local/www/classes/Form/Section.class.php18
-rw-r--r--src/usr/local/www/system_advanced_notifications.php22
3 files changed, 50 insertions, 6 deletions
diff --git a/src/usr/local/www/classes/Form/Input.class.php b/src/usr/local/www/classes/Form/Input.class.php
index 9482c2b..c6110f7 100644
--- a/src/usr/local/www/classes/Form/Input.class.php
+++ b/src/usr/local/www/classes/Form/Input.class.php
@@ -80,6 +80,22 @@ class Form_Input extends Form_Element
return $this->_attributes['name'];
}
+ public function setName($nm)
+ {
+ $this->_attributes['name'] = $nm;
+ $this->_attributes['id'] = $nm;
+ }
+
+ public function setValue($val)
+ {
+ $this->_attributes['value'] = $val;
+ }
+
+ public function setType($tp)
+ {
+ $this->_attributes['type'] = $tp;
+ }
+
public function getId()
{
return $this->_attributes['id'];
diff --git a/src/usr/local/www/classes/Form/Section.class.php b/src/usr/local/www/classes/Form/Section.class.php
index 1d4c67f..b0a441a 100644
--- a/src/usr/local/www/classes/Form/Section.class.php
+++ b/src/usr/local/www/classes/Form/Section.class.php
@@ -68,6 +68,24 @@ class Form_Section extends Form_Element
return $input;
}
+ // Shortcut, adds a group with a password and a confirm password field.
+ // The confirm password element is created by apprnding "_confirm" to the name supplied
+ // The value is overwritten with a default pattern (So the user cannot see it)
+ public function addPassword(Form_Input $input)
+ {
+ $group = new Form_Group($input->getTitle());
+ $input->setValue(DMYPWD);
+ $input->setType("password");
+ $group->add($input);
+ $confirm = clone $input;
+ $confirm->setName($confirm->getName() . "_confirm");
+ $confirm->setHelp("Confirm password");
+ $group->add($confirm);
+ $this->add($group);
+
+ return $input;
+ }
+
public function __toString()
{
$element = parent::__toString();
diff --git a/src/usr/local/www/system_advanced_notifications.php b/src/usr/local/www/system_advanced_notifications.php
index 0c5ed03..7bd5ee8 100644
--- a/src/usr/local/www/system_advanced_notifications.php
+++ b/src/usr/local/www/system_advanced_notifications.php
@@ -153,7 +153,15 @@ if ($_POST) {
$config['notifications']['smtp']['notifyemailaddress'] = $_POST['smtpnotifyemailaddress'];
$config['notifications']['smtp']['username'] = $_POST['smtpusername'];
- $config['notifications']['smtp']['password'] = $_POST['smtppassword'];
+
+ if ($_POST['smtppassword'] != DMYPWD) {
+ if ($_POST['smtppassword'] == $_POST['smtppassword_confirm']) {
+ $config['notifications']['smtp']['password'] = $_POST['smtppassword'];
+ } else {
+ $input_errors[] = gettext("SMTP passwords must match");
+ }
+ }
+
$config['notifications']['smtp']['authentication_mechanism'] = $_POST['smtpauthmech'];
$config['notifications']['smtp']['fromaddress'] = $_POST['smtpfromaddress'];
@@ -170,10 +178,12 @@ if ($_POST) {
unset($config['system']['disablebeep']);
}
- write_config();
+ if (!$input_errors) {
+ write_config();
- pfSenseHeader("system_advanced_notifications.php");
- return;
+ pfSenseHeader("system_advanced_notifications.php");
+ return;
+ }
}
@@ -337,12 +347,12 @@ $section->addInput(new Form_Input(
['autocomplete' => 'off']
))->setHelp('Enter the e-mail address username for SMTP authentication.');
-$section->addInput(new Form_Input(
+$section->addPassword(new Form_Input(
'smtppassword',
'Notification E-Mail auth password',
'password',
$pconfig['smtppassword']
-))->setHelp('Enter the e-mail address password for SMTP authentication.');
+))->setHelp('Enter the e-mail account password for SMTP authentication.');
$section->addInput(new Form_Select(
'smtpauthmech',
OpenPOWER on IntegriCloud