Beispiel #1
0
 /**
  * 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;
 }
Beispiel #2
0
/** Execute query and redirect if successful
* @param string
* @param string
* @param string
* @param bool
* @param bool
* @param bool
* @return bool
*/
function query_adminer_redirect($query, $location, $message, $redirect = true, $execute = true, $failed = false, $time = "")
{
    global $connection, $error, $adminer;
    if ($execute) {
        $start = microtime(true);
        $failed = !$connection->query($query);
        $time = format_time($start);
    }
    $sql = "";
    if ($query) {
        // filter query via plugin fct.
        $query = AdminerForWP::array_map_recursive('stripslashes', $query);
        $sql = $adminer->messageQuery($query, $time);
    }
    if ($failed) {
        $error = error() . $sql;
        return false;
    }
    if ($redirect) {
        adminer_redirect($location, $message . $sql);
    }
    return true;
}
Beispiel #3
0
<?php

/** Adminer - Compact database management
* @link http://www.adminer.org/
* @author Jakub Vrana, http://www.vrana.cz/
* @copyright 2007 Jakub Vrana
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
// Remove Magic Quotes
if (!class_exists('AdminerForWP')) {
    require_once '../../adminer.php';
    new AdminerForWP();
}
AdminerForWP::gpc_strip_slashes();
include "./include/bootstrap.inc.php";
$enum_length = "'(?:''|[^'\\\\]|\\\\.)*+'";
$inout = "IN|OUT|INOUT";
if (isset($_GET["select"]) && ($_POST["edit"] || $_POST["clone"]) && !$_POST["save"]) {
    $_GET["edit"] = $_GET["select"];
}
if (isset($_GET["callf"])) {
    $_GET["call"] = $_GET["callf"];
}
if (isset($_GET["function"])) {
    $_GET["procedure"] = $_GET["function"];
}
if (isset($_GET["download"])) {
    include "./download.inc.php";
} elseif (isset($_GET["table"])) {
    include "./table.inc.php";
            echo "<p class='error'>" . lang('Error in query') . ": " . implode("", $errors) . "\n";
        }
        //! MS SQL - SET SHOWPLAN_ALL OFF
    } else {
        echo "<p class='error'>" . upload_error($query) . "\n";
    }
}
?>

<form action="" method="post" enctype="multipart/form-data" id="form">
<p><?php 
$_GET = AdminerForWP::array_map_recursive('stripslashes_deep', $_GET);
$q = $_GET["sql"];
// overwrite $q from if ($_POST) to save memory
if ($_POST) {
    $_POST = AdminerForWP::array_map_recursive('stripslashes_deep', $_POST);
    $q = $_POST["query"];
} elseif ($_GET["history"] == "all") {
    $q = $history;
} elseif ($_GET["history"] != "") {
    $q = $history[$_GET["history"]];
}
textarea("query", $q, 20);
echo $_POST ? "" : "<script type='text/javascript'>document.getElementsByTagName('textarea')[0].focus();</script>\n";
echo "<p>" . (ini_bool("file_uploads") ? lang('File upload') . ': <input type="file" name="sql_file"' . ($_FILES && $_FILES["sql_file"]["error"] != 4 ? '' : ' onchange="this.form[\'only_errors\'].checked = true;"') . '> (&lt; ' . ini_get("upload_max_filesize") . 'B)' : lang('File uploads are disabled.'));
?>
<p>
<input type="submit" value="<?php 
echo lang('Execute');
?>
" title="Ctrl+Enter">
 /**
  * Deeper array_map()
  *
  * @param string $callback Callback function to map
  * @param array $array Array to map
  * @source http://www.sitepoint.com/blogs/2005/03/02/magic-quotes-headaches/
  * @return array
  */
 static function array_map_recursive($callback, $array)
 {
     $r = array();
     if (is_array($array)) {
         foreach ($array as $k => $v) {
             $r[$k] = is_scalar($v) ? $callback($v) : AdminerForWP::array_map_recursive($callback, $v);
         }
     }
     return $r;
 }
/** Print results of search in all tables
* @uses $_GET["where"][0]
* @uses $_POST["tables"]
* @return null
*/
function search_tables()
{
    global $adminer, $connection;
    $_POST = AdminerForWP::array_map_recursive('stripslashes_deep', $_POST);
    $_GET["where"][0]["op"] = "LIKE %%";
    $_GET["where"][0]["val"] = $_POST["query"];
    $found = false;
    foreach (table_status() as $table => $table_status) {
        $name = $adminer->tableName($table_status);
        if (isset($table_status["Engine"]) && $name != "" && (!$_POST["tables"] || in_array($table, $_POST["tables"]))) {
            $result = $connection->query("SELECT" . limit("1 FROM " . table($table), " WHERE " . implode(" AND ", $adminer->selectSearchProcess(fields($table), array())), 1));
            if ($result->fetch_row()) {
                if (!$found) {
                    echo "<ul>\n";
                    $found = true;
                }
                echo "<li><a href='" . h(ME . "select=" . urlencode($table) . "&where[0][op]=" . urlencode($_GET["where"][0]["op"]) . "&where[0][val]=" . urlencode($_GET["where"][0]["val"])) . "'>{$name}</a>\n";
            }
        }
    }
    echo ($found ? "</ul>" : "<p class='message'>" . lang('No tables.')) . "\n";
}