Example #1
0
			goodsla = ?
			WHERE serviceid = ?
		', $data->name, $data->algorithm, $data->triggerid, $data->showsla, $data->goodsla, $data->id);
        Connection::QueryDatabase($dbh, 'DELETE FROM service_icon WHERE idservice = ?', $data->id);
        if ($data->imageid !== null) {
            Connection::QueryDatabase($dbh, 'INSERT INTO service_icon (idservice,idicon) VALUES (?,?)', $data->id, $data->imageid);
        }
        $dbh->commit();
    } catch (Exception $e) {
        $dbh->rollback();
        Connection::HttpError(500, sprintf(I('Failed to update service with id=%s.<br/>%s'), $data->id, $e->getMessage()));
    }
    header('Content-Type: application/json');
    echo json_encode(array('status' => 'ok'));
    // output status
} else {
    if (isset($_REQUEST['serviceId'])) {
        // --- Query service information. ------------------------------------------
        header('Content-Type: application/json');
        echo json_encode(ServiceTree::GetInfo($dbh, $_REQUEST['serviceId']));
    } else {
        if (isset($_POST['images'])) {
            // --- Query all available images from Zabbix. -----------------------------
            header('Content-Type: application/json');
            echo json_encode(ServiceTree::GetAllImages($dbh));
        } else {
            // --- No request? ---------------------------------------------------------
            Connection::HttpError(400, I('No retrieve/save service request... what are you trying to do?'));
        }
    }
}
Example #2
0
<?php

require_once '__conf.php';
require_once 'inc/Connection.class.php';
require_once 'inc/Install.class.php';
require_once 'inc/ServiceTree.class.php';
session_start();
function_exists('curl_init') or die('cURL module not found.');
$dbh = Connection::GetDatabase();
Install::CheckDbTables($dbh);
$colors = ServiceTree::GetColors($dbh);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<link rel="icon" type="image/x-icon" href="img/favicon.ico"/>
	<?php 
require_once 'i18n/i18n.php';
i18n_set_map('en', $LANG);
?>
	<style type="text/css">
		html,body { height:100%; margin:0; overflow:hidden; }
		body,table,input,select { font:10pt Arial; color:#181818; }
		a { color:#1853AD; }
		a:hover { color:#FE5E00; }
		hr { height:1px; border:0; color:#CCC; background-color:#CCC; }
		div#theBigOne { width:100%; height:100%; background:url('img/serpro.png') no-repeat bottom right; }
		#treeLoading { position:fixed; top:50%; left:50%; margin-top:-75px; margin-left:-75px; }
		/*canvas#treePlot { width:100%; height:100%; }*/
Example #3
0
<?php

session_start();
require 'inc/Connection.class.php';
require 'inc/ServiceTree.class.php';
require_once '__conf.php';
require_once 'i18n/i18n.php';
i18n_set_map('en', $LANG, false);
if (isset($_REQUEST['root'])) {
    // List of root service names.
    $dbh = Connection::GetDatabase();
    header('Content-Type: application/json');
    echo json_encode(ServiceTree::GetRootList($dbh));
} else {
    if (isset($_REQUEST['serviceId']) && $_REQUEST['serviceId'] != '' || isset($_REQUEST['serviceName']) && $_REQUEST['serviceName'] != '') {
        // Build and return the service tree.
        // Service may be queried by its ID or name.
        $dbh = Connection::GetDatabase();
        $serviceId = isset($_REQUEST['serviceId']) && $_REQUEST['serviceId'] != '' ? $_REQUEST['serviceId'] : ServiceTree::GetIdByName($dbh, $_REQUEST['serviceName']);
        // Output JSON data.
        $statusCount = array(0, 0, 0, 0, 0, 0);
        $root = ServiceTree::GetAllToHtml5($dbh, $serviceId, $statusCount);
        header('Content-Type: application/json');
        echo json_encode(array('tree' => $root, 'statusCount' => $statusCount));
    } else {
        Connection::HttpError(400, I('Service tree: no parameters, nothing to query.'));
    }
}