PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 1.4.9
Backup Migration v1.4.9
2.1.6 2.1.5.2 trunk 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.6.1 1.4.7 1.4.8 1.4.9 1.4.9.1 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.5.1
backup-backup / includes / progress / logger-only.php
backup-backup / includes / progress Last commit date
logger-only.php 11 months ago migration.php 11 months ago staging.php 11 months ago zip.php 11 months ago
logger-only.php
75 lines
1 <?php
2
3 // Namespace
4 namespace BMI\Plugin\Progress;
5
6 // Use
7 use BMI\Plugin\BMI_Logger AS Logger;
8
9 // Exit on direct access
10 if (!defined('ABSPATH')) exit;
11
12 /**
13 * Main File Backup Includable Logs
14 */
15 class BMI_ZipProgress {
16
17 public $latest;
18 public $progress;
19 public $latest_progress;
20 public $file;
21 public $muted = false;
22
23 public function __construct() {
24
25 if (!file_exists(BMI_BACKUPS)) mkdir(BMI_BACKUPS, 0755, true);
26
27 $this->latest = BMI_BACKUPS . '/latest.log';
28 $this->latest_progress = BMI_BACKUPS . '/latest_progress.log';
29
30 }
31
32 public function start($muted = false) {
33
34 $this->muted = $muted;
35
36 }
37
38 public function progress($progress = '0') {
39
40 $this->progress = fopen($this->latest_progress, 'w') or die(__("Unable to open file!", 'backup-backup'));
41 fwrite($this->progress, $progress);
42 fclose($this->progress);
43
44 }
45
46 public function log($log = '', $level = 'INFO') {
47
48 if (!$this->muted) {
49 $this->file = @fopen($this->latest, 'a');
50 if ($this->file) {
51 if (defined('BMI_CLI_REQUEST') && BMI_CLI_REQUEST === true) {
52 $log_string = '[' . strtoupper($level) . '] [' . date('Y-m-d H:i:s') . '] [CLI] ' . $log . "\n";
53 } else {
54 $log_string = '[' . strtoupper($level) . '] [' . date('Y-m-d H:i:s') . '] ' . $log . "\n";
55 }
56 @fwrite($this->file, $log_string);
57 if (defined('BMI_USING_CLI_FUNCTIONALITY') && BMI_USING_CLI_FUNCTIONALITY === true) {
58 echo $log_string;
59 }
60 }
61 @fclose($this->file);
62 } else {
63 error_log('[' . strtoupper($level) . '] [' . date('Y-m-d H:i:s') . '] ' . $log);
64 }
65
66 }
67
68 public function end() {
69
70 return true;
71
72 }
73
74 }
75