This function parses the phpinfo output to get details about a PHP module.
$s = strip_tags($s,’
‘);
$s = preg_replace(‘/ ]*>([^<]+)<\/th>/’,”\\1 “,$s);
$s = preg_replace(‘/ ]*>([^<]+)<\/td>/’,”\\1 “,$s);
$vTmp = preg_split(‘/(
[^<]+<\/h2>)/’,$s,-1,PREG_SPLIT_DELIM_CAPTURE);
$vModules = array();
for ($i=1;$i([^<]+)<\/h2>/’,$vTmp[$i],$vMat)) {
$vName = trim($vMat[1]);
$vTmp2 = explode(“\n”,$vTmp[$i+1]);
foreach ($vTmp2 AS $vOne) {
$vPat = ‘([^<]+)<\/info>‘;
$vPat3 = “/$vPat\s*$vPat\s*$vPat/”;
$vPat2 = “/$vPat\s*$vPat/”;
if (preg_match($vPat3,$vOne,$vMat)) { // 3cols
$vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));
} elseif (preg_match($vPat2,$vOne,$vMat)) { // 2cols
$vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
}
}
}
}
return $vModules;
}
/** get a module setting */
function getModuleSetting($pModuleName,$pSetting) {
$vModules = $this->parsePHPModules();
return $vModules[$pModuleName][$pSetting];
}
// Sample Usage
getModuleSetting(‘gd’,’GD Version’); // returns “bundled (2.0.28 compatible)”
Sample Output
[gd] => Array
(
[GD Support] => enabled
[GD Version] => bundled (2.0.28 compatible)
[FreeType Support] => enabled
[FreeType Linkage] => with freetype
[FreeType Version] => 2.1.9
[T1Lib Support] => enabled
[GIF Read Support] => enabled
[GIF Create Support] => enabled
[JPG Support] => enabled
[PNG Support] => enabled
[WBMP Support] => enabled
[XBM Support] => enabled
)
[date] => Array (
[date/time support] => enabled
[Timezone Database Version] => 2005.14
[Timezone Database] => internal
[Default timezone] => America/Los_Angeles
[Directive] => Array (
[0] => Local Value
[1] => Master Value
)
[date.timezone] => Array (
[0] => no value
[1] => no value
)
)
by
Tags:
Comments
$s = preg_replace(‘/
$s = preg_replace(‘/
$vTmp = preg_split(‘/(
[^<]+<\/h2>)/’,$s,-1,PREG_SPLIT_DELIM_CAPTURE);
$vModules = array();
for ($i=1;$i([^<]+)<\/h2>/’,$vTmp[$i],$vMat)) {
$vName = trim($vMat[1]);
$vTmp2 = explode(“\n”,$vTmp[$i+1]);
foreach ($vTmp2 AS $vOne) {
$vPat = ‘([^<]+)<\/info>‘;
$vPat3 = “/$vPat\s*$vPat\s*$vPat/”;
$vPat2 = “/$vPat\s*$vPat/”;
if (preg_match($vPat3,$vOne,$vMat)) { // 3cols
$vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));
} elseif (preg_match($vPat2,$vOne,$vMat)) { // 2cols
$vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
}
}
}
}
return $vModules;
}
/** get a module setting */
function getModuleSetting($pModuleName,$pSetting) {
$vModules = $this->parsePHPModules();
return $vModules[$pModuleName][$pSetting];
}
// Sample Usage
getModuleSetting(‘gd’,’GD Version’); // returns “bundled (2.0.28 compatible)”
Sample Output
[gd] => Array
(
[GD Support] => enabled
[GD Version] => bundled (2.0.28 compatible)
[FreeType Support] => enabled
[FreeType Linkage] => with freetype
[FreeType Version] => 2.1.9
[T1Lib Support] => enabled
[GIF Read Support] => enabled
[GIF Create Support] => enabled
[JPG Support] => enabled
[PNG Support] => enabled
[WBMP Support] => enabled
[XBM Support] => enabled
)
[date] => Array (
[date/time support] => enabled
[Timezone Database Version] => 2005.14
[Timezone Database] => internal
[Default timezone] => America/Los_Angeles
[Directive] => Array (
[0] => Local Value
[1] => Master Value
)
[date.timezone] => Array (
[0] => no value
[1] => no value
)
)
by
Tags:
Comments
$vName = trim($vMat[1]);
$vTmp2 = explode(“\n”,$vTmp[$i+1]);
foreach ($vTmp2 AS $vOne) {
$vPat = ‘
$vPat3 = “/$vPat\s*$vPat\s*$vPat/”;
$vPat2 = “/$vPat\s*$vPat/”;
if (preg_match($vPat3,$vOne,$vMat)) { // 3cols
$vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));
} elseif (preg_match($vPat2,$vOne,$vMat)) { // 2cols
$vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
}
}
}
}
return $vModules;
}
/** get a module setting */
function getModuleSetting($pModuleName,$pSetting) {
$vModules = $this->parsePHPModules();
return $vModules[$pModuleName][$pSetting];
}
// Sample Usage
getModuleSetting(‘gd’,’GD Version’); // returns “bundled (2.0.28 compatible)”
Sample Output
[gd] => Array ( [GD Support] => enabled [GD Version] => bundled (2.0.28 compatible) [FreeType Support] => enabled [FreeType Linkage] => with freetype [FreeType Version] => 2.1.9 [T1Lib Support] => enabled [GIF Read Support] => enabled [GIF Create Support] => enabled [JPG Support] => enabled [PNG Support] => enabled [WBMP Support] => enabled [XBM Support] => enabled ) [date] => Array ( [date/time support] => enabled [Timezone Database Version] => 2005.14 [Timezone Database] => internal [Default timezone] => America/Los_Angeles [Directive] => Array ( [0] => Local Value [1] => Master Value ) [date.timezone] => Array ( [0] => no value [1] => no value ) )
by
Tags:
Leave a Reply