replaced LDAP filtering by local search; renamed some variables
This commit is contained in:
parent
f6d7db5f07
commit
16d28bd336
|
@ -45,13 +45,15 @@ session_save_path("../../sess");
|
||||||
|
|
||||||
setlanguage();
|
setlanguage();
|
||||||
|
|
||||||
|
$scope = 'domain';
|
||||||
|
|
||||||
// get sorting column when register_globals is off
|
// get sorting column when register_globals is off
|
||||||
$sort = $_GET['sort'];
|
$sort = $_GET['sort'];
|
||||||
|
|
||||||
// copy HTTP-GET variables to HTTP-POST
|
// copy HTTP-GET variables to HTTP-POST
|
||||||
$_POST = $_POST + $_GET;
|
$_POST = $_POST + $_GET;
|
||||||
|
|
||||||
$dom_info = $_SESSION['dom_info'];
|
$info = $_SESSION[$scope . 'info'];
|
||||||
$dom_units = $_SESSION['dom_units'];
|
$dom_units = $_SESSION['dom_units'];
|
||||||
|
|
||||||
// check if button was pressed and if we have to add/delete a domain
|
// check if button was pressed and if we have to add/delete a domain
|
||||||
|
@ -104,8 +106,11 @@ if ($_POST['dom_suffix']) $dom_suffix = $_POST['dom_suffix']; // new suffix sel
|
||||||
elseif ($_SESSION['dom_suffix']) $dom_suffix = $_SESSION['dom_suffix']; // old suffix from session
|
elseif ($_SESSION['dom_suffix']) $dom_suffix = $_SESSION['dom_suffix']; // old suffix from session
|
||||||
else $dom_suffix = $_SESSION["config"]->get_DomainSuffix(); // default suffix
|
else $dom_suffix = $_SESSION["config"]->get_DomainSuffix(); // default suffix
|
||||||
|
|
||||||
// first time page is shown
|
$refresh = true;
|
||||||
if (! $_GET['norefresh']) {
|
if ($_GET['norefresh']) $refresh = false;
|
||||||
|
if ($_POST['refresh']) $refresh = true;
|
||||||
|
|
||||||
|
if ($refresh) {
|
||||||
// configure search filter
|
// configure search filter
|
||||||
$filter = "(objectClass=sambaDomain)";
|
$filter = "(objectClass=sambaDomain)";
|
||||||
$attrs = $attr_array;
|
$attrs = $attr_array;
|
||||||
|
@ -114,28 +119,28 @@ if (! $_GET['norefresh']) {
|
||||||
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
|
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
|
||||||
}
|
}
|
||||||
if ($sr) {
|
if ($sr) {
|
||||||
$dom_info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
|
$info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
|
||||||
ldap_free_result($sr);
|
ldap_free_result($sr);
|
||||||
if ($dom_info["count"] == 0) StatusMessage("WARN", "", _("No Samba Domains found!"));
|
if ($info["count"] == 0) StatusMessage("WARN", "", _("No Samba domains found!"));
|
||||||
// delete first array entry which is "count"
|
// delete first array entry which is "count"
|
||||||
unset($dom_info['count']);
|
unset($info['count']);
|
||||||
// sort rows by sort column ($sort)
|
// sort rows by sort column ($sort)
|
||||||
$dom_info = listSort($sort, $attr_array, $dom_info);
|
$info = listSort($sort, $attr_array, $info);
|
||||||
}
|
}
|
||||||
else StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No Samba Domains found!"));
|
else StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No Samba domains found!"));
|
||||||
}
|
}
|
||||||
// use search result from session
|
// use search result from session
|
||||||
else {
|
else {
|
||||||
if (sizeof($dom_info) == 0) StatusMessage("WARN", "", _("No Samba Domains found!"));
|
if (sizeof($info) == 0) StatusMessage("WARN", "", _("No Samba domains found!"));
|
||||||
// sort rows by sort column ($sort)
|
// sort rows by sort column ($sort)
|
||||||
if ($dom_info) $dom_info = listSort($sort, $attr_array, $dom_info);
|
if ($info) $info = listSort($sort, $attr_array, $info);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo ("<form action=\"listdomains.php\" method=\"post\">\n");
|
echo ("<form action=\"listdomains.php?norefresh=true\" method=\"post\">\n");
|
||||||
|
|
||||||
// draw navigation bar if domain accounts were found
|
// draw navigation bar if domain accounts were found
|
||||||
if (sizeof($dom_info) > 0) {
|
if (sizeof($info) > 0) {
|
||||||
listDrawNavigationBar(sizeof($dom_info), $max_page_entries, $page, $sort, '', "domain", _("%s Samba domain(s) found"));
|
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, '', "domain", _("%s Samba domain(s) found"));
|
||||||
echo ("<br>\n");
|
echo ("<br>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,25 +160,25 @@ echo "</tr>\n";
|
||||||
|
|
||||||
// calculate which rows to show
|
// calculate which rows to show
|
||||||
$table_begin = ($page - 1) * $max_page_entries;
|
$table_begin = ($page - 1) * $max_page_entries;
|
||||||
if (($page * $max_page_entries) > sizeof($dom_info)) $table_end = sizeof($dom_info);
|
if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info);
|
||||||
else $table_end = ($page * $max_page_entries);
|
else $table_end = ($page * $max_page_entries);
|
||||||
|
|
||||||
// print domain list
|
// print domain list
|
||||||
for ($i = $table_begin; $i < $table_end; $i++) {
|
for ($i = $table_begin; $i < $table_end; $i++) {
|
||||||
echo("<tr class=\"domainlist\" onMouseOver=\"domain_over(this, '" . $dom_info[$i]["dn"] . "')\"" .
|
echo("<tr class=\"domainlist\" onMouseOver=\"domain_over(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" onMouseOut=\"domain_out(this, '" . $dom_info[$i]["dn"] . "')\"" .
|
" onMouseOut=\"domain_out(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" onClick=\"domain_click(this, '" . $dom_info[$i]["dn"] . "')\"" .
|
" onClick=\"domain_click(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" onDblClick=\"parent.frames[1].location.href='../domain.php?action=edit&DN=" . $dom_info[$i]["dn"] . "'\">" .
|
" onDblClick=\"parent.frames[1].location.href='../domain.php?action=edit&DN=" . $info[$i]["dn"] . "'\">" .
|
||||||
" <td height=22 align=\"center\"><input onClick=\"domain_click(this, '" . $dom_info[$i]["dn"] . "')\" type=\"checkbox\" name=\"" . $dom_info[$i]["dn"] . "\"></td>" .
|
" <td height=22 align=\"center\"><input onClick=\"domain_click(this, '" . $info[$i]["dn"] . "')\" type=\"checkbox\" name=\"" . $info[$i]["dn"] . "\"></td>" .
|
||||||
" <td align='center'><a href=\"../domain.php?action=edit&DN='" . $dom_info[$i]["dn"] . "'\">" . _("Edit") . "</a></td>");
|
" <td align='center'><a href=\"../domain.php?action=edit&DN='" . $info[$i]["dn"] . "'\">" . _("Edit") . "</a></td>");
|
||||||
for ($k = 0; $k < sizeof($attr_array); $k++) {
|
for ($k = 0; $k < sizeof($attr_array); $k++) {
|
||||||
echo ("<td>");
|
echo ("<td>");
|
||||||
// print all attribute entries seperated by "; "
|
// print all attribute entries seperated by "; "
|
||||||
if (sizeof($dom_info[$i][strtolower($attr_array[$k])]) > 0) {
|
if (sizeof($info[$i][strtolower($attr_array[$k])]) > 0) {
|
||||||
// delete first array entry which is "count"
|
// delete first array entry which is "count"
|
||||||
if (is_array($dom_info[$i][strtolower($attr_array[$k])])) unset($dom_info[$i][strtolower($attr_array[$k])]['count']);
|
if (is_array($info[$i][strtolower($attr_array[$k])])) unset($info[$i][strtolower($attr_array[$k])]['count']);
|
||||||
if (is_array($dom_info[$i][strtolower($attr_array[$k])])) echo implode("; ", $dom_info[$i][strtolower($attr_array[$k])]);
|
if (is_array($info[$i][strtolower($attr_array[$k])])) echo implode("; ", $info[$i][strtolower($attr_array[$k])]);
|
||||||
else echo $dom_info[$i][strtolower($attr_array[$k])];
|
else echo $info[$i][strtolower($attr_array[$k])];
|
||||||
}
|
}
|
||||||
echo ("</td>");
|
echo ("</td>");
|
||||||
}
|
}
|
||||||
|
@ -184,8 +189,8 @@ echo ("</table>");
|
||||||
echo ("<br>");
|
echo ("<br>");
|
||||||
|
|
||||||
// draw navigation bar if domain accounts were found
|
// draw navigation bar if domain accounts were found
|
||||||
if (sizeof($dom_info) > 0) {
|
if (sizeof($info) > 0) {
|
||||||
listDrawNavigationBar(sizeof($dom_info), $max_page_entries, $page, $sort, '', "domain", _("%s Samba domain(s) found"));
|
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, '', "domain", _("%s Samba domain(s) found"));
|
||||||
echo ("<br>\n");
|
echo ("<br>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +216,7 @@ if (sizeof($dom_units) > 1) {
|
||||||
|
|
||||||
echo ("<p align=\"left\">\n");
|
echo ("<p align=\"left\">\n");
|
||||||
echo ("<input type=\"submit\" name=\"new_domain\" value=\"" . _("New Domain") . "\">\n");
|
echo ("<input type=\"submit\" name=\"new_domain\" value=\"" . _("New Domain") . "\">\n");
|
||||||
if (sizeof($dom_info) > 0) echo ("<input type=\"submit\" name=\"del_domain\" value=\"" . _("Delete Domain(s)") . "\">\n");
|
if (sizeof($info) > 0) echo ("<input type=\"submit\" name=\"del_domain\" value=\"" . _("Delete Domain(s)") . "\">\n");
|
||||||
echo ("</p>\n");
|
echo ("</p>\n");
|
||||||
|
|
||||||
echo ("</form>\n");
|
echo ("</form>\n");
|
||||||
|
@ -220,7 +225,7 @@ echo "</body></html>\n";
|
||||||
|
|
||||||
|
|
||||||
// save variables to session
|
// save variables to session
|
||||||
$_SESSION['dom_info'] = $dom_info;
|
$_SESSION[$scope . 'info'] = $info;
|
||||||
$_SESSION['dom_units'] = $dom_units;
|
$_SESSION['dom_units'] = $dom_units;
|
||||||
$_SESSION['dom_suffix'] = $dom_suffix;
|
$_SESSION['dom_suffix'] = $dom_suffix;
|
||||||
|
|
||||||
|
|
|
@ -49,13 +49,15 @@ session_save_path("../../sess");
|
||||||
|
|
||||||
setlanguage();
|
setlanguage();
|
||||||
|
|
||||||
|
$scope = 'group';
|
||||||
|
|
||||||
// get sorting column when register_globals is off
|
// get sorting column when register_globals is off
|
||||||
$sort = $_GET['sort'];
|
$sort = $_GET['sort'];
|
||||||
|
|
||||||
// copy HTTP-GET variables to HTTP-POST
|
// copy HTTP-GET variables to HTTP-POST
|
||||||
$_POST = $_POST + $_GET;
|
$_POST = $_POST + $_GET;
|
||||||
|
|
||||||
$grp_info = $_SESSION['grp_info'];
|
$info = $_SESSION[$scope . 'info'];
|
||||||
$grp_units = $_SESSION['grp_units'];
|
$grp_units = $_SESSION['grp_units'];
|
||||||
|
|
||||||
// check if button was pressed and if we have to add/delete a group
|
// check if button was pressed and if we have to add/delete a group
|
||||||
|
@ -95,9 +97,9 @@ if ($_POST['new_group'] || $_POST['del_group'] || $_POST['pdf_group'] || $_POST[
|
||||||
// PDF for all groups
|
// PDF for all groups
|
||||||
elseif ($_POST['pdf_all']){
|
elseif ($_POST['pdf_all']){
|
||||||
$list = array();
|
$list = array();
|
||||||
for ($i = 0; $i < sizeof($_SESSION['grp_info']); $i++) {
|
for ($i = 0; $i < sizeof($_SESSION[$scope . 'info']); $i++) {
|
||||||
$_SESSION["accountPDF-$i"] = new accountContainer("group", "accountPDF-$i");
|
$_SESSION["accountPDF-$i"] = new accountContainer("group", "accountPDF-$i");
|
||||||
$_SESSION["accountPDF-$i"]->load_account($_SESSION['grp_info'][$i]['dn']);
|
$_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$i]['dn']);
|
||||||
$list[$i] = $_SESSION["accountPDF-$i"];
|
$list[$i] = $_SESSION["accountPDF-$i"];
|
||||||
}
|
}
|
||||||
if (sizeof($list) > 0) {
|
if (sizeof($list) > 0) {
|
||||||
|
@ -152,58 +154,58 @@ if ($_POST['grp_suffix']) $grp_suffix = $_POST['grp_suffix']; // new suffix sel
|
||||||
elseif ($_SESSION['grp_suffix']) $grp_suffix = $_SESSION['grp_suffix']; // old suffix from session
|
elseif ($_SESSION['grp_suffix']) $grp_suffix = $_SESSION['grp_suffix']; // old suffix from session
|
||||||
else $grp_suffix = $_SESSION["config"]->get_GroupSuffix(); // default suffix
|
else $grp_suffix = $_SESSION["config"]->get_GroupSuffix(); // default suffix
|
||||||
|
|
||||||
// generate search filter for sort links
|
$refresh = true;
|
||||||
$searchFilter = "";
|
if ($_GET['norefresh']) $refresh = false;
|
||||||
for ($k = 0; $k < sizeof($desc_array); $k++) {
|
if ($_POST['refresh']) $refresh = true;
|
||||||
if (eregi("^([0-9a-z_\\*\\+\\-])+$", $_POST["filter" . strtolower($attr_array[$k])])) {
|
|
||||||
$searchFilter = $searchFilter . "&filter" . strtolower($attr_array[$k]) . "=".
|
|
||||||
$_POST["filter" . strtolower($attr_array[$k])];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $_GET['norefresh']) {
|
if ($refresh) {
|
||||||
// configure search filter
|
// configure search filter
|
||||||
$module_filter = get_ldap_filter("group"); // basic filter is provided by modules
|
$module_filter = get_ldap_filter("group"); // basic filter is provided by modules
|
||||||
$filter = "(&" . $module_filter;
|
$filter = "(&" . $module_filter . ")";
|
||||||
for ($k = 0; $k < sizeof($desc_array); $k++) {
|
|
||||||
if (eregi("^([0-9a-z_\\*\\+\\-])+$", $_POST["filter" . strtolower($attr_array[$k])]))
|
|
||||||
$filter = $filter . "(" . strtolower($attr_array[$k]) . "=" .
|
|
||||||
$_POST["filter" . strtolower($attr_array[$k])] . ")";
|
|
||||||
else
|
|
||||||
$_POST["filter" . strtolower($attr_array[$k])] = "";
|
|
||||||
}
|
|
||||||
$filter = $filter . ")";
|
|
||||||
$attrs = $attr_array;
|
$attrs = $attr_array;
|
||||||
$sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs);
|
$sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs);
|
||||||
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
|
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
|
||||||
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
|
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
|
||||||
}
|
}
|
||||||
if ($sr) {
|
if ($sr) {
|
||||||
$grp_info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
|
$info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
|
||||||
ldap_free_result($sr);
|
ldap_free_result($sr);
|
||||||
if ($grp_info["count"] == 0) StatusMessage("WARN", "", _("No Groups found!"));
|
|
||||||
// delete first array entry which is "count"
|
// delete first array entry which is "count"
|
||||||
unset($grp_info['count']);
|
unset($info['count']);
|
||||||
// sort rows by sort column ($sort)
|
// save results
|
||||||
$grp_info = listSort($sort, $attr_array, $grp_info);
|
$_SESSION[$scope . 'info'] = $info;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$grp_info = array();
|
$info = array();
|
||||||
$_SESSION['grp_info'] = array();
|
$_SESSION[$scope . 'info'] = array();
|
||||||
StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No Groups found!"));
|
StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No groups found!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filter = listBuildFilter($_POST, $attr_array);
|
||||||
|
$info = listFilterAccounts($info, $filter);
|
||||||
|
if (sizeof($info) == 0) StatusMessage("WARN", "", _("No groups found!"));
|
||||||
|
// sort rows by sort column ($sort)
|
||||||
|
if ($info) $info = listSort($sort, $attr_array, $info);
|
||||||
|
|
||||||
|
// build filter URL
|
||||||
|
$searchFilter = array();
|
||||||
|
$filterAttributes = array_keys($filter);
|
||||||
|
for ($i = 0; $i < sizeof($filterAttributes); $i++) {
|
||||||
|
$searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original'];
|
||||||
|
}
|
||||||
|
if (sizeof($searchFilter) > 0) {
|
||||||
|
$searchFilter = "&" . implode("&", $searchFilter);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (sizeof($grp_info) == 0) StatusMessage("WARN", "", _("No Groups found!"));
|
$searchFilter = "";
|
||||||
// sort rows by sort column ($sort)
|
|
||||||
if ($grp_info) $grp_info =listSort($sort, $attr_array, $grp_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo ("<form action=\"listgroups.php\" method=\"post\">\n");
|
echo ("<form action=\"listgroups.php?norefresh=true\" method=\"post\">\n");
|
||||||
|
|
||||||
// draw navigation bar if group accounts were found
|
// draw navigation bar if group accounts were found
|
||||||
if (sizeof($grp_info) > 0) {
|
if (sizeof($info) > 0) {
|
||||||
listDrawNavigationBar(sizeof($grp_info), $max_page_entries, $page, $sort, $searchFilter, "group", _("%s group(s) found"));
|
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, "group", _("%s group(s) found"));
|
||||||
echo ("<br>");
|
echo ("<br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,53 +214,53 @@ listPrintTableHeader("group", $searchFilter, $desc_array, $attr_array, $_POST, $
|
||||||
|
|
||||||
// calculate which rows to show
|
// calculate which rows to show
|
||||||
$table_begin = ($page - 1) * $max_page_entries;
|
$table_begin = ($page - 1) * $max_page_entries;
|
||||||
if (($page * $max_page_entries) > sizeof($grp_info)) $table_end = sizeof($grp_info);
|
if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info);
|
||||||
else $table_end = ($page * $max_page_entries);
|
else $table_end = ($page * $max_page_entries);
|
||||||
|
|
||||||
if (sizeof($grp_info) > 0) {
|
if (sizeof($info) > 0) {
|
||||||
// print group list
|
// print group list
|
||||||
for ($i = $table_begin; $i < $table_end; $i++) {
|
for ($i = $table_begin; $i < $table_end; $i++) {
|
||||||
echo("<tr class=\"grouplist\" onMouseOver=\"group_over(this, '" . $grp_info[$i]["dn"] . "')\"" .
|
echo("<tr class=\"grouplist\" onMouseOver=\"group_over(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" onMouseOut=\"group_out(this, '" . $grp_info[$i]["dn"] . "')\"" .
|
" onMouseOut=\"group_out(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" onClick=\"group_click(this, '" . $grp_info[$i]["dn"] . "')\"" .
|
" onClick=\"group_click(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=group&DN=" . $grp_info[$i]["dn"] . "'\">");
|
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=group&DN=" . $info[$i]["dn"] . "'\">");
|
||||||
if ($_GET['selectall'] == "yes") {
|
if ($_GET['selectall'] == "yes") {
|
||||||
echo " <td height=22 align=\"center\"><input onClick=\"group_click(this, '" . $grp_info[$i]["dn"] . "')\" type=\"checkbox\"" .
|
echo " <td height=22 align=\"center\"><input onClick=\"group_click(this, '" . $info[$i]["dn"] . "')\" type=\"checkbox\"" .
|
||||||
" name=\"" . $grp_info[$i]["dn"] . "\" checked></td>";
|
" name=\"" . $info[$i]["dn"] . "\" checked></td>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo " <td height=22 align=\"center\"><input onClick=\"group_click(this, '" . $grp_info[$i]["dn"] . "')\" type=\"checkbox\"" .
|
echo " <td height=22 align=\"center\"><input onClick=\"group_click(this, '" . $info[$i]["dn"] . "')\" type=\"checkbox\"" .
|
||||||
" name=\"" . $grp_info[$i]["dn"] . "\"></td>";
|
" name=\"" . $info[$i]["dn"] . "\"></td>";
|
||||||
}
|
}
|
||||||
echo (" <td align='center'><a href=\"../account/edit.php?type=group&DN='" . $grp_info[$i]["dn"] . "'\">" . _("Edit") . "</a></td>");
|
echo (" <td align='center'><a href=\"../account/edit.php?type=group&DN='" . $info[$i]["dn"] . "'\">" . _("Edit") . "</a></td>");
|
||||||
for ($k = 0; $k < sizeof($attr_array); $k++) {
|
for ($k = 0; $k < sizeof($attr_array); $k++) {
|
||||||
echo ("<td>");
|
echo ("<td>");
|
||||||
// print all attribute entries seperated by "; "
|
// print all attribute entries seperated by "; "
|
||||||
if (sizeof($grp_info[$i][strtolower($attr_array[$k])]) > 0) {
|
if (sizeof($info[$i][strtolower($attr_array[$k])]) > 0) {
|
||||||
// delete first array entry which is "count"
|
// delete first array entry which is "count"
|
||||||
if (is_array($grp_info[$i][strtolower($attr_array[$k])])) unset($grp_info[$i][strtolower($attr_array[$k])]['count']);
|
if (is_array($info[$i][strtolower($attr_array[$k])])) unset($info[$i][strtolower($attr_array[$k])]['count']);
|
||||||
// generate links for group members
|
// generate links for group members
|
||||||
if (strtolower($attr_array[$k]) == "memberuid") {
|
if (strtolower($attr_array[$k]) == "memberuid") {
|
||||||
// sort array
|
// sort array
|
||||||
sort($grp_info[$i][strtolower($attr_array[$k])]);
|
sort($info[$i][strtolower($attr_array[$k])]);
|
||||||
// make a link for each member of the group
|
// make a link for each member of the group
|
||||||
$linklist = array();
|
$linklist = array();
|
||||||
for ($d = 0; $d < sizeof($grp_info[$i][strtolower($attr_array[$k])]); $d++) {
|
for ($d = 0; $d < sizeof($info[$i][strtolower($attr_array[$k])]); $d++) {
|
||||||
$user = $grp_info[$i][strtolower($attr_array[$k])][$d]; // user name
|
$user = $info[$i][strtolower($attr_array[$k])][$d]; // user name
|
||||||
$linklist[$d] = "<a href=\"userlink.php?user='" . $user . "' \">" . $user . "</a>";
|
$linklist[$d] = "<a href=\"userlink.php?user='" . $user . "' \">" . $user . "</a>";
|
||||||
}
|
}
|
||||||
echo implode("; ", $linklist);
|
echo implode("; ", $linklist);
|
||||||
}
|
}
|
||||||
// print all other attributes
|
// print all other attributes
|
||||||
else {
|
else {
|
||||||
if (is_array($grp_info[$i][strtolower($attr_array[$k])])) {
|
if (is_array($info[$i][strtolower($attr_array[$k])])) {
|
||||||
// delete "count" entry
|
// delete "count" entry
|
||||||
unset($grp_info[$i][strtolower($attr_array[$k])]['count']);
|
unset($info[$i][strtolower($attr_array[$k])]['count']);
|
||||||
// sort array
|
// sort array
|
||||||
sort($grp_info[$i][strtolower($attr_array[$k])]);
|
sort($info[$i][strtolower($attr_array[$k])]);
|
||||||
echo implode("; ", $grp_info[$i][strtolower($attr_array[$k])]);
|
echo implode("; ", $info[$i][strtolower($attr_array[$k])]);
|
||||||
}
|
}
|
||||||
else echo $grp_info[$i][strtolower($attr_array[$k])];
|
else echo $info[$i][strtolower($attr_array[$k])];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo ("</td>");
|
echo ("</td>");
|
||||||
|
@ -278,8 +280,8 @@ echo ("</table>");
|
||||||
echo ("<br>");
|
echo ("<br>");
|
||||||
|
|
||||||
// draw navigation bar if group accounts were found
|
// draw navigation bar if group accounts were found
|
||||||
if (sizeof($grp_info) > 0) {
|
if (sizeof($info) > 0) {
|
||||||
listDrawNavigationBar(sizeof($grp_info), $max_page_entries, $page, $sort, $searchFilter, "group", _("%s group(s) found"));
|
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, "group", _("%s group(s) found"));
|
||||||
echo ("<br>\n");
|
echo ("<br>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +306,7 @@ if (sizeof($grp_units) > 1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
echo ("<input type=\"submit\" name=\"new_group\" value=\"" . _("New Group") . "\">\n");
|
echo ("<input type=\"submit\" name=\"new_group\" value=\"" . _("New Group") . "\">\n");
|
||||||
if (sizeof($grp_info) > 0) {
|
if (sizeof($info) > 0) {
|
||||||
echo ("<input type=\"submit\" name=\"del_group\" value=\"" . _("Delete Group(s)") . "\">\n");
|
echo ("<input type=\"submit\" name=\"del_group\" value=\"" . _("Delete Group(s)") . "\">\n");
|
||||||
echo ("<br><br><br>\n");
|
echo ("<br><br><br>\n");
|
||||||
echo "<fieldset><legend><b>PDF</b></legend>\n";
|
echo "<fieldset><legend><b>PDF</b></legend>\n";
|
||||||
|
@ -324,7 +326,6 @@ echo ("</form>\n");
|
||||||
echo "</body></html>\n";
|
echo "</body></html>\n";
|
||||||
|
|
||||||
// save variables to session
|
// save variables to session
|
||||||
$_SESSION['grp_info'] = $grp_info;
|
|
||||||
$_SESSION['grp_units'] = $grp_units;
|
$_SESSION['grp_units'] = $grp_units;
|
||||||
$_SESSION['grp_suffix'] = $grp_suffix;
|
$_SESSION['grp_suffix'] = $grp_suffix;
|
||||||
|
|
||||||
|
|
|
@ -49,13 +49,15 @@ session_save_path("../../sess");
|
||||||
|
|
||||||
setlanguage();
|
setlanguage();
|
||||||
|
|
||||||
|
$scope = 'host';
|
||||||
|
|
||||||
// get sorting column when register_globals is off
|
// get sorting column when register_globals is off
|
||||||
$sort = $_GET['sort'];
|
$sort = $_GET['sort'];
|
||||||
|
|
||||||
// copy HTTP-GET variables to HTTP-POST
|
// copy HTTP-GET variables to HTTP-POST
|
||||||
$_POST = $_POST + $_GET;
|
$_POST = $_POST + $_GET;
|
||||||
|
|
||||||
$hst_info = $_SESSION['hst_info'];
|
$info = $_SESSION[$scope . 'info'];
|
||||||
$hst_units = $_SESSION['hst_units'];
|
$hst_units = $_SESSION['hst_units'];
|
||||||
|
|
||||||
// check if button was pressed and if we have to add/delete a host
|
// check if button was pressed and if we have to add/delete a host
|
||||||
|
@ -95,9 +97,9 @@ if ($_POST['new_host'] || $_POST['del_host'] || $_POST['pdf_host'] || $_POST['pd
|
||||||
// PDF for all hosts
|
// PDF for all hosts
|
||||||
elseif ($_POST['pdf_all']){
|
elseif ($_POST['pdf_all']){
|
||||||
$list = array();
|
$list = array();
|
||||||
for ($i = 0; $i < sizeof($_SESSION['hst_info']); $i++) {
|
for ($i = 0; $i < sizeof($_SESSION[$scope . 'info']); $i++) {
|
||||||
$_SESSION["accountPDF-$i"] = new accountContainer("host", "accountPDF-$i");
|
$_SESSION["accountPDF-$i"] = new accountContainer("host", "accountPDF-$i");
|
||||||
$_SESSION["accountPDF-$i"]->load_account($_SESSION['hst_info'][$i]['dn']);
|
$_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$i]['dn']);
|
||||||
$list[$i] = $_SESSION["accountPDF-$i"];
|
$list[$i] = $_SESSION["accountPDF-$i"];
|
||||||
}
|
}
|
||||||
if (sizeof($list) > 0) {
|
if (sizeof($list) > 0) {
|
||||||
|
@ -152,58 +154,58 @@ if ($_POST['hst_suffix']) $hst_suffix = $_POST['hst_suffix']; // new suffix sel
|
||||||
elseif ($_SESSION['hst_suffix']) $hst_suffix = $_SESSION['hst_suffix']; // old suffix from session
|
elseif ($_SESSION['hst_suffix']) $hst_suffix = $_SESSION['hst_suffix']; // old suffix from session
|
||||||
else $hst_suffix = $_SESSION["config"]->get_HostSuffix(); // default suffix
|
else $hst_suffix = $_SESSION["config"]->get_HostSuffix(); // default suffix
|
||||||
|
|
||||||
// generate search filter for sort links
|
$refresh = true;
|
||||||
$searchFilter = "";
|
if ($_GET['norefresh']) $refresh = false;
|
||||||
for ($k = 0; $k < sizeof($desc_array); $k++) {
|
if ($_POST['refresh']) $refresh = true;
|
||||||
if (eregi("^([0-9a-z_\\*\\+\\-])+$", $_POST["filter" . strtolower($attr_array[$k])])) {
|
|
||||||
$searchFilter = $searchFilter . "&filter" . strtolower($attr_array[$k]) . "=".
|
|
||||||
$_POST["filter" . strtolower($attr_array[$k])];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $_GET['norefresh']) {
|
if ($refresh) {
|
||||||
// configure search filter
|
// configure search filter
|
||||||
$module_filter = get_ldap_filter("host"); // basic filter is provided by modules
|
$module_filter = get_ldap_filter("host"); // basic filter is provided by modules
|
||||||
$filter = "(&" . $module_filter;
|
$filter = "(&" . $module_filter . ")";
|
||||||
for ($k = 0; $k < sizeof($desc_array); $k++) {
|
|
||||||
if (eregi("^([0-9a-z_\\*\\+\\-])+$", $_POST["filter" . strtolower($attr_array[$k])]))
|
|
||||||
$filter = $filter . "(" . strtolower($attr_array[$k]) . "=" .
|
|
||||||
$_POST["filter" . strtolower($attr_array[$k])] . ")";
|
|
||||||
else
|
|
||||||
$_POST["filter" . strtolower($attr_array[$k])] = "";
|
|
||||||
}
|
|
||||||
$filter = $filter . ")";
|
|
||||||
$attrs = $attr_array;
|
$attrs = $attr_array;
|
||||||
$sr = @ldap_search($_SESSION["ldap"]->server(), $hst_suffix, $filter, $attrs);
|
$sr = @ldap_search($_SESSION["ldap"]->server(), $hst_suffix, $filter, $attrs);
|
||||||
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
|
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
|
||||||
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
|
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
|
||||||
}
|
}
|
||||||
if ($sr) {
|
if ($sr) {
|
||||||
$hst_info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
|
$info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
|
||||||
ldap_free_result($sr);
|
ldap_free_result($sr);
|
||||||
if ($hst_info["count"] == 0) StatusMessage("WARN", "", _("No Samba Hosts found!"));
|
|
||||||
// delete first array entry which is "count"
|
// delete first array entry which is "count"
|
||||||
unset($hst_info['count']);
|
unset($info['count']);
|
||||||
// sort rows by sort column ($sort)
|
// save results
|
||||||
$hst_info = listSort($sort, $attr_array, $hst_info);
|
$_SESSION[$scope . 'info'] = $info;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$hst_info = array();
|
$info = array();
|
||||||
$_SESSION['hst_info'] = array();
|
$_SESSION[$scope . 'info'] = array();
|
||||||
StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No Samba Hosts found!"));
|
StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No hosts found!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filter = listBuildFilter($_POST, $attr_array);
|
||||||
|
$info = listFilterAccounts($info, $filter);
|
||||||
|
if (sizeof($info) == 0) StatusMessage("WARN", "", _("No hosts found!"));
|
||||||
|
// sort rows by sort column ($sort)
|
||||||
|
if ($info) $info = listSort($sort, $attr_array, $info);
|
||||||
|
|
||||||
|
// build filter URL
|
||||||
|
$searchFilter = array();
|
||||||
|
$filterAttributes = array_keys($filter);
|
||||||
|
for ($i = 0; $i < sizeof($filterAttributes); $i++) {
|
||||||
|
$searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original'];
|
||||||
|
}
|
||||||
|
if (sizeof($searchFilter) > 0) {
|
||||||
|
$searchFilter = "&" . implode("&", $searchFilter);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (sizeof($hst_info) == 0) StatusMessage("WARN", "", _("No Samba Hosts found!"));
|
$searchFilter = "";
|
||||||
// sort rows by sort column ($sort)
|
|
||||||
if ($hst_info) $hst_info = listSort($sort, $attr_array, $hst_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo ("<form action=\"listhosts.php\" method=\"post\">\n");
|
echo ("<form action=\"listhosts.php?norefresh=true\" method=\"post\">\n");
|
||||||
|
|
||||||
// draw navigation bar if host accounts were found
|
// draw navigation bar if host accounts were found
|
||||||
if (sizeof($hst_info) > 0) {
|
if (sizeof($info) > 0) {
|
||||||
listDrawNavigationBar(sizeof($hst_info), $max_page_entries, $page, $sort, $searchFilter, "host", _("%s host(s) found"));
|
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, "host", _("%s host(s) found"));
|
||||||
echo ("<br>\n");
|
echo ("<br>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,37 +214,37 @@ listPrintTableHeader("host", $searchFilter, $desc_array, $attr_array, $_POST, $s
|
||||||
|
|
||||||
// calculate which rows to show
|
// calculate which rows to show
|
||||||
$table_begin = ($page - 1) * $max_page_entries;
|
$table_begin = ($page - 1) * $max_page_entries;
|
||||||
if (($page * $max_page_entries) > sizeof($hst_info)) $table_end = sizeof($hst_info);
|
if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info);
|
||||||
else $table_end = ($page * $max_page_entries);
|
else $table_end = ($page * $max_page_entries);
|
||||||
|
|
||||||
if (sizeof($hst_info) > 0) {
|
if (sizeof($info) > 0) {
|
||||||
// print host list
|
// print host list
|
||||||
for ($i = $table_begin; $i < $table_end; $i++) {
|
for ($i = $table_begin; $i < $table_end; $i++) {
|
||||||
echo("<tr class=\"hostlist\" onMouseOver=\"host_over(this, '" . $hst_info[$i]["dn"] . "')\"" .
|
echo("<tr class=\"hostlist\" onMouseOver=\"host_over(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" onMouseOut=\"host_out(this, '" . $hst_info[$i]["dn"] . "')\"" .
|
" onMouseOut=\"host_out(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" onClick=\"host_click(this, '" . $hst_info[$i]["dn"] . "')\"" .
|
" onClick=\"host_click(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=host&DN=" . $hst_info[$i]["dn"] . "'\">");
|
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=host&DN=" . $info[$i]["dn"] . "'\">");
|
||||||
if ($_GET['selectall'] == "yes") {
|
if ($_GET['selectall'] == "yes") {
|
||||||
echo " <td height=22 align=\"center\"><input onClick=\"host_click(this, '" . $hst_info[$i]["dn"] . "')\"" .
|
echo " <td height=22 align=\"center\"><input onClick=\"host_click(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" type=\"checkbox\" checked name=\"" . $hst_info[$i]["dn"] . "\"></td>";
|
" type=\"checkbox\" checked name=\"" . $info[$i]["dn"] . "\"></td>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo " <td height=22 align=\"center\"><input onClick=\"host_click(this, '" . $hst_info[$i]["dn"] . "')\"" .
|
echo " <td height=22 align=\"center\"><input onClick=\"host_click(this, '" . $info[$i]["dn"] . "')\"" .
|
||||||
" type=\"checkbox\" name=\"" . $hst_info[$i]["dn"] . "\"></td>";
|
" type=\"checkbox\" name=\"" . $info[$i]["dn"] . "\"></td>";
|
||||||
}
|
}
|
||||||
echo (" <td align='center'><a href=\"../account/edit.php?type=host&DN='" . $hst_info[$i]["dn"] . "'\">" . _("Edit") . "</a></td>");
|
echo (" <td align='center'><a href=\"../account/edit.php?type=host&DN='" . $info[$i]["dn"] . "'\">" . _("Edit") . "</a></td>");
|
||||||
for ($k = 0; $k < sizeof($attr_array); $k++) {
|
for ($k = 0; $k < sizeof($attr_array); $k++) {
|
||||||
echo ("<td>");
|
echo ("<td>");
|
||||||
// print all attribute entries seperated by "; "
|
// print all attribute entries seperated by "; "
|
||||||
if (sizeof($hst_info[$i][strtolower($attr_array[$k])]) > 0) {
|
if (sizeof($info[$i][strtolower($attr_array[$k])]) > 0) {
|
||||||
// delete "count" entry
|
// delete "count" entry
|
||||||
unset($hst_info[$i][strtolower($attr_array[$k])]['count']);
|
unset($info[$i][strtolower($attr_array[$k])]['count']);
|
||||||
if (is_array($hst_info[$i][strtolower($attr_array[$k])])) {
|
if (is_array($info[$i][strtolower($attr_array[$k])])) {
|
||||||
// sort array
|
// sort array
|
||||||
sort($hst_info[$i][strtolower($attr_array[$k])]);
|
sort($info[$i][strtolower($attr_array[$k])]);
|
||||||
echo implode("; ", $hst_info[$i][strtolower($attr_array[$k])]);
|
echo implode("; ", $info[$i][strtolower($attr_array[$k])]);
|
||||||
}
|
}
|
||||||
else echo $hst_info[$i][strtolower($attr_array[$k])];
|
else echo $info[$i][strtolower($attr_array[$k])];
|
||||||
}
|
}
|
||||||
echo ("</td>");
|
echo ("</td>");
|
||||||
}
|
}
|
||||||
|
@ -262,8 +264,8 @@ echo ("</table>");
|
||||||
echo ("<br>");
|
echo ("<br>");
|
||||||
|
|
||||||
// draw navigation bar if host accounts were found
|
// draw navigation bar if host accounts were found
|
||||||
if (sizeof($hst_info) > 0) {
|
if (sizeof($info) > 0) {
|
||||||
listDrawNavigationBar(sizeof($hst_info), $max_page_entries, $page, $sort, $searchFilter, "host", _("%s host(s) found"));
|
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, "host", _("%s host(s) found"));
|
||||||
echo ("<br>\n");
|
echo ("<br>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +291,7 @@ echo ("<p> </p>\n");
|
||||||
|
|
||||||
// add/delete/PDF buttons
|
// add/delete/PDF buttons
|
||||||
echo ("<input type=\"submit\" name=\"new_host\" value=\"" . _("New Host") . "\">\n");
|
echo ("<input type=\"submit\" name=\"new_host\" value=\"" . _("New Host") . "\">\n");
|
||||||
if (sizeof($hst_info) > 0) {
|
if (sizeof($info) > 0) {
|
||||||
echo ("<input type=\"submit\" name=\"del_host\" value=\"" . _("Delete Host(s)") . "\">\n");
|
echo ("<input type=\"submit\" name=\"del_host\" value=\"" . _("Delete Host(s)") . "\">\n");
|
||||||
echo ("<br><br><br>\n");
|
echo ("<br><br><br>\n");
|
||||||
echo "<fieldset><legend><b>PDF</b></legend>\n";
|
echo "<fieldset><legend><b>PDF</b></legend>\n";
|
||||||
|
@ -309,7 +311,6 @@ echo ("</form>\n");
|
||||||
echo "</body></html>\n";
|
echo "</body></html>\n";
|
||||||
|
|
||||||
// save variables to session
|
// save variables to session
|
||||||
$_SESSION['hst_info'] = $hst_info;
|
|
||||||
$_SESSION['hst_units'] = $hst_units;
|
$_SESSION['hst_units'] = $hst_units;
|
||||||
$_SESSION['hst_suffix'] = $hst_suffix;
|
$_SESSION['hst_suffix'] = $hst_suffix;
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ session_save_path("../../sess");
|
||||||
|
|
||||||
setlanguage();
|
setlanguage();
|
||||||
|
|
||||||
|
$scope = 'user';
|
||||||
|
|
||||||
// copy HTTP-GET variables to HTTP-POST
|
// copy HTTP-GET variables to HTTP-POST
|
||||||
$_POST = $_POST + $_GET;
|
$_POST = $_POST + $_GET;
|
||||||
|
|
||||||
|
@ -76,6 +78,7 @@ if ($trans_primary == "on" && !$_GET["norefresh"]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$info = $_SESSION[$scope . 'info'];
|
||||||
$usr_units = $_SESSION['usr_units'];
|
$usr_units = $_SESSION['usr_units'];
|
||||||
|
|
||||||
// check if button was pressed and if we have to add/delete a user or create a PDF
|
// check if button was pressed and if we have to add/delete a user or create a PDF
|
||||||
|
@ -119,9 +122,9 @@ if ($_POST['new_user'] || $_POST['del_user'] || $_POST['pdf_user'] || $_POST['pd
|
||||||
// PDF for all users
|
// PDF for all users
|
||||||
elseif ($_POST['pdf_all']){
|
elseif ($_POST['pdf_all']){
|
||||||
$list = array();
|
$list = array();
|
||||||
for ($i = 0; $i < sizeof($_SESSION['userlist']); $i++) {
|
for ($i = 0; $i < sizeof($_SESSION[$scope . 'info']); $i++) {
|
||||||
$_SESSION["accountPDF-$i"] = new accountContainer("user", "accountPDF-$i");
|
$_SESSION["accountPDF-$i"] = new accountContainer("user", "accountPDF-$i");
|
||||||
$_SESSION["accountPDF-$i"]->load_account($_SESSION['usr_info'][$i]['dn']);
|
$_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$i]['dn']);
|
||||||
$list[$i] = $_SESSION["accountPDF-$i"];
|
$list[$i] = $_SESSION["accountPDF-$i"];
|
||||||
}
|
}
|
||||||
if (sizeof($list) > 0) {
|
if (sizeof($list) > 0) {
|
||||||
|
@ -182,61 +185,59 @@ elseif ($_SESSION['usr_suffix']) $usr_suffix = $_SESSION['usr_suffix']; // old
|
||||||
else $usr_suffix = $_SESSION["config"]->get_UserSuffix(); // default suffix
|
else $usr_suffix = $_SESSION["config"]->get_UserSuffix(); // default suffix
|
||||||
|
|
||||||
|
|
||||||
// generate search filter for sort links
|
|
||||||
$searchFilter = "";
|
|
||||||
for ($k = 0; $k < sizeof($desc_array); $k++) {
|
|
||||||
if (eregi("^([0-9a-z_\\*\\+\\-])+$", $_POST["filter" . strtolower($attr_array[$k])])) {
|
|
||||||
$searchFilter = $searchFilter . "&filter" .
|
|
||||||
strtolower($attr_array[$k]) . "=".
|
|
||||||
$_POST["filter" . strtolower($attr_array[$k])];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure search filter for LDAP
|
// configure search filter for LDAP
|
||||||
$module_filter = get_ldap_filter("user"); // basic filter is provided by modules
|
$module_filter = get_ldap_filter("user"); // basic filter is provided by modules
|
||||||
$filter = "(&" . $module_filter; // users do not end with "$"
|
$filter = "(&" . $module_filter . ")";
|
||||||
for ($k = 0; $k < sizeof($desc_array); $k++) {
|
|
||||||
if (eregi("^([0-9a-z_\\*\\+\\-])+$", $_POST["filter" . strtolower($attr_array[$k])]))
|
|
||||||
$filter = $filter . "(" . strtolower($attr_array[$k]) . "=" .
|
|
||||||
$_POST["filter" . strtolower($attr_array[$k])] . ")";
|
|
||||||
else
|
|
||||||
$_POST["filter" . strtolower($attr_array[$k])] = "";
|
|
||||||
}
|
|
||||||
$filter = $filter . ")";
|
|
||||||
|
|
||||||
// read entries only from ldap server if not yet stored in session or if refresh
|
$refresh = true;
|
||||||
// button is pressed or if filter is applied
|
if ($_GET['norefresh']) $refresh = false;
|
||||||
if ($_SESSION["userlist"] && $_GET["norefresh"]) {
|
if ($_POST['refresh']) $refresh = true;
|
||||||
$_SESSION["userlist"] = listSort($sort, $attr_array, $_SESSION["userlist"]);
|
|
||||||
$userinfo = $_SESSION["userlist"];
|
if ($refresh) {
|
||||||
}
|
|
||||||
else {
|
|
||||||
$attrs = $attr_array;
|
$attrs = $attr_array;
|
||||||
$sr = @ldap_search($_SESSION["ldap"]->server(), $usr_suffix, $filter, $attrs);
|
$sr = @ldap_search($_SESSION["ldap"]->server(), $usr_suffix, $filter, $attrs);
|
||||||
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
|
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
|
||||||
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
|
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
|
||||||
}
|
}
|
||||||
if ($sr) {
|
if ($sr) {
|
||||||
$userinfo = ldap_get_entries ($_SESSION["ldap"]->server, $sr);
|
$info = ldap_get_entries ($_SESSION["ldap"]->server, $sr);
|
||||||
ldap_free_result ($sr);
|
ldap_free_result ($sr);
|
||||||
if ($userinfo["count"] == 0) StatusMessage("WARN", "", _("No Users found!"));
|
// delete first array entry which is "count"
|
||||||
// delete first array entry which is "count"
|
unset($info['count']);
|
||||||
unset($userinfo['count']);
|
// save results
|
||||||
$userinfo = listSort($sort, $attr_array, $userinfo);
|
$_SESSION[$scope . 'info'] = $info;
|
||||||
$_SESSION["userlist"] = $userinfo;
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
$_SESSION['userlist'] = array();
|
$_SESSION[$scope . 'info'] = array();
|
||||||
$userinfo = array();
|
$info = array();
|
||||||
StatusMessage("ERROR",
|
StatusMessage("ERROR",
|
||||||
_("LDAP Search failed! Please check your preferences."),
|
_("LDAP Search failed! Please check your preferences."),
|
||||||
_("No Users found!"));
|
_("No users found!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_count = sizeof ($_SESSION["userlist"]);
|
$filter = listBuildFilter($_POST, $attr_array);
|
||||||
|
$info = listFilterAccounts($info, $filter);
|
||||||
|
if (sizeof($info) == 0) StatusMessage("WARN", "", _("No users found!"));
|
||||||
|
// sort rows by sort column ($sort)
|
||||||
|
if ($info) $info = listSort($sort, $attr_array, $info);
|
||||||
|
|
||||||
echo ("<form action=\"listusers.php\" method=\"post\">\n");
|
// build filter URL
|
||||||
|
$searchFilter = array();
|
||||||
|
$filterAttributes = array_keys($filter);
|
||||||
|
for ($i = 0; $i < sizeof($filterAttributes); $i++) {
|
||||||
|
$searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original'];
|
||||||
|
}
|
||||||
|
if (sizeof($searchFilter) > 0) {
|
||||||
|
$searchFilter = "&" . implode("&", $searchFilter);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$searchFilter = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_count = sizeof($info);
|
||||||
|
|
||||||
|
echo ("<form action=\"listusers.php?norefresh=true\" method=\"post\">\n");
|
||||||
|
|
||||||
// display table only if users exist in LDAP
|
// display table only if users exist in LDAP
|
||||||
if ($user_count != 0) {
|
if ($user_count != 0) {
|
||||||
|
@ -249,51 +250,55 @@ if ($user_count != 0) {
|
||||||
// account table head
|
// account table head
|
||||||
listPrintTableHeader("user", $searchFilter . "&trans_primary=" . $trans_primary, $desc_array, $attr_array, $_POST, $sort);
|
listPrintTableHeader("user", $searchFilter . "&trans_primary=" . $trans_primary, $desc_array, $attr_array, $_POST, $sort);
|
||||||
|
|
||||||
|
// calculate which rows to show
|
||||||
|
$table_begin = ($page - 1) * $max_page_entries;
|
||||||
|
if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info);
|
||||||
|
else $table_end = ($page * $max_page_entries);
|
||||||
|
|
||||||
if ($user_count != 0) {
|
if ($user_count != 0) {
|
||||||
// translate GIDs and resort array if selected
|
// translate GIDs and resort array if selected
|
||||||
if ($trans_primary == "on") {
|
if ($trans_primary == "on") {
|
||||||
// translate GIDs
|
// translate GIDs
|
||||||
for ($i = 0; $i < sizeof($userinfo); $i++) {
|
for ($i = 0; $i < sizeof($info); $i++) {
|
||||||
if ($trans_primary_hash[$userinfo[$i]['gidnumber'][0]]) {
|
if ($trans_primary_hash[$info[$i]['gidnumber'][0]]) {
|
||||||
$userinfo[$i]['gidnumber'][0] = $trans_primary_hash[$userinfo[$i]['gidnumber'][0]];
|
$info[$i]['gidnumber'][0] = $trans_primary_hash[$info[$i]['gidnumber'][0]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// resort if needed
|
// resort if needed
|
||||||
if ($sort == "gidnumber") {
|
if ($sort == "gidnumber") {
|
||||||
$userinfo = listSort($sort, $attr_array, $userinfo);
|
$info = listSort($sort, $attr_array, $info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// print user list
|
// print user list
|
||||||
$userinfo = array_slice ($userinfo, ($page - 1) * $max_page_entries, $max_page_entries);
|
for ($i = $table_begin; $i < $table_end; $i++) { // ignore last entry in array which is "count"
|
||||||
for ($i = 0; $i < sizeof ($userinfo); $i++) { // ignore last entry in array which is "count"
|
echo("<tr class=\"userlist\"\nonMouseOver=\"user_over(this, '" . $info[$i]["dn"] . "')\"\n" .
|
||||||
echo("<tr class=\"userlist\"\nonMouseOver=\"user_over(this, '" . $userinfo[$i]["dn"] . "')\"\n" .
|
"onMouseOut=\"user_out(this, '" . $info[$i]["dn"] . "')\"\n" .
|
||||||
"onMouseOut=\"user_out(this, '" . $userinfo[$i]["dn"] . "')\"\n" .
|
"onClick=\"user_click(this, '" . $info[$i]["dn"] . "')\"\n" .
|
||||||
"onClick=\"user_click(this, '" . $userinfo[$i]["dn"] . "')\"\n" .
|
"onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=user&DN=" . $info[$i]["dn"] . "'\">\n");
|
||||||
"onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=user&DN=" . $userinfo[$i]["dn"] . "'\">\n");
|
|
||||||
// checkboxes if selectall = "yes"
|
// checkboxes if selectall = "yes"
|
||||||
if ($_GET['selectall'] == "yes") {
|
if ($_GET['selectall'] == "yes") {
|
||||||
echo "<td height=22 align=\"center\">\n<input onClick=\"user_click(this, '" . $userinfo[$i]["dn"] . "')\" type=\"checkbox\" name=\"" .
|
echo "<td height=22 align=\"center\">\n<input onClick=\"user_click(this, '" . $info[$i]["dn"] . "')\" type=\"checkbox\" name=\"" .
|
||||||
$userinfo[$i]["dn"] . "\" value=\"" . $userinfo[$i]["dn"] . "\" checked>\n</td>\n";
|
$info[$i]["dn"] . "\" value=\"" . $info[$i]["dn"] . "\" checked>\n</td>\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo "<td height=22 align=\"center\">\n<input onClick=\"user_click(this, '" . $userinfo[$i]["dn"] . "')\" type=\"checkbox\" name=\"" .
|
echo "<td height=22 align=\"center\">\n<input onClick=\"user_click(this, '" . $info[$i]["dn"] . "')\" type=\"checkbox\" name=\"" .
|
||||||
$userinfo[$i]["dn"] . "\" value=\"" . $userinfo[$i]["dn"] . "\">\n</td>\n";
|
$info[$i]["dn"] . "\" value=\"" . $info[$i]["dn"] . "\">\n</td>\n";
|
||||||
}
|
}
|
||||||
echo ("<td align='center'>\n<a href=\"../account/edit.php?type=user&DN='" . $userinfo[$i]["dn"] . "'\">" .
|
echo ("<td align='center'>\n<a href=\"../account/edit.php?type=user&DN='" . $info[$i]["dn"] . "'\">" .
|
||||||
_("Edit") . "</a>\n</td>\n");
|
_("Edit") . "</a>\n</td>\n");
|
||||||
for ($k = 0; $k < sizeof($attr_array); $k++) {
|
for ($k = 0; $k < sizeof($attr_array); $k++) {
|
||||||
echo ("<td>\n");
|
echo ("<td>\n");
|
||||||
// print attribute values
|
// print attribute values
|
||||||
if (sizeof($userinfo[$i][strtolower($attr_array[$k])]) > 0) {
|
if (sizeof($info[$i][strtolower($attr_array[$k])]) > 0) {
|
||||||
if (is_array($userinfo[$i][strtolower($attr_array[$k])])) {
|
if (is_array($info[$i][strtolower($attr_array[$k])])) {
|
||||||
// delete first array entry which is "count"
|
// delete first array entry which is "count"
|
||||||
unset($userinfo[$i][strtolower($attr_array[$k])]['count']);
|
unset($info[$i][strtolower($attr_array[$k])]['count']);
|
||||||
// sort array
|
// sort array
|
||||||
sort($userinfo[$i][strtolower($attr_array[$k])]);
|
sort($info[$i][strtolower($attr_array[$k])]);
|
||||||
// print all attribute entries seperated by "; "
|
// print all attribute entries seperated by "; "
|
||||||
echo implode("; ", $userinfo[$i][strtolower($attr_array[$k])]) . "\n";
|
echo implode("; ", $info[$i][strtolower($attr_array[$k])]) . "\n";
|
||||||
}
|
}
|
||||||
else echo $userinfo[$i][strtolower($attr_array[$k])] . "\n";
|
else echo $info[$i][strtolower($attr_array[$k])] . "\n";
|
||||||
}
|
}
|
||||||
echo ("</td>\n");
|
echo ("</td>\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue