* * PHP Version 5.2 * * Plugin Name: Adminer * Plugin URI: http://bueltge.de/adminer-fuer-wordpress/1014/ * Text Domain: adminer * Domain Path: /languages * Description: Adminer (formerly phpMinAdmin) is a full-featured MySQL management tool written in PHP. This plugin include this tool in WordPress for a fast management of your database. * Author: Frank Bültge * Version: 1.3.2 * Author URI: http://bueltge.de/ * Donate URI: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6069955 * License: Apache License * Last change: 2014-12-04 * * * License: * ============================================================================== * Copyright 2009/2014 Frank Bueltge (email : frank@bueltge.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Requirements: * ============================================================================== * This plugin requires WordPress >= 3.3 and tested with WP 3.9-alpha and PHP >= 5.3 */ // avoid direct calls to this file, because now WP core and framework has been used if ( ! function_exists( 'add_filter' ) ) { header( 'Status: 403 Forbidden' ); header( 'HTTP/1.1 403 Forbidden' ); exit(); } elseif ( version_compare( phpversion(), '5.0.0', '<' ) ) { header( 'Status: 403 Forbidden' ); header( 'HTTP/1.1 403 Forbidden' ); exit( 'The plugin require PHP 5 or newer' ); } define( 'ADMINER_BASE_FILE', plugin_basename( __FILE__ ) ); add_action( 'plugins_loaded', array( 'AdminerForWP', 'get_object' ) ); class AdminerForWP { private static $classobj; protected $pagehook; public function __construct() { if ( ! is_admin() ) return NULL; if ( is_multisite() && ! function_exists( 'is_plugin_active_for_network' ) ) require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); add_action( 'init', array( $this, 'register_styles' ) ); add_action( 'init', array( $this, 'on_init' ) ); add_action( 'admin_init', array( $this, 'text_domain' ) ); } /** * Handler for the action 'init'. Instantiates this class. * * @since 1.2.2 * @access public * @return \AdminerForWP $classobj */ public static function get_object() { if ( NULL === self::$classobj ) self::$classobj = new self; return self::$classobj; } /** * Call functions on init of WP * * @return void */ public function on_init() { // active for MU ? if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) add_action( 'network_admin_menu', array( $this, 'on_network_admin_menu' ) ); else add_action( 'admin_menu', array( $this, 'on_admin_menu' ) ); } public function text_domain() { load_plugin_textdomain( 'adminer', false, dirname( plugin_basename(__FILE__) ) . '/languages' ); } public function register_styles() { wp_register_style( 'adminer-settings', plugins_url( 'css/settings.css', __FILE__ ) ); if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) { add_action( 'admin_bar_menu', array( $this, 'add_wp_admin_bar_item' ), 20 ); } } public function on_load_page() { add_thickbox(); wp_enqueue_style( 'adminer-settings' ); add_action( 'contextual_help', array( $this, 'contextual_help' ), 10, 3 ); } public function on_admin_menu() { if ( current_user_can( 'unfiltered_html' ) ) { wp_enqueue_style( 'adminer-menu' ); $menutitle = __( 'Adminer', 'adminer' ); $this->pagehook = add_management_page( __( 'Adminer', 'adminer' ), $menutitle, 'unfiltered_html', plugin_basename(__FILE__), array( $this, 'on_show_page' ) ); add_action( 'load-' . $this -> pagehook, array( $this, 'on_load_page' ) ); } } public function on_network_admin_menu() { if ( current_user_can('unfiltered_html' ) ) { wp_enqueue_style( 'adminer-menu' ); $menutitle = __( 'Adminer', 'adminer' ); $this->pagehook = add_submenu_page( 'settings.php', __( 'Adminer', 'adminer' ), $menutitle, 'unfiltered_html', plugin_basename(__FILE__), array( $this, 'on_show_page' ) ); add_action( 'load-' . $this -> pagehook, array( $this, 'on_load_page' ) ); } } public function add_wp_admin_bar_item( $wp_admin_bar ) { if ( is_super_admin() ) { $args = array( 'parent' => 'network-admin', 'secondary' => FALSE, 'id' => 'network-adminer', 'title' => __( 'Adminer' ), 'href' => network_admin_url( 'settings.php?page=adminer/adminer.php' ), ); $wp_admin_bar->add_node( $args ); } } public function contextual_help( $contextual_help, $screen_id, $screen ) { if ( 'tools_page_adminer/adminer' !== $screen_id ) return FALSE; $contextual_help = '
';
$contextual_help .= __( 'Start the Thickbox inside the Adminer-tool with the button ›Start Adminer inside‹.', 'adminer' );
$contextual_help .= '
';
$contextual_help .= __( 'Alternatively, you can use the button for use ›Adminer in a new Tab‹.', 'adminer' );
$contextual_help .= '
' . __( 'Documentation on Plugin Directory', 'adminer' ); $contextual_help .= ' · ' . __( 'Donate', 'adminer' ); $contextual_help .= ' · ' .__( 'Blog of Plugin author', 'adminer' ); $contextual_help .= ' · ' . __( 'Adminer website
', 'adminer' ); return $contextual_help; } /** * Strip slashes for different var * * @param array|string $value optional * @return array|null $value */ static function gpc_strip_slashes( $value = NULL ) { // crazy check, WP change the rules and also Adminer core // result; we must check wrong to the php doc if ( ! get_magic_quotes_gpc() ) { if ( NULL !== $value ) $value = self::array_map_recursive( 'stripslashes_deep', $value ); // stripslashes_deep or stripslashes $_REQUEST = self::array_map_recursive( 'stripslashes_deep', $_REQUEST ); $_GET = self::array_map_recursive( 'stripslashes_deep', $_GET ); $_POST = self::array_map_recursive( 'stripslashes_deep', $_POST ); $_COOKIE = self::array_map_recursive( 'stripslashes_deep', $_COOKIE ); } return $value; } /** * Deeper array_map() * * @param string $callback Callback function to map * @param array, string $value Array to map * @see http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/ * @return array, string */ static function array_map_recursive( $callback, $values ) { $r = NULL; if ( is_string( $values ) ) { $r = $callback( $values ); } elseif ( is_array( $values ) ) { $r = array(); foreach ( $values as $k => $v ) { $r[$k] = is_scalar($v) ? $callback($v) : self::array_map_recursive( $callback, $v ); } } return $r; } /** * Return page content for start Adminer * * @return void */ public function on_show_page() { if ( '' == DB_USER ) $db_user = __( 'empty', 'adminer' ); else $db_user = DB_USER; if ( '' == DB_PASSWORD ) $db_password = __( 'empty', 'adminer' ); else $db_password = DB_PASSWORD; ?>