-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.php
More file actions
723 lines (636 loc) · 24.7 KB
/
database.php
File metadata and controls
723 lines (636 loc) · 24.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
<?php include 'components/head.php'; ?>
<?php include 'redirect.php'; ?>
<?php include 'components/navbar.php'; ?>
<?php
$query;
if(!isset($_GET['db'])) {
header("Location: index.php");
}
$db = $_GET['db'];
$getdbs = mysqli_query($dbconn, "SHOW DATABASES");
$exists = false;
while ($result_dbs = mysqli_fetch_array($getdbs)) {
if ($result_dbs['Database'] == $db) {
$exists = true;
}
}
if (!$exists) {
header("Location: index.php");
}
?>
<!-- For run a query using JS -->
<form id="form_query" action="database.php?db=<?php echo($db); ?>" method="post" style="display: none;">
<input type="hidden" id="query" name="query" value="">
</form>
<?php
if (isset($_GET['drop'])) {
$drop_table = $_GET['drop'];
?>
<script type="text/javascript">
var drop = confirm("Você quer excluir a tabela '<?php echo $drop_table; ?>'?");
if (drop == true) {
document.forms["form_query"].query.value = "DROP TABLE <?php echo $drop_table; ?>";
document.forms["form_query"].submit();
}
</script>
<?php
}
?>
<body>
<main>
<br>
<div class="container" style="border: 1px solid white;">
<div class="row">
<div class="col s12">
<ul class="tabs tabs-fixed-width">
<li class="tab col s3"><a class="active" href="#cmd">Linha de Comando</a></li>
<li class="tab col s3"><a href="#tables">Tabelas</a></li>
<li class="tab col s3"><a href="#create-table">Nova tabela</a></li>
<li class="tab col s3"><a href="#export">Exportar</a></li>
</ul>
</div>
</div>
</div>
<div id="cmd" class="col s12">
<h2 class="brand-logo center black-text" style="font-size: 40px; font-weight: bolder;">Linha de comando</h2>
<br>
<div class="container">
<div class="row">
<div class="col s4 center">
<form method="post">
<input type="hidden" name="query" value="SHOW TABLES">
<button class="btn-flat waves-effect waves-light center tooltipped" data-tooltip="SHOW TABLES" type="submit" name="action" data-position="top">SHOW TABLES</button>
</form>
</div>
<div class="col s4 center">
<form method="post">
<input type="hidden" name="query" value="SHOW DATABASES">
<button class="btn-flat waves-effect waves-light center tooltipped" data-tooltip="SHOW DATABASES" type="submit" name="action" data-position="top">SHOW DATABASES</button>
</form>
</div>
<div class="col s4 center">
<form method="post">
<input type="hidden" name="select">
<button class="btn-flat modal-trigger waves-effect waves-light center tooltipped" data-tooltip="SELECT" href="#modal1" type="submit" name="action" data-position="top">SELECT</button>
</form>
</div>
</div>
<div class="row">
<div class="col s4 center">
<form method="post">
<input type="hidden" name="cmd" value="UPDATE tabela SET campo WHERE condicao">
<button class="btn-flat waves-effect waves-light center tooltipped" data-tooltip="UPDATE tabela SET campo WHERE condicao" type="submit" name="action">UPDATE</button>
</form>
</div>
<div class="col s4 center">
<form method="post">
<input type="hidden" name="cmd" value="DELETE FROM tabela WHERE condicao">
<button class="btn-flat waves-effect waves-light center tooltipped" data-tooltip="DELETE FROM tabela WHERE condicao" type="submit" name="action">DELETE</button>
</form>
</div>
<div class="col s4 center">
<form method="post">
<input type="hidden" name="cmd" value="ALTER TABLE tabela">
<button class="btn-flat waves-effect waves-light center tooltipped" data-tooltip="ALTER TABLE tabela" type="submit" name="action">ALTER TABLE</button>
</form>
</div>
</div>
</div>
<br>
<!-- Modal Structure -->
<div id="modal1" class="modal">
<div class="modal-content">
<h4>Selecione a tabela</h4>
<br>
<div class="input-field col s12">
<form method="get">
<input type="hidden" name="select">
<input type="hidden" name="db" value="<?php echo($_GET['db']);?>">
<select name="table" required="">
<option value="" disabled selected>Escolha a tabela</option>
<?php
mysqli_select_db($dbconn, $db);
$query = mysqli_query($dbconn, "SHOW TABLES");
while($result = mysqli_fetch_array($query)) { ?>
<option value="<?php echo $result['Tables_in_' . $db];?>"><?php echo $result['Tables_in_' . $db];?></option>
<?php
}
?>
</select>
<br><br>
<table>
<tr style="border-bottom: 0">
<td style="width: 10%">
<div class="switch">
<label>
<input id="checkbox" name="check_limit" value="true" type="checkbox">
<span class="lever"></span>
</label>
</div>
</td>
<td style="">
<div class="input-field inline">
<input id="limit" name="limit" min="1" value="1" type="number">
<label for="limit">Limite</label>
</div>
</td>
</tr>
</table>
<p>
Resultados muito extensos podem travar a página ou sobrecarregar o servidor.<br>
Limite o resultado por página para garantir maior fluidez.
</p>
<br><br>
<div class="modal-footer">
<button type="submit" class="modal-close waves-effect waves-green btn-flat">Executar</a>
</div>
<input type="hidden" name="page" value="1">
</form>
</div>
</div>
</div>
<div class="container">
<div class="materialize-textarea z-depth-3" id="editor" name="query" style="resize: none; height: 150px;"><?php
if (isset($_POST['cmd'])) {
echo $_POST['cmd'];
}
elseif(isset($_POST['query'])) echo $_POST['query']; else echo "SHOW TABLES;"
?></div>
<br>
<button onclick="exec()" class="btn waves-effect waves-light right tooltipped" data-tooltip="Executar os comandos inseridos" name="action">Executar</button>
</div>
<div class="container">
<br><br><br>
<h4>Resultado</h4>
<hr>
<?php
if(isset($_POST['query']) || isset($_GET['select']) || isset($_GET['query'])) {
$string = array();
$limit = false;
if (isset($_POST['query'])) {
$string = explode(';', $_POST['query']);
} elseif (isset($_GET['table'])) {
$string[0] = "SELECT * FROM " . $_GET['table'];
if (isset($_GET['check_limit'])) {
$string[0] = $string[0] . " LIMIT " . $_GET['limit'];
$limit = true;
if (isset($_GET['offset'])) {
$string[0] = $string[0] . " OFFSET " . $_GET['offset'];
}
}
}
if (isset($_GET['query'])) {
$string = explode(';', $_GET['query']);
} elseif (isset($_GET['table'])) {
$string[0] = "SELECT * FROM " . $_GET['table'];
if (isset($_GET['check_limit'])) {
$string[0] = $string[0] . " LIMIT " . $_GET['limit'];
$limit = true;
if (isset($_GET['offset'])) {
$string[0] = $string[0] . " OFFSET " . $_GET['offset'];
}
}
}
if ($limit) {
$count = mysqli_query($dbconn, "SELECT COUNT(*) as qtde FROM " . $_GET['table']);
$count = mysqli_fetch_array($count)['qtde'];
$max = $_GET['limit'];
$qtd = $count / $max;
?>
<div class="container center">
<ul class="pagination">
<?php if ($_GET['page'] == 1) { ?>
<li class="blue-grey darken-4 active"><a href="#!">1</a></li>
<?php } else { ?>
<li class="waves-effect"><a onclick="offset(0, <?php echo $max; ?>, <?php echo $count; ?>)">1</a></li>
<?php } ?>
<?php for ($i=1; $i < $qtd; $i++) { ?>
<?php if ($_GET['page'] == $i + 1) { ?>
<li class="blue-grey darken-4 active"><a href="#!"><?php echo $i + 1; ?></a></li>
<?php } else { ?>
<li class="waves-effect"><a onclick="offset(<?php echo $i; ?>, <?php echo $max; ?>, <?php echo $count; ?>)"><?php echo $i + 1; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
</div>
<?php
}
$i = 0;
foreach ($string as $value) {
if(strlen($value) > 0) {
mysqli_select_db($dbconn, $db);
$value = $value;
if (strlen($value) > 1) {
$query = mysqli_query($dbconn, $value);
if ($query) {
?>
<div class='container-fluid blue-grey darken-4 z-depth-4 white-text'>
<div class='container-fluid white-text green center'>
<br>
<h6>
<?php echo $value; ?>
</h6>
<br>
</div>
<br>
<?php echo "<h6 style='margin-left: 20px'>Query ok!</h6>"; ?>
<br>
<?php
//$query = mysqli_query($dbconn, $value);
$current = $value;
if(strpos((strtolower($current)), 'select') !== false || strpos((strtolower($current)), 'show') !== false || strpos((strtolower($current)), 'desc') !== false) {
$result = mysqli_fetch_array($query);
echo "<div class='container-fluid' style='overflow: auto'>";
echo "<table class='centered'>";
echo "<thead>";
echo "<tr>";
$res = mysqli_fetch_array($query);
if (is_array($result) || isset($result[0])) {
$array = array_keys($result);
$fields = array();
foreach ($array as $key => $X) {
if (gettype($array[$key]) != "integer") {
echo "<th class='center'>";
echo $array[$key];
array_push($fields, $array[$key]);
echo "</th>";
}
}
echo "</tr>";
echo "</thead>";
echo "<tbody>";
$query = mysqli_query($dbconn, $string[$i]);
while ($res = mysqli_fetch_array($query)) {
echo "<tr>";
foreach ($fields as $key => $X) {
echo "<td class='cell'>";
echo "<div class='cell' style='max-height: 200px;overflow: auto'>";
if (strlen($res[$X]) > 0) {
echo $res[$X];
} else {
echo "NULL (vazio)";
}
echo "</div>";
echo "</td>";
}
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "</div>";
} else {
echo "<h6 style='margin-left: 20px'>Nenhum resultado!</h6>";
echo "<br>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
echo "</tbody>";
echo "</table>";
echo "</div>";
}
}
?></div><br><br><?php
} else {
echo "<div class='container-fluid blue-grey darken-4 z-depth-4'>
<div class='container-fluid white-text red center'>
<br>
<h6>
"
. $value .
"
</h6>
<br>
</div>
<br>
<h6 class='white-text' style='padding-left: 10px'>Erro:
"
. mysqli_error($dbconn) .
"</h6>
<br>
</div>
<br><br>
";
}
}
$i = $i + 1;
}
}
}
?>
</div>
</div>
<div id="tables" class="col s12">
<h2 class="brand-logo center black-text" style="font-size: 40px; font-weight: bolder;">Tabelas</h2>
<br>
<div class="container">
<div style='max-width: 100%;overflow: auto'>
<table class='highlight' style="border-bottom: none">
<thead style="border-bottom: none">
<tr style="border-bottom: none">
<th>Nome da tabela</th>
<th>Campos</th>
</tr>
</thead>
<tbody style="border-bottom: none">
<?php
$query = mysqli_query($dbconn, "SHOW TABLES;");
while ($result = mysqli_fetch_array($query)) {
echo "<tr style='border-bottom: none'>";
echo '<td style="border-bottom: none"><a href="database.php?db=' . $db . '&drop=' . $result[0] . '"><i class="material-icons prefix left red-text">delete</i></a><b><a href="#" id="tablename" onclick="table(\''.$result[0].'\')">'
. $result[0] . '</a></b></td>';
$query_fields = mysqli_query($dbconn, "DESC " . $result[0]);
while ($table_fields = mysqli_fetch_array($query_fields)) {
echo '<td>' . $table_fields[0] . '</td>';
}
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div id="create-table" class="col s12">
<h2 class="brand-logo center black-text" style="font-size: 40px; font-weight: bolder;">Nova tabela</h2>
<br>
<div class="container">
<?php if (!isset($_POST['table-name'])) {?>
<form method="post" action="#create-table">
<div class="row center">
<div class="col s6">
<div class="input-field">
<input required="" name="table-name" id="table-name" type="text">
<label for="table-name">Nome da tabela</label>
</div>
</div>
<div class="col s4">
<div class="input-field">
<input required="" name="table-cols" id="table-cols" type="text">
<label for="table-cols">Número de colunas</label>
</div>
</div>
<div class="col s2">
<div class="input-field">
<button type="submit" class="btn">Avançar</button>
</div>
</div>
</div>
</form>
<?php } else {
$name = $_POST['table-name'];
$cols = $_POST['table-cols'];
?>
<h5>Tabela "<?php echo $name; ?>"</h5>
<form method="post">
<div class="row">
<?php for ($i=0; $i < $cols; $i++) { ?>
<input type="hidden" name="name" value="<?php echo $_POST['table-name'];?>">
<div class="col s3">
<div class="input-field">
<input required="" name="col<?php echo($i);?>-name" id="col<?php echo($i);?>-name" type="text">
<label for="col<?php echo($i);?>-name">Nome do campo</label>
</div>
</div>
<div class="input-field col s3">
<select required="" name="col<?php echo($i);?>-type">
<option value="" disabled selected>Tipo</option>
<option value="int">INT</option>
<option value="varchar">VARCHAR</option>
<option value="text">TEXT</option>
<option value="date">DATE</option>
<optgroup label="Numérico">
<option value="tinyint">TINYINT</option>
<option value="smallint">SMALLINT</option>
<option value="mediumnint">MEDIUMINT</option>
<option value="int">INT</option>
<option value="bigint">BIGINT</option>
<option value="decimal">DECIMAL</option>
<option value="float">FLOAT</option>
<option value="double">DOUBLE</option>
<option value="real">REAL</option>
<option value="bit">BIT</option>
<option value="boolean">BOOLEAN</option>
<option value="serial">SERIAL</option>
</optgroup>
<optgroup label="Data e hora">
<option value="date">DATE</option>
<option value="datetime">DATETIME</option>
<option value="timestamp">TIMESTAMP</option>
<option value="time">TIME</option>
<option value="year">YEAR</option>
</optgroup>
<optgroup label="Segmento">
<option value="char">CHAR</option>
<option value="varchar">VARCHAR</option>
<option value="tinytext">TINYTEXT</option>
<option value="text">TEXT</option>
<option value="mediumtext">MEDIUMTEXT</option>
<option value="longtext">LONGTEXT</option>
<option value="binary">BINARY</option>
<option value="varbinary">VARBINARY</option>
<option value="tinyblob">TINYBLOB</option>
<option value="blob">BLOB</option>
<option value="mediumblob">MEDIUMBLOB</option>
<option value="longblob">LONGBLOB</option>
<option value="enum">ENUM</option>
<option value="set">SET</option>
</optgroup>
</select>
</div>
<div class="col s2">
<div class="input-field">
<input name="col<?php echo($i);?>-size" id="col<?php echo($i);?>-size" type="text">
<label for="col<?php echo($i);?>-size">Tamanho</label>
</div>
</div>
<div class="input-field col s3">
<select name="col<?php echo($i);?>-extra">
<option value="" selected disabled="">Extras</option>
<option value="NOT NULL AUTO_INCREMENT">AUTO INCREMENT</option>
<option value="UNIQUE">UNIQUE</option>
<option value="NOT NULL">NOT NULL</option>
<option value="NULL">PREDEFINIDO COMO NULL</option>
</select>
</div>
<div class="input-field col s1">
<label>
<input type="checkbox" value="PRIMARY KEY" name="col<?php echo($i);?>-pk">
<span><i class="material-icons">vpn_key</i></span>
</label>
</div>
<?php } ?>
</div>
<button class="btn right" type="submit">Confirmar</button>
</form>
<button class="btn left red"><a class="white-text" href="database.php?db=<?php echo($db);?>">Cancelar</a></button>
<?php } ?>
</div>
<br><br><br>
<?php
if (isset($_POST['name'])) {
$error_pk = false;
$error_ai = false;
$string = "CREATE TABLE " . $_POST['name'] . " (";
$array = $_POST;
$table_name = "null";
$i=0;
$j=0;
$keys = array_keys($array);
$have_pk = false;
$type = "int";
$pk = 0;
foreach ($keys as $key => $value) {
if ($j !== 0) {
$col = explode("col", $value);
$col = explode('-', $col[1]);
// $col[0] = NUMERO DA COLUNA
// $col[1] = TIPO DA VARIAVEL
if ($i == $col[0]) {
if ($col[1] == "pk") {
if ($have_pk) {
$error_pk = true;
} else {
$have_pk = true;
$pk = $i;
}
}
} else {
$i++;
}
} else {
$table_name = $array[$value];
$j++;
}
}
$num_colunas = $i;
$i = 0;
$j = 0;
foreach ($keys as $key => $value) {
if ($j !== 0) {
$col = explode("col", $value);
$col = explode('-', $col[1]);
// $col[0] = NUMERO DA COLUNA
// $col[1] = TIPO DA VARIAVEL
if ($i == $col[0]) {
if ($col[1] == "type") {
$type = $array[$value];
}
if ($col[1] == "extra" && $array[$value] == "NOT NULL AUTO_INCREMENT" && !($type == "int")) {
$error_ai = true;
}
if ($col[1] == "extra" && !($pk == $col[0]) && $array[$value] == "NOT NULL AUTO_INCREMENT"){
$error_ai = true;
} elseif ($col[1] == "name" && $col[0] == 0) {
$string = $string . $array[$value];
} elseif ($col[1] == "name") {
$string = $string . " " . $array[$value];
} elseif ($col[1] == "type") {
$string = $string . " " . $array[$value];
} elseif ($col[1] == "size" && !($array[$value] == "")) {
$string = $string . "(" . $array[$value] . ")";
} elseif ($col[1] == "extra" && !$have_pk && $col[0] !== $num_colunas) {
$string = $string . " " . $array[$value];
} elseif ($col[1] == "extra" && $have_pk && $pk == $col[0]) {
$string = $string . " " . $array[$value] . "";
} elseif ($col[1] == "extra" && !$have_pk && $col[0] == $num_colunas) {
$string = $string . " " . $array[$value];
} elseif ($col[1] == "extra" && $have_pk && $col[0] > $pk && $col[0] == $num_colunas) {
$string = $string . " " . $array[$value];
} elseif ($col[1] == "extra" && $have_pk && $col[0] > $pk) {
$string = $string . " " . $array[$value];
} elseif ($col[1] == "extra" && $have_pk && !($pk == $col[0]) && !($col[0] == $num_colunas)) {
$string = $string . " " . $array[$value];
} elseif ($col[1] == "pk" && $col[0] !== $num_colunas) {
$string = $string . " " . $array[$value];
} elseif ($col[1] == "pk" && $col[0] == $num_colunas) {
$string = $string . $array[$value];
}
} else {
$i++;
if ($col[1] == "name") {
$string = $string . ", " . $array[$value] . " ";
}
}
} else {
$table_name = $array[$value];
$j++;
}
}
$string = $string . ");";
if ($error_ai) {
echo "<div class='container center red white-text'><br>";
echo "ERRO: AUTO_INCREMENT SÓ PODE SER IMPLEMENTADO SE O CAMPO FOR INT E PRIMARY KEY!";
echo "<br><br></div>";
} elseif ($error_pk) {
echo "<div class='container center red white-text'><br>";
echo "ERRO: PRIMARY KEY SÓ PODE SER IMPLEMENTADO EM UM CAMPO!";
echo "<br><br></div>";
} else {
$query = $string;
?>
<form id="form_table" action="database.php?db=<?php echo($db);?>" method="post" style="display: none;">
<input type="hidden" id="query_table" name="query" value="">
</form>
<script type="text/javascript">
function query(string) {
document.forms["form_table"].query_table.value = string;
document.forms["form_table"].submit();
}
query("<?php echo $query;?>");
</script>
<?php
}
}
?>
</div>
<div id="export" class="col s12">
<h2 class="brand-logo center black-text" style="font-size: 40px; font-weight: bolder;">Exportar</h2>
<br>
<div class="container">
<h6>Essa página faz com que você baixe um arquivo .sql do dump da sua base de dados.</h6>
<h5>Prosseguir?</h5>
<br><br><br>
<div class="container center">
<button class="btn btn-large"><a class="white-text" href="dump.php?db=<?php echo($db);?>"><i class="material-icons left">file_download
</i>Fazer download</a></button>
</div>
</div>
<?php
?>
</div>
</div>
</main>
</body>
</html>
<form method="get" id="form_offset" action="#" style="display: none">
<input type="hidden" id="select" name="select" value="1">
<input type="hidden" id="db" name="db" value="<?php echo($db)?>">
<input type="hidden" id="table" name="table" value="<?php echo($_GET['table']);?>">
<input type="hidden" id="limit" name="limit" value="<?php echo($_GET['limit']);?>">
<input type="hidden" id="check_limit" name="check_limit" value="<?php echo($_GET['check_limit']);?>">
<input type="hidden" id="offset" name="offset" value="1">
<input type="hidden" name="page" id="page">
</form>
<?php include 'components/js.php'; ?>
<script type="text/javascript">
$('#editor').keydown(function (e) {
if (e.ctrlKey && e.keyCode == 13) {
exec();
}
});
function exec(e) {
document.forms["form_query"].query.value = editor.getValue();
document.forms["form_query"].submit();
}
function table(table) {
document.forms["form_query"].query.value = "DESC " + table;
document.forms["form_query"].submit();
}
function offset(qtd, limit, total, pag) {
var calc = limit * qtd;
document.forms["form_offset"].page.value = qtd + 1;
document.forms["form_offset"].offset.value = calc;
document.forms["form_offset"].submit();
}
// ?select=&db=ptquest&table=questao&check_limit=true&limit=50#!
</script>