2727if (function_exists ('date_default_timezone_set ' )) date_default_timezone_set ('UTC ' );#required by PHP 5.1+
2828
2929//constants
30- $ VERSION ='1.9.170117 ' ;
30+ $ VERSION ='1.9.170312 ' ;
3131 $ MAX_ROWS_PER_PAGE =50 ; #max number of rows in select per one page
3232 $ D ="\r\n" ; #default delimiter for export
3333 $ BOM =chr (239 ).chr (187 ).chr (191 );
@@ -163,7 +163,7 @@ function do_sql($q){
163163}
164164
165165function display_select ($ sth ,$ q ){
166- global $ dbh ,$ DB ,$ sqldr ,$ reccount ,$ is_sht ,$ xurl ;
166+ global $ dbh ,$ DB ,$ sqldr ,$ reccount ,$ is_sht ,$ xurl, $ is_sm ;
167167 $ rc =array ("o " ,"e " );
168168 $ dbn =$ DB ['db ' ];
169169 $ sqldr ='' ;
@@ -178,6 +178,7 @@ function display_select($sth,$q){
178178 $ fields_num =mysqli_field_count ($ dbh );
179179
180180 $ w ='' ;
181+ if ($ is_sm ) $ w ='sm ' ;
181182 if ($ is_sht || $ is_shd ) {$ w ='wa ' ;
182183 $ url ='? ' .$ xurl ."&db= $ dbn " ;
183184 $ sqldr .="<div class='dot'>
@@ -199,13 +200,13 @@ function display_select($sth,$q){
199200 $ sqldr .=$ abtn ."<input type='hidden' name='dosht' value=''> " ;
200201 }
201202
202- $ sqldr .="<div><table class='res $ w'> " ;
203+ $ sqldr .="<div><table id='res' class='res $ w'> " ;
203204 $ headers ="<tr class='h'> " ;
204205 if ($ is_sht ) $ headers .="<td><input type='checkbox' name='cball' value='' onclick='chkall(this)'></td> " ;
205206 for ($ i =0 ;$ i <$ fields_num ;$ i ++){
206207 if ($ is_sht && $ i >0 ) break ;
207208 $ meta =mysqli_fetch_field ($ sth );
208- $ headers .="<th> " .$ meta ->name ."</th> " ;
209+ $ headers .="<th><div> " .$ meta ->name ."</div> </th> " ;
209210 }
210211 if ($ is_shd ) $ headers .="<th>show create database</th><th>show table status</th><th>show triggers</th> " ;
211212 if ($ is_sht ) $ headers .="<th>engine</th><th>~rows</th><th>data size</th><th>index size</th><th>show create table</th><th>explain</th><th>indexes</th><th>export</th><th>drop</th><th>truncate</th><th>optimize</th><th>repair</th><th>comment</th> " ;
@@ -253,7 +254,7 @@ function display_select($sth,$q){
253254 $ v ='BINARY: ' .chunk_split (strtoupper (bin2hex ($ v )),2 ,' ' ).$ pf ;
254255 }else $ v =hs ($ v );
255256 if ($ is_show_crt ) $ v ="<pre> $ v</pre> " ;
256- $ sqldr .="<td> $ v " .(!strlen ($ v )?"<br> " :'' )."</td> " ;
257+ $ sqldr .="<td><div> $ v " .(!strlen ($ v )?"<br> " :'' )."</div> </td> " ;
257258 }
258259 }
259260 $ sqldr .="</tr> \n" ;
@@ -283,6 +284,10 @@ function print_header(){
283284table.res{width:100%}
284285table.wa{width:auto}
285286table.res th,table.res td{padding:2px;border:1px solid #fff;vertical-align:top}
287+ table.sm th,table.sm td{max-width:30em}
288+ table.sm th>div,table.sm td>div{max-height:3.5em;overflow:hidden}
289+ table.sm th.lg,table.sm td.lg{max-width:inherit}
290+ table.sm th.lg>div,table.sm td.lg>div{max-height:inherit;overflow:inherit}
286291table.restr{vertical-align:top}
287292tr.e{background-color:#CCC}
288293tr.o{background-color:#EEE}
@@ -392,6 +397,15 @@ function after_load(){
392397 if(!chksql()){e.preventDefault();return}
393398 $('q').value=btoa(encodeURIComponent($('qraw').value).replace(/%([0-9A-F]{2})/g,function(m,p){return String.fromCharCode('0x'+p)}));
394399 });
400+ var res=$('res');
401+ if(res)res.addEventListener('dblclick',function(e){
402+ if(!$('is_sm').checked)return;
403+ var el=e.target;
404+ if(el.tagName!='TD')el=el.parentNode;
405+ if(el.tagName!='TD')return;
406+ if(el.className.match(/\b\lg\b/))el.className=el.className.replace(/\blg\b/,' ');
407+ else el.className+=' lg';
408+ });
395409}
396410function logoff(){
397411 if(lschk()){
@@ -410,6 +424,9 @@ function cfg_toggle(){
410424function qtpl(s){
411425 $('qraw').value=s.replace(/%T/g,'`<?php echo $ _REQUEST ['t ' ]?b64d ($ _REQUEST ['t ' ]):'tablename ' ?> `');
412426}
427+ function smview(){
428+ if($('is_sm').checked){$('res').className+=' sm'}else{$('res').className = $('res').className.replace(/\bsm\b/,' ')}
429+ }
413430<?php if ($ is_sht ){?>
414431function chkall(cab){
415432 var e=document.DF.elements;
@@ -453,7 +470,7 @@ function sht(f){
453470}
454471
455472function print_screen (){
456- global $ out_message , $ SQLq , $ err_msg , $ reccount , $ time_all , $ sqldr , $ page , $ MAX_ROWS_PER_PAGE , $ is_limited_sql , $ last_count ;
473+ global $ out_message , $ SQLq , $ err_msg , $ reccount , $ time_all , $ sqldr , $ page , $ MAX_ROWS_PER_PAGE , $ is_limited_sql , $ last_count, $ is_sm ;
457474
458475 $ nav ='' ;
459476 if ($ is_limited_sql && ($ page || $ reccount >=$ MAX_ROWS_PER_PAGE ) ){
@@ -479,6 +496,7 @@ function print_screen(){
479496<?php } ?>
480497</div>
481498<div class="dot">
499+ <div style="float:right;padding:0 15px"><label><input type="checkbox" name="is_sm" value="1" id="is_sm" onclick="smview()" <?php eo ($ is_sm ?'checked ' :'' )?> > compact view</label></div>
482500Records: <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>
483501<b><?php eo ($ out_message )?> </b>
484502</div>
@@ -778,7 +796,7 @@ function loadcfg(){
778796
779797//each time - from session to $DB_*
780798function loadsess (){
781- global $ DB ;
799+ global $ DB , $ is_sm ;
782800
783801 $ DB =$ _SESSION ['DB ' ];
784802
@@ -787,6 +805,8 @@ function loadsess(){
787805 if ($ rdb ) {
788806 $ DB ['db ' ]=$ rdb ;
789807 }
808+ if ($ _REQUEST ['GoSQL ' ]) $ _SESSION ['is_sm ' ]=$ _REQUEST ['is_sm ' ]+0 ;
809+ $ is_sm =$ _SESSION ['is_sm ' ]+0 ;
790810}
791811
792812function print_export (){
0 commit comments