| [ PHPXref.com ] | [ Generated: Sun Jul 20 21:13:29 2008 ] | [ YALA 0.32 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 if (file_exists("config.inc.php")) require "config.inc.php"; 4 else die("Config file not found.. read INSTALL file for installation instructions"); 5 require "ldapfunc.inc.php"; 6 require "general.inc.php"; 7 8 /* {{{ createIconsHash() creates an associative array which maps entry 9 types to their matching icon filenames, 10 and another assoc. array containing the html string for image size 11 (i.e. WIDTH="11" HEIGHT="22") 12 */ 13 function createIconsHash($entry_types, &$icons, &$icons_size) { 14 15 foreach (array_keys($entry_types) as $key) { 16 $filename = IMAGES_PATH."/icons/".$key.".png"; 17 $open_filename = IMAGES_PATH."/icons/open_".$key.".png"; 18 if (file_exists($filename)) { 19 $icons[$key] = $key.".png"; 20 $size = getimagesize($filename); 21 if ($size) 22 $icons_size[$key] = $size[3]; 23 24 if (file_exists($open_filename)) { 25 $icons["open_".$key] = "open_".$key.".png"; 26 $size = getimagesize($open_filename); 27 if ($size) 28 $icons_size["open_".$key] = $size[3]; 29 } 30 } 31 } 32 33 } /* }}} */ 34 35 /* {{{ showContents() 36 */ 37 function showContents($ldap_func, $base_dn) { 38 global $expand, $collapse; 39 40 # Associative arrays mapping group names to icon files / sizes in html 41 global $icons, $icons_size; 42 global $icons_size; 43 44 $sr = @ldap_list($ldap_func->ldap_conn, $base_dn, "(objectClass=*)", array("dn", "objectclass")); 45 if (!$sr) { 46 exitOnError(ERROR_CANT_READ_TREE, $base_dn); 47 } 48 49 $info = ldap_get_entries($ldap_func->ldap_conn, $sr); 50 if (!$info["count"]) return; 51 52 # First let's sort the list of DNs 53 for ($i = 0; $i < $info["count"]; $i++) { 54 $DNs[$i] = $info[$i]["dn"]; 55 56 for ($j = 0; $j < $info[$i]["objectclass"]["count"]; $j++) 57 $objectclasses[$DNs[$i]][$j] = $info[$i]["objectclass"][$j]; 58 } 59 sort($DNs, SORT_STRING); 60 61 echo "<TABLE CLASS=\"dense\">"; 62 63 # Get size of icon1 (plus/minus icon) 64 # We assume they're all in the same size to make code nicer. 65 $size = getimagesize(IMAGES_PATH."/minus.png"); 66 if ($size) 67 $icon1_size = $size[3]; 68 else 69 $icon1_size = ""; 70 71 for ($i = 0; $i < count($DNs); $i++) { 72 $dn = $DNs[$i]; 73 74 # Find out what the objectclass group is 75 $group = getEntryType($objectclasses[$dn]); 76 77 if (ereg("^([^\,]+)", $dn, $regs)) 78 $rdn = $regs[1]; 79 else 80 die("Invalid dn $dn!"); 81 82 # If this is the currently-changed-status (active) entry 83 if ($dn == $collapse || $dn == $expand) { 84 $anchor = "<A NAME=\"activeentry\"></A>"; 85 } 86 else { 87 $anchor = ""; 88 } 89 90 # Set the group's icon 91 if (array_key_exists($group, $icons)) { 92 $icon2 = $icons[$group]; 93 $icon2_size = $icons_size[$group]; 94 } 95 else { 96 $icon2 = DEFAULT_ICON; 97 $icon2_size = ""; 98 } 99 100 if (array_key_exists("expanded", $_SESSION) && array_key_exists($dn, $_SESSION["expanded"]) && $_SESSION["expanded"][$dn] == TRUE) { 101 $argument = "collapse=".urlencode($dn); 102 if ($i == count($DNs)) 103 $last = "last"; 104 else 105 $last = ""; 106 $icon1 = $last."minus.png"; 107 $icon1_alt = " - "; 108 109 # If the 'open' group icon exists, use it instead of 110 # what is already set 111 if (array_key_exists("open_".$group, $icons)) { 112 $icon2 = $icons["open_".$group]; 113 $icon2_size = $icons_size["open_".$group]; 114 } 115 116 $new_link = "<FONT SIZE=\"-2\">[ <A HREF=\"".MAINFILE."?do=choose_entrytype&parent=".urlencode($dn)."\" TARGET=\"right\"><ACRONYM TITLE=\"Create a new entry under this entry\">new</ACRONYM></A> ]</FONT>"; 117 } 118 else { 119 $argument = "expand=".urlencode($dn); 120 if ($i == count($DNs) - 1) 121 $last = "last"; 122 else 123 $last = ""; 124 $icon1 = $last."plus.png"; 125 $icon1_alt = " + "; 126 127 $new_link = ""; 128 } 129 130 131 if (ENABLE_JAVASCRIPT) { 132 $cooljs_href = "onMouseOver=\"javascript:window.status='".$dn."'; return true;\" onMouseOut=\"javascript:window.status=''; return true;\""; 133 } 134 echo "<TR VALIGN=\"middle\"><TD CLASS=\"dense\">".$anchor."<A HREF=\"".TREEFILE."?".$argument."\"><IMG SRC=\"".IMAGES_URLPATH."/".$icon1."\" ".$icon1_size." ALT=\"".$icon1_alt."\" BORDER=\"0\"></A></TD><TD CLASS=\"dense\"><TABLE CLASS=\"dense\" CELLSPACING=0 CELLPADDING=0><TR><TD CLASS=\"dense\"><IMG SRC=\"".IMAGES_URLPATH."/icons/".$icon2."\" ".$icon2_size." ALT=\"\" BORDER=\"0\"></TD><TD CLASS=\"dense\" NOWRAP><FONT SIZE=\"-1\"><A HREF=\"".MAINFILE."?do=view_entry&entry=".urlencode($dn)."\" TARGET=\"right\" ".$cooljs_href.">".$rdn."</A></FONT> ".$new_link."</TD></TR></TABLE></TD></TR>\n"; 135 136 if (array_key_exists("expanded", $_SESSION) && array_key_exists($dn, $_SESSION["expanded"]) && $_SESSION["expanded"][$dn] == TRUE) { 137 echo "<TR><TD ALIGN=\"center\"></TD><TD>"; 138 showContents($ldap_func, $dn); 139 echo "</TD></TR>"; 140 } 141 } 142 echo "</TABLE>"; 143 } /* }}} */ 144 145 session_start(); 146 147 # No ldap_server variable prolly means we're not connected yet 148 if (!array_key_exists("ldap_server", $_SESSION)) die("Not connected!"); 149 150 $ldap_func = new LDAPFunc($_SESSION["ldap_server"], $_SESSION["ldap_port"], $_SESSION["ldap_tls"]) or die("Cannot Connect!"); 151 $ldap_func->bind($_SESSION["ldap_binddn"], $_SESSION["ldap_bindpw"]) or die("Can't bind"); 152 153 if (array_key_exists("expand", $_GET)) 154 $expand = $_GET["expand"]; 155 else 156 $expand = NULL; 157 158 if (array_key_exists("collapse", $_GET)) 159 $collapse = $_GET["collapse"]; 160 else 161 $collapse = NULL; 162 163 if ($expand) $_SESSION["expanded"][$expand] = TRUE; 164 if ($collapse) unset($_SESSION["expanded"][$collapse]); 165 166 require INCLUDE_PATH."/tree_header.inc"; 167 168 require INCLUDE_PATH."/toolbar.inc"; 169 170 $icons = array(); 171 $icons_size = array(); 172 if (isset($entry_types) && is_array($entry_types)) 173 createIconsHash($entry_types, $icons, $icons_size); 174 175 176 showContents($ldap_func, $_SESSION["ldap_basedn"]); 177 178 require INCLUDE_PATH."/footer.inc"; 179 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |