File: query_manager.inc

package info (click to toggle)
openldap2 2.0.23-6.3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,816 kB
  • ctags: 6,366
  • sloc: ansic: 86,391; sh: 9,816; makefile: 1,270; cpp: 1,107; sql: 838; php: 700; perl: 134; tcl: 40
file content (141 lines) | stat: -rw-r--r-- 4,595 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?
class query_manager {
	function get_action() {
		global $ldap_action;
		if (isset ($ldap_action)) {
			$ldap_action = urldecode ($ldap_action);
		}
		else {
			$ldap_action = "read";
		}
		return $ldap_action;
	}
	function get_base_dn() {
		global $base_dn;
		if (isset ($base_dn)) {
			$base_dn = urldecode ($base_dn);
		}
		else {
			$base_dn = "o=University of Michigan, c=US";
		//	$base_dn = "o=Balorda and Balorda, c=UK";
		}
		return $base_dn;
	}

	function get_host() {
		global $host;
		if (isset ($host)) {
			$host = urldecode($host);
		}
		else {
			$host = "localhost";
		}
		return $host;
	}

	function get_search_filter() {
		global $objectclass, $attrib, $precision, $search_string;
//		global $search_filter;
//		if (isset ($search_filter)) {
//			$search_filter = urldecode($search_filter);
//		}
//		else {
			$search_filter = "(objectclass=";
			switch(urldecode($objectclass)) {
				case "People": $search_filter .= "person)";break;
				case "Groups": $search_filter .= "organizationalUnit)"; break;
				case "Joinable Groups": $search_filter .= "joinableGroup)"; break;
				case "Organisations": $search_filter .= "organization)"; break;
				default: $search_filter .= "*)"; break;
			}
			switch(urldecode($attrib)) {
				case "Common Name": $search_filter .= "(cn"; break;
				case "Surname": $search_filter .= "(sn"; break;
				case "Business Phone": $search_filter .= "(telephone"; break;
				case "E-mail Address": $search_filter .= "(mail"; break;
				case "Title": $search_filter .= "(title"; break;
				case "Distinguished Name": $search_filter .="(dn"; break;
				case "Location": $search_filter .="(l"; break;
				default: break;
			}
			switch(urldecode($precision)) {
				case "exactly matches": $search_filter .= "=".$search_string.")"; break;
				case "starts with": $search_filter .= "=".$search_string."*)"; break;
				case "ends with": $search_filter .= "=*".$search_string.")"; break;
				case "approximates": $search_filter .= "~=".$search_string.")"; break;
				case "contains": $search_filter .= "=*".$search_string."*)"; break;
				default: break;
			}
			$search_filter = "(&".$search_filter.")";
		//	echo $search_filter;
//		}
		return $search_filter;
	}

	cfunction get_mode() {
		global $mode;
		if (isset ($mode)) {
			$mode = urldecode($mode);
		}
		else {
			$mode = "tree";
		}
		return $mode;
	}

	function display_form() {
		global $lm, $FILE;
?>		<form method=get action=<? echo $FILE; ?>>
		<input type=text name=search_filter size=25 value="<? echo $lm->search_filter; ?>"><br>
		<input type=hidden name=ldap_action value=search>
		<input type=submit value="Search">
		<input type=reset value="Clear">
		</form>
<?
	}

	cfunction makeForm($s) {
		global $FILE;
		echo "<table border=0 cellspacing=2 cellpadding=2 bgcolor=gray>\n";
		for ($i=0; $i<count($s); $i++) {
		$parameter = $s[$i];
		echo "<form method=get action=".$FILE.">\n";
		echo "<tr>\n\t<td colspan=2 align=left bgcolor=lightgrey>\n";
		echo $parameter[0];
		echo "\t\t</td>\n\t</tr>";
		echo "<tr>\n\t<td align=left bgcolor=white>\n";
		echo "\t\t<input type=submit width=80 height=30 value=".$parameter[1].">\n";
		echo "\t\t</td>\n\t<td align=left bgcolor=lightyellow>\n";
		echo "\t\t<input type=text size=25 name=".$parameter[2].">\n";
		echo "\t\t</td>\n\t</tr>\n</form>\n";
		}
		echo "</table>\n";
	}

	cfunction display_console() {
		echo '<table width="100%" border=0 cellspacing=2 cellpadding=2 bgcolor=gray><tr>';
		echo '<td colspan=2 align=center valign=middle bgcolor=white><h2>LDAP Console</h2></td></tr><tr>';
		echo '<td align=center valign=middle>';
		$things = array(
			0 => array("Bind (authenticate) to the directory.", "bind", "who"),
			1 => array("Change the search base.", "cb", "where"),
			2 => array("Change information associated with an entry","change","entry"),
			3 => array("Create a new group entry","create","group"),
			4 => array("Edit a complete Directory entry","vedit","entry"),
			5 => array("Find an entry in the directory.","find","entry")
		);
		$this->makeForm($things);
		echo '</td><td align=center valign=middle>';
		$things = array(
			0 => array("Change the group base.","groupbase","where"),
			1 => array("Display detailed help for a function","help","command"),
			2 => array("Subscribe to a group.","join","group"),
			3 => array("List the groups owned by someone","list","who"),
			4 => array("List out the groups in which someone is a member.", "memberships", "who"),
			5 => array("Remove obsolete entries from a group.", "purge", "group")
		);
		$this->makeForm($things);
		echo '</td></tr></table>';
	}
}
?>