Source for file upload_max_filesize.php

Documentation is available at upload_max_filesize.php

  1. <?php
  2. /**
  3. * Test Class for upload_max_filesize
  4. *
  5. * @package PhpSecInfo
  6. * @author Ed Finkler <coj@funkatron.com>
  7. */
  8.  
  9. /**
  10. * require the PhpSecInfo_Test_Core class
  11. */
  12. require_once('PhpSecInfo/Test/Test_Core.php');
  13.  
  14. /**
  15. * The max recommended size for the upload_max_filesize setting, in bytes
  16. *
  17. */
  18. define ('PHPSEC_UPLOAD_MAXLIMIT', 1024*256);
  19.  
  20.  
  21. /**
  22. * Test Class for upload_max_filesize
  23. *
  24. * @package PhpSecInfo
  25. */
  26. class PhpSecInfo_Test_Core_Upload_Max_Filesize extends PhpSecInfo_Test_Core
  27. {
  28. /**
  29. * This should be a <b>unique</b>, human-readable identifier for this test
  30. *
  31. * @var string
  32. */
  33. var $test_name = "upload_max_filesize";
  34.  
  35. /**
  36. * Check to see if the upload_max_filesize setting is enabled.
  37. */
  38. function _execTest() {
  39. $uploads_max_filesize = ini_get('upload_max_filesize');
  40. if ($uploads_max_filesize
  41. && $this->returnBytes($uploads_max_filesize) < PHPSEC_UPLOAD_MAXLIMIT
  42. && $uploads_max_filesize != -1) {
  43. return PHPSECINFO_TEST_RESULT_OK;
  44. }
  45. return PHPSECINFO_TEST_RESULT_NOTICE;
  46. }
  47. /**
  48. * Set the messages specific to this test
  49. *
  50. */
  51. function _setMessages() {
  52. parent::_setMessages();
  53. $this->setMessageForResult(PHPSECINFO_TEST_RESULT_OK, 'en', 'upload_max_filesize is enabled, and appears to be a relatively low value.');
  54. $this->setMessageForResult(PHPSECINFO_TEST_RESULT_NOTICE, 'en', 'upload_max_filesize is not enabled, or is set to a high value. Are you sure your apps require uploading files of this size? If not, lower the limit, as large file uploads can impact server performance');
  55. }
  56.  
  57. }

Documentation generated on Tue, 24 Oct 2006 10:53:43 -0400 by phpDocumentor 1.3.0RC3