92
92
}
93
93
94
94
//get initial values
95
- $ SQLq =trim (base64_decode ($ _REQUEST ['q ' ]));
95
+ $ SQLq =trim (b64d ($ _REQUEST ['q ' ]));
96
96
$ page =$ _REQUEST ['p ' ]+0 ;
97
97
if ($ _REQUEST ['refresh ' ] && $ DB ['db ' ] && preg_match ('/^show/ ' ,$ SQLq ) ) $ SQLq =$ SHOW_T ;
98
98
99
99
if (db_connect ('nodie ' )){
100
100
$ time_start =microtime_float ();
101
101
102
102
if ($ _REQUEST ['phpinfo ' ]){
103
- ob_start ();
104
- phpinfo ();
105
- $ html = ob_get_clean ();
106
- preg_match ("/<body[^>]*>(.*?)<\/body>/is " , $ html , $ matches ); // show only <body>-content
107
- $ sqldr ='<div class="phpinfo"> ' .$ matches [1 ].'</div> ' ;
103
+ ob_start ();phpinfo ();$ html =ob_get_clean ();preg_match ("/<body[^>]*>(.*?)<\/body>/is " ,$ html ,$ m );
104
+ $ sqldr ='<div class="pi"> ' .$ m [1 ].'</div> ' ;
108
105
}else {
109
106
if ($ DB ['db ' ]){
110
107
if ($ _REQUEST ['shex ' ]){
@@ -181,29 +178,26 @@ function display_select($sth,$q){
181
178
$ w ='' ;
182
179
if ($ is_sht || $ is_shd ) {$ w ='wa ' ;
183
180
$ url ='? ' .$ xurl ."&db= $ dbn " ;
184
- $ sqldr .="<div > " ;
185
- $ sqldr .= " MySQL Server: " ;
186
- $ sqldr .= " · <a href=' $ url&q= " .b64e ("show variables " )."'>Show Configuration Variables</a> " ;
187
- $ sqldr .= " · <a href=' $ url&q= " .b64e ("show status " )."'>Show Statistics</a> " ;
188
- $ sqldr .= " · <a href=' $ url&q= " .b64e ("show processlist " )."'>Show Processlist</a> " ;
181
+ $ sqldr .="<div class='dot'>
182
+ MySQL Server:
183
+ · <a href=' $ url&q= " .b64e ("show variables " )."'>Show Configuration Variables</a>
184
+ · <a href=' $ url&q= " .b64e ("show status " )."'>Show Statistics</a>
185
+ · <a href=' $ url&q= " .b64e ("show processlist " )."'>Show Processlist</a> " ;
189
186
if ($ is_shd ) $ sqldr .="· <label>Create new database: <input type='text' name='new_db' placeholder='type db name here'></label> <input type='submit' name='crdb' value='Create'> " ;
190
187
$ sqldr .="<br> " ;
191
188
if ($ is_sht ) $ sqldr .="Database: · <a href=' $ url&q= " .b64e ("show table status " )."'>Show Table Status</a> " ;
192
189
$ sqldr .="</div> " ;
193
190
}
194
191
if ($ is_sht ){
195
- $ abtn ="<div> " ;
196
- $ abtn .=" <input type='submit' value='Export' onclick= \"sht('exp') \"> " ;
197
- $ abtn .=" <input type='submit' value='Drop' onclick= \"if(ays()){sht('drop')}else{return false} \"> " ;
198
- $ abtn .=" <input type='submit' value='Truncate' onclick= \"if(ays()){sht('trunc')}else{return false} \"> " ;
199
- $ abtn .=" <input type='submit' value='Optimize' onclick= \"sht('opt') \"> " ;
200
- $ abtn .=" <b>selected tables</b> " ;
201
- $ abtn .="</div> " ;
192
+ $ abtn ="<div><input type='submit' value='Export' onclick= \"sht('exp') \">
193
+ <input type='submit' value='Drop' onclick= \"if(ays()){sht('drop')}else{return false} \">
194
+ <input type='submit' value='Truncate' onclick= \"if(ays()){sht('trunc')}else{return false} \">
195
+ <input type='submit' value='Optimize' onclick= \"sht('opt') \">
196
+ <b>selected tables</b></div> " ;
202
197
$ sqldr .=$ abtn ."<input type='hidden' name='dosht' value=''> " ;
203
198
}
204
199
205
- $ sqldr .="<div> " ;
206
- $ sqldr .="<table class='res $ w'> " ;
200
+ $ sqldr .="<div><table class='res $ w'> " ;
207
201
$ headers ="<tr class='h'> " ;
208
202
if ($ is_sht ) $ headers .="<td><input type='checkbox' name='cball' value='' onclick='chkall(this)'></td> " ;
209
203
for ($ i =0 ;$ i <$ fields_num ;$ i ++){
@@ -221,7 +215,7 @@ function display_select($sth,$q){
221
215
$ v =$ row [0 ];
222
216
if ($ is_sht ){
223
217
$ vq ='` ' .$ v .'` ' ;
224
- $ url ='? ' .$ xurl ."&db= $ dbn" ;
218
+ $ url ='? ' .$ xurl ."&db= $ dbn&t= " . b64e ( $ v ) ;
225
219
$ v ="<input type='checkbox' name='cb[]' value= \"$ vq \"></td> "
226
220
."<td><a href= \"$ url&q= " .b64e ("select * from $ vq " )."\"> $ v</a></td> "
227
221
."<td> " .$ row [1 ]."</td> "
@@ -231,7 +225,7 @@ function display_select($sth,$q){
231
225
."<td>·<a href= \"$ url&q= " .b64e ("show create table $ vq " )."\">sct</a></td> "
232
226
."<td>·<a href= \"$ url&q= " .b64e ("explain $ vq " )."\">exp</a></td> "
233
227
."<td>·<a href= \"$ url&q= " .b64e ("show index from $ vq " )."\">ind</a></td> "
234
- ."<td>·<a href= \"$ url&shex=1&t = $ vq \">export</a></td> "
228
+ ."<td>·<a href= \"$ url&shex=1&rt = $ vq \">export</a></td> "
235
229
."<td>·<a href= \"$ url&q= " .b64e ("drop table $ vq " )."\" onclick='return ays()'>dr</a></td> "
236
230
."<td>·<a href= \"$ url&q= " .b64e ("truncate table $ vq " )."\" onclick='return ays()'>tr</a></td> "
237
231
."<td>·<a href= \"$ url&q= " .b64e ("optimize table $ vq " )."\" onclick='return ays()'>opt</a></td> "
@@ -262,9 +256,7 @@ function display_select($sth,$q){
262
256
}
263
257
$ sqldr .="</tr> \n" ;
264
258
}
265
- $ sqldr .="</table> \n" ;
266
- $ sqldr .="</div> \n" ;
267
- $ sqldr .=$ abtn ;
259
+ $ sqldr .="</table></div> \n" .$ abtn ;
268
260
}
269
261
270
262
function print_header (){
@@ -276,40 +268,41 @@ function print_header(){
276
268
<head><title>phpMiniAdmin</title>
277
269
<meta charset="utf-8">
278
270
<style type="text/css">
279
- *{box-sizing:border-box;}
280
- body{font-family:Arial,sans-serif;font-size:80%;padding:0 1em ;margin:0}
271
+ *{box-sizing:border-box;}
272
+ body{font-family:Arial,sans-serif;font-size:80%;padding:0;margin:0}
281
273
div{padding:3px}
282
274
pre{font-size:125%}
283
- textarea{width:100%; }
275
+ textarea{width:100%}
284
276
.nav{text-align:center}
285
277
.ft{text-align:right;margin-top:20px;font-size:smaller}
286
- .inv{margin:0 -1em; background-color:#069;color:#FFF}
278
+ .inv{background-color:#069;color:#FFF}
287
279
.inv a{color:#FFF}
288
- table{border-collapse:collapse; }
289
- table.res{width:100%; }
280
+ table{border-collapse:collapse}
281
+ table.res{width:100%}
290
282
table.wa{width:auto}
291
283
table.res th,table.res td{padding:2px;border:1px solid #fff;vertical-align:top}
292
284
table.restr{vertical-align:top}
293
285
tr.e{background-color:#CCC}
294
286
tr.o{background-color:#EEE}
295
- tr.e:hover, tr.o:hover{background-color:#FF9}
287
+ tr.e:hover, tr.o:hover{background-color:#FF9}
296
288
tr.h{background-color:#99C}
297
289
tr.s{background-color:#FF9}
298
290
.err{color:#F33;font-weight:bold;text-align:center}
299
291
.frm{width:400px;border:1px solid #999;background-color:#eee;text-align:left}
300
292
.frm label .l{width:100px;float:left}
301
293
.dot{border-bottom:1px dotted #000}
302
- .ajax{text-decoration:none;border-bottom: 1px dashed; }
294
+ .ajax{text-decoration:none;border-bottom: 1px dashed}
303
295
.qnav{width:30px}
304
- .clear {clear:both; height:0; display:block;}
305
- .phpinfo a {text-decoration:none;}
306
- .phpinfo hr {display:none;}
307
- .phpinfo img {float:right;}
308
- .phpinfo .center {text-align:center;}
309
- .phpinfo table {margin:0 auto;}
310
- .phpinfo table td, .phpinfo table th {border:1px solid #000000;text-align:left;vertical-align:baseline;}
311
- .phpinfo table .e {background-color:#ccccff;font-weight:bold;}
312
- .phpinfo table .v {background-color:#cccccc;}
296
+ .sbtn{width:100px}
297
+ .clear{clear:both;height:0;display:block}
298
+ .pi a{text-decoration:none}
299
+ .pi hr{display:none}
300
+ .pi img{float:right}
301
+ .pi .center{text-align:center}
302
+ .pi table{margin:0 auto}
303
+ .pi table td, .pi table th{border:1px solid #000000;text-align:left;vertical-align:baseline}
304
+ .pi table .e{background-color:#ccccff;font-weight:bold}
305
+ .pi table .v{background-color:#cccccc}
313
306
</style>
314
307
315
308
<script type="text/javascript">
@@ -412,6 +405,9 @@ function cfg_toggle(){
412
405
var e=$('cfg-adv');
413
406
e.style.display=e.style.display=='none'?'':'none';
414
407
}
408
+ function qtpl(s){
409
+ $('qraw').value=s.replace(/%T/g,'`<?php echo $ _REQUEST ['t ' ]?b64d ($ _REQUEST ['t ' ]):'tablename ' ?> `');
410
+ }
415
411
<?php if ($ is_sht ){?>
416
412
function chkall(cab){
417
413
var e=document.DF.elements;
@@ -465,21 +461,22 @@ function print_screen(){
465
461
print_header ();
466
462
?>
467
463
468
- <div class="dot">
464
+ <div class="dot" style="padding:3px 20px" >
469
465
<label for="qraw">SQL-query (or multiple queries separated by ";"):</label> <button type="button" class="qnav" onclick="q_prev()"><</button><button type="button" class="qnav" onclick="q_next()">></button><br>
470
466
<textarea id="qraw" cols="70" rows="10"><?php eo ($ SQLq )?> </textarea><br>
471
467
<input type="hidden" name="q" id="q" value="<?php b64e ($ SQLq );?> ">
472
- <input type="submit" name="GoSQL" value="Go" style="width:100px ">
468
+ <input type="submit" name="GoSQL" value="Go" class="sbtn ">
473
469
<input type="button" name="Clear" value=" Clear " onclick="$('qraw').value='';" style="width:100px">
474
- <?php if (!empty ($ _REQUEST ['db ' ])) { ?>
475
- <input type="button" name="Delete" value=" Delete " onclick="$('qraw').value='DELETE FROM `<?php echo $ _REQUEST ['db ' ]; ?> ` WHERE 1';" style="float:right; width:100px">
476
- <input type="button" name="Update" value=" Update " onclick="$('qraw').value='UPDATE `<?php echo $ _REQUEST ['db ' ]; ?> ` SET `column`=\'value\' WHERE 1';" style="float:right; width:100px">
477
- <input type="button" name="Insert" value=" Insert " onclick="$('qraw').value='INSERT INTO `<?php echo $ _REQUEST ['db ' ]; ?> ` (`column`, `column`) VALUES (\'value\', \'value\')';" style="float:right; width:100px">
478
- <input type="button" name="Select" value=" Select " onclick="$('qraw').value='SELECT * FROM `<?php echo $ _REQUEST ['db ' ]; ?> ` WHERE 1';" style="float:right; width:100px">
479
- <br class="clear">
470
+ <?php if (!empty ($ _REQUEST ['db ' ])){ ?>
471
+ <div style="float:right">
472
+ <input type="button" value="Select" class="sbtn" onclick="qtpl('SELECT *\nFROM %T\nWHERE 1')">
473
+ <input type="button" value="Insert" class="sbtn" onclick="qtpl('INSERT INTO %T (`column`, `column`)\nVALUES (\'value\', \'value\')')">
474
+ <input type="button" value="Update" class="sbtn" onclick="qtpl('UPDATE %T\nSET `column`=\'value\'\nWHERE 1=0')">
475
+ <input type="button" value="Delete" class="sbtn" onclick="qtpl('DELETE FROM %T\nWHERE 1=0')">
476
+ </div><br class="clear">
480
477
<?php } ?>
481
478
</div>
482
- <div class="dot"" >
479
+ <div class="dot">
483
480
Records: <b><?php eo ($ reccount ); if (!is_null ($ last_count ) && $ reccount <$ last_count ){eo (' out of ' .$ last_count );}?> </b> in <b><?php eo ($ time_all )?> </b> sec<br>
484
481
<b><?php eo ($ out_message )?> </b>
485
482
</div>
@@ -791,7 +788,7 @@ function loadsess(){
791
788
792
789
function print_export (){
793
790
global $ self ,$ xurl ,$ DB ;
794
- $ t =$ _REQUEST ['t ' ];
791
+ $ t =$ _REQUEST ['rt ' ];
795
792
$ l =($ t )?"Table $ t " :"whole DB " ;
796
793
print_header ();
797
794
?>
@@ -813,7 +810,7 @@ function print_export(){
813
810
<div><label><input type="checkbox" name="gz" value="1"> compress as .gz</label></div>
814
811
<br>
815
812
<input type="hidden" name="doex" value="1">
816
- <input type="hidden" name="t " value="<?php eo ($ t )?> ">
813
+ <input type="hidden" name="rt " value="<?php eo ($ t )?> ">
817
814
<input type="submit" value=" Download "><input type="button" value=" Cancel " onclick="window.location='<?php eo ($ self .'? ' .$ xurl .'&db= ' .$ DB ['db ' ])?> '">
818
815
</div>
819
816
</center>
@@ -824,7 +821,7 @@ function print_export(){
824
821
825
822
function do_export (){
826
823
global $ DB ,$ VERSION ,$ D ,$ BOM ,$ ex_isgz ,$ dbh ;
827
- $ rt =str_replace ('` ' ,'' ,$ _REQUEST ['t ' ]);
824
+ $ rt =str_replace ('` ' ,'' ,$ _REQUEST ['rt ' ]);
828
825
$ t =explode (", " ,$ rt );
829
826
$ th =array_flip ($ t );
830
827
$ ct =count ($ t );
@@ -1209,4 +1206,7 @@ function eo($s){//echo+escape
1209
1206
function b64e ($ s ){
1210
1207
return base64_encode ($ s );
1211
1208
}
1209
+ function b64d ($ s ){
1210
+ return base64_decode ($ s );
1211
+ }
1212
1212
?>
0 commit comments