Code Search for Developers
 
 
  

UploadTmpDir.php from Astrum Futura at Krugle


Show UploadTmpDir.php syntax highlighted

<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Environment
 * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Exception.php 2794 2007-01-16 01:29:51Z bkarwin $
 */

/**
 * require the Zend_Environment_Security_Test_Core class
 */
require_once 'Zend/Environment/Security/Test/Core.php';

/**
 * Test Class for upload_tmp_dir
 *
 * @package Zend_Environment
 */
class Zend_Environment_Security_Test_Core_UploadTmpDir extends Zend_Environment_Security_Test_Core
{

    /**
	 * This should be a <b>unique</b>, human-readable identifier for this test
	 *
	 * @var string
	 */
    protected $_name = "upload_tmp_dir";

    protected $_recommended_value = "A non-world readable/writable directory";

    protected function _retrieveCurrentValue() {
        $this->_current_value =  ini_get('upload_tmp_dir');

        if( empty($this->_current_value) ) {
            if (function_exists("sys_get_temp_dir")) {
                $this->_current_value = sys_get_temp_dir();
            } else {
                $this->_current_value = $this->sys_get_temp_dir();
            }
        }
    }

    /**
	 * We are disabling this function on Windows OSes right now until
	 * we can be certain of the proper way to check world-readability
	 *
	 * @return unknown
	 */
    public function isTestable() {
        if ($this->osIsWindows()) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    /**
	 * Check if upload_tmp_dir matches self::COMMON_TMPDIR, or is word-writable
	 *
	 * This is still unix-specific, and it's possible that for now
	 * this test should be disabled under Windows builds.
	 *
	 * @see self::COMMON_TMPDIR
	 */
    protected function _execTest() {

        $perms = fileperms($this->_current_value);

        if ($this->_current_value
        && !preg_match("|".self::COMMON_TMPDIR."/?|", $this->_current_value)
        && ! ($perms & 0x0004)
        && ! ($perms & 0x0002) ) {
            return self::RESULT_OK;
        }

        // rewrite _current_value to display perms
        $this->_current_value .= " (".substr(sprintf('%o', $perms), -4).")";

        return self::RESULT_NOTICE;
    }


    /**
	 * Set the messages specific to this test
	 *
	 */
    protected function _setMessages() {
        parent::_setMessages();

        $this->setMessageForResult(self::RESULT_NOTRUN, 'en', 'Test not run -- currently disabled on Windows OSes');
        $this->setMessageForResult(self::RESULT_OK, 'en', 'upload_tmp_dir is enabled, which is the
						recommended setting. Make sure your upload_tmp_dir path is not world-readable');
        $this->setMessageForResult(self::RESULT_NOTICE, 'en', 'upload_tmp_dir is disabled, or is set to a
						common world-writable directory.  This typically allows other users on this server
						to access temporary copies of files uploaded via your PHP scripts.  You should set
						upload_tmp_dir to a non-world-readable directory');
    }

}



See more files for this project here

Astrum Futura

Multiplayer space strategy game written in PHP5 with the Zend Framework. User interface uses Javascript/AJAX for dynamic interaction. Players compete across a hexagonal map of 10,000 sectors, planets, stars and other locations through trade and combat.

Project homepage: http://sourceforge.net/projects/astrumfutura
Programming language(s): PHP,XML
License: other

  AllowUrlFopen.php
  AllowUrlInclude.php
  DisplayErrors.php
  ExposePHP.php
  FileUploads.php
  GID.php
  MagicQuotesGPC.php
  OpenBasedir.php
  PostMaxSize.php
  RegisterGlobals.php
  UID.php
  UploadMaxFilesize.php
  UploadTmpDir.php