Source for file upload_tmp_dir.php

Documentation is available at upload_tmp_dir.php

  1. <?php
  2. /**
  3. * Test Class for upload_tmp_dir
  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. * Test Class for upload_tmp_dir
  16. *
  17. * @package PhpSecInfo
  18. */
  19. class PhpSecInfo_Test_Core_Upload_Tmp_Dir extends PhpSecInfo_Test_Core
  20. {
  21.  
  22. /**
  23. * This should be a <b>unique</b>, human-readable identifier for this test
  24. *
  25. * @var string
  26. */
  27. var $test_name = "upload_tmp_dir";
  28. var $_messages = array();
  29.  
  30. /**
  31. * Check to see if the upload_tmp_dir setting is enabled. If it is set, check if it matches PHPSECINFO_TEST_COMMON_TMPDIR
  32. *
  33. * The test for PHPSECINFO_TEST_COMMON_TMPDIR is pretty UNIX-specific, and should probably include other common world-writable
  34. * dirs from other OSes
  35. *
  36. * @see PHPSECINFO_TEST_COMMON_TMPDIR
  37. */
  38. function _execTest() {
  39. if (ini_get('upload_tmp_dir') && !preg_match("|".PHPSECINFO_TEST_COMMON_TMPDIR."/?|", ini_get('upload_tmp_dir'))) {
  40. return PHPSECINFO_TEST_RESULT_OK;
  41. }
  42. return PHPSECINFO_TEST_RESULT_NOTICE;
  43. }
  44. /**
  45. * Set the messages specific to this test
  46. *
  47. */
  48. function _setMessages() {
  49. parent::_setMessages();
  50. $this->setMessageForResult(PHPSECINFO_TEST_RESULT_OK, 'en', 'upload_tmp_dir is enabled, which is the
  51. recommended setting. Make sure your upload_tmp_dir path is not world-readable');
  52. $this->setMessageForResult(PHPSECINFO_TEST_RESULT_NOTICE, 'en', 'upload_tmp_dir is disabled, or is set to a
  53. common world-writable directory. This typically allows other users on this server
  54. to access temporary copies of files uploaded via your PHP scripts. You should set
  55. upload_tmp_dir to a non-world-readable directory');
  56. }
  57. }

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