2121 'port ' =>"" ,#optional
2222 'chset ' =>"utf8 " ,#optional, default charset
2323 );
24- date_default_timezone_set ('UTC ' );#required by PHP 5.1+
24+ if ( function_exists ( ' date_default_timezone_set ' )) date_default_timezone_set ('UTC ' );#required by PHP 5.1+
2525
2626//constants
2727 $ VERSION ='1.9.140405 ' ;
@@ -849,7 +849,7 @@ function ex_hdr($ct,$fn){
849849function ex_start (){
850850 global $ ex_isgz ,$ ex_gz ,$ ex_tmpf ;
851851 if ($ ex_isgz ){
852- $ ex_tmpf =tempnam ( sys_get_temp_dir (), ' pma ' ).'.gz ' ;
852+ $ ex_tmpf =tmp_name ( ).'.gz ' ;
853853 if (!($ ex_gz =gzopen ($ ex_tmpf ,'wb9 ' ))) die ("Error trying to create gz tmp file " );
854854 }
855855}
@@ -866,6 +866,7 @@ function ex_end(){
866866 if ($ ex_isgz ){
867867 gzclose ($ ex_gz );
868868 readfile ($ ex_tmpf );
869+ unlink ($ ex_tmpf );
869870 }
870871}
871872
@@ -920,7 +921,7 @@ function do_import(){
920921 $ filename =$ F ['tmp_name ' ];
921922 $ pi =pathinfo ($ F ['name ' ]);
922923 if ($ pi ['extension ' ]!='sql ' ){//if not sql - assume .gz
923- $ tmpf =tempnam ( sys_get_temp_dir (), ' pma ' );
924+ $ tmpf =tmp_name ( );
924925 if (($ gz =gzopen ($ filename ,'rb ' )) && ($ tf =fopen ($ tmpf ,'wb ' ))){
925926 while (!gzeof ($ gz )){
926927 if (fwrite ($ tf ,gzread ($ gz ,8192 ),8192 )===FALSE ){$ err_msg ='Error during gz file extraction to tmp file ' ;break ;}
@@ -1118,4 +1119,19 @@ function rw($s){#for debug
11181119 echo $ s ."<br> \n" ;
11191120}
11201121
1122+ function tmp_name () {
1123+ if ( function_exists ('sys_get_temp_dir ' )) return tempnam (sys_get_temp_dir (),'pma ' );
1124+
1125+ if ( !($ temp =getenv ('TMP ' )) )
1126+ if ( !($ temp =getenv ('TEMP ' )) )
1127+ if ( !($ temp =getenv ('TMPDIR ' )) ) {
1128+ $ temp =tempnam (__FILE__ ,'' );
1129+ if (file_exists ($ temp )) {
1130+ unlink ($ temp );
1131+ $ temp =dirname ($ temp );
1132+ }
1133+ }
1134+ return $ temp ? tempnam ($ temp ,'pma ' ) : null ;
1135+ }
1136+
11211137?>
0 commit comments