40 |
40 |
$username = strtolower($config['system']['acb']['gold_username']);
|
41 |
41 |
$password = $config['system']['acb']['gold_password'];
|
42 |
42 |
|
43 |
|
// URL to restore.php
|
44 |
|
$get_url = "https://portal.pfsense.org/pfSconfigbackups/restore.php";
|
45 |
|
|
46 |
|
// URL to stats
|
47 |
|
$stats_url = "https://portal.pfsense.org/pfSconfigbackups/showstats.php";
|
48 |
|
|
49 |
|
// URL to delete.php
|
50 |
|
$del_url = "https://portal.pfsense.org/pfSconfigbackups/delete.php";
|
51 |
|
|
52 |
43 |
// Set hostname
|
53 |
44 |
if ($_REQUEST['hostname']) {
|
54 |
45 |
$hostname = $_REQUEST['hostname'];
|
... | ... | |
80 |
71 |
|
81 |
72 |
include("head.inc");
|
82 |
73 |
|
83 |
|
function get_hostnames() {
|
84 |
|
global $stats_url, $username, $password, $oper_sep, $config, $g, $exp_sep;
|
85 |
|
// Populate available backups
|
86 |
|
$curl_session = curl_init();
|
87 |
|
curl_setopt($curl_session, CURLOPT_URL, $stats_url);
|
88 |
|
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array("Authorization: Basic " . base64_encode("{$username}:{$password}")));
|
89 |
|
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 1);
|
90 |
|
curl_setopt($curl_session, CURLOPT_POST, 1);
|
91 |
|
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
|
92 |
|
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showstats");
|
93 |
|
curl_setopt($curl_session, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version")));
|
94 |
|
// Proxy
|
95 |
|
curl_setopt_array($curl_session, configure_proxy());
|
96 |
|
|
97 |
|
$data = curl_exec($curl_session);
|
98 |
|
if (curl_errno($curl_session)) {
|
99 |
|
$fd = fopen("/tmp/acb_statsdebug.txt", "w");
|
100 |
|
fwrite($fd, $stats_url . "" . "action=showstats" . "\n\n");
|
101 |
|
fwrite($fd, $data);
|
102 |
|
fwrite($fd, curl_error($curl_session));
|
103 |
|
fclose($fd);
|
104 |
|
} else {
|
105 |
|
curl_close($curl_session);
|
106 |
|
}
|
107 |
|
|
108 |
|
// Loop through and create new confvers
|
109 |
|
$data_split = explode("\n", $data);
|
110 |
|
$statvers = array();
|
111 |
|
foreach ($data_split as $ds) {
|
112 |
|
$ds_split = explode($exp_sep, $ds);
|
113 |
|
if ($ds_split[0]) {
|
114 |
|
$statvers[] = $ds_split[0];
|
115 |
|
}
|
116 |
|
}
|
117 |
|
return $statvers;
|
118 |
|
}
|
119 |
74 |
|
120 |
75 |
if ($_REQUEST['rmver'] != "") {
|
121 |
76 |
$curl_session = curl_init();
|
... | ... | |
134 |
89 |
$data = curl_exec($curl_session);
|
135 |
90 |
if (curl_errno($curl_session)) {
|
136 |
91 |
$fd = fopen("/tmp/acb_deletedebug.txt", "w");
|
137 |
|
fwrite($fd, $get_url . "" . "action=delete&hostname=" . urlencode($hostname) . "&revision=" . urlencode($_REQUEST['rmver']) . "\n\n");
|
|
92 |
fwrite($fd, "https://acb.netgate.com/rmbkp" . "" . "action=delete&hostname=" . urlencode($hostname) . "&revision=" . urlencode($_REQUEST['rmver']) . "\n\n");
|
138 |
93 |
fwrite($fd, $data);
|
139 |
94 |
fwrite($fd, curl_error($curl_session));
|
140 |
95 |
fclose($fd);
|
141 |
|
$savemsg = "An error occurred while trying to remove the item from portal.pfsense.org.";
|
|
96 |
$savemsg = "An error occurred while trying to remove the item from acb.netgate.com.";
|
142 |
97 |
} else {
|
143 |
98 |
curl_close($curl_session);
|
144 |
99 |
$budate = new DateTime($_REQUEST['rmver'], $acbtz);
|
... | ... | |
195 |
150 |
if (curl_errno($curl_session)) {
|
196 |
151 |
/* If an error occured, log the error in /tmp/ */
|
197 |
152 |
$fd = fopen("/tmp/acb_restoredebug.txt", "w");
|
198 |
|
fwrite($fd, $get_url . "" . "action=restore&hostname={$hostname}&revision=" . urlencode($_REQUEST['newver']) . "\n\n");
|
|
153 |
fwrite($fd, "https://acb.netgate.com/getbkp" . "" . "action=restore&hostname={$hostname}&revision=" . urlencode($_REQUEST['newver']) . "\n\n");
|
199 |
154 |
fwrite($fd, $data);
|
200 |
155 |
fwrite($fd, curl_error($curl_session));
|
201 |
156 |
fclose($fd);
|
... | ... | |
284 |
239 |
|
285 |
240 |
if (curl_errno($curl_session)) {
|
286 |
241 |
$fd = fopen("/tmp/acb_backupdebug.txt", "w");
|
287 |
|
fwrite($fd, $get_url . "" . "action=showbackups" . "\n\n");
|
|
242 |
fwrite($fd, "https://acb.netgate.com/list" . "" . "action=showbackups" . "\n\n");
|
288 |
243 |
fwrite($fd, $data);
|
289 |
244 |
fwrite($fd, curl_error($curl_session));
|
290 |
245 |
fclose($fd);
|
... | ... | |
339 |
294 |
$tab_array[] = array("Backup now", false, "/services_acb_backup.php");
|
340 |
295 |
|
341 |
296 |
display_top_tabs($tab_array);
|
342 |
|
|
343 |
|
$hostnames = get_hostnames();
|
344 |
297 |
?>
|
345 |
298 |
|
346 |
299 |
<div id="loading">
|
Remove vestiges of legacy ACB system
(cherry picked from commit 8a6d9d7f82e7a992d2c48910fb4bb847b28f3f45)