diff options
-rw-r--r-- | packages/autoconfigbackup/autoconfigbackup.php | 10 | ||||
-rw-r--r-- | packages/autoconfigbackup/upload_config_filter.php | 33 |
2 files changed, 32 insertions, 11 deletions
diff --git a/packages/autoconfigbackup/autoconfigbackup.php b/packages/autoconfigbackup/autoconfigbackup.php index acd5568d..ae027c4a 100644 --- a/packages/autoconfigbackup/autoconfigbackup.php +++ b/packages/autoconfigbackup/autoconfigbackup.php @@ -38,9 +38,6 @@ $pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); // Seperator used during client / server communications $oper_sep = "\|\|"; -// URL to restore.php -$get_url = "https://portal.pfsense.org/pfSconfigbackups/restore.php"; - // Encryption password $decrypt_password = $config['installedpackages']['autoconfigbackup']['config'][0]['decrypt_password']; @@ -50,6 +47,9 @@ $username = $config['installedpackages']['autoconfigbackup']['config'][0]['usern // Defined password $password = $config['installedpackages']['autoconfigbackup']['config'][0]['password']; +// URL to restore.php +$get_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/restore.php?"; + if(!$username) { Header("Location: /pkg_edit.php?xml=autoconfigbackup.xml&id=0"); exit; @@ -59,7 +59,7 @@ if($_GET['newver'] != "") { // Phone home and obtain backups $curl_Session = curl_init($get_url); curl_setopt($curl_Session, CURLOPT_POST, 1); - curl_setopt($curl_Session, CURLOPT_POSTFIELDS, "action=restore&username={$username}&password={$password}&revision={$_GET['newver']}"); + curl_setopt($curl_Session, CURLOPT_POSTFIELDS, "action=restore&revision={$_GET['newver']}"); curl_setopt($curl_Session, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($curl_Session); if (!tagfile_deformat($data, $data, "config.xml")) @@ -82,7 +82,7 @@ if($_GET['newver'] != "") { // Phone home and obtain backups $curl_Session = curl_init($get_url); curl_setopt($curl_Session, CURLOPT_POST, 1); - curl_setopt($curl_Session, CURLOPT_POSTFIELDS, "action=showbackups&username={$username}&password={$password}"); + curl_setopt($curl_Session, CURLOPT_POSTFIELDS, "action=showbackups"); curl_setopt($curl_Session, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($curl_Session); curl_close($curl_Session); diff --git a/packages/autoconfigbackup/upload_config_filter.php b/packages/autoconfigbackup/upload_config_filter.php index 954910fe..a97328a7 100644 --- a/packages/autoconfigbackup/upload_config_filter.php +++ b/packages/autoconfigbackup/upload_config_filter.php @@ -38,13 +38,32 @@ if($last_backup_date <> $last_config_change) { $configxml = encrypt_data($data, $encryptpw); tagfile_reformat($data, $data, "config.xml"); + $post_fields = array( + 'reason'=>urlencode($reason), + 'hostname'=>urlencode($hostname), + 'configxml'=>urlencode($configxml) + ); + + //url-ify the data for the POST + foreach($post_fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } + rtrim($fields_string,'&'); + // Check configuration into the BSDP repo - $curl_Session = curl_init($upload_url); - curl_setopt($curl_Session, CURLOPT_POST, 1); - curl_setopt($curl_Session, CURLOPT_POSTFIELDS, "reason={$reason}&configxml={$configxml}&hostname={$hostname}"); - curl_setopt($curl_Session, CURLOPT_FOLLOWLOCATION, 1); - $data = curl_exec($curl_Session); - curl_close($curl_Session); + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $upload_url); + curl_setopt($curl_session, CURLOPT_POST, count($post_fields)); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, $fields_string); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + $data = curl_exec($curl_session); + if (curl_errno($curl_session)) { + $fd = fopen("/tmp/backupdebug.txt", "w"); + fwrite($fd, $upload_url . "" . $fields_string . "\n\n"); + fwrite($fd, $data); + fwrite($fd, curl_error($curl_session)); + fclose($fd); + } else { + curl_close($curl_session); + } // Update last pfS backup time $fd = fopen("/cf/conf/lastpfSbackup.txt", "w"); @@ -59,6 +78,8 @@ if($last_backup_date <> $last_config_change) { conf_mount_ro(); } +} else { + log_error("No portal.pfsense.org backup required."); } ?>
\ No newline at end of file |