-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathBackup.php
40 lines (38 loc) · 1.28 KB
/
Backup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace FreePBX\modules\Certman;
use FreePBX\modules\Backup as Base;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
class Backup Extends Base\BackupBase{
public $dirs = [];
public function runBackup($id,$transaction){
$this->certman = $this->FreePBX->Certman;
$this->buildFileStructure()
->addDirectories($this->dirs);
$this->addDependency('core');
$this->addConfigs($this->buildConfigs());
}
public function buildConfigs(){
return [
'managedCerts' => $this->certman->getAllManagedCertificates(),
'managedCSRs' => $this->certman->getAllManagedCSRs(),
'dtlsOptions' => $this->certman->getAllDTLSOptions(),
'keyDir' => $this->certman->PKCS->getKeysLocation()
];
}
public function buildFileStructure(){
$keyDir = $this->certman->PKCS->getKeysLocation();
$this->dirs[] = $keyDir;
$directory = new RecursiveDirectoryIterator($keyDir);
$iterator = new RecursiveIteratorIterator($directory);
foreach ($iterator as $fileObj) {
if($fileObj->isDir()){
$this->dirs[] = $fileObj->getPath();
continue;
}
$this->addFile($fileObj->getBasename(), $fileObj->getPath(), '', $fileObj->getExtension());
}
$this->dirs = array_unique($this->dirs);
return $this;
}
}