removed session_(un)register(...), minor bug fixes

This commit is contained in:
Roland Gruber 2003-08-09 10:56:46 +00:00
parent f28f522507
commit 55cbfebe12
8 changed files with 144 additions and 133 deletions

View File

@ -143,7 +143,7 @@ class Ldap{
}
}
// add root suffix if needed
$found == false;
$found = false;
for ($i = 0; $i < sizeof($ret); $i++) { // search suffix case-intensitive
if (strtolower($suffix) == strtolower($ret[$i])) {
$found = true;

View File

@ -33,30 +33,30 @@ session_save_path("../../sess");
setlanguage();
// remove settings from session
session_unregister('passwd');
session_unregister('passwd1');
session_unregister('passwd2');
session_unregister('serverurl');
session_unregister('admins');
session_unregister('suffusers');
session_unregister('suffgroups');
session_unregister('suffhosts');
session_unregister('minUID');
session_unregister('maxUID');
session_unregister('minGID');
session_unregister('maxGID');
session_unregister('minMach');
session_unregister('maxMach');
session_unregister('usrlstattr');
session_unregister('grplstattr');
session_unregister('hstlstattr');
session_unregister('maxlistentries');
session_unregister('lang');
session_unregister('scriptpath');
session_unregister('scriptserver');
session_unregister('samba3');
session_unregister('domainSID');
session_unregister('filename');
unset($_SESSION['passwd']);
unset($_SESSION['passwd1']);
unset($_SESSION['passwd2']);
unset($_SESSION['serverurl']);
unset($_SESSION['admins']);
unset($_SESSION['suffusers']);
unset($_SESSION['suffgroups']);
unset($_SESSION['suffhosts']);
unset($_SESSION['minUID']);
unset($_SESSION['maxUID']);
unset($_SESSION['minGID']);
unset($_SESSION['maxGID']);
unset($_SESSION['minMach']);
unset($_SESSION['maxMach']);
unset($_SESSION['usrlstattr']);
unset($_SESSION['grplstattr']);
unset($_SESSION['hstlstattr']);
unset($_SESSION['maxlistentries']);
unset($_SESSION['lang']);
unset($_SESSION['scriptpath']);
unset($_SESSION['scriptserver']);
unset($_SESSION['samba3']);
unset($_SESSION['domainSID']);
unset($_SESSION['filename']);
echo $_SESSION['header'];

View File

@ -38,45 +38,40 @@ if ($_POST['back'] || $_POST['submitconf']){
if ($_POST['submitconf']){
// save HTTP-POST variables in session
// get data if register_globals is off
if ($_POST['passwd']) $passwd = $_POST['passwd'];
if ($_POST['passwd1']) $passwd1 = $_POST['passwd1'];
if ($_POST['passwd2']) $passwd2 = $_POST['passwd2'];
if ($_POST['serverurl']) $serverurl = $_POST['serverurl'];
if ($_POST['admins']) $admins = $_POST['admins'];
if ($_POST['suffusers']) $suffusers = $_POST['suffusers'];
if ($_POST['suffgroups']) $suffgroups = $_POST['suffgroups'];
if ($_POST['suffhosts']) $suffhosts = $_POST['suffhosts'];
if ($_POST['suffdomains']) $suffdomains = $_POST['suffdomains'];
if ($_POST['passwd']) $_SESSION['passwd'] = $_POST['passwd'];
if ($_POST['passwd1']) $_SESSION['passwd1'] = $_POST['passwd1'];
if ($_POST['passwd2']) $_SESSION['passwd2'] = $_POST['passwd2'];
if ($_POST['serverurl']) $_SESSION['serverurl'] = $_POST['serverurl'];
if ($_POST['admins']) $_SESSION['admins'] = $_POST['admins'];
if ($_POST['suffusers']) $_SESSION['suffusers'] = $_POST['suffusers'];
if ($_POST['suffgroups']) $_SESSION['suffgroups'] = $_POST['suffgroups'];
if ($_POST['suffhosts']) $_SESSION['suffhosts'] = $_POST['suffhosts'];
if ($_POST['suffdomains']) $_SESSION['suffdomains'] = $_POST['suffdomains'];
// if ($_POST['suffmap']) $suffmap = $_POST['suffmap'];
if ($_POST['minUID']) $minUID = $_POST['minUID'];
if ($_POST['maxUID']) $maxUID = $_POST['maxUID'];
if ($_POST['minGID']) $minGID = $_POST['minGID'];
if ($_POST['maxGID']) $maxGID = $_POST['maxGID'];
if ($_POST['minMach']) $minMach = $_POST['minMach'];
if ($_POST['maxMach']) $maxMach = $_POST['maxMach'];
if ($_POST['usrlstattr']) $usrlstattr = $_POST['usrlstattr'];
if ($_POST['grplstattr']) $grplstattr = $_POST['grplstattr'];
if ($_POST['hstlstattr']) $hstlstattr = $_POST['hstlstattr'];
if ($_POST['maxlistentries']) $maxlistentries = $_POST['maxlistentries'];
if ($_POST['lang']) $lang = $_POST['lang'];
if ($_POST['scriptpath']) $scriptpath = $_POST['scriptpath'];
if ($_POST['samba3']) $samba3 = $_POST['samba3'];
if ($_POST['domainSID']) $domainSID = $_POST['domainSID'];
if ($_POST['scriptpath']) $scriptpath = $_POST['scriptpath'];
else $scriptpath = "";
if ($_POST['scriptserver']) $scriptserver = $_POST['scriptserver'];
else $scriptserver = "";
if ($_POST['filename']) $filename = $_POST['filename'];
session_register('passwd', 'passwd1', 'passwd2', 'serverurl', 'admins', 'suffusers',
'suffgroups', 'suffhosts', 'suffdomains', 'minUID', 'maxUID', 'minGID',
'maxGID', 'minMach', 'maxMach', 'usrlstattr', 'grplstattr', 'hstlstattr', 'maxlistentries',
'lang', 'scriptpath', 'scriptserver', 'samba3', 'domainSID', 'filename');
if ($_POST['minUID']) $_SESSION['minUID'] = $_POST['minUID'];
if ($_POST['maxUID']) $_SESSION['maxUID'] = $_POST['maxUID'];
if ($_POST['minGID']) $_SESSION['minGID'] = $_POST['minGID'];
if ($_POST['maxGID']) $_SESSION['maxGID'] = $_POST['maxGID'];
if ($_POST['minMach']) $_SESSION['minMach'] = $_POST['minMach'];
if ($_POST['maxMach']) $_SESSION['maxMach'] = $_POST['maxMach'];
if ($_POST['usrlstattr']) $_SESSION['usrlstattr'] = $_POST['usrlstattr'];
if ($_POST['grplstattr']) $_SESSION['grplstattr'] = $_POST['grplstattr'];
if ($_POST['hstlstattr']) $_SESSION['hstlstattr'] = $_POST['hstlstattr'];
if ($_POST['maxlistentries']) $_SESSION['maxlistentries'] = $_POST['maxlistentries'];
if ($_POST['lang']) $_SESSION['lang'] = $_POST['lang'];
if ($_POST['samba3']) $_SESSION['samba3'] = $_POST['samba3'];
if ($_POST['domainSID']) $_SESSION['domainSID'] = $_POST['domainSID'];
if ($_POST['scriptpath']) $_SESSION['scriptpath'] = $_POST['scriptpath'];
else $_SESSION['scriptpath'] = "";
if ($_POST['scriptserver']) $_SESSION['scriptserver'] = $_POST['scriptserver'];
else $_SESSION['scriptserver'] = "";
if ($_POST['filename']) $_SESSION['filename'] = $_POST['filename'];
echo("<meta http-equiv=\"refresh\" content=\"0; URL=confsave.php\">");
}
// back to login
else if ($_POST['back']){
echo("<meta http-equiv=\"refresh\" content=\"0; URL=../login.php\">");
}
}
exit;
}

View File

@ -239,31 +239,31 @@ echo ("<br><br><br><br><br><a href=\"../login.php\" target=\"_top\">" . _("Back
echo("</body></html>");
// remove settings from session
session_unregister('passwd');
session_unregister('passwd1');
session_unregister('passwd2');
session_unregister('serverurl');
session_unregister('admins');
session_unregister('suffusers');
session_unregister('suffgroups');
session_unregister('suffhosts');
session_unregister('suffdomains');
//session_unregister('suffmap');
session_unregister('minUID');
session_unregister('maxUID');
session_unregister('minGID');
session_unregister('maxGID');
session_unregister('minMach');
session_unregister('maxMach');
session_unregister('usrlstattr');
session_unregister('grplstattr');
session_unregister('hstlstattr');
session_unregister('maxlistentries');
session_unregister('lang');
session_unregister('scriptpath');
session_unregister('scriptserver');
session_unregister('samba3');
session_unregister('domainSID');
session_unregister('filename');
unset($_SESSION['passwd']);
unset($_SESSION['passwd1']);
unset($_SESSION['passwd2']);
unset($_SESSION['serverurl']);
unset($_SESSION['admins']);
unset($_SESSION['suffusers']);
unset($_SESSION['suffgroups']);
unset($_SESSION['suffhosts']);
unset($_SESSION['suffdomains']);
//unset($_SESSION['suffmap']);
unset($_SESSION['minUID']);
unset($_SESSION['maxUID']);
unset($_SESSION['minGID']);
unset($_SESSION['maxGID']);
unset($_SESSION['minMach']);
unset($_SESSION['maxMach']);
unset($_SESSION['usrlstattr']);
unset($_SESSION['grplstattr']);
unset($_SESSION['hstlstattr']);
unset($_SESSION['maxlistentries']);
unset($_SESSION['lang']);
unset($_SESSION['scriptpath']);
unset($_SESSION['scriptserver']);
unset($_SESSION['samba3']);
unset($_SESSION['domainSID']);
unset($_SESSION['filename']);
?>

View File

@ -39,9 +39,7 @@ $sort = $_GET['sort'];
$_POST = $_POST + $_GET;
$dom_info = $_SESSION['dom_info'];
session_register('dom_info');
$dom_units = $_SESSION['dom_units'];
session_register('dom_units');
// check if button was pressed and if we have to add/delete a domain
if ($_POST['new_domain'] || $_POST['del_domain']){
@ -77,8 +75,8 @@ else
// generate attribute and description tables
$attr_array; // list of LDAP attributes to show
$desc_array; // list of descriptions for the attributes
$attr_array = array(); // list of LDAP attributes to show
$desc_array = array(); // list of descriptions for the attributes
$attr_array[] = "sambaDomainName";
$attr_array[] = "sambaSID";
$attr_array[] = "dn";
@ -90,15 +88,16 @@ $desc_array[] = "DN";
if ($_POST['dom_suffix']) $dom_suffix = $_POST['dom_suffix']; // new suffix selected via combobox
elseif ($_SESSION['dom_suffix']) $dom_suffix = $_SESSION['dom_suffix']; // old suffix from session
else $dom_suffix = $_SESSION["config"]->get_DomainSuffix(); // default suffix
session_register('dom_suffix');
// first time page is shown
if (! $_GET['norefresh']) {
// configure search filter
$filter = "(objectClass=sambaDomain)";
$attrs = $attr_array;
$sr = @ldap_search($_SESSION["ldap"]->server(),
$dom_suffix,
$filter, $attrs);
$sr = @ldap_search($_SESSION["ldap"]->server(), $dom_suffix, $filter, $attrs);
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), "See README.openldap to solve this problem.");
}
if ($sr) {
$dom_info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
ldap_free_result($sr);
@ -110,6 +109,7 @@ if (! $_GET['norefresh']) {
}
else StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No Samba Domains found!"));
}
// use search result from session
else {
if (sizeof($dom_info) == 0) StatusMessage("WARN", "", _("No Samba Domains found!"));
// sort rows by sort column ($sort)
@ -251,4 +251,10 @@ function cmp_array($a, $b) {
else return -1;
}
// save variables to session
$_SESSION['dom_info'] = $dom_info;
$_SESSION['dom_units'] = $dom_units;
$_SESSION['dom_suffix'] = $dom_suffix;
?>

View File

@ -39,9 +39,7 @@ $sort = $_GET['sort'];
$_POST = $_POST + $_GET;
$grp_info = $_SESSION['grp_info'];
session_register('grp_info');
$grp_units = $_SESSION['grp_units'];
session_register('grp_units');
// check if button was pressed and if we have to add/delete a group
if ($_POST['new_group'] || $_POST['del_group']){
@ -67,8 +65,8 @@ echo "</head><body>\n";
echo "<script src=\"../../lib/functions.js\" type=\"text/javascript\" language=\"javascript\"></script>\n";
// generate attribute-description table
$attr_array; // list of LDAP attributes to show
$desc_array; // list of descriptions for the attributes
$attr_array = array(); // list of LDAP attributes to show
$desc_array = array(); // list of descriptions for the attributes
$attr_string = $_SESSION["config"]->get_grouplistAttributes();
$temp_array = explode(";", $attr_string);
$hash_table = $_SESSION["ldap"]->attributeGroupArray();
@ -102,7 +100,6 @@ for ($i = 0; $i < sizeof($temp_array); $i++) {
if ($_POST['grp_suffix']) $grp_suffix = $_POST['grp_suffix']; // new suffix selected via combobox
elseif ($_SESSION['grp_suffix']) $grp_suffix = $_SESSION['grp_suffix']; // old suffix from session
else $grp_suffix = $_SESSION["config"]->get_GroupSuffix(); // default suffix
session_register('grp_suffix');
// generate search filter for sort links
$searchfilter = "";
@ -126,9 +123,10 @@ if (! $_GET['norefresh']) {
}
$filter = $filter . ")";
$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) {
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), "See README.openldap to solve this problem.");
}
if ($sr) {
$grp_info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
ldap_free_result($sr);
@ -309,4 +307,9 @@ function cmp_array($a, $b) {
else return -1;
}
// save variables to session
$_SESSION['grp_info'] = $grp_info;
$_SESSION['grp_units'] = $grp_units;
$_SESSION['grp_suffix'] = $grp_suffix;
?>

View File

@ -39,9 +39,7 @@ $sort = $_GET['sort'];
$_POST = $_POST + $_GET;
$hst_info = $_SESSION['hst_info'];
session_register('hst_info');
$hst_units = $_SESSION['hst_units'];
session_register('hst_units');
// check if button was pressed and if we have to add/delete a host
if ($_POST['new_host'] || $_POST['del_host']){
@ -67,8 +65,8 @@ echo "</head><body>\n";
echo "<script src=\"../../lib/functions.js\" type=\"text/javascript\" language=\"javascript\"></script>\n";
// generate attribute-description table
$attr_array; // list of LDAP attributes to show
$desc_array; // list of descriptions for the attributes
$attr_array = array(); // list of LDAP attributes to show
$desc_array = array(); // list of descriptions for the attributes
$attr_string = $_SESSION["config"]->get_hostlistAttributes();
$temp_array = explode(";", $attr_string);
$hash_table = $_SESSION["ldap"]->attributeHostArray();
@ -102,7 +100,6 @@ else {
if ($_POST['hst_suffix']) $hst_suffix = $_POST['hst_suffix']; // new suffix selected via combobox
elseif ($_SESSION['hst_suffix']) $hst_suffix = $_SESSION['hst_suffix']; // old suffix from session
else $hst_suffix = $_SESSION["config"]->get_HostSuffix(); // default suffix
session_register('hst_suffix');
// generate search filter for sort links
$searchfilter = "";
@ -132,9 +129,10 @@ if (! $_GET['norefresh']) {
}
$filter = $filter . ")";
$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) {
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), "See README.openldap to solve this problem.");
}
if ($sr) {
$hst_info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
ldap_free_result($sr);
@ -301,4 +299,9 @@ function cmp_array($a, $b) {
else return -1;
}
// save variables to session
$_SESSION['hst_info'] = $hst_info;
$_SESSION['hst_units'] = $hst_units;
$_SESSION['hst_suffix'] = $hst_suffix;
?>

View File

@ -37,7 +37,6 @@ setlanguage();
$_POST = $_POST + $_GET;
$usr_units = $_SESSION['usr_units'];
session_register('usr_units');
// check if button was pressed and if we have to add/delete a user
if ($_POST['new_user'] || $_POST['del_user']){
@ -64,8 +63,8 @@ echo "</head><body>\n";
echo "<script src=\"../../lib/functions.js\" type=\"text/javascript\" language=\"javascript\"></script>\n";
// generate attribute-description table
$attr_array; // list of LDAP attributes to show
$desc_array; // list of descriptions for the attributes
$attr_array = array(); // list of LDAP attributes to show
$desc_array = array(); // list of descriptions for the attributes
$attr_string = $_SESSION["config"]->get_userlistAttributes();
$temp_array = explode(";", $attr_string);
$hash_table = $_SESSION["ldap"]->attributeUserArray();
@ -103,7 +102,6 @@ if (!$sortattrib)
if ($_POST['usr_suffix']) $usr_suffix = $_POST['usr_suffix']; // new suffix selected via combobox
elseif ($_SESSION['usr_suffix']) $usr_suffix = $_SESSION['usr_suffix']; // old suffix from session
else $usr_suffix = $_SESSION["config"]->get_UserSuffix(); // default suffix
session_register('usr_suffix');
// generate search filter for sort links
@ -138,27 +136,29 @@ $filter = $filter . ")";
// read entries only from ldap server if not yet stored in session or if refresh
// button is pressed or if filter is applied
if ($_SESSION["userlist"] && $_GET["norefresh"]) {
usort ($_SESSION["userlist"], "cmp_array");
$userinfo = $_SESSION["userlist"];
} else {
$attrs = $attr_array;
$sr = @ldap_search($_SESSION["ldap"]->server(),
$usr_suffix,
$filter, $attrs);
if ($sr) {
$userinfo = ldap_get_entries ($_SESSION["ldap"]->server, $sr);
ldap_free_result ($sr);
if ($userinfo["count"] == 0) StatusMessage("WARN", "", _("No Users found!"));
// delete first array entry which is "count"
array_shift($userinfo);
usort ($userinfo, "cmp_array");
$_SESSION["userlist"] = $userinfo;
}
else
StatusMessage("ERROR",
_("LDAP Search failed! Please check your preferences."),
_("No Users found!"));
usort ($_SESSION["userlist"], "cmp_array");
$userinfo = $_SESSION["userlist"];
}
else {
$attrs = $attr_array;
$sr = @ldap_search($_SESSION["ldap"]->server(), $usr_suffix, $filter, $attrs);
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), "See README.openldap to solve this problem.");
}
if ($sr) {
$userinfo = ldap_get_entries ($_SESSION["ldap"]->server, $sr);
ldap_free_result ($sr);
if ($userinfo["count"] == 0) StatusMessage("WARN", "", _("No Users found!"));
// delete first array entry which is "count"
array_shift($userinfo);
usort ($userinfo, "cmp_array");
$_SESSION["userlist"] = $userinfo;
}
else {
StatusMessage("ERROR",
_("LDAP Search failed! Please check your preferences."),
_("No Users found!"));
}
}
$user_count = sizeof ($_SESSION["userlist"]);
@ -325,4 +325,8 @@ function cmp_array($a, $b) {
else return -1;
}
// save variables to session
$_SESSION['usr_units'] = $usr_units;
$_SESSION['usr_suffix'] = $usr_suffix;
?>