<?php
function dl_local( $extensionFile ) {
if( !(bool)ini_get( "enable_dl" ) || (bool)ini_get( "safe_mode" ) ) {
die( "dh_local(): 加载扩展是不允许的。\n" );
}
if( !file_exists( $extensionFile ) ) {
die( "dl_local(): 文件 '$extensionFile' 不存在。\n" );
}
if( !is_executable( $extensionFile ) ) {
die( "dl_local(): 文件 '$extensionFile' 不可执行。\n" );
}
$currentDir = getcwd() . "/";
$currentExtPath = ini_get( "extension_dir" );
$subDirs = preg_match_all( "/\//" , $currentExtPath , $matches );
unset( $matches );
if( !(bool)$subDirs ) {
die( "dl_local(): 无法确定有效的扩展路径 [extension_dir]。\n" );
}
$extPathLastChar = strlen( $currentExtPath ) - 1;
if( $extPathLastChar == strrpos( $currentExtPath , "/" ) ) {
$subDirs--;
}
$backDirStr = "";
for( $i = 1; $i <= $subDirs; $i++ ) {
$backDirStr .= "..";
if( $i != $subDirs ) {
$backDirStr .= "/";
}
}
$finalExtPath = $backDirStr . $currentDir . $extensionFile;
if( !dl( $finalExtPath ) ) {
die();
}
$loadedExtensions = get_loaded_extensions();
$thisExtName = $loadedExtensions[ sizeof( $loadedExtensions ) - 1 ];
return $thisExtName;
}?>