]> git.joonet.de Git - adminer.git/commitdiff
Suhosin compatibility (thanks to Klemens Hackel)
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 2 Mar 2009 13:38:00 +0000 (13:38 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 2 Mar 2009 13:38:00 +0000 (13:38 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@559 7c3ca157-0c34-0410-bff1-cbf682f78f5c

create.inc.php
editing.inc.php
lang/cs.inc.php

index 0aac00f173e2a7163ef4ebb6fe5ab8cf3257afbf..5acf780b5e24bd6b8d17ddc61cd6d3208b76b133 100644 (file)
@@ -106,6 +106,11 @@ if ($_POST) {
        $row = array("fields" => array(array("field" => "")), "partition_names" => array());
 }
 $collations = collations();
+
+$suhosin = floor(extension_loaded("suhosin") ? (min(ini_get("suhosin.request.max_vars"), ini_get("suhosin.post.max_vars")) - 13) / 8 : 0);
+if ($suhosin && count($row["fields"]) > $suhosin) {
+       echo "<p class='error'>" . htmlspecialchars(lang('Maximum number of allowed fields exceeded. Please increase %s and %s.', 'suhosin.post.max_vars', 'suhosin.request.max_vars')) . "</p>\n";
+}
 ?>
 
 <form action="" method="post" id="form">
@@ -118,7 +123,7 @@ $collations = collations();
 <table border="0" cellspacing="0" cellpadding="2">
 <?php $column_comments = edit_fields($row["fields"], $collations); ?>
 </table>
-<?php echo type_change(count($row["fields"])); ?>
+<?php echo type_change(count($row["fields"]), $suhosin); ?>
 <p>
 <?php echo lang('Auto Increment'); ?>: <input name="Auto_increment" size="4" value="<?php echo intval($row["Auto_increment"]); ?>" />
 <?php echo lang('Comment'); ?>: <input name="Comment" value="<?php echo htmlspecialchars($row["Comment"]); ?>" maxlength="60" />
index 12d7e199d72442d141110abb5410a101a9540d81..58bec4aede8737b25233bbe1a32cad7b1f77dc2e 100644 (file)
@@ -90,7 +90,7 @@ function edit_type($key, $field, $collations) {
        ?>
 <td><select name="<?php echo $key; ?>[type]" onchange="type_change(this);"><?php echo optionlist(array_keys($types), $field["type"]); ?></select></td>
 <td><input name="<?php echo $key; ?>[length]" value="<?php echo htmlspecialchars($field["length"]); ?>" size="3" /></td>
-<td><select name="<?php echo $key; ?>[collation]"><option value="">(<?php echo lang('collation'); ?>)</option><?php echo optionlist($collations, $field["collation"]); ?></select> <select name="<?php echo $key; ?>[unsigned]"><?php echo optionlist($unsigned, $field["unsigned"]); ?></select></td>
+<td><select name="<?php echo $key; ?>[collation]"<?php echo (preg_match('~char|text|enum|set~', $field["type"]) ? "" : " class='hidden'"); ?>><option value="">(<?php echo lang('collation'); ?>)</option><?php echo optionlist($collations, $field["collation"]); ?></select> <select name="<?php echo $key; ?>[unsigned]"<?php echo (!$field["type"] || preg_match('~int|float|double|decimal~', $field["type"]) ? "" : " class='hidden'"); ?>><?php echo optionlist($unsigned, $field["unsigned"]); ?></select></td>
 <?php
 }
 
@@ -186,11 +186,15 @@ function process_fields(&$fields) {
        }
 }
 
-function type_change($count) {
+function type_change($count, $allowed = 0) {
        ?>
-<script type="text/javascript">
+<script type="text/javascript">// <![CDATA[
 var added = '.';
+var row_count = <?php echo $count; ?>;
 function add_row(button) {
+       if (<?php echo $allowed; ?> && row_count >= <?php echo $allowed; ?>) {
+               return false;
+       }
        var match = /([0-9]+)(\.[0-9]+)?/.exec(button.name)
        var x = match[0] + (match[2] ? added.substr(match[2].length) : added) + '1';
        var row = button.parentNode.parentNode;
@@ -215,6 +219,7 @@ function add_row(button) {
        row.parentNode.insertBefore(row2, row);
        tags[0].focus();
        added += '0';
+       row_count++;
        return true;
 }
 function remove_row(button) {
@@ -235,10 +240,7 @@ function type_change(type) {
                }
        }
 }
-for (var i=1; <?php echo $count; ?> >= i; i++) {
-       document.getElementById('form')['fields[' + i + '][type]'].onchange();
-}
-</script>
+// ]]></script>
 <?php
 }
 
index 748e087c69584c5141e7719ca721f5546c4b2ca1..7c97aaf274bbddb3d314db3176a82a4d8de15b33 100644 (file)
@@ -214,4 +214,6 @@ $translations = array(
        'Table structure' => 'Struktura tabulky',
        'Select table' => 'Vypsat tabulku',
        'Stop on error' => 'Zastavit při chybě',
+       'Maximum number of allowed fields exceeded. Please increase %s and %s.' => 'Byl překročen maximální povolený počet polí. Zvyšte prosím %s a %s.',
+       '(anywhere)' => '(kdekoliv)',
 );