Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6e2e52b

Browse files
committed
added ability to setup SSL connection
1 parent 9dc4e81 commit 6e2e52b

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

‎README.md‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ In the directory samples you'll find phpminiconfig.php for known OpenSource pack
3838
- [My website](http://osalabs.com)
3939

4040
## Change Log
41-
### changes in phpMiniAdmin 1.9.190822 (latest)
41+
42+
### changes in phpMiniAdmin 1.9.200928 (latest)
43+
- added ability to setup SSL connection (define at least "ssl_ca" in `$DBDEF`)
44+
45+
### changes in phpMiniAdmin 1.9.190822
4246
- added ability to set socket for db connection
4347

4448
### changes in phpMiniAdmin 1.9.170730
@@ -52,10 +56,5 @@ In the directory samples you'll find phpminiconfig.php for known OpenSource pack
5256
### changes in phpMiniAdmin 1.9.170117
5357
- greatly optimized memory usage for large result sets (especially in export)
5458

55-
### changes in phpMiniAdmin 1.9.161116
56-
- added ability to dump exports right on server, without need to download
57-
- added ability to import from .sql or .gz file right on server, without need to upload one
58-
- fixed export, now it won't dump data for VIEWs
59-
6059
[see older changes in changelog](changelog.md)
6160

‎changelog.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
### changes in phpMiniAdmin 1.9.190822 (latest)
1+
### changes in phpMiniAdmin 1.9.200928 (latest)
2+
- added ability to setup SSL connection (define at least "ssl_ca" in `$DBDEF`)
3+
4+
### changes in phpMiniAdmin 1.9.190822
25
- added ability to set socket for db connection
36

47
### changes in phpMiniAdmin 1.9.170203

‎phpminiadmin.php‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,24 @@
1616
$DBDEF=array(
1717
'user'=>"",#required
1818
'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'=>"",
2324
'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
2429
);
2530
$IS_COUNT=false; #set to true if you want to see Total records when pagination occurs (SLOWS down all select queries!)
2631
$DUMP_FILE=dirname(__FILE__).'/pmadump'; #path to file without extension used for server-side exports (timestamp, .sql/.csv/.gz extension added) or imports(.sql)
2732
file_exists($f=dirname(__FILE__) . '/phpminiconfig.php')&&require($f); // Read from config (easier to update)
2833
if (function_exists('date_default_timezone_set')) date_default_timezone_set('UTC');#required by PHP 5.1+
2934

3035
//constants
31-
$VERSION='1.9.190822';
36+
$VERSION='1.9.200928';
3237
$MAX_ROWS_PER_PAGE=50; #max number of rows in select per one page
3338
$D="\r\n"; #default delimiter for export
3439
$BOM=chr(239).chr(187).chr(191);
@@ -80,8 +85,8 @@
8085
print_login();
8186
exit;
8287
}
83-
}
8488

89+
}
8590
if ($_REQUEST['savecfg']){
8691
check_xss();
8792
savecfg();
@@ -96,7 +101,7 @@
96101

97102
//get initial values
98103
$SQLq=trim(b64d($_REQUEST['q']));
99-
$page=$_REQUEST['p']+0;
104+
$page=intval($_REQUEST['p']);
100105
if ($_REQUEST['refresh'] && $DB['db'] && preg_match('/^show/',$SQLq) ) $SQLq=$SHOW_T;
101106

102107
if (db_connect('nodie')){
@@ -561,8 +566,14 @@ function db_connect($nodie=0){
561566

562567
$po=$DB['port'];if(!$po) $po=ini_get("mysqli.default_port");
563568
$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+
}
566577
if (!$dbh) {
567578
$err_msg='Cannot connect to the database because: '.mysqli_connect_error();
568579
if (!$nodie) die($err_msg);
@@ -747,8 +758,10 @@ function killmq($value){
747758
}
748759

749760
function savecfg(){
761+
global $DBDEF;
750762
$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);
752765
unset($_SESSION['sql_sd']);
753766

754767
if ($_REQUEST['rmb']){
@@ -779,7 +792,7 @@ function loadcfg(){
779792
global $DBDEF;
780793

781794
if( isset($_COOKIE['conn']) ){
782-
$_SESSION['DB']=$_COOKIE['conn'];
795+
$_SESSION['DB']=array_merge($DBDEF,$_COOKIE['conn']);
783796
}else{
784797
$_SESSION['DB']=$DBDEF;
785798
}

‎samples/phpminiconfig.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@
1111
'port'=>'',#optional
1212
'socket'=>'',#optional
1313
'chset'=>'utf8',#optional, default charset
14+
#optional paths for ssl
15+
'ssl_key'=>NULL,
16+
'ssl_cert'=>NULL,
17+
'ssl_ca'=>"",#minimum this is required for ssl connections, if set - ssl connection will try to be established. Example: /path/to/cacert.pem
1418
);
1519

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /