summaryrefslogtreecommitdiffstats
path: root/frontends/php/scripts_exec.php
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-10-22 14:26:35 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-10-22 14:26:35 +0000
commit8586918ae51297d8be70ff360a8cac4d58f593eb (patch)
tree0defc400008c8db04b8169b6bf7412a2afc47640 /frontends/php/scripts_exec.php
parenta3881a9c2fbc9e6a58bfeadbccba819979d94937 (diff)
downloadzabbix-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/scripts_exec.php')
-rw-r--r--frontends/php/scripts_exec.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/frontends/php/scripts_exec.php b/frontends/php/scripts_exec.php
new file mode 100644
index 00000000..b96d29cd
--- /dev/null
+++ b/frontends/php/scripts_exec.php
@@ -0,0 +1,69 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2007 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ include_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/scripts.inc.php";
+
+ $page['title'] = "S_SCRIPTS";
+ $page['file'] = 'scripts_exec.php';
+
+ define('ZBX_PAGE_NO_MENU', 1);
+
+include_once "include/page_header.php";
+
+//---------------------------------- CHECKS ------------------------------------
+
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+
+ $fields=array(
+ 'hostid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({execute})'),
+ 'scriptid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({execute})'),
+ 'execute'=> array(T_ZBX_INT, O_OPT, P_ACT, IN('0,1'), null),
+ );
+
+
+check_fields($fields);
+
+if(isset($_REQUEST['execute'])){
+ if($script = get_script_by_scriptid($_REQUEST['scriptid'])){
+ if($script['host_access'] == SCRIPT_HOST_ACCESS_WRITE){
+ $hosts_read_write = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,get_current_nodeid()));
+
+ if(in_array($_REQUEST['hostid'],$hosts_read_write)){
+SDI('WRITE: '.$_REQUEST['scriptid'].' : '.$_REQUEST['hostid']);
+ $result = execute_script($_REQUEST['scriptid'],$_REQUEST['hostid']);
+ }
+ }
+ else{
+ $hosts_read_only = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,get_current_nodeid()));
+
+ if(in_array($_REQUEST['hostid'],$hosts_read_only)){
+SDI('READ: '.$_REQUEST['scriptid'].' : '.$_REQUEST['hostid']);
+ $result = execute_script($_REQUEST['scriptid'],$_REQUEST['hostid']);
+ }
+ }
+ }
+}
+?>
+<?php
+include_once "include/page_footer.php";
+?> \ No newline at end of file