fixed several minor problems after code analysis

This commit is contained in:
Roland Gruber 2004-09-14 18:56:41 +00:00
parent 3b47260d69
commit a8ddb13545
9 changed files with 25 additions and 17 deletions

View File

@ -322,7 +322,7 @@ class Cipher_blowfish {
var $_rounds = 16; var $_rounds = 16;
/** Constructor */ /** Constructor */
function Cipher_blowfish($params = null) function Cipher_blowfish()
{ {
} }

View File

@ -224,6 +224,7 @@ class Ldap{
ldap_free_result($sr); ldap_free_result($sr);
return $ret; return $ret;
} }
else return "";
} }
/** /**
@ -301,7 +302,7 @@ class Ldap{
if ($info) { if ($info) {
$this->objectClasses = $info[0]['objectclasses']; $this->objectClasses = $info[0]['objectclasses'];
array_shift($this->objectClasses); array_shift($this->objectClasses);
return true; return;
} }
} }
// if search failed save empty result // if search failed save empty result
@ -357,7 +358,7 @@ class Ldap{
} }
} }
} }
@closedir($h); @closedir($dir);
} }
} }
@ -488,6 +489,7 @@ class Ldap{
elseif ($part_a == max($part_a, $part_b)) return 1; elseif ($part_a == max($part_a, $part_b)) return 1;
else return -1; else return -1;
} }
return -1;
} }
/** /**

View File

@ -59,12 +59,12 @@ function listSort($sort, $attr_array, $info) {
if ($sort != "dn") { if ($sort != "dn") {
// sort by first attribute with name $sort // sort by first attribute with name $sort
if ($a[$sort][0] == $b[$sort][0]) return 0; if ($a[$sort][0] == $b[$sort][0]) return 0;
else if ($a[$sort][0] == max($a[$sort][0], $b[$sort][0])) return 1; elseif ($a[$sort][0] == max($a[$sort][0], $b[$sort][0])) return 1;
else return -1; else return -1;
} }
else { else {
if ($a[$sort] == $b[$sort]) return 0; if ($a[$sort] == $b[$sort]) return 0;
else if ($a[$sort] == max($a[$sort], $b[$sort])) return 1; elseif ($a[$sort] == max($a[$sort], $b[$sort])) return 1;
else return -1; else return -1;
} }
} }

View File

@ -326,6 +326,7 @@ function saveHostProfile($attributes, $profile) {
* Deletes a user profile * Deletes a user profile
* *
* @param string $file name of profile (Without .pru) * @param string $file name of profile (Without .pru)
* @return boolean true if profile was deleted
*/ */
function delUserProfile($file) { function delUserProfile($file) {
if (!$_SESSION['loggedIn'] == true) return false; if (!$_SESSION['loggedIn'] == true) return false;
@ -334,12 +335,14 @@ function delUserProfile($file) {
if (is_file($prof)) { if (is_file($prof)) {
return @unlink($prof); return @unlink($prof);
} }
else return false;
} }
/** /**
* Deletes a group profile * Deletes a group profile
* *
* @param string $file name of profile (Without .prg) * @param string $file name of profile (Without .prg)
* @return boolean true if profile was deleted
*/ */
function delGroupProfile($file) { function delGroupProfile($file) {
if (!$_SESSION['loggedIn'] == true) return false; if (!$_SESSION['loggedIn'] == true) return false;
@ -348,12 +351,14 @@ function delGroupProfile($file) {
if (is_file($prof)) { if (is_file($prof)) {
return @unlink($prof); return @unlink($prof);
} }
else return false;
} }
/** /**
* Deletes a host profile * Deletes a host profile
* *
* @param string $file name of profile (Without .prh) * @param string $file name of profile (Without .prh)
* @return boolean true if profile was deleted
*/ */
function delHostProfile($file) { function delHostProfile($file) {
if (!$_SESSION['loggedIn'] == true) return false; if (!$_SESSION['loggedIn'] == true) return false;
@ -362,6 +367,7 @@ function delHostProfile($file) {
if (is_file($prof)) { if (is_file($prof)) {
return @unlink($prof); return @unlink($prof);
} }
else return false;
} }
?> ?>

View File

@ -89,7 +89,7 @@ echo $_SESSION['header'];
<tr><td style="border-style:none" >&nbsp;</td></tr> <tr><td style="border-style:none" >&nbsp;</td></tr>
<?php <?php
// print message if login was incorrect // print message if login was incorrect
if ($message) { if ($message) { // $message is set by confmain.php (requires conflogin.php then)
echo ("<tr><td style=\"border-style:none\" rowspan=\"2\"></td>" . echo ("<tr><td style=\"border-style:none\" rowspan=\"2\"></td>" .
"<td style=\"border-style:none\" colspan=2 align=\"center\"><b><font color=red>" . $message . "</font></b></td>" . "<td style=\"border-style:none\" colspan=2 align=\"center\"><b><font color=red>" . $message . "</font></b></td>" .
"<td style=\"border-style:none\" rowspan=\"2\"></td></tr>"); "<td style=\"border-style:none\" rowspan=\"2\"></td></tr>");

View File

@ -264,7 +264,7 @@ elseif ($_POST['sub_save']) {
if ($_POST['dom_DN'] != $newDN) { if ($_POST['dom_DN'] != $newDN) {
$success = ldap_rename($_SESSION['ldap']->server(), $_POST['dom_DN'], $RDN, $_POST['dom_suffix'], true); $success = ldap_rename($_SESSION['ldap']->server(), $_POST['dom_DN'], $RDN, $_POST['dom_suffix'], true);
} }
if ($success) StatusMessage("INFO", _("Domain has been modified."), $DN); if ($success) StatusMessage("INFO", _("Domain has been modified."), $_POST['dom_DN']);
else StatusMessage("ERROR", "", _("Failed to modify domain!")); else StatusMessage("ERROR", "", _("Failed to modify domain!"));
} }
// add entry // add entry

View File

@ -135,7 +135,7 @@ echo ("<form action=\"listdomains.php\" 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($dom_info) > 0) {
listDrawNavigationBar(sizeof($dom_info), $max_page_entries, $page, $sort, $searchFilter, "domain", _("%s Samba domain(s) found")); listDrawNavigationBar(sizeof($dom_info), $max_page_entries, $page, $sort, '', "domain", _("%s Samba domain(s) found"));
echo ("<br>\n"); echo ("<br>\n");
} }
@ -185,7 +185,7 @@ 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($dom_info) > 0) {
listDrawNavigationBar(sizeof($dom_info), $max_page_entries, $page, $sort, $searchFilter, "domain", _("%s Samba domain(s) found")); listDrawNavigationBar(sizeof($dom_info), $max_page_entries, $page, $sort, '', "domain", _("%s Samba domain(s) found"));
echo ("<br>\n"); echo ("<br>\n");
} }

View File

@ -110,21 +110,21 @@ else { // input data is valid, save profile
// save profile // save profile
if ($_POST['accounttype'] == "user") { if ($_POST['accounttype'] == "user") {
if (saveUserProfile($options, $_POST['profname'])) { if (saveUserProfile($options, $_POST['profname'])) {
echo StatusMessage("INFO", _("Profile was saved."), $profname); echo StatusMessage("INFO", _("Profile was saved."), $_POST['profname']);
} }
else StatusMessage("ERROR", _("Unable to save profile!"), $profname); else StatusMessage("ERROR", _("Unable to save profile!"), $_POST['profname']);
} }
elseif ($_POST['accounttype'] == "group") { elseif ($_POST['accounttype'] == "group") {
if (saveGroupProfile($options, $_POST['profname'])) { if (saveGroupProfile($options, $_POST['profname'])) {
echo StatusMessage("INFO", _("Profile was saved."), $profname); echo StatusMessage("INFO", _("Profile was saved."), $_POST['profname']);
} }
else StatusMessage("ERROR", _("Unable to save profile!"), $profname); else StatusMessage("ERROR", _("Unable to save profile!"), $_POST['profname']);
} }
elseif ($_POST['accounttype'] == "host") { elseif ($_POST['accounttype'] == "host") {
if (saveHostProfile($options, $_POST['profname'])) { if (saveHostProfile($options, $_POST['profname'])) {
echo StatusMessage("INFO", _("Profile was saved."), $profname); echo StatusMessage("INFO", _("Profile was saved."), $_POST['profname']);
} }
else StatusMessage("ERROR", _("Unable to save profile!"), $profname); else StatusMessage("ERROR", _("Unable to save profile!"), $_POST['profname']);
} }
echo ("<br><p><a href=\"profilemain.php\">" . _("Back to Profile Editor") . "</a></p>"); echo ("<br><p><a href=\"profilemain.php\">" . _("Back to Profile Editor") . "</a></p>");
} }

View File

@ -68,8 +68,8 @@ $options = getProfileOptions($type);
$old_options = array(); $old_options = array();
if ($_GET['edit']) { if ($_GET['edit']) {
if ($type == "user") $old_options = loadUserProfile($_GET['edit']); if ($type == "user") $old_options = loadUserProfile($_GET['edit']);
else if ($type == "group") $old_options = loadGroupProfile($_GET['edit']); elseif ($type == "group") $old_options = loadGroupProfile($_GET['edit']);
else if ($type == "host") $old_options = loadHostProfile($_GET['edit']); elseif ($type == "host") $old_options = loadHostProfile($_GET['edit']);
} }
// display formular // display formular