1
|
|
|
<?php |
2
|
|
|
namespace eoxia; |
3
|
|
|
|
4
|
|
|
if ( !defined( 'ABSPATH' ) ) exit; |
5
|
|
|
|
6
|
|
|
if ( ! class_exists( '\eoxia\log_page_class' ) ) { |
7
|
|
|
class log_page_class extends \eoxia\Singleton_Util { |
8
|
|
|
protected function construct() {} |
9
|
|
|
|
10
|
|
|
public function get_array_size_format() { |
11
|
|
|
return array('oc' => 'Octets', 'ko' => 'Ko', 'mo' => 'Mo', 'go' => 'Go'); |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
public function open_log( $service_name ) { |
15
|
|
|
$upload_dir = wp_upload_dir(); |
16
|
|
|
$dir_file = $upload_dir['basedir'] . '/wpeolog/' . $service_name . '.csv'; |
17
|
|
|
|
18
|
|
|
if ( file_exists( $dir_file ) ) { |
19
|
|
|
$file = file( $dir_file ); |
20
|
|
|
// Remove the first case empty |
21
|
|
|
array_shift( $file ); |
22
|
|
|
foreach( $file as &$data ) { |
23
|
|
|
$data = explode( log_class::$file_separator, $data ); |
24
|
|
|
$data[3] = base64_decode( $data[3] ); |
25
|
|
|
$data[4] = stripcslashes( $data[4] ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
return array( 'data' => $file, 'count' => count( $file ) ); |
29
|
|
|
} |
30
|
|
|
else { |
31
|
|
|
return array( 'data' => null, 'count' => 0 ); |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function check_page() { |
36
|
|
|
if( empty( $_GET['action'] ) || empty( $_GET['type'] ) ) |
37
|
|
|
return false; |
38
|
|
|
|
39
|
|
|
$action = sanitize_text_field( $_GET['action'] ); |
|
|
|
|
40
|
|
|
$type = sanitize_text_field( !empty( $_GET['type'] ) ? $_GET['type'] : '' ); |
|
|
|
|
41
|
|
|
|
42
|
|
|
if ( !isset( $_GET['service_id'] ) ) return false; |
43
|
|
|
else $service_id = (int) $_GET['service_id']; |
44
|
|
|
if ( isset( $_GET['key'] ) && 0 !== (int) $_GET['key'] ) $key = (int) $_GET['key']; |
45
|
|
|
|
46
|
|
|
if ( 'view' == $action && isset( $service_id ) ) { |
47
|
|
|
$service = log_service_class::g()->get_service_by_id( $service_id ); |
|
|
|
|
48
|
|
|
if( $service == null ) |
49
|
|
|
return false; |
50
|
|
|
$service_name = $service['name']; |
51
|
|
|
if ( !empty( $type ) ) { |
52
|
|
|
$service_name .= '-' . $type; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Tous les fichiers |
56
|
|
|
$list_archive_file = log_archive_class::g()->get_archive_file( $service_name ); |
|
|
|
|
57
|
|
|
if( !empty( $key ) ) { |
58
|
|
|
$service_name .= '_' . $key; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$count_warning = $this->open_log( $service['name'] . '-warning' ); |
62
|
|
|
$count_error = $this->open_log( $service['name'] . '-error' ); |
63
|
|
|
$array_data = $this->open_log( $service_name ); |
64
|
|
|
|
65
|
|
|
return array( 'data' => $array_data, 'list_archive_file' => $list_archive_file, 'count_warning' => $count_warning['count'], 'count_error' => $count_error['count'] ); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
?> |
|
|
|
|
73
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.