', $sanitized); // remove email addresses $sanitized = preg_replace($email_regexp, '', $sanitized); return $sanitized; } /** * Renders an HTML page with AWPCP informaiton useful for debugging tasks. * * @since 2.0.7 */ private function render($download=false) { global $awpcp, $wpdb, $wp_rewrite; $debug_info = $this; $options = $awpcp->settings->options; $options['awpcp_installationcomplete'] = get_option('awpcp_installationcomplete'); $options['awpcp_pagename_warning'] = get_option('awpcp_pagename_warning'); $options['widget_awpcplatestads'] = get_option('widget_awpcplatestads'); $options['awpcp_db_version'] = get_option('awpcp_db_version'); $sql = 'SELECT posts.ID post, posts.post_title title, pages.page ref, pages.id FROM ' . AWPCP_TABLE_PAGES . ' AS pages '; $sql.= 'LEFT JOIN ' . $wpdb->posts . ' AS posts '; $sql.= 'ON (posts.ID = pages.id)'; $pages = $wpdb->get_results($sql); $rules = (array) $wp_rewrite->wp_rewrite_rules(); ob_start(); include(AWPCP_DIR . '/admin/templates/admin-panel-debug.tpl.php'); $content = ob_get_contents(); ob_end_clean(); return $content; } /** * Allow users to download Debug Info as an HTML file. * * @since 2.0.7 */ public function download() { global $pagenow; if (!awpcp_current_user_is_admin()) return; if ($pagenow == 'admin.php' && awpcp_request_param('page') === 'awpcp-debug' && awpcp_request_param('download') === 'debug-info') { $filename = sprintf('awpcp-debug-info-%s.html', date('Y-m-d-Hi', current_time('timestamp'))); header('Content-Description: File Transfer'); header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); header('Content-Disposition: attachment; filename=' . $filename); header("Pragma: no-cache"); die($this->render(true)); } } /** * Handler for the Classifieds->Debug AWPCP Admin page. * * @since unknown */ public function dispatch() { echo $this->render(); } }