Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
f91f54d0
Commit
f91f54d0
authored
Mar 17, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work in progress config rewrite
parent
73442dbf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
config.lib.inc
src/etc/inc/config.lib.inc
+37
-0
No files found.
src/etc/inc/config.lib.inc
View file @
f91f54d0
<?php
require_once
(
"xmlparse.inc"
);
require_once
(
"crypt.inc"
);
require_once
(
"script/load_phalcon.php"
);
/*
...
...
@@ -433,6 +434,42 @@ function pfSense_clear_globals() {
unset
(
$config
);
}
/**
* backup config to google drive and return current file list
*
*/
function
backup_to_google_drive
()
{
$client
=
new
Google\API\Drive
()
;
$cnf
=
OPNsense\Core\Config
::
getInstance
();
if
(
$cnf
->
isValid
())
{
$config
=
$cnf
->
object
()
;
if
(
isset
(
$config
->
system
->
remotebackup
)
&&
isset
(
$config
->
system
->
remotebackup
->
GDriveEnabled
)
&&
$config
->
system
->
remotebackup
->
GDriveEnabled
==
"on"
){
$client
->
login
(
$config
->
system
->
remotebackup
->
GDriveEmail
,
$config
->
system
->
remotebackup
->
GDriveP12key
);
// backup config
$target_filename
=
"config-"
.
time
()
.
".xml"
;
$confdata
=
encrypt_data
(
file_get_contents
(
'/conf/config.xml'
),
$config
->
system
->
remotebackup
->
GDrivePassword
)
;
$client
->
upload
(
$config
->
system
->
remotebackup
->
GDriveFolderID
,
$target_filename
,
$confdata
);
// cleanup old files
$files
=
$client
->
listFiles
(
$config
->
system
->
remotebackup
->
GDriveFolderID
);
$configfiles
=
array
();
foreach
(
$files
as
$file
)
{
if
(
fnmatch
(
"config-*.xml"
,
$file
[
'title'
]))
{
$configfiles
[
$file
[
'title'
]]
=
$file
;
}
}
krsort
(
$configfiles
);
foreach
(
$configfiles
as
$filename
=>
$file
)
{
print
(
$filename
.
"
\n
"
);
}
// print_r($configfiles);
}
}
}
register_shutdown_function
(
'pfSense_clear_globals'
);
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment