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/scripts.inc.php | |
| 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/scripts.inc.php')
| -rw-r--r-- | frontends/php/include/scripts.inc.php | 80 |
1 files changed, 80 insertions, 0 deletions
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 |
