Location: PHPKode > scripts > Platform_pear > platform_pear/Pear/class5.php
<?php
/*------------------------------------------------------------------------------
// File:		[Platform/Pear/]proc.php
// Description:	PHP 4, 5 Pear Package Check
// Purpose:		Use this class to check for installed PEAR packages in an
//				auto-detect like fashion.
// Version:		1.0
// Application:	PHCL-WTK
// Author:		Asher Kadar Wolfstein
// Email:		hide@address.com
// Homepage:	http://www.asherwolf.com/projects/php/platform/pear/index.html
//------------------------------------------------------------------------------
//
// ALL CODE AND (GENERATED) DOCUMENTATION
//		IS COPYRIGHT © 2007 WOLFSTEIN CONSULTING (COLORADO)
//
// LICENSE INFORMATION
//
// http://www.asherwolf.com/code_license_1.php?p=Platform_pear&l=lgpl&l2=c30
//
// THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY INCLUDING THE IMPLIED
// WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE.
//
// THIS FILE IS PART OF 'Platform_pear'.
//
// 'Platform_pear' IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
// IT UNDER THE TERMS OF THE GNU LESSER GENERAL PUBLIC LICENSE AS PUBLISHED BY
// THE FREE SOFTWARE FOUNDATION;
//
// 'Platform_pear' IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
// BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
// MERCHANTIBILITY OR FITNESS FOR A PARTICULAR PURPOSE.  SEE THE
// GNU LESSER GENERAL PUBLIC LICENSE FOR MORE DETAILS.
//
// YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE
// ALONG WITH 'Filecloak'; IF NOT, WRITE TO THE FREE SOFTWARE FOUNDATION, INC.,
// 51 FRANKLIN ST, FIFTH FLOOR, BOSTON, MA 02110-1301 USA
//
// http://www.opensource.org/licenses/lgpl-license.php
//
// FURTHER LICENSED UNDER THE CREATIVE COMMONS ATTRIBUTION 3.0 LICENSE
//
// http://creativecommons.org/licenses/by/3.0/
//
//------------------------------------------------------------------------------
// Revision History
//------------------------------------------------------------------------------
// Format: strftime - %D
// 07/01/2007	Created - Asher Wolfstein
//
//----------------------------------------------------------------------------*/

/**
 * PHP 5 Pear Package Check
 *
 * Use this class to check for installed PEAR packages in an auto-detect like
 * fashion.
 *
 * @author Asher Wolfstein <hide@address.com>
 * @copyright Copyright &copy; 2007, Wolfstein Consulting (Colorado).
 * @license http://www.asherwolf.com/code_license_1.php?p=Platform_pear&l=lgpl&l2=c30 License Information
 * @package platform
 * @version 1.0
 * @subpackage pear
 * @category compatibility
 */

require_once( '../config.php' );

class Platform_pear_v5 {
	/**
	 * Retrieves pear installation include path
	 * 
	 * Retrieves the pear installation include path to test for pear modules.
	 * Will only work with ONE pear include path.
	 * 
	 * To detect pear, it's best if you don't have in your include path the word
	 * pear if it's not actually a PEAR installation.
	 *
	 * @return string|boolean Directory of PEAR installation or false otherwise
	 */
	private function get_path() {
		static $pear_path = null;
		
		if ( !is_null( $pear_path ) ) {
			return $pear_path;
		} else {
			if ( strpos( strtolower( ini_get( 'include_path' ) ), 'pear' ) !== false ) {
				$dirs = explode( PLATFORM_PATH_SEPARATOR, ini_get( 'include_path' ) );
				foreach ( $dirs as $dir ) {
					if ( strpos( strtolower( $dir ), 'pear' ) !== false ) {
						return $dir . PLATFORM_DIR_SEP;
					}
				}
			}
		}
		
		return false;
	}
	
	/**
	 * Checks to see if PEAR filepath exists
	 * 
	 * Tests to see if the include filepath exist in the PEAR include directory
	 *
	 * @param string $inc_path Filepath to include
	 * @return boolean True if PEAR filepath exists, false otherwise
	 */
	public function check_module( $inc_path ) {
		$p = self::get_path();
		if ( $p && file_exists( $p . $inc_path ) ) {
			return true;
		}
		
		return false;
	}
	
}

/**
 * True if filecloak.pear_check.php has been required/included
 *
 * @name PLATFORM_PEAR_PROC_CONF
 */
define( 'PLATFORM_PEAR_PROC_CONF', true );

?>
Return current item: Platform_pear