PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Controllers / Configuration / Queue.php

Queue.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.1.0, at back/Controllers/Configuration/Queue.php

88 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Controllers\Configuration;
4
5 trait Queue
6 {
7 public function deletereport(): void
8 {
9 wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
10
11 $path = trim(html_entity_decode($this->config->get('cron_savepath')));
12 if (!preg_match('#^[a-z0-9/_\-{}]*\.log$#i', $path)) {
13 acym_enqueueMessage(acym_translation('ACYM_WRONG_LOG_NAME'), 'error');
14
15 return;
16 }
17
18 $path = str_replace(['{year}', '{month}'], [gmdate('Y'), gmdate('m')], $this->config->get('cron_savepath'));
19 $reportPath = acym_cleanPath(ACYM_ROOT.$path);
20
21 if (is_file($reportPath)) {
22 $result = acym_deleteFile($reportPath);
23 if ($result) {
24 acym_enqueueMessage(acym_translation('ACYM_SUCC_DELETE_LOG'), 'success');
25 } else {
26 acym_enqueueMessage(acym_translation('ACYM_ERROR_DELETE_LOG'), 'error');
27 }
28 } else {
29 acym_enqueueMessage(acym_translation('ACYM_EXIST_LOG'), 'info');
30 }
31
32 $this->listing();
33 }
34
35 public function seereport(): void
36 {
37 acym_noCache();
38
39 $path = trim(html_entity_decode($this->config->get('cron_savepath')));
40 if (!preg_match('#^[a-z0-9/_\-{}]*\.log$#i', $path)) {
41 acym_display(acym_translation('ACYM_WRONG_LOG_NAME'), 'error');
42
43 return;
44 }
45
46 $path = str_replace(['{year}', '{month}'], [gmdate('Y'), gmdate('m')], $path);
47 $reportPath = acym_cleanPath(ACYM_ROOT.$path);
48
49 if (file_exists($reportPath) && !is_dir($reportPath)) {
50 try {
51 $lines = 5000;
52 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- Necessary tail to save on resources.
53 $f = fopen($reportPath, 'rb');
54 fseek($f, -1, SEEK_END);
55 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fread -- Necessary tail to save on resources.
56 if (fread($f, 1) != "\n") {
57 $lines -= 1;
58 }
59
60 $report = '';
61 while (ftell($f) > 0 && $lines >= 0) {
62 $seek = min(ftell($f), 4096);
63 fseek($f, -$seek, SEEK_CUR);
64 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fread -- Necessary tail to save on resources.
65 $report = ($chunk = fread($f, $seek)).$report; // Get the line
66 fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR);
67 $lines -= substr_count($chunk, "\n"); // Move to previous line
68 }
69
70 while ($lines++ < 0) {
71 $report = substr($report, strpos($report, "\n") + 1);
72 }
73 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- Necessary tail to save on resources.
74 fclose($f);
75 } catch (\Exception $e) {
76 $report = '';
77 }
78 }
79
80 if (empty($report)) {
81 $report = acym_translation('ACYM_EMPTY_LOG');
82 }
83
84 echo nl2br(esc_html($report));
85 exit;
86 }
87 }
88