optimized the 'check_rights()' function

This commit is contained in:
Loïc Chapeaux
2001-08-29 07:43:41 +00:00
parent 9007431f71
commit cddde7052c
2 changed files with 20 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ $Source$
main.php3; sql.php3; tbl_properties.php3; tbl_select.php3; main.php3; sql.php3; tbl_properties.php3; tbl_select.php3;
tbl_replace.php3: the $server variable do not need to be urlencoded (it's tbl_replace.php3: the $server variable do not need to be urlencoded (it's
an integer). an integer).
* user_details.php3: optimized the 'check_rights()' function.
2001-08-28 Lo<4C>c Chapeaux <lolo@phpheaven.net> 2001-08-28 Lo<4C>c Chapeaux <lolo@phpheaven.net>
* lang/galician.inc.php3, select_lang.inc.php3: new Galician lang thanks to * lang/galician.inc.php3, select_lang.inc.php3: new Galician lang thanks to

View File

@@ -2,8 +2,8 @@
/* $Id$*/ /* $Id$*/
require("./grab_globals.inc.php3"); require('./grab_globals.inc.php3');
require("./lib.inc.php3"); require('./lib.inc.php3');
function check_operations() function check_operations()
{ {
@@ -672,15 +672,23 @@ function edit_operations($host, $user)
<?php <?php
} }
/**
* Checks whether the current user is a super-user or not
*
* @return boolean true as soon as the current user is super-user, no return
* else
*
* @access private
*/
function check_rights() function check_rights()
{ {
global $strNoRights; $result = @mysql_query('USE mysql');
if (mysql_error()) {
mysql_die($GLOBALS['strNoRights']);
}
$result = mysql_query("SELECT * FROM mysql.user"); return true;
$rows = @mysql_num_rows($result); } // end of the 'check_rights()' function
if (!isset($rows)) mysql_die($strNoRights);
}
function table_users($host = FALSE, $user = FALSE) function table_users($host = FALSE, $user = FALSE)
@@ -814,7 +822,7 @@ function confirm() {
if(!isset($message)) if(!isset($message))
{ {
include("./header.inc.php3"); include('./header.inc.php3');
} }
else else
{ {
@@ -882,6 +890,6 @@ if (isset($edit) && $edit) { # Edit an user
normal_operations(); normal_operations();
} }
require("./footer.inc.php3"); require('./footer.inc.php3');
?> ?>