Skip to content

Commit 5df556c

Browse files
committed
get_magic_quotes_gpc removed, resolved #40
1 parent eb1474c commit 5df556c

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ In the directory samples you'll find phpminiconfig.php for known OpenSource pack
3939

4040
## Change Log
4141

42-
### changes in phpMiniAdmin 1.9.200928 (latest)
42+
### changes in phpMiniAdmin 1.9.210705 (latest)
43+
- removed use of function `get_magic_quotes_gpc` deprecated since PHP 7.4.0
44+
- utf8mb4 is now default charset
45+
- tested in PHP 8, cleaned up several PHP Warnings
46+
47+
### changes in phpMiniAdmin 1.9.210129
48+
- limited max packet size during export to aviod PHP memory exhausted errors on huge tables
49+
50+
### changes in phpMiniAdmin 1.9.200928
4351
- added ability to setup SSL connection (define at least "ssl_ca" in `$DBDEF`)
4452

4553
### changes in phpMiniAdmin 1.9.190822
@@ -50,11 +58,5 @@ In the directory samples you'll find phpminiconfig.php for known OpenSource pack
5058
- db NULLs now displayed in italic to distinguish from "NULL" text
5159
- misc formatting adjustments
5260

53-
### changes in phpMiniAdmin 1.9.170203
54-
- added "compact view" option. If checked - width/height of grid cells limited, so you can see more rows/columns in case your data is large. And in this mode you can double-click on cells to "expand" just that particular cell.
55-
56-
### changes in phpMiniAdmin 1.9.170117
57-
- greatly optimized memory usage for large result sets (especially in export)
58-
5961
[see older changes in changelog](changelog.md)
6062

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
### changes in phpMiniAdmin 1.9.210129 (latest)
1+
### changes in phpMiniAdmin 1.9.210705 (latest)
2+
- removed use of function `get_magic_quotes_gpc` deprecated since PHP 7.4.0
3+
- utf8mb4 is now default charset
4+
- tested in PHP 8, cleaned up several PHP Warnings
5+
6+
### changes in phpMiniAdmin 1.9.210129
27
- limited max packet size during export to aviod PHP memory exhausted errors on huge tables
38

49
### changes in phpMiniAdmin 1.9.200928

phpminiadmin.php

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/*
33
PHP Mini MySQL Admin
4-
(c) 2004-2019 Oleg Savchuk <[email protected]> http://osalabs.com
4+
(c) 2004-2021 Oleg Savchuk <[email protected]> http://osalabs.com
55
66
Light standalone PHP script for quick and easy access MySQL databases.
77
http://phpminiadmin.sourceforge.net
@@ -21,7 +21,7 @@
2121
'host'=>"",
2222
'port'=>"",
2323
'socket'=>"",
24-
'chset'=>"utf8",#optional, default charset
24+
'chset'=>"utf8mb4",#optional, default charset
2525
#optional paths for ssl
2626
'ssl_key'=>NULL,
2727
'ssl_cert'=>NULL,
@@ -33,7 +33,7 @@
3333
if (function_exists('date_default_timezone_set')) date_default_timezone_set('UTC');#required by PHP 5.1+
3434

3535
//constants
36-
$VERSION='1.9.210129';
36+
$VERSION='1.9.210705';
3737
$MAX_ROWS_PER_PAGE=50; #max number of rows in select per one page
3838
$D="\r\n"; #default delimiter for export
3939
$BOM=chr(239).chr(187).chr(191);
@@ -51,12 +51,6 @@
5151
ini_set('display_errors',0); #turn on to debug db or script issues
5252
error_reporting(E_ALL ^ E_NOTICE);
5353

54-
//strip quotes if they set
55-
if (get_magic_quotes_gpc()){
56-
$_COOKIE=array_map('killmq',$_COOKIE);
57-
$_REQUEST=array_map('killmq',$_REQUEST);
58-
}
59-
6054
if ($_REQUEST['login']){
6155
if ($_REQUEST['pwd']!=$ACCESS_PWD){
6256
$err_msg="Invalid password. Try again";
@@ -197,6 +191,7 @@ function display_select($sth,$q){
197191
if ($is_sht) $sqldr.="Database: &#183; <a href='$url&q=".b64u("show table status")."'>Show Table Status</a>";
198192
$sqldr.="</div>";
199193
}
194+
$abtn='';
200195
if ($is_sht){
201196
$abtn="<div><input type='submit' value='Export' onclick=\"sht('exp')\">
202197
<input type='submit' value='Drop' onclick=\"if(ays()){sht('drop')}else{return false}\">
@@ -219,6 +214,7 @@ function display_select($sth,$q){
219214
$headers.="</tr>\n";
220215
$sqldr.=$headers;
221216
$swapper=false;
217+
$swp=0;
222218
while($row=mysqli_fetch_row($sth)){
223219
$sqldr.="<tr class='".$rc[$swp=!$swp]."' onclick='tc(this)'>";
224220
$v=$row[0];
@@ -299,7 +295,7 @@ function print_header(){
299295
tr.h{background-color:#99C}
300296
tr.s{background-color:#FF9}
301297
.err{color:#F33;font-weight:bold;text-align:center}
302-
.frm{width:450px;border:1px solid #999;background-color:#eee;text-align:left}
298+
.frm{width:460px;border:1px solid #999;background-color:#eee;text-align:left}
303299
.frm label .l{width:100px;float:left}
304300
.dot{border-bottom:1px dotted #000}
305301
.ajax{text-decoration:none;border-bottom: 1px dashed}
@@ -512,7 +508,7 @@ function print_screen(){
512508
function print_footer(){
513509
?>
514510
</form>
515-
<div class="ft">&copy; 2004-2017 <a href="http://osalabs.com" target="_blank">Oleg Savchuk</a></div>
511+
<div class="ft">&copy; 2004-2021 <a href="http://osalabs.com" target="_blank">Oleg Savchuk</a></div>
516512
</body></html>
517513
<?php
518514
}
@@ -607,9 +603,9 @@ function dbq($s){
607603

608604
function db_query($sql, $dbh1=NULL, $skiperr=0, $resmod=MYSQLI_STORE_RESULT){
609605
$dbh1=db_checkconnect($dbh1, $skiperr);
610-
$sth=mysqli_query($dbh1, $sql, $resmod);
611-
if (!$sth && $skiperr) return;
612-
if (!$sth) die("Error in DB operation:<br>\n".mysqli_error($dbh1)."<br>\n$sql");
606+
if($dbh1) $sth=mysqli_query($dbh1, $sql, $resmod);
607+
if(!$sth && $skiperr) return;
608+
if(!$sth) die("Error in DB operation:<br>\n".mysqli_error($dbh1)."<br>\n$sql");
613609
return $sth;
614610
}
615611

@@ -753,13 +749,10 @@ function pen($p,$np=''){
753749
return str_replace('%p%',$p, $np);
754750
}
755751

756-
function killmq($value){
757-
return is_array($value)?array_map('killmq',$value):stripslashes($value);
758-
}
759-
760752
function savecfg(){
761753
global $DBDEF;
762754
$v=$_REQUEST['v'];
755+
if(!is_array($v))$v=array();
763756
unset($v['ssl_ca']);unset($v['ssl_key']);unset($v['ssl_cert']);#don't allow override ssl paths from web
764757
$_SESSION['DB']=array_merge($DBDEF,$v);
765758
unset($_SESSION['sql_sd']);
@@ -785,7 +778,7 @@ function savecfg(){
785778
}
786779

787780
// Allow httponly cookies, or the password is stored plain text in a cookie
788-
function newcookie($n,$v,$e){$x;return setcookie($n,$v,$e,$x,$x,!!$x,!$x);}
781+
function newcookie($n,$v,$e){$x='';return setcookie($n,$v,$e,$x,$x,!!$x,!$x);}
789782

790783
//during login only - from cookies or use defaults;
791784
function loadcfg(){
@@ -877,7 +870,7 @@ function do_export(){
877870
if ($ct==1&&$_REQUEST['et']=='csv'){
878871
ex_start('.csv');
879872
ex_hdr($ctp?$ctp:'text/csv',"$t[0].csv$aext");
880-
if ($DB['chset']=='utf8') ex_w($BOM);
873+
if ($DB['chset']=='utf8mb4') ex_w($BOM);
881874

882875
$sth=db_query("select * from `$t[0]`",NULL,0,MYSQLI_USE_RESULT);
883876
$fn=mysqli_field_count($dbh);
@@ -1005,7 +998,7 @@ function print_import(){
1005998
.csv file (Excel style): <input type="file" name="file2" value="" size=40><br>
1006999
<input type="checkbox" name="r1" value="1" checked> first row contain field names<br>
10071000
<small>(note: for success, field names should be exactly the same as in DB)</small><br>
1008-
Character set of the file: <select name="chset"><?php echo chset_select('utf8')?></select>
1001+
Character set of the file: <select name="chset"><?php echo chset_select('utf8mb4')?></select>
10091002
<br><br>
10101003
Import into:<br>
10111004
<input type="radio" name="tt" value="1" checked="checked"> existing table:
@@ -1145,6 +1138,7 @@ function get_next_chunk($insql, $fname){
11451138
}
11461139

11471140
function get_open_char($str, $pos){
1141+
$ochar='';$opos='';
11481142
if ( preg_match("/(\/\*|^--|(?<=\s)--|#|'|\"|;)/", $str, $m, PREG_OFFSET_CAPTURE, $pos) ) {
11491143
$ochar=$m[1][0];
11501144
$opos=$m[1][1];

samples/phpminiconfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'host'=>'',#optional
1111
'port'=>'',#optional
1212
'socket'=>'',#optional
13-
'chset'=>'utf8',#optional, default charset
13+
'chset'=>'utf8mb4',#optional, default charset
1414
#optional paths for ssl
1515
'ssl_key'=>NULL,
1616
'ssl_cert'=>NULL,

0 commit comments

Comments
 (0)