summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-01-14 14:45:56 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-01-14 14:45:56 +0000
commit8c131d6804ff7f8b8d30ec2405671a14a7ec84f9 (patch)
treec03a1511056dbd3c66f674162006c5b9764620ee /frontends/php/include
parent3ee8a188032fbd4f0d112ba7a7af55e1cfb0e50c (diff)
downloadzabbix-8c131d6804ff7f8b8d30ec2405671a14a7ec84f9.tar.gz
zabbix-8c131d6804ff7f8b8d30ec2405671a14a7ec84f9.tar.xz
zabbix-8c131d6804ff7f8b8d30ec2405671a14a7ec84f9.zip
- [DEV-96] added availability to disable default user "guest" (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5246 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/forms.inc.php22
-rw-r--r--frontends/php/include/locales/en_gb.inc.php5
-rw-r--r--frontends/php/include/page_footer.php2
-rw-r--r--frontends/php/include/page_header.php7
-rw-r--r--frontends/php/include/perm.inc.php15
-rw-r--r--frontends/php/include/users.inc.php33
6 files changed, 52 insertions, 32 deletions
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index ad6b9faf..e8327c45 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -795,7 +795,11 @@
}
else
{
- $frmUser->AddRow(S_PASSWORD, new CButton("change_password", S_CHANGE_PASSWORD));
+ $passwd_but = new CButton("change_password", S_CHANGE_PASSWORD);
+ if($alias == ZBX_GUEST_USER){
+ $passwd_but->AddOption('disabled','disabled');
+ }
+ $frmUser->AddRow(S_PASSWORD, $passwd_but);
}
if($profile==0)
@@ -890,11 +894,17 @@
$frmUser->AddRow(S_URL_AFTER_LOGIN, new CTextBox("url",$url,50));
$frmUser->AddRow(S_SCREEN_REFRESH, new CNumericBox("refresh",$refresh,4));
- $cmbStat = new CComboBox('status',$status);
- $cmbStat->AddItem(USER_STATUS_ENABLED,S_ENABLED);
- $cmbStat->AddItem(USER_STATUS_DISABLED,S_DISABLED);
-
- $frmUser->AddRow(S_STATUS, $cmbStat);
+ if((bccomp($USER_DETAILS['userid'],$userid) == 0)){
+ $frmUser->AddVar('status',USER_STATUS_ENABLED);
+ $frmUser->AddRow(S_STATUS, new CSpan(S_ENABLED,'green'));
+ }
+ else{
+ $cmbStat = new CComboBox('status',$status);
+ $cmbStat->AddItem(USER_STATUS_ENABLED,S_ENABLED);
+ $cmbStat->AddItem(USER_STATUS_DISABLED,S_DISABLED);
+
+ $frmUser->AddRow(S_STATUS, $cmbStat);
+ }
if($profile==0)
{
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index a0906ac9..560dd0f5 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -492,8 +492,9 @@
// Footer
'S_ZABBIX_VER'=> 'ZABBIX 1.5',
- 'S_COPYRIGHT_BY'=> 'Copyright 2001-2007 by ',
+ 'S_COPYRIGHT_BY'=> 'Copyright 2001-2008 by ',
'S_CONNECTED_AS'=> 'Connected as',
+ 'S_NOT_CONNECTED'=> 'Not connected',
'S_SIA_ZABBIX'=> 'SIA Zabbix',
// graph.php
@@ -1268,6 +1269,7 @@
'S_CANNOT_ADD_USER_BOTH_PASSWORDS_MUST'=>'Cannot add user. Both passwords must be equal.',
'S_USER_DELETED'=> 'User deleted',
'S_CANNOT_DELETE_USER'=> 'Cannot delete user',
+ 'S_FOR_GUEST_PASSWORD_MUST_BE_EMPTY'=> 'For guest, password must be empty',
'S_PERMISSION_DELETED'=> 'Permission deleted',
'S_CANNOT_DELETE_PERMISSION'=> 'Cannot delete permission',
'S_PERMISSION_ADDED'=> 'Permission added',
@@ -1282,6 +1284,7 @@
'S_CANNOT_UPDATE_GROUP'=> 'Cannot update group',
'S_GROUP_DELETED'=> 'Group deleted',
'S_CANNOT_DELETE_GROUP'=> 'Cannot delete group',
+ 'S_USER_CANNOT_DISABLE_ITSELF'=> 'User cannot disable itself',
'S_CONFIGURATION_OF_USERS_AND_USER_GROUPS'=>'CONFIGURATION OF USERS AND USER GROUPS',
'S_USER_GROUPS_BIG'=> 'USER GROUPS',
'S_USERS_BIG'=> 'USERS',
diff --git a/frontends/php/include/page_footer.php b/frontends/php/include/page_footer.php
index aef44e5a..48e3fec7 100644
--- a/frontends/php/include/page_footer.php
+++ b/frontends/php/include/page_footer.php
@@ -65,7 +65,7 @@ function zbxCallPostScripts()
"page_footer_l"),
new CCol(array(
new CSpan(SPACE.SPACE."|".SPACE.SPACE,"divider"),
- new CSpan(S_CONNECTED_AS.SPACE."'".$USER_DETAILS["alias"]."'".
+ new CSpan(($USER_DETAILS['userid'] == 0)?S_NOT_CONNECTED:S_CONNECTED_AS.SPACE."'".$USER_DETAILS["alias"]."'".
(ZBX_DISTRIBUTED ? SPACE.S_FROM_SMALL.SPACE."'".$USER_DETAILS["node"]['name']."'" : ''),'footer_sign')
),
"page_footer_r")
diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php
index 562fb54d..a2e3e640 100644
--- a/frontends/php/include/page_header.php
+++ b/frontends/php/include/page_header.php
@@ -402,14 +402,15 @@ COpt::compare_files_with_menu($ZBX_MENU);
$printview = new CLink(S_PRINT, $_SERVER['REQUEST_URI'].(empty($_GET)?'?':'&').'print=1', 'small_font');
$page_header_r_col = array($help,'|', $support,'|',$printview);
- if($USER_DETAILS["alias"] != ZBX_GUEST_USER){
+
+ if($USER_DETAILS["alias"]!=ZBX_GUEST_USER){
$page_header_r_col[] = array("|",
new CLink(S_PROFILE, "profile.php", "small_font"),"|",
new CLink(S_LOGOUT, "index.php?reconnect=1", "small_font"));
} else {
- $page_header_r_col[] = array("|", new CLink(S_LOGIN, "index.php", "small_font"));
+ $page_header_r_col[] = array("|", new CLink(S_LOGIN, "index.php?reconnect=1", "small_font"));
}
-
+
$logo = new CLink(new CImg("images/general/zabbix.png","ZABBIX"),"http://www.zabbix.com");
$logo->SetTarget('_blank');
diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php
index bf1381a7..a0eec67e 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -71,8 +71,10 @@
}
if(!$USER_DETAILS){
- if(!($USER_DETAILS = DBfetch(DBselect("select u.* from users u where u.alias=".zbx_dbstr(ZBX_GUEST_USER).
- " and ".DBin_node('u.userid', $ZBX_LOCALNODEID)))))
+ if(!($USER_DETAILS = DBfetch(DBselect('SELECT u.* FROM users u '.
+ ' WHERE u.alias='.zbx_dbstr(ZBX_GUEST_USER).
+ ' AND '.DBin_node('u.userid', $ZBX_LOCALNODEID).
+ ' AND status='.USER_STATUS_ENABLED))))
{
$missed_user_guest = true;
}
@@ -100,9 +102,14 @@
if(isset($incorrect_session) || isset($missed_user_guest))
{
if(isset($incorrect_session)) $message = "Session was ended, please relogin!";
- else if(isset($missed_user_guest)) $message = "Database corrupted, missed default user 'guest'";
+ else if(isset($missed_user_guest)){
+ $row = DBfetch(DBselect('SELECT count(u.userid) as user_cnt FROM users u'));
+ if(!$row || $row['user_cnt'] == 0){
+ $message = "Table users is empty. Possible database corruption.";
+ }
+ }
- if(!isset($_REQUEST['message'])) $_REQUEST['message'] = $message;
+ if(!isset($_REQUEST['message']) && isset($message)) $_REQUEST['message'] = $message;
include('index.php');
exit;
diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php
index 49bdf322..3bac4b30 100644
--- a/frontends/php/include/users.inc.php
+++ b/frontends/php/include/users.inc.php
@@ -50,10 +50,12 @@
$userid = get_dbid("users","userid");
- $result = DBexecute('insert into users (userid,name,surname,alias,passwd,url,autologout,lang,refresh,type,status)'.
+ $result = DBexecute('insert into users (userid,name,surname,alias,passwd,url,autologout,lang,refresh,type)'.
' values ('.$userid.','.zbx_dbstr($name).','.zbx_dbstr($surname).','.zbx_dbstr($alias).','.
- zbx_dbstr(md5($passwd)).','.zbx_dbstr($url).','.$autologout.','.zbx_dbstr($lang).','.$refresh.','.$user_type.','.$status.')');
-
+ zbx_dbstr(md5($passwd)).','.zbx_dbstr($url).','.$autologout.','.zbx_dbstr($lang).','.$refresh.','.$user_type.')');
+
+ $result &= change_user_status($userid,$status);
+
if($result)
{
DBexecute('delete from users_groups where userid='.$userid);
@@ -98,8 +100,10 @@
$result = DBexecute("update users set name=".zbx_dbstr($name).",surname=".zbx_dbstr($surname).","."alias=".zbx_dbstr($alias).
(isset($passwd) ? (',passwd='.zbx_dbstr(md5($passwd))) : '').
",url=".zbx_dbstr($url).","."autologout=$autologout,lang=".zbx_dbstr($lang).",refresh=$refresh,".
- "type=$user_type,status=$status".
+ "type=$user_type".
" where userid=$userid");
+
+ $result &= change_user_status($userid,$status);
if($result)
{
@@ -150,15 +154,12 @@
# Delete User definition
- function delete_user($userid)
- {
-
- if(DBfetch(DBselect('select * from users where userid='.$userid.' and alias='.zbx_dbstr(ZBX_GUEST_USER))))
- {
- error("Cannot delete user '".ZBX_GUEST_USER."'");
+ function delete_user($userid){
+ if(DBfetch(DBselect('select * from users where userid='.$userid.' and alias='.zbx_dbstr(ZBX_GUEST_USER)))){
+ error(S_CANNOT_DELETE_USER.SPACE."'".ZBX_GUEST_USER."'");
return false;
}
-
+
DBexecute('delete from operations where object='.OPERATION_OBJECT_USER.' and objectid='.$userid);
$result = DBexecute('delete from media where userid='.$userid);
@@ -187,12 +188,10 @@
function change_user_status($userid,$status){
global $USER_DETAILS;
$res = false;
- if(bccomp($USER_DETAILS['userid'],$userid) != 0){
- if(DBfetch(DBselect('select * from users where userid='.$userid.' and alias='.zbx_dbstr(ZBX_GUEST_USER)))){
- error("Cannot disable user '".ZBX_GUEST_USER."'");
- return $res;
- }
-
+ if((bccomp($USER_DETAILS['userid'],$userid) == 0) && ($status==USER_STATUS_DISABLED)){
+ show_error_message(S_USER_CANNOT_DISABLE_ITSELF);
+ }
+ else{
$res = DBexecute('UPDATE users SET status='.$status.' WHERE userid='.zbx_dbstr($userid));
}
return $res;