function get_schema_attributes($server_id, $lower_case_keys = false) { // Cache gets filled in later (bottom). each subsequent call uses // the cache which has the attributes already fetched and parsed static $cache = null; if (isset($cache[$server_id])) { //echo "Using attr cache<br />"; return $cache[$server_id]; } $ds = pla_ldap_connect($server_id); if (!$ds) { return false; } // get all the attributeTypes $result = @ldap_read($ds, 'cn=subschema', '(objectClass=*)', array('attributeTypes'), 0, 200, 0, LDAP_DEREF_ALWAYS); if (!$result) { $result = @ldap_read($ds, 'cn=schema', '(objectClass=*)', array('attributeTypes'), 0, 200, 0, LDAP_DEREF_ALWAYS); } if ($result) { $raw_attrs = ldap_get_entries($ds, $result); } else { $raw_attrs = array(); } $syntaxes = get_schema_syntaxes($server_id); // build the array of attribueTypes $attrs = array(); for ($i = 0; $i < $raw_attrs[0]['attributetypes']['count']; $i++) { $attr_string = $raw_attrs[0]['attributetypes'][$i]; if ($attr_string == null || 0 == strlen($attr_string)) { continue; } $attr = new AttributeType($attr_string); if (isset($syntaxes[$attr->getSyntaxOID()])) { $attr->setType($syntaxes[$attr->getSyntaxOID()]['description']); } $name = $attr->getName(); $key = strtolower($name); $attrs[$key] = $attr; } add_aliases_to_attrs($attrs); add_sup_to_attrs($attrs); ksort($attrs); // cache the schema to prevent multiple schema fetches from LDAP server $cache[$server_id] = $attrs; return $attrs; }
</center> <br /> <?php flush(); ?> <?php if ($view == 'syntaxes') { $highlight_oid = isset($_GET['highlight_oid']) ? $_GET['highlight_oid'] : false; echo "<center>" . $lang['the_following_syntaxes'] . "</center><br />\n\n"; echo "\n\n<table class=\"schema_attr\" width=\"100%\">\n"; echo "<tr><th>" . $lang['syntax_oid'] . "</th><th>" . $lang['desc'] . "</th></tr>\n"; flush(); $counter = 1; $schema_syntaxes = get_schema_syntaxes($server_id); if (!$schema_syntaxes) { pla_error($schema_error_str); } foreach ($schema_syntaxes as $oid => $desc) { $counter++; $oid = htmlspecialchars($oid); $desc = htmlspecialchars($desc['description']); if ($highlight_oid && $highlight_oid == $oid) { echo "<tr class=\"highlight\">"; } else { echo "<tr class=\"" . ($counter % 2 == 0 ? 'even' : 'odd') . "\">"; } echo "<td><a name=\"{$oid}\">{$oid}</a></td><td>{$desc}</td></tr>\n\n"; } echo "</table>\n";