|
16 | 16 | $DBDEF=array( |
17 | 17 | 'user'=>"",#required |
18 | 18 | 'pwd'=>"", #required |
19 | | -'db'=>"", #optional, default DB |
20 | | -'host'=>"",#optional |
21 | | -'port'=>"",#optional |
22 | | -'socket'=>"",#optional |
| 19 | +#optional: |
| 20 | +'db'=>"", #default DB |
| 21 | +'host'=>"", |
| 22 | +'port'=>"", |
| 23 | +'socket'=>"", |
23 | 24 | 'chset'=>"utf8",#optional, default charset |
| 25 | +#optional paths for ssl |
| 26 | +'ssl_key'=>NULL, |
| 27 | +'ssl_cert'=>NULL, |
| 28 | +'ssl_ca'=>'',#minimum this is required for ssl connections, if set - ssl connection will try to be established. Example: /path/to/cacert.pem |
24 | 29 | ); |
25 | 30 | $IS_COUNT=false; #set to true if you want to see Total records when pagination occurs (SLOWS down all select queries!) |
26 | 31 | $DUMP_FILE=dirname(__FILE__).'/pmadump'; #path to file without extension used for server-side exports (timestamp, .sql/.csv/.gz extension added) or imports(.sql) |
27 | 32 | file_exists($f=dirname(__FILE__) . '/phpminiconfig.php')&&require($f); // Read from config (easier to update) |
28 | 33 | if (function_exists('date_default_timezone_set')) date_default_timezone_set('UTC');#required by PHP 5.1+ |
29 | 34 |
|
30 | 35 | //constants |
31 | | -$VERSION='1.9.190822'; |
| 36 | +$VERSION='1.9.200928'; |
32 | 37 | $MAX_ROWS_PER_PAGE=50; #max number of rows in select per one page |
33 | 38 | $D="\r\n"; #default delimiter for export |
34 | 39 | $BOM=chr(239).chr(187).chr(191); |
|
80 | 85 | print_login(); |
81 | 86 | exit; |
82 | 87 | } |
83 | | -} |
84 | 88 |
|
| 89 | +} |
85 | 90 | if ($_REQUEST['savecfg']){ |
86 | 91 | check_xss(); |
87 | 92 | savecfg(); |
|
96 | 101 |
|
97 | 102 | //get initial values |
98 | 103 | $SQLq=trim(b64d($_REQUEST['q'])); |
99 | | -$page=$_REQUEST['p']+0; |
| 104 | +$page=intval($_REQUEST['p']); |
100 | 105 | if ($_REQUEST['refresh'] && $DB['db'] && preg_match('/^show/',$SQLq) ) $SQLq=$SHOW_T; |
101 | 106 |
|
102 | 107 | if (db_connect('nodie')){ |
@@ -561,8 +566,14 @@ function db_connect($nodie=0){ |
561 | 566 |
|
562 | 567 | $po=$DB['port'];if(!$po) $po=ini_get("mysqli.default_port"); |
563 | 568 | $so=$DB['socket'];if(!$so) $so=ini_get("mysqli.default_socket"); |
564 | | - $dbh=mysqli_connect($DB['host'],$DB['user'],$DB['pwd'],$DB['db'],$po,$so); |
565 | | - |
| 569 | + if ($DB['ssl_ca']){#ssl connection |
| 570 | + $dbh=mysqli_init(); |
| 571 | + mysqli_options($dbh,MYSQLI_OPT_SSL_VERIFY_SERVER_CERT,true); |
| 572 | + mysqli_ssl_set($dbh,$DB['ssl_key'],$DB['ssl_cert'],$DB['ssl_ca'],NULL,NULL); |
| 573 | + if (!mysqli_real_connect($dbh,$DB['host'],$DB['user'],$DB['pwd'],$DB['db'],$po,$so,MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT)) $dbh=null; |
| 574 | + }else{#non-ssl |
| 575 | + $dbh=mysqli_connect($DB['host'],$DB['user'],$DB['pwd'],$DB['db'],$po,$so); |
| 576 | + } |
566 | 577 | if (!$dbh) { |
567 | 578 | $err_msg='Cannot connect to the database because: '.mysqli_connect_error(); |
568 | 579 | if (!$nodie) die($err_msg); |
@@ -747,8 +758,10 @@ function killmq($value){ |
747 | 758 | } |
748 | 759 |
|
749 | 760 | function savecfg(){ |
| 761 | + global $DBDEF; |
750 | 762 | $v=$_REQUEST['v']; |
751 | | - $_SESSION['DB']=$v; |
| 763 | + unset($v['ssl_ca']);unset($v['ssl_key']);unset($v['ssl_cert']);#don't allow override ssl paths from web |
| 764 | + $_SESSION['DB']=array_merge($DBDEF,$v); |
752 | 765 | unset($_SESSION['sql_sd']); |
753 | 766 |
|
754 | 767 | if ($_REQUEST['rmb']){ |
@@ -779,7 +792,7 @@ function loadcfg(){ |
779 | 792 | global $DBDEF; |
780 | 793 |
|
781 | 794 | if( isset($_COOKIE['conn']) ){ |
782 | | - $_SESSION['DB']=$_COOKIE['conn']; |
| 795 | + $_SESSION['DB']=array_merge($DBDEF,$_COOKIE['conn']); |
783 | 796 | }else{ |
784 | 797 | $_SESSION['DB']=$DBDEF; |
785 | 798 | } |
|
0 commit comments