/usr/share/php/ezc/Base/features.php is in php-zeta-base 1.9-3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | <?php
/**
* File containing the ezcBaseFeatures class.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @package Base
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
/**
* Provides methods needed to check for features.
*
* Example:
* <code>
* <?php
* echo "supports uid: " . ezcBaseFeatures::supportsUserId() . "\n";
* echo "supports symlink: " . ezcBaseFeatures::supportsSymLink() . "\n";
* echo "supports hardlink: " . ezcBaseFeatures::supportsLink() . "\n";
* echo "has imagemagick identify: " . ezcBaseFeatures::hasImageIdentify() . "\n";
* echo " identify path: " . ezcBaseFeatures::getImageIdentifyExecutable() . "\n";
* echo "has imagemagick convert: " . ezcBaseFeatures::hasImageConvert() . "\n";
* echo " convert path: " . ezcBaseFeatures::getImageConvertExecutable() . "\n";
* echo "has gzip extension: " . ezcBaseFeatures::hasExtensionSupport( 'zlib' ) . "\n";
* echo "has pdo_mysql 1.0.2: " . ezcBaseFeatures::hasExtensionSupport( 'pdo_mysql', '1.0.2' ) . "\n"
* ?>
* </code>
*
* @package Base
* @version //autogentag//
*/
class ezcBaseFeatures
{
/**
* Used to store the path of the ImageMagick convert utility.
*
* It is initialized in the {@link getImageConvertExecutable()} function.
*
* @var string
*/
private static $imageConvert = null;
/**
* Used to store the path of the ImageMagick identify utility.
*
* It is initialized in the {@link getImageIdentifyExecutable()} function.
*
* @var string
*/
private static $imageIdentify = null;
/**
* Used to store the operating system.
*
* It is initialized in the {@link os()} function.
*
* @var string
*/
private static $os = null;
/**
* Determines if hardlinks are supported.
*
* @return bool
*/
public static function supportsLink()
{
return function_exists( 'link' );
}
/**
* Determines if symlinks are supported.
*
* @return bool
*/
public static function supportsSymLink()
{
return function_exists( 'symlink' );
}
/**
* Determines if posix uids are supported.
*
* @return bool
*/
public static function supportsUserId()
{
return function_exists( 'posix_getpwuid' );
}
/**
* Determines if the ImageMagick convert utility is installed.
*
* @return bool
*/
public static function hasImageConvert()
{
return !is_null( self::getImageConvertExecutable() );
}
/**
* Returns the path to the ImageMagick convert utility.
*
* On Linux, Unix,... it will return something like: /usr/bin/convert
* On Windows it will return something like: C:\Windows\System32\convert.exe
*
* @return string
*/
public static function getImageConvertExecutable()
{
if ( !is_null( self::$imageConvert ) )
{
return self::$imageConvert;
}
return ( self::$imageConvert = self::findExecutableInPath( 'convert' ) );
}
/**
* Determines if the ImageMagick identify utility is installed.
*
* @return bool
*/
public static function hasImageIdentify()
{
return !is_null( self::getImageIdentifyExecutable() );
}
/**
* Returns the path to the ImageMagick identify utility.
*
* On Linux, Unix,... it will return something like: /usr/bin/identify
* On Windows it will return something like: C:\Windows\System32\identify.exe
*
* @return string
*/
public static function getImageIdentifyExecutable()
{
if ( !is_null( self::$imageIdentify ) )
{
return self::$imageIdentify;
}
return ( self::$imageIdentify = self::findExecutableInPath( 'identify' ) );
}
/**
* Determines if the specified extension is loaded.
*
* If $version is specified, the specified extension will be tested also
* against the version of the loaded extension.
*
* Examples:
* <code>
* hasExtensionSupport( 'gzip' );
* </code>
* will return true if gzip extension is loaded.
*
* <code>
* hasExtensionSupport( 'pdo_mysql', '1.0.2' );
* </code>
* will return true if pdo_mysql extension is loaded and its version is at least 1.0.2.
*
* @param string $extension
* @param string $version
* @return bool
*/
public static function hasExtensionSupport( $extension, $version = null )
{
if ( is_null( $version ) )
{
return extension_loaded( $extension );
}
return extension_loaded( $extension ) && version_compare( phpversion( $extension ), $version, ">=" ) ;
}
/**
* Determines if the specified function is available.
*
* Examples:
* <code>
* ezcBaseFeatures::hasFunction( 'imagepstext' );
* </code>
* will return true if support for Type 1 fonts is available with your GD
* extension.
*
* @param string $functionName
* @return bool
*/
public static function hasFunction( $functionName )
{
return function_exists( $functionName );
}
/**
* Returns if a given class exists.
* Checks for a given class name and returns if this class exists or not.
* Catches the ezcBaseAutoloadException and returns false, if it was thrown.
*
* @param string $className The class to check for.
* @param bool $autoload True to use __autoload(), otherwise false.
* @return bool True if the class exists. Otherwise false.
*/
public static function classExists( $className, $autoload = true )
{
try
{
if ( class_exists( $className, $autoload ) )
{
return true;
}
return false;
}
catch ( ezcBaseAutoloadException $e )
{
return false;
}
}
/**
* Returns the operating system on which PHP is running.
*
* This method returns a sanitized form of the OS name, example
* return values are "Windows", "Mac", "Linux" and "FreeBSD". In
* all other cases it returns the value of the internal PHP constant
* PHP_OS.
*
* @return string
*/
public static function os()
{
if ( is_null( self::$os ) )
{
$uname = php_uname( 's' );
if ( substr( $uname, 0, 7 ) == 'Windows' )
{
self::$os = 'Windows';
}
elseif ( substr( $uname, 0, 3 ) == 'Mac' )
{
self::$os = 'Mac';
}
elseif ( strtolower( $uname ) == 'linux' )
{
self::$os = 'Linux';
}
elseif ( strtolower( substr( $uname, 0, 7 ) ) == 'freebsd' )
{
self::$os = 'FreeBSD';
}
else
{
self::$os = PHP_OS;
}
}
return self::$os;
}
/**
* Returns the path of the specified executable, if it can be found in the system's path.
*
* It scans the PATH enviroment variable based on the OS to find the
* $fileName. For Windows, the path is with \, not /. If $fileName is not
* found, it returns null.
*
* @todo consider using getenv( 'PATH' ) instead of $_ENV['PATH']
* (but that won't work under IIS)
*
* @param string $fileName
* @return string
*/
public static function findExecutableInPath( $fileName )
{
if ( array_key_exists( 'PATH', $_ENV ) )
{
$envPath = trim( $_ENV['PATH'] );
}
else if ( ( $envPath = getenv( 'PATH' ) ) !== false )
{
$envPath = trim( $envPath );
}
if ( is_string( $envPath ) && strlen( trim( $envPath ) ) == 0 )
{
$envPath = false;
}
switch ( self::os() )
{
case 'Unix':
case 'FreeBSD':
case 'Mac':
case 'MacOS':
case 'Darwin':
case 'Linux':
case 'SunOS':
if ( $envPath )
{
$dirs = explode( ':', $envPath );
foreach ( $dirs as $dir )
{
// The @-operator is used here mainly to avoid
// open_basedir warnings. If open_basedir (or any other
// circumstance) prevents the desired file from being
// accessed, it is fine for file_exists() to return
// false, since it is useless for use then, anyway.
if ( file_exists( "{$dir}/{$fileName}" ) )
{
return "{$dir}/{$fileName}";
}
}
}
// The @-operator is used here mainly to avoid open_basedir
// warnings. If open_basedir (or any other circumstance)
// prevents the desired file from being accessed, it is fine
// for file_exists() to return false, since it is useless for
// use then, anyway.
elseif ( @file_exists( "./{$fileName}" ) )
{
return $fileName;
}
break;
case 'Windows':
if ( $envPath )
{
$dirs = explode( ';', $envPath );
foreach ( $dirs as $dir )
{
// The @-operator is used here mainly to avoid
// open_basedir warnings. If open_basedir (or any other
// circumstance) prevents the desired file from being
// accessed, it is fine for file_exists() to return
// false, since it is useless for use then, anyway.
if ( @file_exists( "{$dir}\\{$fileName}.exe" ) )
{
return "{$dir}\\{$fileName}.exe";
}
}
}
// The @-operator is used here mainly to avoid open_basedir
// warnings. If open_basedir (or any other circumstance)
// prevents the desired file from being accessed, it is fine
// for file_exists() to return false, since it is useless for
// use then, anyway.
elseif ( @file_exists( "{$fileName}.exe" ) )
{
return "{$fileName}.exe";
}
break;
}
return null;
}
/**
* Reset the cached information.
*
* @return void
* @access private
* @ignore
*/
public static function reset()
{
self::$imageIdentify = null;
self::$imageConvert = null;
self::$os = null;
}
}
?>
|