You are here

function ldap_help_parsePHPModules in Lightweight Directory Access Protocol (LDAP) 7

Same name in this branch
  1. 7 ldap_help/ldap_help.status.inc \ldap_help_parsePHPModules()
  2. 7 ldap_help/ldap_test_script/functions.inc \ldap_help_parsePHPModules()
Same name and namespace in other branches
  1. 8.2 ldap_help/ldap_help.status.inc \ldap_help_parsePHPModules()
  2. 8.2 ldap_help/ldap_test_script/functions.inc \ldap_help_parsePHPModules()
  3. 7.2 ldap_help/ldap_help.status.inc \ldap_help_parsePHPModules()
  4. 7.2 ldap_help/ldap_test_script/functions.inc \ldap_help_parsePHPModules()

parse php modules from phpinfo

2 calls to ldap_help_parsePHPModules()
ldap_help_status in ldap_help/ldap_help.status.inc
@file status file for ldaphelp module
test.php in ldap_help/ldap_test_script/test.php

File

ldap_help/ldap_help.status.inc, line 209
status file for ldaphelp module

Code

function ldap_help_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;
}