post->get('_wpnonce')) { if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_debug')) { if ($this->post->get('e2pdf_updated')) { update_option('e2pdf_version', '1.00.00'); $this->redirect( $this->helper->get_url( [ 'page' => 'e2pdf-debug', 'notification' => $this->add_notification('update', __('Success', 'e2pdf')), ] ) ); } } else { wp_die($this->message('wp_verify_nonce_error')); } } $this->view('api', new Model_E2pdf_Api()); if (ini_get('disable_functions')) { $disabled_functions = explode(',', ini_get('disable_functions')); } else { $disabled_functions = []; } $this->view('disabled_functions', $disabled_functions); } // url: admin.php?page=e2pdf-debug&action=db public function db_action() { global $wpdb; if ($this->post->get('_wpnonce')) { if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_debug')) { if ($this->post->get('e2pdf_db_repair')) { $db_prefix = $wpdb->prefix; $this->helper->load('db')->db_repair($db_prefix); } elseif ($this->post->get('e2pdf_db_repair_collate')) { $db_prefix = $wpdb->prefix; $this->helper->load('db')->db_repair_collate($db_prefix); } elseif ($this->post->get('e2pdf_db')) { $db_prefix = $wpdb->prefix; $this->helper->load('db')->db_init($db_prefix); } $this->redirect( $this->helper->get_url( [ 'page' => 'e2pdf-debug', 'action' => 'db', 'notification' => $this->add_notification('update', __('Success', 'e2pdf')), ] ) ); } else { wp_die($this->message('wp_verify_nonce_error')); } } $this->view('db_structure', $this->helper->load('db')->db_structure($wpdb->prefix, true)); $this->view('db_check_collate', $this->helper->load('db')->db_check_collate($wpdb->prefix)); } // url: admin.php?page=e2pdf-debug&action=phpinfo public function phpinfo_action() { $this->view('phpinfo', $this->get_php_info()); } // url: admin.php?page=e2pdf-debug&action=requests public function connections_action() { $connections = [ 'self_connection' => [], 'api_connection_upload' => [], 'api_connection_download' => [], ]; $url = plugins_url('img/loader.svg?v=' . time(), $this->helper->get('plugin_file_path')); $image = $this->helper->load('image')->get_by_url($url); if ($image !== '') { $connections['self_connection'] = [ 'error' => '', ]; } $file = 10000000; $times = []; $times[] = microtime(true); $model_e2pdf_api = new Model_E2pdf_Api(); $model_e2pdf_api->set( [ 'action' => 'common/connection', 'data' => [ 'upload' => str_repeat(' ', $file), ], ] ); $request = $model_e2pdf_api->request(); $times[] = microtime(true); if (isset($request['error'])) { $connections['api_connection_upload'] = [ 'error' => $request['error'], 'result' => '', ]; } else { $connections['api_connection_upload'] = [ '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)', ]; } $times[] = microtime(true); $model_e2pdf_api = new Model_E2pdf_Api(); $model_e2pdf_api->set( [ 'action' => 'common/connection', 'data' => [ 'download' => true, ], ] ); $request = $model_e2pdf_api->request(); $times[] = microtime(true); if (isset($request['error'])) { $connections['api_connection_download'] = [ 'error' => $request['error'], 'result' => '', ]; } else { $connections['api_connection_download'] = [ '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)', ]; } $this->view('connections', $connections); } // php info public function get_php_info() { ob_start(); phpinfo(); $contents = ob_get_contents(); ob_end_clean(); $php_info = (str_replace('module_Zend Optimizer', 'module_Zend_Optimizer', preg_replace('%^.*(.*).*$%ms', '$1', $contents))); return $php_info; } }