diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-22 14:26:35 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-22 14:26:35 +0000 |
| commit | 8586918ae51297d8be70ff360a8cac4d58f593eb (patch) | |
| tree | 0defc400008c8db04b8169b6bf7412a2afc47640 /frontends/php/include | |
| parent | a3881a9c2fbc9e6a58bfeadbccba819979d94937 (diff) | |
| download | zabbix-8586918ae51297d8be70ff360a8cac4d58f593eb.tar.gz zabbix-8586918ae51297d8be70ff360a8cac4d58f593eb.tar.xz zabbix-8586918ae51297d8be70ff360a8cac4d58f593eb.zip | |
- [DEV-48] merged rev. 4890:4891 of branches/1.4.j/ (Artem) [added scripts form,scripts list, script call menu]
git-svn-id: svn://svn.zabbix.com/trunk@4893 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/defines.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 22 | ||||
| -rw-r--r-- | frontends/php/include/page_header.php | 3 | ||||
| -rw-r--r-- | frontends/php/include/scripts.inc.php | 80 |
4 files changed, 109 insertions, 0 deletions
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 55bf5699..3c7658d1 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -104,6 +104,7 @@ define('AUDIT_RESOURCE_SCENARIO', 22); define('AUDIT_RESOURCE_DISCOVERY_RULE', 23); define('AUDIT_RESOURCE_SLIDESHOW', 24); + define('AUDIT_RESOURCE_SCRIPT', 25); define('CONDITION_TYPE_HOST_GROUP', 0); define('CONDITION_TYPE_HOST', 1); @@ -330,6 +331,9 @@ define('PERM_READ_ONLY', 2); define('PERM_READ_LIST', 1); define('PERM_DENY', 0); + + define('SCRIPT_HOST_ACCESS_READ', 0); + define('SCRIPT_HOST_ACCESS_WRITE', 1); define('PERM_RES_STRING_LINE', 0); /* return string of nodes id - '1,2,3,4,5' */ define('PERM_RES_IDS_ARRAY', 1); /* return array of nodes id - array(1,2,3,4) */ diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 6f1cb3af..fd6d464d 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -1287,6 +1287,27 @@ 'S_DELETE_SELECTED_USERS_Q'=> 'Delete selected users?', 'S_NO_ACCESSIBLE_RESOURCES'=> 'No accessibles resources', +//scripts.php + 'S_SCRIPTS'=> 'Scripts', + 'S_SCRIPT'=> 'Script', + 'S_COMMAND'=> 'Command', + 'S_PERMISSIONS_SMALL'=> 'permissions', + 'S_REQUIRED_HOST'=> 'Required host', + 'S_READ'=> 'Read', + 'S_WRITE'=> 'Write', + 'S_NO_SCRIPTS_DEFINED'=> 'No scripts defined', + 'S_HOST_ACCESS'=> 'Host access', + 'S_DELETE_SELECTED_SCRIPTS_Q'=> 'Delete selected scripts?', + 'S_ADD_SCRIPT'=> 'Add script', + 'S_SCRIPT_ADDED'=> 'Script added', + 'S_CANNOT_ADD_SCRIPT'=> 'Cannot add script', + 'S_SCRIPT_UPDATED'=> 'Script updated', + 'S_CANNOT_UPDATE_SCRIPT'=> 'Cannot update script', + 'S_SCRIPT_DELETED'=> 'Script deleted', + 'S_CANNOT_DELETE_SCRIPT'=> 'Cannot delete script', + 'S_TOOLS'=> 'Tools', + + // audit.php 'S_AUDIT_LOG'=> 'Audit log', 'S_AUDIT_LOG_BIG'=> 'AUDIT LOG', @@ -1300,6 +1321,7 @@ 'S_MEDIA_TYPE'=> 'Media type', 'S_GRAPH_ELEMENT'=> 'Graph element', 'S_UNKNOWN_RESOURCE'=> 'Unknown resource', + 'S_ALREADY_EXISTS_SMALL'=> 'alredy exists', // profile.php 'S_USER_PROFILE_BIG'=> 'USER PROFILE', diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php index 0a633104..bb7772b0 100644 --- a/frontends/php/include/page_header.php +++ b/frontends/php/include/page_header.php @@ -191,6 +191,9 @@ COpt::profiling_start("page"); "popup_usrgrp.php","popup_right.php","popup_users.php") ), array("url"=>"media_types.php" ,"label"=>S_MEDIA_TYPES ), + array("url"=>"scripts.php" ,"label"=>S_SCRIPTS, + "sub_pages"=> array("scripts_exec.php") + ), array("url"=>"audit.php" ,"label"=>S_AUDIT ), array("url"=>"report4.php" ,"label"=>S_NOTIFICATIONS ), array("url"=>"instal.php" ,"label"=>S_INSTALLATION , diff --git a/frontends/php/include/scripts.inc.php b/frontends/php/include/scripts.inc.php new file mode 100644 index 00000000..071b45f9 --- /dev/null +++ b/frontends/php/include/scripts.inc.php @@ -0,0 +1,80 @@ +<?php + +function get_script_by_scriptid($scriptid){ + $sql = 'SELECT * FROM scripts WHERE scriptid='.$scriptid; + + $rows = false; + if($res = DBSelect($sql)){ + $rows = DBfetch($res); + } +return $rows; +} + +function add_script($name,$command,$access){ + $scriptid = get_dbid('scripts','scriptid'); + $sql = 'INSERT INTO scripts (scriptid,name,command,host_access) '. + " VALUES ('$scriptid','$name',".zbx_dbstr($command).",$access)"; + $result = DBexecute($sql); + if($result){ + $result = $scriptid; + } +return $result; +} + +function delete_script($scriptid){ + $sql = 'DELETE FROM scripts WHERE scriptid='.$scriptid; + $result = DBexecute($sql); +return $result; +} + +function update_script($scriptid,$name,$command,$access){ + + $sql = 'UPDATE scripts SET '. + ' name='.zbx_dbstr($name). + ' ,command='.zbx_dbstr($command). + ' ,host_access='.$access. + ' WHERE scriptid='.$scriptid; + + $result = DBexecute($sql); +return $result; +} + +function execute_script($scriptid,$hostid){ +} + +function get_accessible_scripts_by_hosts($hosts){ + global $USER_DETAILS; + + if(!is_array($hosts)){ + $hosts = array('0' => hosts); + } + + $hosts_read_only = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,get_current_nodeid())); + $hosts_read_write = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,get_current_nodeid())); + + $scripts_by_host = array(); + + $sql = 'SELECT * FROM scripts '. + ' WHERE '.DBin_node('scriptid'). + ' ORDER BY scriptid ASC'; + + $res=DBselect($sql); + + while($script = DBfetch($res)){ + foreach($hosts as $id => $hostid){ + if($script['host_access'] == SCRIPT_HOST_ACCESS_WRITE){ + if(in_array($hostid,$hosts_read_write)){ + $scripts_by_host[$hostid][] = $script; + } + } + else{ + if(in_array($hostid,$hosts_read_only)){ + $scripts_by_host[$hostid][] = $script; + } + } + } + } + +return $scripts_by_host; +} +?>
\ No newline at end of file |
