You are here

function ldaphelp_parsePHPModules in LDAP integration 6

parse php modules from phpinfo

1 call to ldaphelp_parsePHPModules()
ldaphelp_status in ldaphelp/ldaphelp_status.inc

File

ldaphelp/ldaphelp_status.inc, line 467
status file for ldaphelp module

Code

function ldaphelp_parsePHPModules() {
  ob_start();
  phpinfo();
  $s = ob_get_contents();
  ob_end_clean();
  $s = strip_tags($s, '<h2><th><td>');
  $s = preg_replace('/<th[^>]*>([^<]+)<\\/th>/', "<info>\\1</info>", $s);
  $s = preg_replace('/<td[^>]*>([^<]+)<\\/td>/', "<info>\\1</info>", $s);
  $vtmp = preg_split('/(<h2>[^<]+<\\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE);
  $vmodules = array();
  for ($i = 1; $i < count($vtmp); $i++) {
    if (preg_match('/<h2>([^<]+)<\\/h2>/', $vtmp[$i], $vmat)) {
      $vname = trim($vmat[1]);
      $vtmp2 = explode("\n", $vtmp[$i + 1]);
      foreach ($vtmp2 as $vone) {
        $vpat = '<info>([^<]+)<\\/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;
}