adminerevo/adminer/procedure.inc.php

59 lines
2.3 KiB
PHP
Raw Permalink Normal View History

<?php
2018-01-30 14:18:26 +00:00
$PROCEDURE = ($_GET["name"] ? $_GET["name"] : $_GET["procedure"]);
$routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
$row = $_POST;
$row["fields"] = (array) $row["fields"];
2013-05-08 18:43:53 +00:00
if ($_POST && !process_fields($row["fields"]) && !$error) {
2018-01-30 14:18:26 +00:00
$orig = routine($_GET["procedure"], $routine);
2013-05-08 18:43:53 +00:00
$temp_name = "$row[name]_adminer_" . uniqid();
drop_create(
2018-01-30 14:18:26 +00:00
"DROP $routine " . routine_id($PROCEDURE, $orig),
2013-05-08 18:43:53 +00:00
create_routine($routine, $row),
2018-01-30 14:18:26 +00:00
"DROP $routine " . routine_id($row["name"], $row),
2013-05-08 18:43:53 +00:00
create_routine($routine, array("name" => $temp_name) + $row),
2018-01-30 14:18:26 +00:00
"DROP $routine " . routine_id($temp_name, $row),
2013-05-08 18:43:53 +00:00
substr(ME, 0, -1),
lang('Routine has been dropped.'),
lang('Routine has been altered.'),
lang('Routine has been created.'),
$PROCEDURE,
$row["name"]
2013-05-08 18:43:53 +00:00
);
}
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 != "") {
2018-01-30 14:18:26 +00:00
$row = routine($_GET["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"]); ?>" data-maxlength="64" autocapitalize="off">
2018-01-30 14:18:26 +00:00
<?php echo ($routine_languages ? lang('Language') . ": " . html_select("language", $routine_languages, $row["language"]) . "\n" : ""); ?>
<input type="submit" value="<?php echo lang('Save'); ?>">
2018-10-27 19:20:56 +00:00
<div class="scrollable">
<table cellspacing="0" class="nowrap">
<?php
edit_fields($row["fields"], $collations, $routine);
if (isset($_GET["function"])) {
echo "<tr><td>" . lang('Return type');
edit_type("returns", $row["returns"], $collations, array(), ($jush == "pgsql" ? array("void", "trigger") : array()));
}
?>
</table>
2019-12-20 12:50:20 +00:00
<?php echo script("editFields();"); ?>
</div>
<p><?php textarea("definition", $row["definition"]); ?>
<p>
<input type="submit" value="<?php echo lang('Save'); ?>">
<?php if ($PROCEDURE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"><?php echo confirm(lang('Drop %s?', $PROCEDURE)); ?><?php } ?>
2011-03-08 12:43:05 +00:00
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form>