Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 383 lines (367 sloc) 15.316 kb
a7096dd Separate editing functions
jakubvrana authored
1 <?php
471ae2b Move select function
jakubvrana authored
2 /** Print select result
3 * @param Min_Result
4 * @param Min_DB connection to examine indexes
0449351 @vrana Report errors only in primary connection
authored
5 * @param string base link for <th> fields
471ae2b Move select function
jakubvrana authored
6 * @return null
7 */
5a2c064 @vrana Link to EXPLAIN output
authored
8 function select($result, $connection2 = null, $href = "") {
782921b @vrana Finish SQLite
authored
9 $links = array(); // colno => orgtable - create links from these columns
10 $indexes = array(); // orgtable => array(column => colno) - primary keys
11 $columns = array(); // orgtable => array(column => ) - not selected columns in primary key
12 $blobs = array(); // colno => bool - display bytes for blobs
13 $types = array(); // colno => type - display char in <code>
14 odd(''); // reset odd for each result
15 for ($i=0; $row = $result->fetch_row(); $i++) {
16 if (!$i) {
17 echo "<table cellspacing='0' class='nowrap'>\n";
18 echo "<thead><tr>";
19 for ($j=0; $j < count($row); $j++) {
20 $field = $result->fetch_field();
8a9642b @vrana Link tables and indexes from SQL command EXPLAIN
authored
21 $name = $field->name;
782921b @vrana Finish SQLite
authored
22 $orgtable = $field->orgtable;
23 $orgname = $field->orgname;
8a9642b @vrana Link tables and indexes from SQL command EXPLAIN
authored
24 if ($href) { // MySQL EXPLAIN
25 $links[$j] = ($name == "table" ? "table=" : ($name == "possible_keys" ? "indexes=" : null));
26 } elseif ($orgtable != "") {
782921b @vrana Finish SQLite
authored
27 if (!isset($indexes[$orgtable])) {
28 // find primary key in each table
29 $indexes[$orgtable] = array();
30 foreach (indexes($orgtable, $connection2) as $index) {
31 if ($index["type"] == "PRIMARY") {
32 $indexes[$orgtable] = array_flip($index["columns"]);
33 break;
471ae2b Move select function
jakubvrana authored
34 }
35 }
782921b @vrana Finish SQLite
authored
36 $columns[$orgtable] = $indexes[$orgtable];
471ae2b Move select function
jakubvrana authored
37 }
782921b @vrana Finish SQLite
authored
38 if (isset($columns[$orgtable][$orgname])) {
39 unset($columns[$orgtable][$orgname]);
40 $indexes[$orgtable][$orgname] = $j;
41 $links[$j] = $orgtable;
471ae2b Move select function
jakubvrana authored
42 }
43 }
782921b @vrana Finish SQLite
authored
44 if ($field->charsetnr == 63) { // 63 - binary
45 $blobs[$j] = true;
46 }
47 $types[$j] = $field->type;
8a9642b @vrana Link tables and indexes from SQL command EXPLAIN
authored
48 $name = h($name);
f195903 @vrana Use rel="noreferrer" for documentation links
authored
49 echo "<th" . ($orgtable != "" || $field->name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">" . ($href ? "<a href='$href" . strtolower($name) . "' target='_blank' rel='noreferrer'>$name</a>" : $name);
471ae2b Move select function
jakubvrana authored
50 }
782921b @vrana Finish SQLite
authored
51 echo "</thead>\n";
52 }
53 echo "<tr" . odd() . ">";
54 foreach ($row as $key => $val) {
55 if (!isset($val)) {
56 $val = "<i>NULL</i>";
8a9642b @vrana Link tables and indexes from SQL command EXPLAIN
authored
57 } elseif ($blobs[$key] && !is_utf8($val)) {
58 $val = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>"; //! link to download
59 } elseif (!strlen($val)) { // strlen - SQLite can return int
60 $val = "&nbsp;"; // some content to print a border
782921b @vrana Finish SQLite
authored
61 } else {
8a9642b @vrana Link tables and indexes from SQL command EXPLAIN
authored
62 $val = h($val);
63 if ($types[$key] == 254) { // 254 - char
64 $val = "<code>$val</code>";
782921b @vrana Finish SQLite
authored
65 }
8a9642b @vrana Link tables and indexes from SQL command EXPLAIN
authored
66 }
67 if (isset($links[$key]) && !$columns[$links[$key]]) {
68 if ($href) { // MySQL EXPLAIN
69 $link = $links[$key] . urlencode($row[array_search("table=", $links)]);
70 } else {
782921b @vrana Finish SQLite
authored
71 $link = "edit=" . urlencode($links[$key]);
72 foreach ($indexes[$links[$key]] as $col => $j) {
73 $link .= "&where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]);
471ae2b Move select function
jakubvrana authored
74 }
75 }
8a9642b @vrana Link tables and indexes from SQL command EXPLAIN
authored
76 $val = "<a href='" . h(ME . $link) . "'>$val</a>";
471ae2b Move select function
jakubvrana authored
77 }
782921b @vrana Finish SQLite
authored
78 echo "<td>$val";
471ae2b Move select function
jakubvrana authored
79 }
80 }
782921b @vrana Finish SQLite
authored
81 echo ($i ? "</table>" : "<p class='message'>" . lang('No rows.')) . "\n";
471ae2b Move select function
jakubvrana authored
82 }
83
1118566 Documentation
jakubvrana authored
84 /** Get referencable tables with single column primary key except self
85 * @param string
86 * @return array ($table_name => $field)
87 */
ced9de9 Create single column foreign key in table structure
jakubvrana authored
88 function referencable_primary($self) {
89 $return = array(); // table_name => field
3f5b683 Reintegrate sqlite branch
jakubvrana authored
90 foreach (table_status() as $table_name => $table) {
91 if ($table_name != $self && fk_support($table)) {
ced9de9 Create single column foreign key in table structure
jakubvrana authored
92 foreach (fields($table_name) as $field) {
93 if ($field["primary"]) {
94 if ($return[$table_name]) { // multi column primary key
95 unset($return[$table_name]);
96 break;
97 }
98 $return[$table_name] = $field;
99 }
100 }
101 }
102 }
103 return $return;
104 }
105
d6ac5f1 @vrana Move textarea function to editing.*
authored
106 /** Print SQL <textarea> tag
107 * @param string
108 * @param int
109 * @param int
110 * @param string
111 * @return null
112 */
113 function textarea($name, $value, $rows = 10, $cols = 80) {
4787b57 @vrana Revert "Highlight SQL code in textarea"
authored
114 echo "<textarea name='$name' rows='$rows' cols='$cols' class='sqlarea' spellcheck='false' wrap='off' onkeydown='return textareaKeydown(this, event);'>"; // spellcheck, wrap - not valid before HTML5
ef9d6d4 @vrana Save memory
authored
115 if (is_array($value)) {
116 foreach ($value as $val) { // not implode() to save memory
2e6ad20 @vrana Display ; in history (thanks to Jan Cerny)
authored
117 echo h($val) . "\n\n\n";
ef9d6d4 @vrana Save memory
authored
118 }
119 } else {
120 echo h($value);
121 }
122 echo "</textarea>";
d6ac5f1 @vrana Move textarea function to editing.*
authored
123 }
124
9eced78 @vrana Display total time in show only errors mode in SQL command
authored
125 /** Format time difference
0060c60 @vrana Save bytes
authored
126 * @param string output of microtime()
127 * @param string output of microtime()
9eced78 @vrana Display total time in show only errors mode in SQL command
authored
128 * @return string HTML code
129 */
130 function format_time($start, $end) {
0060c60 @vrana Save bytes
authored
131 return " <span class='time'>(" . lang('%.3f s', max(0, array_sum(explode(" ", $end)) - array_sum(explode(" ", $start)))) . ")</span>";
9eced78 @vrana Display total time in show only errors mode in SQL command
authored
132 }
133
1118566 Documentation
jakubvrana authored
134 /** Print table columns for type edit
135 * @param string
136 * @param array
137 * @param array
138 * @param array returned by referencable_primary()
139 * @return null
140 */
ced9de9 Create single column foreign key in table structure
jakubvrana authored
141 function edit_type($key, $field, $collations, $foreign_keys = array()) {
b0d637b @vrana Avoid fatal errors
authored
142 global $structured_types, $types, $unsigned, $on_actions;
f2813b5 Don't hide/show added/dropped columns (bug 1920167)
jakubvrana authored
143 ?>
6e2a887 @vrana Typos
authored
144 <td><select name="<?php echo $key; ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);"><?php echo optionlist((!$field["type"] || isset($types[$field["type"]]) ? array() : array($field["type"])) + $structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
d0cf5a8 @vrana Create table options width
authored
145 <td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"><td class="options"><?php
5cac902 Work with default values
jakubvrana authored
146 echo "<select name='$key" . "[collation]'" . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
dc4fc82 @vrana ON DELETE action for foreign keys in Create table
authored
147 echo ($unsigned ? "<select name='$key" . "[unsigned]'" . (!$field["type"] || ereg('(int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
8e75d54 @vrana Save bytes
authored
148 echo ($foreign_keys ? "<select name='$key" . "[on_delete]'" . (ereg("`", $field["type"]) ? "" : " class='hidden'") . "><option value=''>(" . lang('ON DELETE') . ")" . optionlist(explode("|", $on_actions), $field["on_delete"]) . "</select> " : " "); // space for IE
a7096dd Separate editing functions
jakubvrana authored
149 }
150
1118566 Documentation
jakubvrana authored
151 /** Filter length value including enums
152 * @param string
153 * @return string
154 */
f93c84e Function process_length used only in Adminer
jakubvrana authored
155 function process_length($length) {
156 global $enum_length;
157 return (preg_match("~^\\s*(?:$enum_length)(?:\\s*,\\s*(?:$enum_length))*\\s*\$~", $length) && preg_match_all("~$enum_length~", $length, $matches) ? implode(",", $matches[0]) : preg_replace('~[^0-9,+-]~', '', $length));
158 }
159
1118566 Documentation
jakubvrana authored
160 /** Create SQL string from field type
161 * @param array
162 * @param string
163 * @return string
164 */
a3c969c Routines uses CHARACTER SET
jakubvrana authored
165 function process_type($field, $collate = "COLLATE") {
7e644b4 @vrana Save bytes ($connection->quote shortcut)
authored
166 global $unsigned;
9e1d1c3 @vrana Respect unsupported types
authored
167 return " $field[type]"
4780703 @vrana Respect PostgreSQL custom types
authored
168 . ($field["length"] != "" ? "(" . process_length($field["length"]) . ")" : "")
5abd943 Change simple preg_match to ereg
jakubvrana authored
169 . (ereg('int|float|double|decimal', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
7e644b4 @vrana Save bytes ($connection->quote shortcut)
authored
170 . (ereg('char|text|enum|set', $field["type"]) && $field["collation"] ? " $collate " . q($field["collation"]) : "")
a7096dd Separate editing functions
jakubvrana authored
171 ;
172 }
173
1118566 Documentation
jakubvrana authored
174 /** Create SQL string from field
175 * @param array basic field information
176 * @param array information about field type
9e1d1c3 @vrana Respect unsupported types
authored
177 * @return array array("field", "type", "NULL", "DEFAULT", "ON UPDATE", "COMMENT", "AUTO_INCREMENT")
1118566 Documentation
jakubvrana authored
178 */
2e680bc Speedup of simple alter table
jakubvrana authored
179 function process_field($field, $type_field) {
3f5b683 Reintegrate sqlite branch
jakubvrana authored
180 return array(
181 idf_escape($field["field"]),
182 process_type($type_field),
183 ($field["null"] ? " NULL" : " NOT NULL"), // NULL for timestamp
4ff2f03 @vrana Alter bit type default value
authored
184 (isset($field["default"]) ? " DEFAULT " . (($field["type"] == "timestamp" && eregi('^CURRENT_TIMESTAMP$', $field["default"])) || ($field["type"] == "bit" && ereg("^([0-9]+|b'[0-1]+')\$", $field["default"])) ? $field["default"] : q($field["default"])) : ""),
3f5b683 Reintegrate sqlite branch
jakubvrana authored
185 ($field["on_update"] ? " ON UPDATE $field[on_update]" : ""),
7e644b4 @vrana Save bytes ($connection->quote shortcut)
authored
186 (support("comment") && $field["comment"] != "" ? " COMMENT " . q($field["comment"]) : ""),
736d6e4 @vrana Fix alter table
authored
187 ($field["auto_increment"] ? auto_increment() : null),
3f5b683 Reintegrate sqlite branch
jakubvrana authored
188 );
2e680bc Speedup of simple alter table
jakubvrana authored
189 }
190
1118566 Documentation
jakubvrana authored
191 /** Get type class to use in CSS
192 * @param string
193 * @return string class=''
194 */
3015aed Separate type_class
jakubvrana authored
195 function type_class($type) {
d144e9c Save bytes
jakubvrana authored
196 foreach (array(
197 'char' => 'text',
198 'date' => 'time|year',
199 'binary' => 'blob',
200 'enum' => 'set',
201 ) as $key => $val) {
c0c7ab3 Typo
jakubvrana authored
202 if (ereg("$key|$val", $type)) {
d144e9c Save bytes
jakubvrana authored
203 return " class='$key'";
204 }
3015aed Separate type_class
jakubvrana authored
205 }
206 }
207
1118566 Documentation
jakubvrana authored
208 /** Print table interior for fields editing
209 * @param array
210 * @param array
211 * @param string TABLE or PROCEDURE
212 * @param int number of fields allowed by Suhosin
213 * @param array returned by referencable_primary()
3a14845 @vrana Respect defaults and comments checkbox after post (bug #3311791)
authored
214 * @param bool display comments column
215 * @return null
1118566 Documentation
jakubvrana authored
216 */
3f5b683 Reintegrate sqlite branch
jakubvrana authored
217 function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0, $foreign_keys = array(), $comments = false) {
d31d4e9 Emulate REQUEST_URI
jakubvrana authored
218 global $inout;
f2813b5 Don't hide/show added/dropped columns (bug 1920167)
jakubvrana authored
219 ?>
dfe2540 Centralize nowrap
jakubvrana authored
220 <thead><tr class="wrap">
b349612 Remove useless translations
jakubvrana authored
221 <?php if ($type == "PROCEDURE") { ?><td>&nbsp;<?php } ?>
ace55ed HTML instead of XHTML
jakubvrana authored
222 <th><?php echo ($type == "TABLE" ? lang('Column name') : lang('Parameter name')); ?>
3a76704 Spaces
jakubvrana authored
223 <td><?php echo lang('Type'); ?><textarea id="enum-edit" rows="4" cols="12" wrap="off" style="display: none;" onblur="editingLengthBlur(this);"></textarea>
ace55ed HTML instead of XHTML
jakubvrana authored
224 <td><?php echo lang('Length'); ?>
225 <td><?php echo lang('Options'); ?>
a7096dd Separate editing functions
jakubvrana authored
226 <?php if ($type == "TABLE") { ?>
b349612 Remove useless translations
jakubvrana authored
227 <td>NULL
3f5b683 Reintegrate sqlite branch
jakubvrana authored
228 <td><input type="radio" name="auto_increment_col" value=""><acronym title="<?php echo lang('Auto Increment'); ?>">AI</acronym>
3a14845 @vrana Respect defaults and comments checkbox after post (bug #3311791)
authored
229 <td<?php echo ($_POST["defaults"] ? "" : " class='hidden'"); ?>><?php echo lang('Default values'); ?>
3f5b683 Reintegrate sqlite branch
jakubvrana authored
230 <?php echo (support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . ">" . lang('Comment') : ""); ?>
a7096dd Separate editing functions
jakubvrana authored
231 <?php } ?>
da8a1b6 Respect move and drop column support
jakubvrana authored
232 <td><?php echo "<input type='image' name='add[" . (support("move_col") ? 0 : count($fields)) . "]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>"; ?><script type="text/javascript">row_count = <?php echo count($fields); ?>;</script>
ace55ed HTML instead of XHTML
jakubvrana authored
233 </thead>
dfc03ca @vrana Comment
authored
234 <tbody onkeydown="return editingKeydown(event);">
235 <?php
93c27c9 Separate type_change()
jakubvrana authored
236 foreach ($fields as $i => $field) {
237 $i++;
da8a1b6 Respect move and drop column support
jakubvrana authored
238 $orig = $field[($_POST ? "orig" : "field")];
239 $display = (isset($_POST["add"][$i-1]) || (isset($field["field"]) && !$_POST["drop_col"][$i])) && (support("drop_col") || $orig == "");
93c27c9 Separate type_change()
jakubvrana authored
240 ?>
a76c555 Remove odd() from create
jakubvrana authored
241 <tr<?php echo ($display ? "" : " style='display: none;'"); ?>>
55e2b75 @vrana Save bytes
authored
242 <?php echo ($type == "PROCEDURE" ? "<td>" . html_select("fields[$i][inout]", explode("|", $inout), $field["inout"]) : ""); ?>
da8a1b6 Respect move and drop column support
jakubvrana authored
243 <th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" onchange="<?php echo ($field["field"] != "" || count($fields) > 1 ? "" : "editingAddRow(this, $allowed); "); ?>editingNameChange(this);" maxlength="64"><?php } ?><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($orig); ?>">
ced9de9 Create single column foreign key in table structure
jakubvrana authored
244 <?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
a7096dd Separate editing functions
jakubvrana authored
245 <?php if ($type == "TABLE") { ?>
6b30cfa Separate checkbox
jakubvrana authored
246 <td><?php echo checkbox("fields[$i][null]", 1, $field["null"]); ?>
b79a28f @vrana Link table names in SQL queries
authored
247 <td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?> onclick="var field = this.form['fields[' + this.value + '][field]']; if (!field.value) { field.value = 'id'; field.onchange(); }">
3a14845 @vrana Respect defaults and comments checkbox after post (bug #3311791)
authored
248 <td<?php echo ($_POST["defaults"] ? "" : " class='hidden'"); ?>><?php echo checkbox("fields[$i][has_default]", 1, $field["has_default"]); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" onchange="this.previousSibling.checked = true;">
3f5b683 Reintegrate sqlite branch
jakubvrana authored
249 <?php echo (support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . "><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' maxlength='255'>" : ""); ?>
a7096dd Separate editing functions
jakubvrana authored
250 <?php } ?>
251 <?php
da8a1b6 Respect move and drop column support
jakubvrana authored
252 echo "<td>";
253 echo (support("move_col") ?
254 "<input type='image' name='add[$i]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "' onclick='return !editingAddRow(this, $allowed, 1);'>&nbsp;"
255 . "<input type='image' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "'>&nbsp;"
256 . "<input type='image' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "'>&nbsp;"
257 : "");
258 echo ($orig == "" || support("drop_col") ? "<input type='image' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick='return !editingRemoveRow(this);'>" : "");
50881f8 Move whitespace to CSS
jakubvrana authored
259 echo "\n";
a7096dd Separate editing functions
jakubvrana authored
260 }
261 }
93c27c9 Separate type_change()
jakubvrana authored
262
1118566 Documentation
jakubvrana authored
263 /** Move fields up and down or add field
264 * @param array
265 * @return null
266 */
fd8948f Order of columns in table
jakubvrana authored
267 function process_fields(&$fields) {
268 ksort($fields);
269 $offset = 0;
270 if ($_POST["up"]) {
271 $last = 0;
272 foreach ($fields as $key => $field) {
273 if (key($_POST["up"]) == $key) {
274 unset($fields[$key]);
275 array_splice($fields, $last, 0, array($field));
276 break;
277 }
278 if (isset($field["field"])) {
279 $last = $offset;
280 }
281 $offset++;
282 }
283 }
284 if ($_POST["down"]) {
285 $found = false;
286 foreach ($fields as $key => $field) {
287 if (isset($field["field"]) && $found) {
288 unset($fields[key($_POST["down"])]);
289 array_splice($fields, $offset, 0, array($found));
290 break;
291 }
292 if (key($_POST["down"]) == $key) {
293 $found = $field;
294 }
295 $offset++;
296 }
297 }
298 $fields = array_values($fields);
299 if ($_POST["add"]) {
300 array_splice($fields, key($_POST["add"]), 0, array(array()));
301 }
302 }
303
1118566 Documentation
jakubvrana authored
304 /** Callback used in routine()
305 * @param array
306 * @return string
307 */
8060c5b Routines
jakubvrana authored
308 function normalize_enum($match) {
3f5b683 Reintegrate sqlite branch
jakubvrana authored
309 return "'" . str_replace("'", "''", addcslashes(stripcslashes(str_replace($match[0][0] . $match[0][0], $match[0][0], substr($match[0], 1, -1))), '\\')) . "'";
8060c5b Routines
jakubvrana authored
310 }
311
1118566 Documentation
jakubvrana authored
312 /** Issue grant or revoke commands
313 * @param string GRANT or REVOKE
314 * @param array
315 * @param string
316 * @param string
83d659c @vrana Comments
authored
317 * @return bool
1118566 Documentation
jakubvrana authored
318 */
464d84a Define functions unconditionally
jakubvrana authored
319 function grant($grant, $privileges, $columns, $on) {
320 if (!$privileges) {
321 return true;
322 }
323 if ($privileges == array("ALL PRIVILEGES", "GRANT OPTION")) {
324 // can't be granted or revoked together
325 return ($grant == "GRANT"
326 ? queries("$grant ALL PRIVILEGES$on WITH GRANT OPTION")
327 : queries("$grant ALL PRIVILEGES$on") && queries("$grant GRANT OPTION$on")
328 );
329 }
330 return queries("$grant " . preg_replace('~(GRANT OPTION)\\([^)]*\\)~', '\\1', implode("$columns, ", $privileges) . $columns) . $on);
331 }
32d5b9c Inform about dropped routine, trigger and view
jakubvrana authored
332
1118566 Documentation
jakubvrana authored
333 /** Drop old object and create a new one
334 * @param string drop query
335 * @param string create query
336 * @param string
337 * @param string
338 * @param string
339 * @param string
340 * @param string
341 * @return bool dropped
342 */
32d5b9c Inform about dropped routine, trigger and view
jakubvrana authored
343 function drop_create($drop, $create, $location, $message_drop, $message_alter, $message_create, $name) {
344 if ($_POST["drop"]) {
345 return query_redirect($drop, $location, $message_drop, true, !$_POST["dropped"]);
346 }
7352c28 Replace strlen() by != ""
jakubvrana authored
347 $dropped = $name != "" && ($_POST["dropped"] || queries($drop));
32d5b9c Inform about dropped routine, trigger and view
jakubvrana authored
348 $created = queries($create);
7352c28 Replace strlen() by != ""
jakubvrana authored
349 if (!queries_redirect($location, ($name != "" ? $message_alter : $message_create), $created) && $dropped) {
a379bde @vrana Save bytes
authored
350 redirect(null, $message_drop);
32d5b9c Inform about dropped routine, trigger and view
jakubvrana authored
351 }
352 return $dropped;
353 }
095d472 @vrana Customizable export
authored
354
355 /** Get string to add a file in TAR
356 * @param string
357 * @param string
358 * @return string
359 */
360 function tar_file($filename, $contents) {
361 $return = pack("a100a8a8a8a12a12", $filename, 644, 0, 0, decoct(strlen($contents)), decoct(time()));
362 $checksum = 8*32; // space for checksum itself
363 for ($i=0; $i < strlen($return); $i++) {
364 $checksum += ord($return{$i});
365 }
366 $return .= sprintf("%06o", $checksum) . "\0 ";
367 return $return . str_repeat("\0", 512 - strlen($return)) . $contents . str_repeat("\0", 511 - (strlen($contents) + 511) % 512);
368 }
9d944c8 @vrana Respect original memory_limit
authored
369
370 /** Get INI bytes value
371 * @param string
372 * @return int
373 */
374 function ini_bytes($ini) {
375 $val = ini_get($ini);
376 switch (strtolower(substr($val, -1))) {
377 case 'g': $val *= 1024; // no break
378 case 'm': $val *= 1024; // no break
379 case 'k': $val *= 1024;
380 }
381 return $val;
382 }
Something went wrong with that request. Please try again.