Skip to content

Commit

Permalink
Create backup before editing a config file
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCrankHank committed Nov 1, 2015
1 parent 06f1130 commit 35b0d8b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ In version 0.6:
- [x] Log also successful messages
- [x] User Model: Delete user, develop better way to check if user is in use
- [x] Support for live resizing of targets (with workaround, since iet doesn't support)
- [x] Create backup before editing a config file
- [ ] Rework controller/models
- [x] Targets
- [x] Users
Expand All @@ -82,7 +83,6 @@ In version 0.6:
- [ ] Database model
- [ ] phpietadmin user
- [ ] Database error log
- [ ] Create backup before editing a config file
- [ ] Create first user via gui

* Misc
Expand Down
4 changes: 2 additions & 2 deletions app/models/Std.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ public function tail($filename, $lines = 10, $buffer = 4096) {
* @return bool
*/
public function backupFile($path, $type = 'file') {
$backupDir = $this->database->get_config('backupDir');
$maxBackups = $this->database->get_config('maxBackups');
$backupDir = $this->database->get_config('backupDir')['value'];
$maxBackups = $this->database->get_config('maxBackups')['value'];
$backupDirFiles = $backupDir . '/files';
$backupDirDb = $backupDir . '/db';

Expand Down
16 changes: 10 additions & 6 deletions app/models/target/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,16 @@ public function parse_file($filename, callable $callback, array $params, $return
$data .= "\n";

if ($test === false) {
// Write back
if (file_put_contents($filename, $data, LOCK_EX) !== false) {
return 0;
} else {
return 6;
}
if($this->std->backupFile($filename, 'file') === true) {
// Write back
if (file_put_contents($filename, $data, LOCK_EX) !== false) {
return 0;
} else {
return 6;
}
} else {
return 12;
}
} else {
echo htmlspecialchars($data);
return 0;
Expand Down
1 change: 1 addition & 0 deletions app/notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
9 wrong usage
10 passwords do not match
11 function not available
12 backup unsuccessful


http://manpages.ubuntu.com/manpages/trusty/man5/ietd.conf.5.html
Expand Down

0 comments on commit 35b0d8b

Please sign in to comment.