server_info.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Tidypics server analysis
  4. */
  5. function tp_readable_size($bytes) {
  6. if (strpos($bytes, 'M')) {
  7. return $bytes . 'B';
  8. }
  9. $size = $bytes / 1024;
  10. if ($size < 1024) {
  11. $size = number_format($size, 2);
  12. $size .= ' KB';
  13. } else {
  14. $size = $size / 1024;
  15. if ($size < 1024) {
  16. $size = number_format($size, 2);
  17. $size .= ' MB';
  18. } else {
  19. $size = $size / 1024;
  20. $size = number_format($size, 2);
  21. $size .= ' GB';
  22. }
  23. }
  24. return $size;
  25. }
  26. $disablefunc = explode(',', ini_get('disable_functions'));
  27. $exec_avail = elgg_echo('tidypics:disabled');
  28. if (is_callable('exec') && !in_array('exec',$disablefunc)) {
  29. $exec_avail = elgg_echo('tidypics:enabled');
  30. }
  31. ob_start();
  32. ?>
  33. <table class="elgg-table-alt">
  34. <tr>
  35. <td><?php echo elgg_echo('tidypics:server_info:php_version'); ?></td>
  36. <td><?php echo phpversion(); ?></td>
  37. <td></td>
  38. </tr>
  39. <tr>
  40. <td>GD</td>
  41. <td><?php echo (extension_loaded('gd')) ? elgg_echo('tidypics:enabled') : elgg_echo('tidypics:disabled'); ?></td>
  42. <td><?php echo elgg_echo('tidypics:server_info:gd_desc'); ?></td>
  43. </tr>
  44. <tr>
  45. <td>imagick</td>
  46. <td><?php echo (extension_loaded('imagick')) ? elgg_echo('tidypics:enabled') : elgg_echo('tidypics:disabled'); ?></td>
  47. <td></td>
  48. </tr>
  49. <tr>
  50. <td>exec()</td>
  51. <td><?php echo $exec_avail; ?></td>
  52. <td><?php echo elgg_echo('tidypics:server_info:exec_desc'); ?></td>
  53. </tr>
  54. <tr>
  55. <td><?php echo elgg_echo('tidypics:server_info:memory_limit'); ?></td>
  56. <td><?php echo tp_readable_size(ini_get('memory_limit')); ?></td>
  57. <td><?php echo elgg_echo('tidypics:server_info:memory_limit_desc'); ?></td>
  58. </tr>
  59. <tr>
  60. <td><?php echo elgg_echo('tidypics:server_info:peak_usage'); ?></td>
  61. <td><?php if (function_exists('memory_get_peak_usage')) echo tp_readable_size(memory_get_peak_usage()); ?></td>
  62. <td><?php echo elgg_echo('tidypics:server_info:peak_usage_desc'); ?></td>
  63. </tr>
  64. <tr>
  65. <td><?php echo elgg_echo('tidypics:server_info:upload_max_filesize'); ?></td>
  66. <td><?php echo tp_readable_size(ini_get('upload_max_filesize')); ?></td>
  67. <td><?php echo elgg_echo('tidypics:server_info:upload_max_filesize_desc'); ?></td>
  68. </tr>
  69. <tr>
  70. <td><?php echo elgg_echo('tidypics:server_info:post_max_size'); ?></td>
  71. <td><?php echo tp_readable_size(ini_get('post_max_size')); ?></td>
  72. <td><?php echo elgg_echo('tidypics:server_info:post_max_size_desc'); ?></td>
  73. </tr>
  74. <tr>
  75. <td><?php echo elgg_echo('tidypics:server_info:max_input_time'); ?></td>
  76. <td><?php echo ini_get('max_input_time'); ?>s</td>
  77. <td><?php echo elgg_echo('tidypics:server_info:max_input_time_desc'); ?></td>
  78. </tr>
  79. <tr>
  80. <td><?php echo elgg_echo('tidypics:server_info:max_execution_time'); ?></td>
  81. <td><?php echo ini_get('max_execution_time'); ?> s</td>
  82. <td><?php echo elgg_echo('tidypics:server_info:max_execution_time_desc'); ?></td>
  83. </tr>
  84. <tr>
  85. <td>GD imagejpeg</td>
  86. <td><?php echo (is_callable('imagejpeg')) ? elgg_echo('tidypics:enabled') : elgg_echo('tidypics:disabled'); ?></td>
  87. <td></td>
  88. </tr>
  89. <tr>
  90. <td>GD imagepng</td>
  91. <td><?php echo (is_callable('imagepng')) ? elgg_echo('tidypics:enabled') : elgg_echo('tidypics:disabled'); ?></td>
  92. <td></td>
  93. </tr>
  94. <tr>
  95. <td>GD imagegif</td>
  96. <td><?php echo (is_callable('imagegif')) ? elgg_echo('tidypics:enabled') : elgg_echo('tidypics:disabled'); ?></td>
  97. <td></td>
  98. </tr>
  99. <tr>
  100. <td>EXIF</td>
  101. <td><?php echo (is_callable('exif_read_data')) ? elgg_echo('tidypics:enabled') : elgg_echo('tidypics:disabled'); ?></td>
  102. <td></td>
  103. </tr>
  104. </table>
  105. <?php
  106. $content = ob_get_clean();
  107. echo elgg_view_module('inline', elgg_echo('tidypics:server_info'), $content);