Пример #1
0
     if ($out) {
         echo "DELIMITER ;;\n\n{$out}" . "DELIMITER ;\n\n";
     }
 }
 if ($_POST["table_style"] || $_POST["data_style"]) {
     $views = array();
     foreach (table_status('', true) as $name => $table_status) {
         $table = DB == "" || in_array($name, (array) $_POST["tables"]);
         $data = DB == "" || in_array($name, (array) $_POST["data"]);
         if ($table || $data) {
             if ($ext == "tar") {
                 $tmp_file = new TmpFile();
                 ob_start(array($tmp_file, 'write'), 100000.0);
             }
             $adminer->dumpTable($name, $table ? $_POST["table_style"] : "", is_view($table_status) ? 2 : 0);
             if (is_view($table_status)) {
                 $views[] = $name;
             } elseif ($data) {
                 $fields = fields($name);
                 $adminer->dumpData($name, $_POST["data_style"], "SELECT *" . convert_fields($fields, $fields) . " FROM " . table($name));
             }
             if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($name, $_POST["table_style"]))) {
                 echo "\nDELIMITER ;;\n{$triggers}\nDELIMITER ;\n";
             }
             if ($ext == "tar") {
                 ob_end_flush();
                 tar_file((DB != "" ? "" : "{$db}/") . "{$name}.csv", $tmp_file);
             } elseif ($is_sql) {
                 echo "\n";
             }
         }
Пример #2
0
        echo "<h3 id='foreign-keys'>" . lang('Foreign keys') . "</h3>\n";
        $foreign_keys = foreign_keys($TABLE);
        if ($foreign_keys) {
            echo "<table cellspacing='0'>\n";
            echo "<thead><tr><th>" . lang('Source') . "<td>" . lang('Target') . "<td>" . lang('ON DELETE') . "<td>" . lang('ON UPDATE') . "<td>&nbsp;</thead>\n";
            foreach ($foreign_keys as $name => $foreign_key) {
                echo "<tr title='" . h($name) . "'>";
                echo "<th><i>" . implode("</i>, <i>", array_map('h', $foreign_key["source"])) . "</i>";
                echo "<td><a href='" . h($foreign_key["db"] != "" ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), ME) : ($foreign_key["ns"] != "" ? preg_replace('~ns=[^&]*~', "ns=" . urlencode($foreign_key["ns"]), ME) : ME)) . "table=" . urlencode($foreign_key["table"]) . "'>" . ($foreign_key["db"] != "" ? "<b>" . h($foreign_key["db"]) . "</b>." : "") . ($foreign_key["ns"] != "" ? "<b>" . h($foreign_key["ns"]) . "</b>." : "") . h($foreign_key["table"]) . "</a>";
                echo "(<i>" . implode("</i>, <i>", array_map('h', $foreign_key["target"])) . "</i>)";
                echo "<td>" . nbsp($foreign_key["on_delete"]) . "\n";
                echo "<td>" . nbsp($foreign_key["on_update"]) . "\n";
                echo '<td><a href="' . h(ME . 'foreign=' . urlencode($TABLE) . '&name=' . urlencode($name)) . '">' . lang('Alter') . '</a>';
            }
            echo "</table>\n";
        }
        echo '<p class="links"><a href="' . h(ME) . 'foreign=' . urlencode($TABLE) . '">' . lang('Add foreign key') . "</a>\n";
    }
}
if (support(is_view($table_status) ? "view_trigger" : "trigger")) {
    echo "<h3 id='triggers'>" . lang('Triggers') . "</h3>\n";
    $triggers = triggers($TABLE);
    if ($triggers) {
        echo "<table cellspacing='0'>\n";
        foreach ($triggers as $key => $val) {
            echo "<tr valign='top'><td>" . h($val[0]) . "<td>" . h($val[1]) . "<th>" . h($key) . "<td><a href='" . h(ME . 'trigger=' . urlencode($TABLE) . '&name=' . urlencode($key)) . "'>" . lang('Alter') . "</a>\n";
        }
        echo "</table>\n";
    }
    echo '<p class="links"><a href="' . h(ME) . 'trigger=' . urlencode($TABLE) . '">' . lang('Add trigger') . "</a>\n";
}
Пример #3
0
 /** Prints table list in menu
  * @param array result of table_status('', true)
  * @return null
  */
 function tablesPrint($tables)
 {
     echo "<p id='tables' onmouseover='menuOver(this, event);' onmouseout='menuOut(this);'>\n";
     foreach ($tables as $table => $status) {
         echo '<a href="' . h(ME) . 'select=' . urlencode($table) . '"' . bold($_GET["select"] == $table || $_GET["edit"] == $table, "select") . ">" . lang('select') . "</a> ";
         $name = $this->tableName($status);
         echo (support("table") || support("indexes") ? '<a href="' . h(ME) . 'table=' . urlencode($table) . '"' . bold(in_array($table, array($_GET["table"], $_GET["create"], $_GET["indexes"], $_GET["foreign"], $_GET["trigger"])), is_view($status) ? "view" : "", "structure") . " title='" . lang('Show structure') . "'>{$name}</a>" : "<span>{$name}</span>") . "<br>\n";
     }
 }
Пример #4
0
 /** Print links after select heading
  * @param array result of SHOW TABLE STATUS
  * @param string new item options, NULL for no new item
  * @return null
  */
 function selectLinks($tableStatus, $set = "")
 {
     echo '<p class="tabs">';
     $links = array("select" => lang('Select data'), "table" => lang('Show structure'));
     if (is_view($tableStatus)) {
         $links["view"] = lang('Alter view');
     } else {
         $links["create"] = lang('Alter table');
     }
     if (isset($set)) {
         $links["edit"] = lang('New item');
     }
     foreach ($links as $key => $val) {
         echo " <a href='" . h(ME) . "{$key}=" . urlencode($tableStatus["Name"]) . ($key == "edit" ? $set : "") . "'" . bold(isset($_GET[$key])) . ">{$val}</a>";
     }
     echo "\n";
 }