aboutsummaryrefslogtreecommitdiffstats
path: root/packages/autoconfigbackup
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2008-10-11 22:24:19 +0000
committerScott Ullrich <sullrich@pfsense.org>2008-10-11 22:24:19 +0000
commit1fa48d5b4cf02a83d22aca35ba74c136e69278b3 (patch)
tree7454cc29c519a0537575c3c3c062d63cd2dd1716 /packages/autoconfigbackup
parent85cf29693832d3e91e25abb43d852e6f7abb13be (diff)
downloadpfsense-packages-1fa48d5b4cf02a83d22aca35ba74c136e69278b3.tar.gz
pfsense-packages-1fa48d5b4cf02a83d22aca35ba74c136e69278b3.tar.bz2
pfsense-packages-1fa48d5b4cf02a83d22aca35ba74c136e69278b3.zip
Add test connection feature
Diffstat (limited to 'packages/autoconfigbackup')
-rw-r--r--packages/autoconfigbackup/autoconfigbackup.inc51
-rw-r--r--packages/autoconfigbackup/autoconfigbackup.xml6
2 files changed, 56 insertions, 1 deletions
diff --git a/packages/autoconfigbackup/autoconfigbackup.inc b/packages/autoconfigbackup/autoconfigbackup.inc
index 7cef7a12..0808009a 100644
--- a/packages/autoconfigbackup/autoconfigbackup.inc
+++ b/packages/autoconfigbackup/autoconfigbackup.inc
@@ -28,13 +28,62 @@
/* ensures patches match */
function custom_php_validation_command($post, $input_errors) {
- global $_POST;
+ global $_POST, $savemsg, $config;
+
if($post['password'] <> $post['passwordagain'])
$input_errors[] = "Sorry, the entered passwords do not match.";
if($post['crypto_password'] <> $post['crypto_password2'])
$input_errors[] = "Sorry, the entered encryption passwords do not match.";
+ if($post['testconnection']) {
+ $status = test_connection($post);
+ if(!$status)
+ $savemsg = "Connection to portal.pfsense.org was tested with no errors.";
+ else
+ $savemsg = "There was a problem connecting to portal.pfsense.org.";
+ }
+
+ // We do not need to store this value.
+ unset($_POST['testconnection']);
+}
+
+function test_connection($post) {
+ global $savemsg, $config;
+
+ // Seperator used during client / server communications
+ $oper_sep = "\|\|";
+
+ // Encryption password
+ $decrypt_password = $post['crypto_password'];
+
+ // Defined username
+ $username = $post['username'];
+
+ // Defined password
+ $password = $post['password'];
+
+ // Set hostname
+ $hostname = $config['system']['hostname'];
+
+ // URL to restore.php
+ $get_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/restore.php";
+
+ // Populate available backups
+ $curl_session = curl_init();
+ curl_setopt($curl_session, CURLOPT_URL, $get_url);
+ curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt($curl_session, CURLOPT_POST, 1);
+ curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showbackups&hostname={$hostname}");
+ $data = curl_exec($curl_session);
+
+ if (curl_errno($curl_session))
+ return("An error occurred " . curl_error($curl_session));
+ else
+ curl_close($curl_session);
+
+ return;
}
?> \ No newline at end of file
diff --git a/packages/autoconfigbackup/autoconfigbackup.xml b/packages/autoconfigbackup/autoconfigbackup.xml
index 8155bc10..840ccd85 100644
--- a/packages/autoconfigbackup/autoconfigbackup.xml
+++ b/packages/autoconfigbackup/autoconfigbackup.xml
@@ -109,6 +109,12 @@
<fieldname>crypto_password2</fieldname>
<type>password</type>
</field>
+ <field>
+ <fielddescr>Test connection</fielddescr>
+ <description>Check this box to test the connection to portal.pfsense.org.</description>
+ <fieldname>testconnection</fieldname>
+ <type>checkbox</type>
+ </field>
</fields>
<custom_php_validation_command>
custom_php_validation_command($_POST, &amp;$input_errors);