]> git.sur5r.net Git - openldap/blob - contrib/php3-tool/include/query_manager.inc
Update contrib software.
[openldap] / contrib / php3-tool / include / query_manager.inc
1 <?
2 class query_manager {
3         function get_action() {
4                 global $ldap_action;
5                 if (isset ($ldap_action)) {
6                         $ldap_action = urldecode ($ldap_action);
7                 }
8                 else {
9                         $ldap_action = "read";
10                 }
11                 return $ldap_action;
12         }
13         function get_base_dn() {
14                 global $base_dn;
15                 if (isset ($base_dn)) {
16                         $base_dn = urldecode ($base_dn);
17                 }
18                 else {
19                         $base_dn = "o=University of Michigan, c=US";
20                 //      $base_dn = "o=Balorda and Balorda, c=UK";
21                 }
22                 return $base_dn;
23         }
24
25         function get_host() {
26                 global $host;
27                 if (isset ($host)) {
28                         $host = urldecode($host);
29                 }
30                 else {
31                         $host = "localhost";
32                 }
33                 return $host;
34         }
35
36         function get_search_filter() {
37                 global $objectclass, $attrib, $precision, $search_string;
38 //              global $search_filter;
39 //              if (isset ($search_filter)) {
40 //                      $search_filter = urldecode($search_filter);
41 //              }
42 //              else {
43                         $search_filter = "(objectclass=";
44                         switch(urldecode($objectclass)) {
45                                 case "People": $search_filter .= "person)";break;
46                                 case "Groups": $search_filter .= "organizationalUnit)"; break;
47                                 case "Joinable Groups": $search_filter .= "joinableGroup)"; break;
48                                 case "Organisations": $search_filter .= "organization)"; break;
49                                 default: $search_filter .= "*)"; break;
50                         }
51                         switch(urldecode($attrib)) {
52                                 case "Common Name": $search_filter .= "(cn"; break;
53                                 case "Surname": $search_filter .= "(sn"; break;
54                                 case "Business Phone": $search_filter .= "(telephone"; break;
55                                 case "E-mail Address": $search_filter .= "(mail"; break;
56                                 case "Title": $search_filter .= "(title"; break;
57                                 case "Distinguished Name": $search_filter .="(dn"; break;
58                                 case "Location": $search_filter .="(l"; break;
59                                 default: break;
60                         }
61                         switch(urldecode($precision)) {
62                                 case "exactly matches": $search_filter .= "=".$search_string.")"; break;
63                                 case "starts with": $search_filter .= "=".$search_string."*)"; break;
64                                 case "ends with": $search_filter .= "=*".$search_string.")"; break;
65                                 case "approximates": $search_filter .= "~=".$search_string.")"; break;
66                                 case "contains": $search_filter .= "=*".$search_string."*)"; break;
67                                 default: break;
68                         }
69                         $search_filter = "(&".$search_filter.")";
70                 //      echo $search_filter;
71 //              }
72                 return $search_filter;
73         }
74
75         cfunction get_mode() {
76                 global $mode;
77                 if (isset ($mode)) {
78                         $mode = urldecode($mode);
79                 }
80                 else {
81                         $mode = "tree";
82                 }
83                 return $mode;
84         }
85
86         function display_form() {
87                 global $lm, $FILE;
88 ?>              <form method=get action=<? echo $FILE; ?>>
89                 <input type=text name=search_filter size=25 value="<? echo $lm->search_filter; ?>"><br>
90                 <input type=hidden name=ldap_action value=search>
91                 <input type=submit value="Search">
92                 <input type=reset value="Clear">
93                 </form>
94 <?
95         }
96
97         cfunction makeForm($s) {
98                 global $FILE;
99                 echo "<table border=0 cellspacing=2 cellpadding=2 bgcolor=gray>\n";
100                 for ($i=0; $i<count($s); $i++) {
101                 $parameter = $s[$i];
102                 echo "<form method=get action=".$FILE.">\n";
103                 echo "<tr>\n\t<td colspan=2 align=left bgcolor=lightgrey>\n";
104                 echo $parameter[0];
105                 echo "\t\t</td>\n\t</tr>";
106                 echo "<tr>\n\t<td align=left bgcolor=white>\n";
107                 echo "\t\t<input type=submit width=80 height=30 value=".$parameter[1].">\n";
108                 echo "\t\t</td>\n\t<td align=left bgcolor=lightyellow>\n";
109                 echo "\t\t<input type=text size=25 name=".$parameter[2].">\n";
110                 echo "\t\t</td>\n\t</tr>\n</form>\n";
111                 }
112                 echo "</table>\n";
113         }
114
115         cfunction display_console() {
116                 echo '<table width="100%" border=0 cellspacing=2 cellpadding=2 bgcolor=gray><tr>';
117                 echo '<td colspan=2 align=center valign=middle bgcolor=white><h2>LDAP Console</h2></td></tr><tr>';
118                 echo '<td align=center valign=middle>';
119                 $things = array(
120                         0 => array("Bind (authenticate) to the directory.", "bind", "who"),
121                         1 => array("Change the search base.", "cb", "where"),
122                         2 => array("Change information associated with an entry","change","entry"),
123                         3 => array("Create a new group entry","create","group"),
124                         4 => array("Edit a complete Directory entry","vedit","entry"),
125                         5 => array("Find an entry in the directory.","find","entry")
126                 );
127                 $this->makeForm($things);
128                 echo '</td><td align=center valign=middle>';
129                 $things = array(
130                         0 => array("Change the group base.","groupbase","where"),
131                         1 => array("Display detailed help for a function","help","command"),
132                         2 => array("Subscribe to a group.","join","group"),
133                         3 => array("List the groups owned by someone","list","who"),
134                         4 => array("List out the groups in which someone is a member.", "memberships", "who"),
135                         5 => array("Remove obsolete entries from a group.", "purge", "group")
136                 );
137                 $this->makeForm($things);
138                 echo '</td></tr></table>';
139         }
140 }
141 ?>