PageRenderTime 32ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/plugins/adminer/adminer.php

https://gitlab.com/Blueprint-Marketing/interoccupy.net
PHP | 397 lines | 241 code | 68 blank | 88 comment | 31 complexity | 43271fe2c259310263b8032aa06be5d7 MD5 | raw file
  1. <?php
  2. /**
  3. * @package Adminer
  4. * @author Frank B&uuml;ltge
  5. *
  6. * Plugin Name: Adminer
  7. * Plugin URI: http://bueltge.de/adminer-fuer-wordpress/1014/
  8. * Text Domain: adminer
  9. * Domain Path: /languages
  10. * Description: <a href="http://www.adminer.org/en/">Adminer</a> (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.
  11. * Author: Frank B&uuml;ltge
  12. * Version: 1.2.3
  13. * Author URI: http://bueltge.de/
  14. * Donate URI: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=6069955
  15. * License: Apache License
  16. * Last change: 01/08/2013
  17. *
  18. *
  19. * License:
  20. * ==============================================================================
  21. * Copyright 2009/2013 Frank Bueltge (email : frank@bueltge.de)
  22. *
  23. * This program is free software; you can redistribute it and/or modify
  24. * it under the terms of the GNU General Public License as published by
  25. * the Free Software Foundation; either version 2 of the License, or
  26. * (at your option) any later version.
  27. *
  28. * This program is distributed in the hope that it will be useful,
  29. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  30. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  31. * GNU General Public License for more details.
  32. *
  33. * You should have received a copy of the GNU General Public License
  34. * along with this program; if not, write to the Free Software
  35. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  36. *
  37. * Requirements:
  38. * ==============================================================================
  39. * This plugin requires WordPress >= 2.7 and tested with WP 3.6 and PHP >= 5.3
  40. */
  41. // avoid direct calls to this file, because now WP core and framework has been used
  42. if ( ! function_exists( 'add_filter' ) ) {
  43. header( 'Status: 403 Forbidden' );
  44. header( 'HTTP/1.1 403 Forbidden' );
  45. exit();
  46. } elseif ( version_compare( phpversion(), '5.0.0', '<' ) ) {
  47. header( 'Status: 403 Forbidden' );
  48. header( 'HTTP/1.1 403 Forbidden' );
  49. exit( 'The plugin require PHP 5 or newer' );
  50. }
  51. class AdminerForWP {
  52. static private $classobj;
  53. public function __construct() {
  54. if ( ! is_admin() )
  55. return NULL;
  56. if ( is_multisite() && ! function_exists( 'is_plugin_active_for_network' ) )
  57. require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
  58. add_action( 'init', array( $this, 'register_styles' ) );
  59. add_action( 'init', array( $this, 'on_init' ) );
  60. add_action( 'admin_init', array( $this, 'text_domain' ) );
  61. }
  62. /**
  63. * Handler for the action 'init'. Instantiates this class.
  64. *
  65. * @since 1.2.2
  66. * @access public
  67. * @return $classobj
  68. */
  69. public function get_object() {
  70. if ( NULL === self::$classobj )
  71. self::$classobj = new self;
  72. return self::$classobj;
  73. }
  74. /**
  75. * Call functions on init of WP
  76. *
  77. * @return void
  78. */
  79. public function on_init() {
  80. // active for MU ?
  81. if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
  82. add_action( 'network_admin_menu', array( $this, 'on_network_admin_menu' ) );
  83. else
  84. add_action( 'admin_menu', array( $this, 'on_admin_menu' ) );
  85. }
  86. public function text_domain() {
  87. load_plugin_textdomain( 'adminer', false, dirname( plugin_basename(__FILE__) ) . '/languages' );
  88. }
  89. public function register_styles() {
  90. wp_register_style( 'adminer-menu', plugins_url( 'css/menu.css', __FILE__ ) );
  91. wp_register_style( 'adminer-settings', plugins_url( 'css/settings.css', __FILE__ ) );
  92. if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
  93. wp_enqueue_style( 'adminer-menu' );
  94. add_action( 'admin_bar_menu', array( $this, 'add_wp_admin_bar_item' ), 20 );
  95. }
  96. }
  97. public function on_load_page() {
  98. add_thickbox();
  99. wp_enqueue_style( 'adminer-settings' );
  100. add_action( 'contextual_help', array( $this, 'contextual_help' ), 10, 3 );
  101. }
  102. public function on_admin_menu() {
  103. if ( current_user_can( 'unfiltered_html' ) ) {
  104. wp_enqueue_style( 'adminer-menu' );
  105. $menutitle = '<span class="adminer-icon">&nbsp;</span>';
  106. $menutitle .= __( 'Adminer', 'adminer' );
  107. $this->pagehook = add_management_page(
  108. __( 'Adminer', 'adminer' ),
  109. $menutitle,
  110. 'unfiltered_html',
  111. plugin_basename(__FILE__),
  112. array( $this, 'on_show_page' )
  113. );
  114. add_action( 'load-' . $this -> pagehook, array( $this, 'on_load_page' ) );
  115. }
  116. }
  117. public function on_network_admin_menu() {
  118. if ( current_user_can('unfiltered_html' ) ) {
  119. wp_enqueue_style( 'adminer-menu' );
  120. $menutitle = '<span class="adminer-icon">&nbsp;</span>';
  121. $menutitle .= __( 'Adminer', 'adminer' );
  122. $this->pagehook = add_submenu_page(
  123. 'settings.php',
  124. __( 'Adminer', 'adminer' ),
  125. $menutitle,
  126. 'unfiltered_html',
  127. plugin_basename(__FILE__),
  128. array( $this, 'on_show_page' )
  129. );
  130. add_action( 'load-' . $this -> pagehook, array( $this, 'on_load_page' ) );
  131. }
  132. }
  133. public function add_wp_admin_bar_item( $wp_admin_bar ) {
  134. if ( is_super_admin() ) {
  135. $wp_admin_bar -> add_menu( array(
  136. 'parent' => 'network-admin',
  137. 'secondary' => FALSE,
  138. 'id' => 'network-adminer',
  139. 'title' => '<span class="adminer-icon">&nbsp;</span>' . __( 'Adminer' ),
  140. 'href' => network_admin_url( 'settings.php?page=adminer/adminer.php' ),
  141. ) );
  142. }
  143. }
  144. public function contextual_help( $contextual_help, $screen_id, $screen ) {
  145. if ( 'tools_page_adminer/adminer' !== $screen_id )
  146. return FALSE;
  147. $contextual_help = '<p>';
  148. $contextual_help .= __( 'Start the Thickbox inside the Adminer-tool with the button &rsaquo;<em>Start Adminer inside</em>&lsaquo;.', 'adminer' );
  149. $contextual_help .= '<br />';
  150. $contextual_help .= __( 'Alternatively, you can use the button for use &rsaquo;<em>Adminer in a new Tab</em>&lsaquo;.', 'adminer' );
  151. $contextual_help .= '</p>' . "\n";
  152. $contextual_help .= '<p>' . __( '<a href="http://wordpress.org/extend/plugins/adminer/">Documentation on Plugin Directory</a>', 'adminer' );
  153. $contextual_help .= ' &middot; ' . __( '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=6069955">Donate</a>', 'adminer' );
  154. $contextual_help .= ' &middot; ' .__( '<a href="http://bueltge.de/">Blog of Plugin author</a>', 'adminer' );
  155. $contextual_help .= ' &middot; ' . __( '<a href="http://www.adminer.org/">Adminer website</a></p>', 'adminer' );
  156. return $contextual_help;
  157. }
  158. /**
  159. * Strip slashes for different var
  160. *
  161. * @param $value optional Array, String
  162. * @return void
  163. */
  164. static function gpc_strip_slashes( $value = NULL ) {
  165. // cracy check, WP change the rules and also Adminer core
  166. // result; we must check wrong to the php doc
  167. if ( ! get_magic_quotes_gpc() ) {
  168. if ( NULL !== $value )
  169. $value = self::array_map_recursive( 'stripslashes_deep', $value );
  170. // stripslashes_deep or stripslashes
  171. $_REQUEST = self::array_map_recursive( 'stripslashes_deep', $_REQUEST );
  172. $_GET = self::array_map_recursive( 'stripslashes_deep', $_GET );
  173. $_POST = self::array_map_recursive( 'stripslashes_deep', $_POST );
  174. $_COOKIE = self::array_map_recursive( 'stripslashes_deep', $_COOKIE );
  175. }
  176. return $value;
  177. }
  178. /**
  179. * Deeper array_map()
  180. *
  181. * @param string $callback Callback function to map
  182. * @param array, string $value Array to map
  183. * @see http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/
  184. * @return array, string
  185. */
  186. static function array_map_recursive( $callback, $values ) {
  187. if ( is_string( $values ) ) {
  188. $r = $callback( $values );
  189. } elseif ( is_array( $values ) ) {
  190. $r = array();
  191. foreach ( $values as $k => $v ) {
  192. $r[$k] = is_scalar($v)
  193. ? $callback($v)
  194. : self::array_map_recursive( $callback, $v );
  195. }
  196. }
  197. return $r;
  198. }
  199. /**
  200. * Return page content for start Adminer
  201. *
  202. * @return void
  203. */
  204. public function on_show_page() {
  205. global $wpdb;
  206. if ( '' == DB_USER )
  207. $db_user = __( 'empty', 'adminer' );
  208. else
  209. $db_user = DB_USER;
  210. if ( '' == DB_PASSWORD )
  211. $db_password = __( 'empty', 'adminer' );
  212. else
  213. $db_password = DB_PASSWORD;
  214. ?>
  215. <div class="wrap">
  216. <?php //screen_icon('tools' ); ?>
  217. <?php screen_icon( 'adminer-settings' ); ?>
  218. <h2><?php _e( 'Adminer for WordPress', 'adminer' ); ?></h2>
  219. <img class="alignright" src="<?php echo WP_PLUGIN_URL . '/' . dirname( plugin_basename(__FILE__) ); ?>/images/logo.png" alt="Adminer Logo" />
  220. <p><a href="http://www.adminer.org/">Adminer</a> <?php _e( '(formerly phpMinAdmin) is a full-featured MySQL management tool written in PHP.', 'adminer' ); ?><br><?php _e( 'Current used version of Plugin', 'adminer' ); echo ' ' . self :: get_plugin_data( 'Name' ) . ': ' . self :: get_plugin_data( 'Version' ); ?></p>
  221. <br class="clear"/>
  222. <p>
  223. <script type="text/javascript">
  224. <!--
  225. var viewportwidth,
  226. viewportheight;
  227. if (typeof window.innerWidth != 'undefined' ) {
  228. viewportwidth = window.innerWidth-80,
  229. viewportheight = window.innerHeight-100
  230. } else if (typeof document.documentElement != 'undefined'
  231. && typeof document.documentElement.clientWidth !=
  232. 'undefined' && document.documentElement.clientWidth != 0)
  233. {
  234. viewportwidth = document.documentElement.clientWidth,
  235. viewportheight = document.documentElement.clientHeight
  236. } else { // older versions of IE
  237. viewportwidth = document.getElementsByTagName('body' )[0].clientWidth,
  238. viewportheight = document.getElementsByTagName('body' )[0].clientHeight
  239. }
  240. //document.write('<p class="textright">Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>' );
  241. document.write('<a onclick="return false;" href="<?php echo WP_PLUGIN_URL . '/' . dirname( plugin_basename(__FILE__) ); ?>/inc/adminer/loader.php?username=<?php echo DB_USER . '&amp;db=' . DB_NAME; ?>&amp;?KeepThis=true&amp;TB_iframe=true&amp;height=' + viewportheight + '&amp;width=' + viewportwidth + '" class="thickbox button"><?php _e( 'Start Adminer inside', 'adminer' ); ?></a>' );
  242. //-->
  243. </script>
  244. <a target="_blank" href="<?php echo WP_PLUGIN_URL . '/' . dirname( plugin_basename(__FILE__) ); ?>/inc/adminer/loader.php?username=<?php echo DB_USER . '&amp;db=' . DB_NAME; ?>" class="button"><?php _e( 'Start Adminer in a new tab', 'adminer' ); ?></a>
  245. </p>
  246. <p>&nbsp;</p>
  247. <noscript>
  248. <iframe src="inc/adminer/loader.php?username=<?php echo DB_USER; ?>" width="100%" height="600" name="adminer">
  249. <p><?php _e('Your browser does not support embedded frames.', 'adminer'); ?></p>
  250. </iframe>
  251. </noscript>
  252. <div class="metabox-holder has-right-sidebar">
  253. <div class="inner-sidebar">
  254. <div class="postbox">
  255. <h3><span><?php _e( 'Like this plugin?', 'adminer' ); ?></span></h3>
  256. <div class="inside">
  257. <p><?php _e( 'Here\'s how you can give back:', 'adminer' ); ?></p>
  258. <ul>
  259. <li><a href="http://wordpress.org/extend/plugins/adminer/" title="<?php esc_attr_e( 'The Plugin on the WordPress plugin repository', 'adminer' ); ?>"><?php _e( 'Give the plugin a good rating.', 'adminer' ); ?></a></li>
  260. <li><a href="http://wordpress.org/support/view/plugin-reviews/adminer" title="<?php esc_attr_e( 'Write a good review on the repository', 'adminer' ); ?>"><?php _e( 'Write a review about the plugin.', 'adminer' ); ?></a></li>
  261. <li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6069955" title="<?php esc_attr_e( 'Donate via PayPal', 'adminer' ); ?>"><?php _e( 'Donate a few euros.', 'adminer' ); ?></a></li>
  262. <li><a href="http://www.amazon.de/gp/registry/3NTOGEK181L23/ref=wl_s_3" title="<?php esc_attr_e( 'Frank B�ltge\'s Amazon Wish List', 'adminer' ); ?>"><?php _e( 'Get me something from my wish list.', 'adminer' ); ?></a></li>
  263. <li><a href="http://adminer.org" title="<?php _e( 'Adminer website for more informations and versions without WordPress', 'adminer' ); ?>"><?php _e( 'More about Adminer', 'adminer' ); ?></a></li>
  264. </ul>
  265. </div> <!-- .inside -->
  266. </div> <!-- .postbox -->
  267. </div> <!-- .inner-sidebar -->
  268. <div id="post-body">
  269. <div id="post-body-content">
  270. <div class="postbox">
  271. <h3><span><?php _e( 'Your Database Data', 'adminer' ); ?></span></h3>
  272. <div class="inside">
  273. <table class="widefat post fixed">
  274. <thead>
  275. <tr>
  276. <th><?php _e('Typ', 'adminer'); ?></th>
  277. <th><?php _e('Value', 'adminer'); ?></th>
  278. </tr>
  279. </thead>
  280. <tbody>
  281. <tr valign="top">
  282. <th scope="row"><?php _e('Server', 'adminer'); ?></th>
  283. <td><code><?php echo DB_HOST; ?></code></td>
  284. </tr>
  285. <tr valign="top">
  286. <th scope="row"><?php _e('Database', 'adminer'); ?></th>
  287. <td><code><?php echo DB_NAME; ?></code></td>
  288. </tr>
  289. <tr valign="top" class="alternate">
  290. <th scope="row"><?php _e('User', 'adminer'); ?></th>
  291. <td><code><?php echo $db_user; ?></code></td>
  292. </tr>
  293. <tr valign="top">
  294. <th scope="row"><?php _e('Password', 'adminer'); ?></th>
  295. <td><code><?php echo $db_password; ?></code></td>
  296. </tr>
  297. </tbody>
  298. </table>
  299. </div> <!-- .inside -->
  300. </div> <!-- .postbox -->
  301. </div> <!-- #post-body-content -->
  302. </div> <!-- #post-body -->
  303. </div> <!-- .metabox-holder -->
  304. </div>
  305. <?php
  306. }
  307. /**
  308. * return plugin comment data
  309. *
  310. * @uses get_plugin_data
  311. * @access public
  312. * @since 1.1.0
  313. * @param $value string, default = 'TextDomain'
  314. * Name, PluginURI, Version, Description, Author, AuthorURI, TextDomain, DomainPath, Network, Title
  315. * @return string
  316. */
  317. private static function get_plugin_data( $value = 'TextDomain' ) {
  318. static $plugin_data = array();
  319. // fetch the data just once.
  320. if ( isset( $plugin_data[ $value ] ) )
  321. return $plugin_data[ $value ];
  322. if ( ! function_exists( 'get_plugin_data' ) )
  323. require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
  324. $plugin_data = get_plugin_data( __FILE__ );
  325. $plugin_value = $plugin_data[$value];
  326. return empty ( $plugin_data[ $value ] ) ? '' : $plugin_data[ $value ];
  327. }
  328. } // end class
  329. add_action( 'plugins_loaded', array( 'AdminerForWP', 'get_object' ) );