Skip to content

Commit 16bd85c

Browse files
committed
version 2.0.0
1 parent 01d4b9f commit 16bd85c

395 files changed

Lines changed: 76761 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Configuration.Default.jsonc

Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
1+
{
2+
"phpBAT":{
3+
4+
//jsonc is a modified json to support comments
5+
6+
//"Timezone":"Europe/Berlin", //set php timezone [optional]
7+
"Timeshort":true, //true: date("Y-m-d"), false: date("Y-m-d_H-i-s")
8+
9+
"Logging":{
10+
"Level":"Info", //Trace, Debug, Info, Warn or Error
11+
"Path":"logs", //log path, default: logs
12+
"chmod":"0600", //log chmod, default: 0600 (null = disabled)
13+
"Days":30 //time in days to delete old logs (0 = disabled)
14+
},
15+
16+
"Backup":{
17+
18+
"Path":"backups", //backup path, default: backups
19+
"chmod":"0600", //backup chmod, default: 0600 (null = disabled)
20+
"Days":14, //time in days to delete old backups (0 = disabled)
21+
22+
"Encrypt":{
23+
"Enabled":false, //enabled true/false
24+
"Cipher":"aes-256-cbc", //encryption cipher, default: aes-256-cbc
25+
"Password":"password" //encryption password
26+
},
27+
28+
"Decrypt":{
29+
"Path":"decrypted" //decryption path, default: decrypted
30+
}
31+
32+
},
33+
34+
//automatic update to latest github release
35+
"SelfUpdate":true, //enabled true/false
36+
37+
//PHPMailer - using pure php
38+
//https://github.com/PHPMailer/PHPMailer
39+
"Mail":{
40+
"Enabled":false, //enabled true/false
41+
"Host":"smtp.example.com", //smtp server
42+
"User":"noreply@example.com", //smtp username
43+
"Password":"password", //smtp password
44+
"SSL":true, //true: ssl, false: tls
45+
"Port":465, //tls: 587, ssl: 465
46+
"From":"noreply@example.com", //send from this address
47+
"To":"mail@example.com" //send to this address
48+
},
49+
50+
"Jobs":{
51+
52+
//System Backup - using php exec/popen and tar
53+
//supported OS: debian, rasbian, ubuntu, arch, manjaro
54+
//need root privileges
55+
"ServerBackup":{
56+
"Enabled":false,
57+
"Compress":true,
58+
"Filename":"server",
59+
"Excludes":[] //https://www.gnu.org/software/tar/manual/html_node/exclude.html
60+
},
61+
62+
//System Update - using php exec/popen
63+
//supported OS: debian, rasbian, ubuntu, arch, manjaro
64+
//need root privileges
65+
//Update on debian/rasbian/ubuntu: apt-get
66+
//Cleanup on debian/rasbian/ubuntu: deborphan
67+
//Update on arch/manjaro: pacman
68+
//Cleanup on arch/manjaro: paccache
69+
"ServerUpdate":{
70+
"Enabled":false,
71+
"Cleanup":false
72+
},
73+
74+
//System Cleanup - using php exec/popen
75+
//supported OS: debian, rasbian, ubuntu, arch, manjaro
76+
//need root privileges
77+
//delete all .gz and .old files in /var/log
78+
//delete all journals older than ten days in /var/log/journal/
79+
"ServerCleanup":false,
80+
81+
//MySQLDump - using pure php
82+
//need pdo_mysql extension
83+
//compress using zlib extension (gzip file)
84+
//https://github.com/ifsnop/mysqldump-php
85+
"MySQLDump":[
86+
{
87+
"Host":"localhost", //mysql or mariadb server
88+
"Port":3306,
89+
"DB":"database1",
90+
"User":"user",
91+
"Password":"password",
92+
"Filename":"database_one", //[optional] if this is not set, using DB as Filename
93+
"Compress":true
94+
}
95+
],
96+
97+
//PHPArchive:Tar - using pure php
98+
//compress using zlib extension (gzip file)
99+
//https://github.com/splitbrain/php-archive
100+
"Backup":[
101+
{
102+
"Path":"/local/path/source/", //save this path to archive
103+
"Compress":true,
104+
"Filename":"filename",
105+
"Excludes":[
106+
"/local/path/source/exclude/", //skip folder
107+
"/local/path/source/exclude.ext", //skip file
108+
"exlude.ext", //skip all files
109+
".log" //skip all .log files
110+
]
111+
}
112+
],
113+
114+
//rsync - using php exec/popen and rsync
115+
//if password set: need sshpass
116+
//if not set: using ssh key: https://www.ssh.com/ssh/key/ and https://www.ssh.com/ssh/copy-id
117+
"rsync":[
118+
119+
//local mode
120+
{
121+
"Source":"/local/path/source/",
122+
"Destination":"/local/path/destination/",
123+
"Excludes":[]
124+
},
125+
126+
//local to remote mode (insecure rsync) using password
127+
{
128+
"Source":"/local/path/source/",
129+
"Server":"server",
130+
"User":"user",
131+
"Password":"password",
132+
"SSH":false,
133+
"remote_to_local":false,
134+
"Destination":"/server/path/destination/",
135+
"Excludes":[]
136+
},
137+
138+
//local to remote mode (ssh rsync) using password
139+
{
140+
"Source":"/local/path/source/",
141+
"Server":"server",
142+
"User":"user",
143+
"Password":"password",
144+
"SSH":true,
145+
"remote_to_local":false,
146+
"Destination":"/server/path/destination/",
147+
"Excludes":[]
148+
},
149+
150+
//local to remote mode (ssh rsync) using ssh key
151+
{
152+
"Source":"/local/path/source/",
153+
"Server":"server",
154+
"User":"user",
155+
"Key":"/local/path/keyfile",
156+
"SSH":true,
157+
"remote_to_local":false,
158+
"Destination":"/server/path/destination/",
159+
"Excludes":[]
160+
},
161+
162+
//remote to local mode (insecure rsync) using password
163+
{
164+
"Destination":"/local/path/destination/",
165+
"Server":"server",
166+
"User":"user",
167+
"Password":"password",
168+
"SSH":false,
169+
"remote_to_local":true,
170+
"Source":"/server/path/source/",
171+
"Excludes":[]
172+
},
173+
174+
//remote to local mode (ssh rsync) using password
175+
{
176+
"Destination":"/local/path/destination/",
177+
"Server":"server",
178+
"User":"user",
179+
"Password":"password",
180+
"SSH":true,
181+
"remote_to_local":true,
182+
"Source":"/server/path/source/",
183+
"Excludes":[]
184+
},
185+
186+
//remote to local mode (ssh rsync) using ssh key
187+
{
188+
"Destination":"/local/path/destination/",
189+
"Server":"server",
190+
"User":"user",
191+
"Key":"/local/path/keyfile",
192+
"SSH":true,
193+
"remote_to_local":true,
194+
"Source":"/server/path/source/",
195+
"Excludes":[]
196+
}
197+
198+
],
199+
200+
//FTP - using pure php
201+
//File Transfer Protocol
202+
//need sockets and ftp extension
203+
"FTP":[
204+
205+
//local to remote
206+
{
207+
"Source":"/local/path/source/",
208+
"Server":"server",
209+
"Port":21,
210+
"User":"user",
211+
"Password":"password",
212+
"SSL":false,
213+
"remote_to_local":false,
214+
"Destination":"/server/path/destination/"
215+
},
216+
217+
//remote to local
218+
{
219+
"Destination":"/local/path/destination/",
220+
"Server":"server",
221+
"Port":21,
222+
"User":"user",
223+
"Password":"password",
224+
"SSL":false,
225+
"remote_to_local":false,
226+
"Source":"/server/path/source/"
227+
}
228+
],
229+
230+
//SFTP - using pure php
231+
//SSH File Transfer Protocol
232+
//https://github.com/phpseclib/phpseclib
233+
//https://github.com/paragonie/constant_time_encoding
234+
"SFTP":[
235+
236+
//local to remote mode using password
237+
{
238+
"Source":"/local/path/source/",
239+
"Server":"server",
240+
"Port":22,
241+
"User":"user",
242+
"Password":"password",
243+
"remote_to_local":false,
244+
"Destination":"/server/path/destination/"
245+
},
246+
247+
//local to remote mode using key
248+
{
249+
"Source":"/local/path/source/",
250+
"Server":"server",
251+
"Port":22,
252+
"User":"user",
253+
"Key":"/local/path/keyfile",
254+
"remote_to_local":false,
255+
"Destination":"/server/path/destination/"
256+
},
257+
258+
//local to remote mode using ssh agent
259+
{
260+
"Source":"/local/path/source/",
261+
"Server":"server",
262+
"Port":22,
263+
"User":"user",
264+
"remote_to_local":false,
265+
"Destination":"/server/path/destination/"
266+
},
267+
268+
//remote to local mode using password
269+
{
270+
"Destination":"/local/path/destination/",
271+
"Server":"server",
272+
"Port":22,
273+
"User":"user",
274+
"Password":"password",
275+
"remote_to_local":true,
276+
"Source":"/server/path/source/"
277+
},
278+
279+
//remote to local mode using key
280+
{
281+
"Destination":"/local/path/destination/",
282+
"Server":"server",
283+
"Port":22,
284+
"User":"user",
285+
"Key":"/local/path/keyfile",
286+
"remote_to_local":true,
287+
"Source":"/server/path/source/"
288+
},
289+
290+
//remote to local mode using ssh agent
291+
{
292+
"Destination":"/local/path/destination/",
293+
"Server":"server",
294+
"Port":22,
295+
"User":"user",
296+
"remote_to_local":true,
297+
"Source":"/server/path/source/"
298+
}
299+
300+
]
301+
302+
}
303+
304+
}
305+
}

Library/.htaccess

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Options -Indexes
2+
Order deny,allow
3+
Deny from all

Library/Autoloader.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* phpBAT
4+
*
5+
* Please report bugs on https://github.com/robertsaupe/phpbat/issues
6+
*
7+
* @author Robert Saupe <mail@robertsaupe.de>
8+
* @copyright Copyright (c) 2018, Robert Saupe. All rights reserved
9+
* @link https://github.com/robertsaupe/phpbat
10+
* @license MIT License
11+
*/
12+
13+
/**
14+
* implements autoloader
15+
*/
16+
class Autoloader {
17+
18+
/**
19+
* registered an autoloader
20+
*
21+
* @param string $path
22+
* @param string $ext
23+
* @return void
24+
*/
25+
public static function Register(string $path, string $ext = '.php'):void {
26+
new self($path, $ext);
27+
}
28+
29+
/**
30+
* constructor for autoloader
31+
*/
32+
private function __construct(
33+
private string $path,
34+
private string $ext) {
35+
spl_autoload_register(array($this, 'load'));
36+
}
37+
38+
/**
39+
* load a class
40+
*
41+
* @param string $class
42+
* @return void
43+
*/
44+
private function load(string $class):void {
45+
$file = $this->path . '/' . str_replace('\\','/', $class) . $this->ext;
46+
$file = realpath($file);
47+
if (file_exists($file) && is_readable($file)) {
48+
require_once($file);
49+
}
50+
}
51+
}
52+
?>

0 commit comments

Comments
 (0)