Commit fe6bb22f authored by Franco Fichtner's avatar Franco Fichtner

src: whitespace sweep

parent f1d7efc6
......@@ -144,4 +144,3 @@ if (!$timezone) {
}
date_default_timezone_set("$timezone");
......@@ -93,7 +93,7 @@ function parse_config_bootup()
if (count($backups) > 0) {
log_error("No config.xml found, attempting last known config restore.");
file_notice("config.xml", gettext("No config.xml found, attempting last known config restore."), "pfSenseConfigurator", "");
$cnf->restoreBackup($backups[0]);
$cnf->restoreBackup($backups[0]);
} else {
echo sprintf(gettext("XML configuration file not found. %s cannot continue booting."), $g['product_name']) . "\n";
mwexec("/sbin/halt");
......@@ -356,7 +356,7 @@ function cleanup_backups() {
}
$cnf = OPNsense\Core\Config::getInstance();
$cnt=1;
foreach ($cnf->getBackups() as $filename) {
if ($cnt > $revisions ) {
......@@ -451,11 +451,11 @@ function backup_to_google_drive() {
if ( isset($config->system->remotebackup) && isset($config->system->remotebackup->GDriveEnabled) && $config->system->remotebackup->GDriveEnabled == "on" ){
$client->login($config->system->remotebackup->GDriveEmail->__toString(), $config->system->remotebackup->GDriveP12key->__toString() );
// backup source data to local strings (plain/encrypted)
$confdata = file_get_contents('/conf/config.xml') ;
$confdata = file_get_contents('/conf/config.xml') ;
$confdata_enc = encrypt_data($confdata, $config->system->remotebackup->GDrivePassword->__toString()) ;
tagfile_reformat($confdata_enc, $confdata_enc, "config.xml");
tagfile_reformat($confdata_enc, $confdata_enc, "config.xml");
// read filelist (config-*.xml) and cleanup old files
$files = $client->listFiles($config->system->remotebackup->GDriveFolderID->__toString());
$configfiles = array();
......@@ -465,9 +465,9 @@ function backup_to_google_drive() {
}
}
krsort($configfiles);
if (isset($config->system->remotebackup->GDriveBackupCount) && is_numeric($config->system->remotebackup->GDriveBackupCount->__toString())) {
$fcount = 0;
$fcount = 0;
foreach ($configfiles as $filename => $file) {
if ($fcount > $config->system->remotebackup->GDriveBackupCount->__toString()) {
log_error("remove " . $filename . " from Google Drive" );
......@@ -480,18 +480,18 @@ function backup_to_google_drive() {
// backup new file if changed (or if first in backup)
$target_filename = "config-".time().".xml";
if (count($configfiles) > 1) {
// compare last backup with current, only save new
// compare last backup with current, only save new
$bck_data_enc = $client->download($configfiles[array_keys($configfiles)[0]]);
$bck_data = decrypt_data($bck_data_enc, $config->system->remotebackup->GDrivePassword->__toString());
if ($bck_data == $confdata) {
$target_filename = null;
}
}
}
}
if (!is_null($target_filename)) {
log_error("backup configuration as " . $target_filename);
$configfiles[$target_filename] = $client->upload($config->system->remotebackup->GDriveFolderID->__toString(),$target_filename, $confdata_enc );
}
}
// return filelist
return $configfiles;
......@@ -499,7 +499,7 @@ function backup_to_google_drive() {
}
// not configured / issue, return empty list
return array();
return array();
}
register_shutdown_function('pfSense_clear_globals');
......
......@@ -130,4 +130,3 @@ function is_install_media()
return true;
}
......@@ -376,4 +376,3 @@ if ($ipsec_dynamic_hosts) {
}
led_normalize();
#!/usr/local/bin/php
<?
/**
/**
* Backup to Google Drive (if configured)
*/
require_once("config.lib.inc");
backup_to_google_drive();
......@@ -85,7 +85,7 @@ function openvpn_client_export_prefix($srvid, $usrid = null, $crtid = null) {
$host = empty($config['system']['hostname']) ? "openvpn" : $config['system']['hostname'];
$prot = ($settings['protocol'] == 'UDP' ? 'udp' : $settings['protocol']);
$port = $settings['local_port'];
$filename_addition = "";
if ($usrid && is_numeric($usrid))
$filename_addition = "-".$config['system']['user'][$usrid]['name'];
......@@ -128,7 +128,7 @@ function openvpn_client_export_validate_config($srvid, $usrid, $crtid) {
// lookup server certificate info
$server_cert = lookup_cert($settings['certref']);
if (!$server_cert)
if (!$server_cert)
{
$input_errors[] = "Could not locate server certificate.";
} else {
......@@ -173,7 +173,7 @@ function openvpn_client_export_validate_config($srvid, $usrid, $crtid) {
if ($input_errors)
return false;
return array($settings, $server_cert, $server_ca, $servercn, $user, $cert, $nokeys);
}
......@@ -250,7 +250,7 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $verifys
}
$conf .= "http-proxy {$proxy['ip']} {$proxy['port']} ";
}
if ($proxy['proxy_type'] == "socks")
if ($proxy['proxy_type'] == "socks")
$conf .= "socks-proxy {$proxy['ip']} {$proxy['port']} ";
if ($proxy['proxy_authtype'] != "none") {
if (!isset($proxy['passwdfile']))
......@@ -358,7 +358,7 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $verifys
$conf .= "management-forget-disconnect{$nl}";
$conf .= $nl;
};
// add advanced options
$advancedoptions = str_replace("\r\n", "\n", $advancedoptions);
$advancedoptions = str_replace("\n", $nl, $advancedoptions);
......@@ -581,12 +581,12 @@ function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $veri
$files .= "openvpn-install.exe ";
$files .= "openvpn-postinstall.exe ";
if ($usetoken)
$procchain = ';!@Install@!UTF-8!
$procchain = ';!@Install@!UTF-8!
RunProgram="openvpn-postinstall.exe /Import"
;!@InstallEnd@!'
;
else
$procchain = ';!@Install@!UTF-8!
$procchain = ';!@Install@!UTF-8!
RunProgram="openvpn-postinstall.exe"
;!@InstallEnd@!'
;
......@@ -804,7 +804,7 @@ function openvpn_client_export_sharedkey_config($srvid, $useaddr, $proxy, $zipco
}
$conf .= "http-proxy {$proxy['ip']} {$proxy['port']} ";
}
if ($proxy['proxy_type'] == "socks")
if ($proxy['proxy_type'] == "socks")
$conf .= "socks-proxy {$proxy['ip']} {$proxy['port']} ";
if ($proxy['proxy_authtype'] != "none") {
if (!isset($proxy['passwdfile']))
......
......@@ -27,7 +27,7 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("script/load_phalcon.php");
require_once("script/load_phalcon.php");
/* Allow additional execution time 0 = no limit. */
ini_set('max_execution_time', '0');
......@@ -491,25 +491,25 @@ if ($_POST) {
$config['system']['remotebackup']['GDriveFolderID'] = $_POST['GDriveFolderID'];
$config['system']['remotebackup']['GDrivePassword'] = $_POST['GDrivePassword'];
if (is_numeric($_POST['GDriveBackupCount'])) {
$config['system']['remotebackup']['GDriveBackupCount'] = $_POST['GDriveBackupCount'];
$config['system']['remotebackup']['GDriveBackupCount'] = $_POST['GDriveBackupCount'];
} else {
$config['system']['remotebackup']['GDriveBackupCount'] = 30;
}
if ( $_POST['GDrivePasswordConfirm'] != $_POST['GDrivePassword'] ) {
// log error, but continue
$input_errors[] = gettext("The supplied 'Password' and 'Confirm' field values must match.");
}
if (is_uploaded_file($_FILES['GDriveP12file']['tmp_name'])) {
if (is_uploaded_file($_FILES['GDriveP12file']['tmp_name'])) {
$data = file_get_contents($_FILES['GDriveP12file']['tmp_name']);
$config['system']['remotebackup']['GDriveP12key'] = base64_encode($data);
} elseif ($config['system']['remotebackup']['GDriveEnabled'] != "on") {
unset($config['system']['remotebackup']['GDriveP12key']);
}
write_config();
// test / perform backup
// test / perform backup
try {
$filesInBackup = backup_to_google_drive() ;
$cron_job = "/usr/local/opnsense/scripts/remote_backup.php";
......@@ -517,10 +517,10 @@ if ($_POST) {
// initial cron job install
install_cron_job($cron_job,true,0,1);
}
} catch (Exception $e) {
} catch (Exception $e) {
$filesInBackup = array() ;
}
if (count($filesInBackup) == 0) {
$input_errors[] = gettext("Google Drive communication failure");
} else {
......@@ -742,16 +742,16 @@ function backuparea_change(obj) {
</div>
</section>
<section class="__mb">
<div class="content-box">
<header class="content-box-head container-fluid">
<div class="content-box">
<header class="content-box-head container-fluid">
<h3><?=gettext("Remote backup (using Google drive)"); ?></h3>
</header>
<div class="content-box-main ">
<div class="content-box-main ">
<div class="table-responsive">
<table class="table table-striped __nomb">
<table class="table table-striped __nomb">
<thead>
<th class="col-sm-1"></th>
<th class="col-sm-3"></th>
......@@ -761,7 +761,7 @@ function backuparea_change(obj) {
<tr><td><?=gettext("Email Address"); ?> </td><td><input name="GDriveEmail" class="formfld" size="20" value="<? echo $config['system']['remotebackup']['GDriveEmail'];?>" type="text"> </td> </tr>
<tr><td><?=gettext("P12 key"); ?> <? if (isset($config['system']['remotebackup']['GDriveP12key'])) echo gettext("(replace)"); else echo gettext("(not loaded)"); ?> </td><td> <input name="GDriveP12file" class="formbtn" id="P12file" size="40" type="file"></td> </tr>
<tr><td><?=gettext("Folder ID"); ?> </td><td> <input name="GDriveFolderID" class="formbtn" id="GDriveFolderID" value="<? echo $config['system']['remotebackup']['GDriveFolderID'];?>" size="40" type="text"></td> </tr>
<tr><td><?=gettext("Backup Count"); ?> </td><td> <input name="GDriveBackupCount" class="formbtn" id="GDriveBackupCount" value="<? echo $config['system']['remotebackup']['GDriveBackupCount'];?>" size="40" type="text"></td> </tr>
<tr><td><?=gettext("Backup Count"); ?> </td><td> <input name="GDriveBackupCount" class="formbtn" id="GDriveBackupCount" value="<? echo $config['system']['remotebackup']['GDriveBackupCount'];?>" size="40" type="text"></td> </tr>
<tr><td colspan=2><?=gettext("Password protect your data"); ?> :</td></tr>
<tr><td><?=gettext("Password :"); ?></td> <td> <input name="GDrivePassword" type="password" class="formfld pwd" size="20" value="<? echo $config['system']['remotebackup']['GDrivePassword'] ;?>" /> </td></tr>
<tr><td><?=gettext("Confirm :"); ?></td> <td> <input name="GDrivePasswordConfirm" type="password" class="formfld pwd" size="20" value="<? echo $config['system']['remotebackup']['GDrivePassword'] ;?>" /> </td></tr>
......@@ -769,7 +769,7 @@ function backuparea_change(obj) {
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
......@@ -783,8 +783,8 @@ function backuparea_change(obj) {
</section>
</section>
</div>
</div>
</section>
......
......@@ -197,7 +197,7 @@ include("head.inc");
if (add < 10) {
var TimeServerID = 'timeserver' + add;
document.getElementById(TimeServerID).style.display = 'block';
//then revise the add another server line
if (add < 9) {
var next = add + 1;
......
......@@ -103,8 +103,8 @@ if ($_POST) {
$config['ntpd']['gps']['flag1'] = $_POST['gpsflag1'];
} elseif (isset($config['ntpd']['gps']['flag1'])) {
unset($config['ntpd']['gps']['flag1']);
}
}
if (!empty($_POST['gpsflag2']))
$config['ntpd']['gps']['flag2'] = $_POST['gpsflag2'];
elseif (isset($config['ntpd']['gps']['flag2']))
......@@ -586,9 +586,9 @@ SureGPS = #Sure Electronics SKG16B
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function() {
setTimeout(function(){
setTimeout(function(){
set_gps_default(this.form);
}, 1000);
}, 1000);
});
//]]>
</script>
......
......@@ -578,7 +578,7 @@ function useproxy_changed(obj) {
print_info_box($savemsg);
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="openvpn export">
<tr>
<tr>
<td>
<?php
$tab_array = array();
......
<?php
<?php
/*
vpn_openvpn_export_shared.php
Copyright (C) 2008 Shrew Soft Inc.
Copyright (C) 2010 Ermal Luçi
All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
......@@ -261,7 +261,7 @@ function useaddr_changed(obj) {
$('HostName').show();
else
$('HostName').hide();
}
function useproxy_changed(obj) {
......@@ -282,9 +282,9 @@ function useproxy_changed(obj) {
print_info_box($savemsg);
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="openvpn export shared">
<tr>
<tr>
<td>
<?php
<?php
$tab_array = array();
$tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment