1
1
<?php
2
2
/*
3
- Version 1.2
4
- Copyright 2012-2015 - Amaury Balmer ([email protected] )
3
+ Version 1.3
4
+ Copyright 2012-2016 - Amaury Balmer ([email protected] )
5
5
6
6
This program is free software; you can redistribute it and/or modify
7
7
it under the terms of the GNU General Public License, version 2, as
@@ -309,12 +309,12 @@ public function test_php_config() {
309
309
$ this ->html_table_row ( 'register_argc_argv ' , '- ' , 'Off ' , 'Off ' , 'success ' );
310
310
}
311
311
312
- $ value = ini_get ( 'memory_limit ' );
313
- if ( intval ( $ value ) < 64 ) {
314
- $ this ->html_table_row ( 'memory_limit ' , '64M ' , '256M ' , $ value , 'error ' );
312
+ $ value = $ this -> return_bytes ( ini_get ( 'memory_limit ' ) );
313
+ if ( intval ( $ value ) < $ this -> return_bytes ( ' 64M ' ) ) {
314
+ $ this ->html_table_row ( 'memory_limit ' , '64 MB ' , '256 MB ' , $ this -> _format_bytes ( $ value) , 'error ' );
315
315
} else {
316
- $ status = (intval ( $ value ) >= ( 8388608 * 32 )) ? 'success ' : 'warning ' ; // 256mb
317
- $ this ->html_table_row ( 'memory_limit ' , '64M ' , '256M ' , $ value , $ status );
316
+ $ status = (intval ( $ value ) >= $ this -> return_bytes ( ' 256M ' )) ? 'success ' : 'warning ' ;
317
+ $ this ->html_table_row ( 'memory_limit ' , '64 MB ' , '256 MB ' , $ this -> _format_bytes ( $ value) , $ status );
318
318
}
319
319
320
320
$ value = ini_get ( 'max_input_vars ' );
@@ -332,20 +332,20 @@ public function test_php_config() {
332
332
$ this ->html_table_row ( 'file_uploads ' , 'On ' , 'On ' , 'Off ' , 'error ' );
333
333
}
334
334
335
- $ value = ini_get ( 'upload_max_filesize ' );
336
- if ( intval ( $ value ) < 32 ) {
337
- $ this ->html_table_row ( 'upload_max_filesize ' , '32M ' , '128M ' , $ value , 'warning ' );
335
+ $ value = $ this -> return_bytes ( ini_get ( 'upload_max_filesize ' ) );
336
+ if ( intval ( $ value ) < $ this -> return_bytes ( ' 32M ' ) ) {
337
+ $ this ->html_table_row ( 'upload_max_filesize ' , '32 MB ' , '128 MB ' , $ this -> _format_bytes ( $ value) , 'error ' );
338
338
} else {
339
- $ status = (intval ( $ value ) >= ( 8388608 * 8 )) ? 'success ' : 'warning ' ; // 128mb
340
- $ this ->html_table_row ( 'upload_max_filesize ' , '32M ' , '128M ' , $ value , $ status );
339
+ $ status = (intval ( $ value ) >= $ this -> return_bytes ( ' 128M ' )) ? 'success ' : 'warning ' ;
340
+ $ this ->html_table_row ( 'upload_max_filesize ' , '32 MB ' , '128 MB ' , $ this -> _format_bytes ( $ value) , $ status );
341
341
}
342
342
343
- $ value = ini_get ( 'post_max_size ' );
344
- if ( intval ( $ value ) < 32 ) {
345
- $ this ->html_table_row ( 'post_max_size ' , '32M ' , '128M ' , $ value , 'warning ' );
343
+ $ value = $ this -> return_bytes ( ini_get ( 'post_max_size ' ) );
344
+ if ( intval ( $ value ) < $ this -> return_bytes ( ' 32M ' ) ) {
345
+ $ this ->html_table_row ( 'post_max_size ' , '32 MB ' , '128 MB ' , $ this -> _format_bytes ( $ value) , 'warning ' );
346
346
} else {
347
- $ status = (intval ( $ value ) >= ( 8388608 * 8 )) ? 'success ' : 'warning ' ; // 128mb
348
- $ this ->html_table_row ( 'post_max_size ' , '32M ' , '128M ' , $ value , $ status );
347
+ $ status = (intval ( $ value ) >= $ this -> return_bytes ( ' 128M ' )) ? 'success ' : 'warning ' ;
348
+ $ this ->html_table_row ( 'post_max_size ' , '32 MB ' , '128 MB ' , $ this -> _format_bytes ( $ value) , $ status );
349
349
}
350
350
351
351
$ value = ini_get ( 'short_open_tag ' );
@@ -403,18 +403,39 @@ public function test_php_config() {
403
403
}
404
404
405
405
if ( is_callable ( 'apc_store ' ) ) {
406
- $ value = ini_get ( 'apc.shm_size ' );
407
- if ( intval ( $ value ) < 32 ) {
408
- $ this ->html_table_row ( 'apc.shm_size ' , '32M ' , '128M ' , $ value , 'error ' );
406
+ $ value = $ this -> return_bytes ( ini_get ( 'apc.shm_size ' ) );
407
+ if ( intval ( $ value ) < $ this -> return_bytes ( ' 32M ' ) ) {
408
+ $ this ->html_table_row ( 'apc.shm_size ' , '32 MB ' , '128 MB ' , $ this -> _format_bytes ( $ value) , 'error ' );
409
409
} else {
410
- $ status = (intval ( $ value ) >= ( 8388608 * 16 )) ? 'success ' : 'warning ' ; // 128mb
411
- $ this ->html_table_row ( 'apc.shm_size ' , '32M ' , '128M ' , $ value , $ status );
410
+ $ status = (intval ( $ value ) >= $ this -> return_bytes ( ' 128M ' )) ? 'success ' : 'warning ' ;
411
+ $ this ->html_table_row ( 'apc.shm_size ' , '32 MB ' , '128 MB ' , $ this -> _format_bytes ( $ value) , $ status );
412
412
}
413
413
}
414
414
415
415
$ this ->html_table_close ();
416
416
}
417
417
418
+ /**
419
+ * Convert PHP variable (G/M/K) to bytes
420
+ * Source: http://php.net/manual/fr/function.ini-get.php
421
+ *
422
+ */
423
+ public function return_bytes ($ val ) {
424
+ $ val = trim ($ val );
425
+ $ last = strtolower ($ val [strlen ($ val )-1 ]);
426
+ switch ($ last ) {
427
+ // Le modifieur 'G' est disponible depuis PHP 5.1.0
428
+ case 'g ' :
429
+ $ val *= 1024 ;
430
+ case 'm ' :
431
+ $ val *= 1024 ;
432
+ case 'k ' :
433
+ $ val *= 1024 ;
434
+ }
435
+
436
+ return $ val ;
437
+ }
438
+
418
439
/**
419
440
* @return bool
420
441
*/
@@ -439,8 +460,8 @@ public function test_mysqli_config() {
439
460
$ result = mysqli_query ( $ this ->db_link , "SHOW VARIABLES LIKE 'query_cache_size' " );
440
461
if ( $ result != false ) {
441
462
while ( $ row = mysqli_fetch_assoc ( $ result ) ) {
442
- if ( intval ( $ row ['Value ' ] ) >= 8388608 ) { // 8mb
443
- $ status = (intval ( $ row ['Value ' ] ) >= ( 8388608 * 8 )) ? 'success ' : 'warning ' ; // 64mb
463
+ if ( intval ( $ row ['Value ' ] ) >= $ this -> return_bytes ( ' 8M ' ) ) {
464
+ $ status = (intval ( $ row ['Value ' ] ) >= $ this -> return_bytes ( ' 64M ' )) ? 'success ' : 'warning ' ;
444
465
$ this ->html_table_row ( "Query cache size " , '8M ' , '64MB ' , $ this ->_format_bytes ( (int ) $ row ['Value ' ] ), $ status );
445
466
} else {
446
467
$ this ->html_table_row ( "Query cache size " , '8M ' , '64MB ' , $ this ->_format_bytes ( (int ) $ row ['Value ' ] ), 'error ' );
0 commit comments