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 / staging.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
staging.php
81 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 Staging Logs
14 */
15 class BMI_StagingProgress {
16
17 public $latest;
18 public $progress;
19 public $file;
20 public $muted = false;
21
22 public function __construct($continue = false) {
23
24 if (!file_exists(BMI_STAGING)) mkdir(BMI_STAGING, 0755, true);
25
26 $this->latest = BMI_STAGING . '/latest_staging.log';
27 $this->progress = BMI_STAGING . '/latest_staging_progress.log';
28
29 if (file_exists($this->latest) && $continue === false) {
30 unlink($this->latest);
31 }
32
33 }
34
35 public function start($muted = false) {
36
37 $this->muted = $muted;
38
39 }
40
41 public function mute() {
42
43 $this->muted = true;
44
45 }
46
47 public function unmute() {
48
49 $this->muted = false;
50
51 }
52
53 public function progress($progress = '0') {
54
55 file_put_contents($this->progress, $progress);
56
57 }
58
59 public function log($log = '', $level = 'INFO') {
60
61 $this->file = fopen($this->latest, 'a');
62
63 if (!$this->muted) {
64 $log_string = '[' . strtoupper($level) . '] [' . date('Y-m-d H:i:s') . '] ' . $log . "\n";
65 fwrite($this->file, $log_string);
66 if (defined('BMI_USING_CLI_FUNCTIONALITY') && BMI_USING_CLI_FUNCTIONALITY === true) {
67 echo $log_string;
68 }
69 }
70
71 fclose($this->file);
72 }
73
74 public function end() {
75
76 return true;
77
78 }
79
80 }
81