PluginProbe
E2Pdf – Export Pdf Tool for WordPress / trunk
E2Pdf – Export Pdf Tool for WordPress vtrunk
1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 1.08.09 All 71 releases
e2pdf / classes / controller / e2pdf-debug.php

e2pdf-debug.php in E2Pdf – Export Pdf Tool for WordPress trunk, at classes/controller/e2pdf-debug.php

157 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * File: /controller/e2pdf-debug.php
5 *
6 * @package E2Pdf
7 * @license GPLv3
8 * @link https://e2pdf.com
9 */
10 if (!defined('ABSPATH')) {
11 die('Access denied.');
12 }
13
14 class Controller_E2pdf_Debug extends Helper_E2pdf_View {
15
16 // url: admin.php?page=e2pdf-debug
17 public function index_action() {
18 if ($this->post->get('_wpnonce')) {
19 if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_debug')) {
20 if ($this->post->get('e2pdf_updated')) {
21 update_option('e2pdf_version', '1.00.00');
22 $this->redirect(
23 $this->helper->get_url(
24 [
25 'page' => 'e2pdf-debug',
26 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
27 ]
28 )
29 );
30 }
31 } else {
32 wp_die($this->message('wp_verify_nonce_error'));
33 }
34 }
35 $this->view('api', new Model_E2pdf_Api());
36 if (ini_get('disable_functions')) {
37 $disabled_functions = explode(',', ini_get('disable_functions'));
38 } else {
39 $disabled_functions = [];
40 }
41 $this->view('disabled_functions', $disabled_functions);
42 }
43
44 // url: admin.php?page=e2pdf-debug&action=db
45 public function db_action() {
46 global $wpdb;
47 if ($this->post->get('_wpnonce')) {
48 if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_debug')) {
49 if ($this->post->get('e2pdf_db_repair')) {
50 $db_prefix = $wpdb->prefix;
51 $this->helper->load('db')->db_repair($db_prefix);
52 } elseif ($this->post->get('e2pdf_db_repair_collate')) {
53 $db_prefix = $wpdb->prefix;
54 $this->helper->load('db')->db_repair_collate($db_prefix);
55 } elseif ($this->post->get('e2pdf_db')) {
56 $db_prefix = $wpdb->prefix;
57 $this->helper->load('db')->db_init($db_prefix);
58 }
59 $this->redirect(
60 $this->helper->get_url(
61 [
62 'page' => 'e2pdf-debug',
63 'action' => 'db',
64 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
65 ]
66 )
67 );
68 } else {
69 wp_die($this->message('wp_verify_nonce_error'));
70 }
71 }
72 $this->view('db_structure', $this->helper->load('db')->db_structure($wpdb->prefix, true));
73 $this->view('db_check_collate', $this->helper->load('db')->db_check_collate($wpdb->prefix));
74 }
75
76 // url: admin.php?page=e2pdf-debug&action=phpinfo
77 public function phpinfo_action() {
78 $this->view('phpinfo', $this->get_php_info());
79 }
80
81 // url: admin.php?page=e2pdf-debug&action=requests
82 public function connections_action() {
83 $connections = [
84 'self_connection' => [],
85 'api_connection_upload' => [],
86 'api_connection_download' => [],
87 ];
88
89 $url = plugins_url('img/loader.svg?v=' . time(), $this->helper->get('plugin_file_path'));
90 $image = $this->helper->load('image')->get_by_url($url);
91 if ($image !== '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="20px" height="20px" viewBox="0 0 128 128" xml:space="preserve"><g><path d="M63.9.45A63.46 63.46 0 1 1 .47 63.9 63.46 63.46 0 0 1 63.9.46zM41.8 19.38a22.27 22.27 0 1 1-22.3 22.27 22.27 22.27 0 0 1 22.27-22.27z" fill="#808080" fill-rule="evenodd"/><animateTransform attributeName="transform" type="rotate" from="0 64 64" to="360 64 64" dur="960ms" repeatCount="indefinite"></animateTransform></g></svg>') {
92 $connections['self_connection'] = [
93 'error' => '',
94 ];
95 }
96
97 $file = 10000000;
98 $times = [];
99 $times[] = microtime(true);
100 $model_e2pdf_api = new Model_E2pdf_Api();
101 $model_e2pdf_api->set(
102 [
103 'action' => 'common/connection',
104 'data' => [
105 'upload' => str_repeat(' ', $file),
106 ],
107 ]
108 );
109 $request = $model_e2pdf_api->request();
110 $times[] = microtime(true);
111 if (isset($request['error'])) {
112 $connections['api_connection_upload'] = [
113 'error' => $request['error'],
114 'result' => '',
115 ];
116 } else {
117 $connections['api_connection_upload'] = [
118 'result' => $this->helper->load('convert')->from_bytes($file / ($times[1] - $times[0])) . '/s (' . $this->helper->load('convert')->from_bytes($file) . ' in ' . number_format(($times[1] - $times[0]), 2) . 's)',
119 ];
120 }
121
122 $times[] = microtime(true);
123 $model_e2pdf_api = new Model_E2pdf_Api();
124 $model_e2pdf_api->set(
125 [
126 'action' => 'common/connection',
127 'data' => [
128 'download' => true,
129 ],
130 ]
131 );
132 $request = $model_e2pdf_api->request();
133 $times[] = microtime(true);
134 if (isset($request['error'])) {
135 $connections['api_connection_download'] = [
136 'error' => $request['error'],
137 'result' => '',
138 ];
139 } else {
140 $connections['api_connection_download'] = [
141 'result' => $this->helper->load('convert')->from_bytes($file / ($times[3] - $times[2])) . '/s (' . $this->helper->load('convert')->from_bytes($file) . ' in ' . number_format(($times[3] - $times[2]), 2) . 's)',
142 ];
143 }
144 $this->view('connections', $connections);
145 }
146
147 // php info
148 public function get_php_info() {
149 ob_start();
150 phpinfo();
151 $contents = ob_get_contents();
152 ob_end_clean();
153 $php_info = (str_replace('module_Zend Optimizer', 'module_Zend_Optimizer', preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $contents)));
154 return $php_info;
155 }
156 }
157