Ejemplo n.º 1
0
<?php

$TABLE = $_GET["trigger"];
$trigger_options = trigger_options();
$trigger_event = array("INSERT", "UPDATE", "DELETE");
$dropped = false;
if ($_POST && !$error && in_array($_POST["Timing"], $trigger_options["Timing"]) && in_array($_POST["Event"], $trigger_event) && in_array($_POST["Type"], $trigger_options["Type"])) {
    $timing_event = " {$_POST['Timing']} {$_POST['Event']}";
    $on = " ON " . table($TABLE);
    $dropped = drop_create("DROP TRIGGER " . idf_escape($_GET["name"]) . ($jush == "pgsql" ? $on : ""), "CREATE TRIGGER " . idf_escape($_POST["Trigger"]) . ($jush == "mssql" ? $on . $timing_event : $timing_event . $on) . rtrim(" {$_POST['Type']}\n{$_POST['Statement']}", ";") . ";", ME . "table=" . urlencode($TABLE), array(lang('Trigger has been dropped.'), 'success'), array(lang('Trigger has been altered.'), 'success'), array(lang('Trigger has been created.'), 'success'), $_GET["name"]);
}
page_header($_GET["name"] != "" ? lang('Alter trigger') . ": " . h($_GET["name"]) : lang('Create trigger'), $error, array("table" => $TABLE));
$row = $_POST;
if (!$row) {
    $row = trigger($_GET["name"]) + array("Trigger" => $TABLE . "_bi");
}
?>

<form action="" method="post" id="form">
<table cellspacing="0">
<tr><th><?php 
echo lang('Time');
?>
<td><?php 
echo html_select("Timing", $trigger_options["Timing"], $row["Timing"], "if (/^" . preg_quote($TABLE, "/") . "_[ba][iud]\$/.test(this.form['Trigger'].value)) this.form['Trigger'].value = '" . js_escape($TABLE) . "_' + selectValue(this).charAt(0).toLowerCase() + selectValue(this.form['Event']).charAt(0).toLowerCase();");
?>
<tr><th><?php 
echo lang('Event');
?>
<td><?php 
echo html_select("Event", $trigger_event, $row["Event"], "this.form['Timing'].onchange();");
Ejemplo n.º 2
0
    $location = ME . "table=" . urlencode($name);
    $message = lang('View has been altered.');
    if ($_GET["materialized"]) {
        $type = "MATERIALIZED VIEW";
    } else {
        $type = "VIEW";
        if ($jush == "pgsql") {
            $status = table_status($name);
            $type = $status ? strtoupper($status["Engine"]) : $type;
        }
    }
    if (!$_POST["drop"] && $TABLE == $name && $jush != "sqlite" && $type != "MATERIALIZED VIEW") {
        query_redirect(($jush == "mssql" ? "ALTER" : "CREATE OR REPLACE") . " VIEW " . table($name) . $as, $location, $message);
    } else {
        $temp_name = $name . "_adminer_" . uniqid();
        drop_create("DROP {$type} " . table($TABLE), "CREATE {$type} " . table($name) . $as, "DROP {$type} " . table($name), "CREATE {$type} " . table($temp_name) . $as, "DROP {$type} " . table($temp_name), $_POST["drop"] ? substr(ME, 0, -1) : $location, lang('View has been dropped.'), $message, lang('View has been created.'), $TABLE, $name);
    }
}
if (!$_POST && $TABLE != "") {
    $row = view($TABLE);
    $row["name"] = $TABLE;
    if (!$error) {
        $error = error();
    }
}
page_header($TABLE != "" ? lang('Alter view') : lang('Create view'), $error, array("table" => $TABLE), h($TABLE));
?>

<form action="" method="post">
<p><?php 
echo lang('Name');
Ejemplo n.º 3
0
$PROCEDURE = $_GET["procedure"];
$routine = isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE";
$routine_languages = routine_languages();
$dropped = false;
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
    $set = array();
    $fields = (array) $_POST["fields"];
    ksort($fields);
    // enforce fields order
    foreach ($fields as $field) {
        if ($field["field"] != "") {
            $set[] = (ereg("^({$inout})\$", $field["inout"]) ? "{$field['inout']} " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
        }
    }
    $dropped = drop_create("DROP {$routine} " . idf_escape($PROCEDURE), "CREATE {$routine} " . idf_escape(trim($_POST["name"])) . " (" . implode(", ", $set) . ")" . (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "") . (in_array($_POST["language"], $routine_languages) ? " LANGUAGE {$_POST['language']}" : "") . rtrim("\n{$_POST['definition']}", ";") . ";", substr(ME, 0, -1), lang('Routine has been dropped.'), lang('Routine has been altered.'), lang('Routine has been created.'), $PROCEDURE);
}
page_header($PROCEDURE != "" ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($PROCEDURE) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure')), $error);
$collations = get_vals("SHOW CHARACTER SET");
sort($collations);
$row = array("fields" => array());
if ($_POST) {
    $row = $_POST;
    $row["fields"] = (array) $row["fields"];
    process_fields($row["fields"]);
} elseif ($PROCEDURE != "") {
    $row = routine($PROCEDURE, $routine);
    $row["name"] = $PROCEDURE;
}
?>
Ejemplo n.º 4
0
<?php

$PROCEDURE = $_GET["procedure"];
$routine = isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE";
$row = $_POST;
$row["fields"] = (array) $row["fields"];
if ($_POST && !process_fields($row["fields"]) && !$error) {
    $temp_name = "{$row['name']}_adminer_" . uniqid();
    drop_create("DROP {$routine} " . idf_escape($PROCEDURE), create_routine($routine, $row), "DROP {$routine} " . idf_escape($row["name"]), create_routine($routine, array("name" => $temp_name) + $row), "DROP {$routine} " . idf_escape($temp_name), substr(ME, 0, -1), lang('Routine has been dropped.'), lang('Routine has been altered.'), lang('Routine has been created.'), $PROCEDURE, $row["name"]);
}
page_header($PROCEDURE != "" ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($PROCEDURE) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure')), $error);
if (!$_POST && $PROCEDURE != "") {
    $row = routine($PROCEDURE, $routine);
    $row["name"] = $PROCEDURE;
}
$collations = get_vals("SHOW CHARACTER SET");
sort($collations);
$routine_languages = routine_languages();
?>

<form action="" method="post" id="form">
<p><?php 
echo lang('Name');
?>
: <input name="name" value="<?php 
echo h($row["name"]);
?>
" maxlength="64" autocapitalize="off">
<?php 
echo $routine_languages ? lang('Language') . ": " . html_select("language", $routine_languages, $row["language"]) : "";
?>
Ejemplo n.º 5
0
<?php

$TABLE = $_GET["view"];
$dropped = false;
if ($_POST && !$error) {
    $dropped = drop_create("DROP VIEW " . table($TABLE), "CREATE VIEW " . table($_POST["name"]) . " AS\n{$_POST['select']}", $_POST["drop"] ? substr(ME, 0, -1) : ME . "table=" . urlencode($_POST["name"]), lang('View has been dropped.'), lang('View has been altered.'), lang('View has been created.'), $TABLE);
}
page_header($TABLE != "" ? lang('Alter view') : lang('Create view'), $error, array("table" => $TABLE), $TABLE);
$row = $_POST;
if (!$row && $TABLE != "") {
    $row = view($TABLE);
    $row["name"] = $TABLE;
}
?>

<form action="" method="post">
<p><?php 
echo lang('Name');
?>
: <input name="name" value="<?php 
echo h($row["name"]);
?>
" maxlength="64">
<p><?php 
textarea("select", $row["select"]);
?>
<p>
<?php 
if ($dropped) {
    // old view was dropped but new wasn't created
    ?>