From 1e53b1bb164b339f7ca82b3db801d35c96c493d8 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 22 Feb 2005 20:20:47 +0000 Subject: [PATCH] fixed several PHP notices --- lam/lib/account.inc | 8 ++--- lam/lib/ldap.inc | 1 + lam/lib/lists.inc | 22 +++++++------ lam/lib/modules/posixAccount.inc | 2 +- lam/templates/lists/listdomains.php | 29 +++++++++-------- lam/templates/lists/listgroups.php | 20 ++++++------ lam/templates/lists/listhosts.php | 50 +++++++++++++++-------------- lam/templates/lists/listusers.php | 31 +++++++++--------- lam/templates/login.php | 2 +- 9 files changed, 87 insertions(+), 78 deletions(-) diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 09d0a1bc..69dbbbc1 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -356,16 +356,16 @@ function pwd_is_enabled($hash) { if ($sr) { $units = ldap_get_entries($_SESSION['ldap']->server, $sr); // delete count entry - array_shift($units); + unset($units['count']); // extract attributes for ($i = 0; $i < sizeof($units); $i++) { $ret[$i] = new samba3domain(); $ret[$i]->dn = $units[$i]['dn']; $ret[$i]->name = $units[$i]['sambadomainname'][0]; $ret[$i]->SID = $units[$i]['sambasid'][0]; - $ret[$i]->nextRID = $units[$i]['sambanextrid'][0]; - $ret[$i]->nextGroupRID = $units[$i]['sambanextgrouprid'][0]; - $ret[$i]->nextUserRID = $units[$i]['sambanextuserrid'][0]; + if (isset($units[$i]['sambanextrid'][0])) $ret[$i]->nextRID = $units[$i]['sambanextrid'][0]; + if (isset($units[$i]['sambanextgrouprid'][0])) $ret[$i]->nextGroupRID = $units[$i]['sambanextgrouprid'][0]; + if (isset($units[$i]['sambanextuserrid'][0])) $ret[$i]->nextUserRID = $units[$i]['sambanextuserrid'][0]; if (isset($units[$i]['sambaalgorithmicridbase'][0])) $ret[$i]->RIDbase = $units[$i]['sambaalgorithmicridbase'][0]; } // sort array by domain name diff --git a/lam/lib/ldap.inc b/lam/lib/ldap.inc index 38171add..857f6686 100644 --- a/lam/lib/ldap.inc +++ b/lam/lib/ldap.inc @@ -159,6 +159,7 @@ class Ldap{ $sr = @ldap_search($this->server(), $suffix, "objectClass=organizationalunit", array("DN")); if ($sr) { $units = ldap_get_entries($this->server, $sr); + unset($units['count']); // extract Dns for ($i = 0; $i < sizeof($units); $i++) { if ($units[$i]['dn']) $ret[] = $units[$i]['dn']; diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index 99dc2d55..b04c4e43 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -40,7 +40,7 @@ $Id$ function listBuildFilter($post, $attributes) { $filter = array(); for ($i = 0; $i < sizeof($attributes); $i++) { - if (eregi('^([0-9a-z_\\*\\$])+$', $_POST["filter" . strtolower($attributes[$i])])) { + if (isset($_POST["filter" . strtolower($attributes[$i])]) && eregi('^([0-9a-z_\\*\\$])+$', $_POST["filter" . strtolower($attributes[$i])])) { $filter[$attributes[$i]]['original'] = $_POST["filter" . strtolower($attributes[$i])]; $filter[$attributes[$i]]['regex'] = $_POST["filter" . strtolower($attributes[$i])]; // replace special characters @@ -212,11 +212,13 @@ function listPrintTableHeader($scope, $searchFilter, $desc_array, $attr_array, $ echo "\n"; // print input boxes for filters for ($k = 0; $k < sizeof ($desc_array); $k++) { + $value = ""; + if (isset($_POST["filter" . strtolower($attr_array[$k])])) { + $value = " value=\"" . $_POST["filter" . strtolower($attr_array[$k])] . "\""; + } echo ""; - echo (""); + echo (""); echo "\n"; } echo "\n"; @@ -229,14 +231,14 @@ function listPrintTableHeader($scope, $searchFilter, $desc_array, $attr_array, $ */ function listDoPost($scope) { // check if button was pressed and if we have to add/delete an account - if ($_POST['new'] || $_POST['del'] || $_POST['pdf'] || $_POST['pdf_all']){ + if (isset($_POST['new']) || isset($_POST['del']) || isset($_POST['pdf']) || isset($_POST['pdf_all'])){ // add new account - if ($_POST['new']){ + if (isset($_POST['new'])){ metaRefresh("../account/edit.php?type=" . $scope); exit; } // delete account(s) - elseif ($_POST['del']){ + elseif (isset($_POST['del'])){ // search for checkboxes $accounts = array_keys($_POST, "on"); $_SESSION['delete_dn'] = array(); @@ -249,7 +251,7 @@ function listDoPost($scope) { } } // PDF for selected accounts - elseif ($_POST['pdf']){ + elseif (isset($_POST['pdf'])){ $pdf_structure = $_POST['pdf_structure']; // search for checkboxes $accounts = array_keys($_POST, "on"); @@ -266,7 +268,7 @@ function listDoPost($scope) { } } // PDF for all accounts - elseif ($_POST['pdf_all']){ + elseif (isset($_POST['pdf_all'])){ $list = array(); for ($i = 0; $i < sizeof($_SESSION[$scope . 'info']); $i++) { $_SESSION["accountPDF-$i"] = new accountContainer($scope, "accountPDF-$i"); diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 8c97c3b3..2d0bae23 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -317,7 +317,7 @@ class posixAccount extends baseModule { ), 'homeDirectory' => array( "Headline" => _("Home directory"), - "Text" => _("$user and $group are replaced with username or primary groupname.") + "Text" => _('$user and $group are replaced with username or primary groupname.') ), /*'userPassword' =>*/ 'userPassword_no' => array( diff --git a/lam/templates/lists/listdomains.php b/lam/templates/lists/listdomains.php index 392dfac3..b722d419 100644 --- a/lam/templates/lists/listdomains.php +++ b/lam/templates/lists/listdomains.php @@ -47,9 +47,6 @@ setlanguage(); $scope = 'domain'; -// get sorting column when register_globals is off -$sort = $_GET['sort']; - // copy HTTP-GET variables to HTTP-POST $_POST = $_POST + $_GET; @@ -57,14 +54,14 @@ $info = $_SESSION[$scope . 'info']; $dom_units = $_SESSION['dom_units']; // check if button was pressed and if we have to add/delete a domain -if ($_POST['new_domain'] || $_POST['del_domain']){ +if (isset($_POST['new_domain']) || isset($_POST['del_domain'])){ // add new domain - if ($_POST['new_domain']){ + if (isset($_POST['new_domain'])){ metaRefresh("../domain.php?action=new"); exit; } // delete domain(s) - if ($_POST['del_domain']){ + if (isset($_POST['del_domain'])){ // search for checkboxes $domains = array_keys($_POST, "on"); $domainstr = implode(";", $domains); @@ -82,8 +79,9 @@ echo "\n"; echo "\n"; // get current page -$page = $_GET["page"]; -if (!$page) $page = 1; +if (isset($_GET["page"])) $page = $_GET["page"]; +else $page = 1; + // take maximum count of domain entries shown on one page out of session if ($_SESSION["config"]->get_MaxListEntries() <= 0) $max_page_entries = 10; // default setting, if not yet set @@ -101,14 +99,17 @@ $desc_array[] = strtoupper(_("Domain name")); $desc_array[] = strtoupper(_("Domain SID")); $desc_array[] = "DN"; +if (isset($_GET["sort"])) $sort = $_GET["sort"]; +else $sort = strtolower($attr_array[0]); + // check search suffix -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 +if (isset($_POST['dom_suffix'])) $dom_suffix = $_POST['dom_suffix']; // new suffix selected via combobox +elseif (isset($_SESSION['dom_suffix'])) $dom_suffix = $_SESSION['dom_suffix']; // old suffix from session else $dom_suffix = $_SESSION["config"]->get_DomainSuffix(); // default suffix $refresh = true; -if ($_GET['norefresh']) $refresh = false; -if ($_POST['refresh']) $refresh = true; +if (isset($_GET['norefresh'])) $refresh = false; +if (isset($_POST['refresh'])) $refresh = true; if ($refresh) { // configure search filter @@ -194,9 +195,9 @@ listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, '', "domai echo ("
\n"); } -if (! $_GET['norefresh']) { +if ($refresh) { // generate list of possible suffixes -$dom_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_DomainSuffix()); + $dom_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_DomainSuffix()); } // print combobox with possible sub-DNs diff --git a/lam/templates/lists/listgroups.php b/lam/templates/lists/listgroups.php index a5334de6..5b6eb95c 100644 --- a/lam/templates/lists/listgroups.php +++ b/lam/templates/lists/listgroups.php @@ -51,9 +51,6 @@ setlanguage(); $scope = 'group'; -// get sorting column when register_globals is off -$sort = $_GET['sort']; - // copy HTTP-GET variables to HTTP-POST $_POST = $_POST + $_GET; @@ -76,8 +73,9 @@ $temp_array = explode(";", $attr_string); $hash_table = listGetAttributeGroupArray(); // get current page -$page = $_GET["page"]; -if (!$page) $page = 1; +if (isset($_GET["page"])) $page = $_GET["page"]; +else $page = 1; + // take maximum count of group entries shown on one page out of session if ($_SESSION["config"]->get_MaxListEntries() <= 0) $max_page_entries = 10; // default setting, if not yet set @@ -102,14 +100,18 @@ for ($i = 0; $i < sizeof($temp_array); $i++) { } } +// get sorting column +if (isset($_GET["sort"])) $sort = $_GET["sort"]; +else $sort = strtolower($attr_array[0]); + // check search suffix 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 $refresh = true; -if ($_GET['norefresh']) $refresh = false; -if ($_POST['refresh']) $refresh = true; +if (isset($_GET['norefresh'])) $refresh = false; +if (isset($_POST['refresh'])) $refresh = true; if ($refresh) { // configure search filter @@ -180,7 +182,7 @@ if (sizeof($info) > 0) { " onMouseOut=\"group_out(this, '" . $i . "')\"" . " onClick=\"group_click(this, '" . $i . "')\"" . " onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=group&DN=" . $info[$i]['dn'] . "'\">"); - if ($_GET['selectall'] == "yes") { + if (isset($_GET['selectall'])) { echo " "; } @@ -241,7 +243,7 @@ listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFil echo ("
\n"); } -if (! $_GET['norefresh']) { +if ($refresh) { // generate list of possible suffixes $grp_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_GroupSuffix()); } diff --git a/lam/templates/lists/listhosts.php b/lam/templates/lists/listhosts.php index 898e8273..f7802e19 100644 --- a/lam/templates/lists/listhosts.php +++ b/lam/templates/lists/listhosts.php @@ -51,9 +51,6 @@ setlanguage(); $scope = 'host'; -// get sorting column when register_globals is off -$sort = $_GET['sort']; - // copy HTTP-GET variables to HTTP-POST $_POST = $_POST + $_GET; @@ -76,8 +73,9 @@ $temp_array = explode(";", $attr_string); $hash_table = listGetAttributeHostArray(); // get current page -$page = $_GET["page"]; -if (!$page) $page = 1; +if (isset($_GET["page"])) $page = $_GET["page"]; +else $page = 1; + // take maximum count of host entries shown on one page out of session if ($_SESSION["config"]->get_MaxListEntries() <= 0) $max_page_entries = 10; // default setting, if not yet set @@ -86,30 +84,34 @@ else // generate column attributes and descriptions for ($i = 0; $i < sizeof($temp_array); $i++) { -// if value is predifined, look up description in hash_table -if (substr($temp_array[$i],0,1) == "#") { - $attr = strtolower(substr($temp_array[$i],1)); - $attr_array[$i] = $attr; - if ($hash_table[$attr]) $desc_array[] = strtoupper($hash_table[$attr]); - else $desc_array[] = strtoupper($attr); -} -// if not predefined, the attribute is seperated by a ":" from description -else { - $attr = explode(":", $temp_array[$i]); - $attr_array[$i] = $attr[0]; - if ($attr[1]) $desc_array[$i] = strtoupper($attr[1]); - else $desc_array[$i] = strtoupper($attr[0]); -} + // if value is predifined, look up description in hash_table + if (substr($temp_array[$i],0,1) == "#") { + $attr = strtolower(substr($temp_array[$i],1)); + $attr_array[$i] = $attr; + if ($hash_table[$attr]) $desc_array[] = strtoupper($hash_table[$attr]); + else $desc_array[] = strtoupper($attr); + } + // if not predefined, the attribute is seperated by a ":" from description + else { + $attr = explode(":", $temp_array[$i]); + $attr_array[$i] = $attr[0]; + if ($attr[1]) $desc_array[$i] = strtoupper($attr[1]); + else $desc_array[$i] = strtoupper($attr[0]); + } } +// get sorting column +if (isset($_GET["sort"])) $sort = $_GET["sort"]; +else $sort = strtolower($attr_array[0]); + // check search suffix 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 $refresh = true; -if ($_GET['norefresh']) $refresh = false; -if ($_POST['refresh']) $refresh = true; +if (isset($_GET['norefresh'])) $refresh = false; +if (isset($_POST['refresh'])) $refresh = true; if ($refresh) { // configure search filter @@ -180,7 +182,7 @@ if (sizeof($info) > 0) { " onMouseOut=\"host_out(this, '" . $i . "')\"" . " onClick=\"host_click(this, '" . $i . "')\"" . " onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=host&DN=" . $info[$i]['dn'] . "'\">"); - if ($_GET['selectall'] == "yes") { + if (isset($_GET['selectall'])) { echo " "; } @@ -225,9 +227,9 @@ listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFil echo ("
\n"); } -if (! $_GET['norefresh']) { +if ($refresh) { // generate list of possible suffixes -$hst_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_HostSuffix()); + $hst_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_HostSuffix()); } // print combobox with possible sub-DNs diff --git a/lam/templates/lists/listusers.php b/lam/templates/lists/listusers.php index de6771ac..e4ff78e8 100644 --- a/lam/templates/lists/listusers.php +++ b/lam/templates/lists/listusers.php @@ -56,12 +56,17 @@ $scope = 'user'; // copy HTTP-GET variables to HTTP-POST $_POST = $_POST + $_GET; +$refresh = true; +if (isset($_GET['norefresh'])) $refresh = false; +if (isset($_POST['refresh'])) $refresh = true; + // check if primary group should be translated -if ($_POST['trans_primary'] == "on") $trans_primary = "on"; +if (isset($_POST['trans_primary'])) $trans_primary = "on"; else $trans_primary = "off"; -$trans_primary_hash = $_SESSION['trans_primary_hash']; +if (isset($_SESSION['trans_primary_hash'])) $trans_primary_hash = $_SESSION['trans_primary_hash']; +else $trans_primary_hash = array(); // generate hash table for group translation -if ($trans_primary == "on" && !$_GET["norefresh"]) { +if ($trans_primary == "on" && ($refresh || (sizeof($trans_primary_hash) == 0))) { $trans_primary_hash = array(); $suffix = $_SESSION['config']->get_groupSuffix(); $filter = "objectClass=posixGroup"; @@ -90,8 +95,9 @@ echo "\n"; echo "\n"; -$page = $_GET["page"]; -if (!$page) $page = 1; +// get current page +if (isset($_GET["page"])) $page = $_GET["page"]; +else $page = 1; // take maximum count of user entries shown on one page out of session if ($_SESSION["config"]->get_MaxListEntries() <= 0) { @@ -124,9 +130,8 @@ for ($i = 0; $i < sizeof($temp_array); $i++) { } } -$sort = $_GET["sort"]; -if (!$sort) - $sort = strtolower($attr_array[0]); +if (isset($_GET["sort"])) $sort = $_GET["sort"]; +else $sort = strtolower($attr_array[0]); // check search suffix if ($_POST['usr_suffix']) $usr_suffix = $_POST['usr_suffix']; // new suffix selected via combobox @@ -138,10 +143,6 @@ else $usr_suffix = $_SESSION["config"]->get_UserSuffix(); // default suffix $module_filter = get_ldap_filter("user"); // basic filter is provided by modules $filter = "(&" . $module_filter . ")"; -$refresh = true; -if ($_GET['norefresh']) $refresh = false; -if ($_POST['refresh']) $refresh = true; - if ($refresh) { $attrs = $attr_array; $sr = @ldap_search($_SESSION["ldap"]->server(), $usr_suffix, $filter, $attrs); @@ -212,7 +213,7 @@ if ($user_count != 0) { if ($trans_primary == "on") { // translate GIDs for ($i = 0; $i < sizeof($info); $i++) { - if ($trans_primary_hash[$info[$i]['gidnumber'][0]]) { + if (isset($trans_primary_hash[$info[$i]['gidnumber'][0]])) { $info[$i]['gidnumber'][0] = $trans_primary_hash[$info[$i]['gidnumber'][0]]; } } @@ -229,7 +230,7 @@ if ($user_count != 0) { "onClick=\"user_click(this, '" . $i . "')\"\n" . "onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=user&DN=" . $info[$i]['dn'] . "'\">\n"); // checkboxes if selectall = "yes" - if ($_GET['selectall'] == "yes") { + if (isset($_GET['selectall'])) { echo "\n\n\n"; } @@ -275,7 +276,7 @@ if ($user_count != 0) { echo ("
"); } -if (! $_GET['norefresh']) { +if ($refresh) { // generate list of possible suffixes $usr_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_UserSuffix()); } diff --git a/lam/templates/login.php b/lam/templates/login.php index 2dd86b18..f5be3fe2 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -33,7 +33,7 @@ function display_LoginPage($config_object,$profile) global $error_message; // generate 256 bit key and initialization vector for user/passwd-encryption // check if we can use /dev/random otherwise use /dev/urandom or rand() - if(function_exists(mcrypt_create_iv)) { + if(function_exists('mcrypt_create_iv')) { $key = @mcrypt_create_iv(32, MCRYPT_DEV_RANDOM); if (! $key) $key = @mcrypt_create_iv(32, MCRYPT_DEV_URANDOM); if (! $key) {