Esempio n. 1
0
function add_service($name, $triggerid, $algorithm, $showsla, $goodsla, $sortorder, $service_times = array(), $parentid, $childs)
{
    foreach ($childs as $id => $child) {
        //add childs
        if (bccomp($parentid, $child['serviceid']) == 0) {
            error('Service can\'t be parent and child in onetime.');
            return FALSE;
        }
    }
    if (is_null($triggerid) || $triggerid == 0) {
        $triggerid = 'NULL';
    }
    $serviceid = get_dbid("services", "serviceid");
    remove_service_links($serviceid);
    //removes all links with current serviceid
    $result = $parentid != 0 ? add_service_link($serviceid, $parentid, 0) : true;
    //add parent
    foreach ($childs as $id => $child) {
        //add childs
        if (!isset($child['soft']) || empty($child['soft'])) {
            $child['soft'] = 0;
        }
        $result = add_service_link($child['serviceid'], $serviceid, $child['soft']);
    }
    if (!$result) {
        return FALSE;
    }
    $result = DBexecute('INSERT INTO services (serviceid,name,status,triggerid,algorithm,showsla,goodsla,sortorder)' . ' VALUES (' . $serviceid . ',' . zbx_dbstr($name) . ',0 ,' . $triggerid . ' ,' . zbx_dbstr($algorithm) . ' ,' . $showsla . ',' . zbx_dbstr($goodsla) . ',' . $sortorder . ')');
    if (!$result) {
        return FALSE;
    }
    update_services_status_all();
    // updating status to all services by the dependency
    DBExecute('DELETE FROM services_times WHERE serviceid=' . $serviceid);
    foreach ($service_times as $val) {
        $timeid = get_dbid('services_times', 'timeid');
        $result = DBexecute('INSERT INTO services_times (timeid, serviceid, type, ts_from, ts_to, note)' . ' values (' . $timeid . ',' . $serviceid . ',' . $val['type'] . ',' . $val['from'] . ',' . $val['to'] . ',' . zbx_dbstr($val['note']) . ')');
        if (!$result) {
            delete_service($serviceid);
            return FALSE;
        }
    }
    return $serviceid;
}
Esempio n. 2
0
<?php

/*
 * LibreNMS
 *
 * Copyright (c) 2016 Aaron Daniels <*****@*****.**>
 *
 * 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 3 of the License, or (at your
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
if (is_admin() === false) {
    $status = array('status' => 1, 'message' => 'ERROR: You need to be admin to delete services');
} else {
    if (!is_numeric($vars['service_id'])) {
        $status = array('status' => 1, 'message' => 'No Service has been selected');
    } else {
        if (delete_service($vars['service_id'])) {
            $status = array('status' => 0, 'message' => 'Service: <i>' . $vars['service_id'] . ', has been deleted.</i>');
        } else {
            $status = array('status' => 1, 'message' => 'Service: <i>' . $vars['service_id'] . ', has NOT been deleted.</i>');
        }
    }
}
header('Content-Type: application/json');
echo _json_encode($status);
Esempio n. 3
0
function delete_services_by_triggerid($triggerids)
{
    zbx_value2array($triggerids);
    $result = DBselect('SELECT serviceid FROM services WHERE ' . DBcondition('triggerid', $triggerids));
    while ($row = DBfetch($result)) {
        delete_service($row['serviceid']);
    }
    return TRUE;
}
function mokpag_edit_service_form()
{
    echo "<h1>Paslaugos redagavimas</h1><br>";
    if (isset($_POST['save_edit'])) {
        edit_service($_POST['service_id'], $_POST['name'], $_POST['pex_name'], $_POST['desc'], $_POST['price_eu'], $_POST['price_lt']);
        echo '<b>Paslauga sekmingai redaguota!</b>';
        echo "<form action='" . get_admin_url() . "admin.php?page=edit_service' method='POST'>" . "<input type='hidden' name='service_id' value='" . $_POST['service_id'] . "'>" . "<input type='submit' value='GRYZTI I PASLAUGOS REDAGAVIMA'></form><br>";
        echo "<form action='" . get_admin_url() . "admin.php?page=edit_service' method='POST'>" . "<input type='submit' value='GRYZTI I VISU PASLAUGU REDAGAVIMA'></form>";
    } else {
        if (isset($_POST['service_id']) && !isset($_POST['delete_service'])) {
            $service = get_service_by_id($_POST['service_id']);
            echo "Pasirinkta paslauga: <b>" . $service->get_name() . "<br><br>";
            echo '<form action="' . get_admin_url() . 'admin.php?page=edit_service" method="POST">';
            echo '<input type="hidden" name="service_id" value="' . $service->get_service_id() . '">';
            echo 'Pavadinimas (Bus rodomas kaip pagrindinis):<br>';
            echo '<input type="text" name="name" value="' . $service->get_name() . '"><br><br>';
            echo 'PEx Pavadinimas (Bus naudojamas ieskoti privilegiju):<br>';
            echo '<input type="text" name="pex_name" value="' . $service->get_pex_name() . '"><br><br>';
            echo 'Aprasimas:<br>';
            echo '<input type="text" name="desc" value="' . $service->get_desc() . '"><br><br>';
            echo 'Kaina Eurais:<br>';
            echo '<input type="text" name="price_eu" value="' . $service->get_priceEu() . '"><br><br>';
            echo 'Kaina Litais:<br>';
            echo '<input type="text" name="price_lt" value="' . $service->get_priceLt() . '"><br><br>';
            echo '<input type="hidden" name="save_edit" value="1">';
            echo '<input type="submit" value="REDAGUOTI">';
            echo '</form>';
        } else {
            if (isset($_POST['service_id']) && isset($_POST['delete_service'])) {
                delete_service($_POST['service_id']);
                echo "<b>Paslauga istrinta!</b>";
                echo "<form action='" . get_admin_url() . "admin.php?page=edit_service' method='POST'>" . "<input type='submit' value='GRYZTI I VISU PASLAUGU REDAGAVIMA'></form>";
            } else {
                echo "Norint redaguoti paslauga ja pasirinkite:<br><br>";
                gen_service_table();
            }
        }
    }
}
Esempio n. 5
0
function delete_machine($machine)
{
    global $ldapConnection;
    global $hostGroups;
    if (!isset($hostGroups[$machine])) {
        echo "Error, machine {$machine} doesn't exist!\n";
        exit;
    } else {
        if (count($hostGroups[$machine]) != 0) {
            foreach ($hostGroups[$machine] as $service) {
                echo "Deleting {$service} from {$machine}\n";
                delete_service($service, $machine);
            }
        }
        $deleteDN = "ou={$machine},ou=machines,dc=netsoc,dc=dit,dc=ie";
        $deleteResult = ldap_delete($ldapConnection, $deleteDN);
        if ($deleteResult == false) {
            echo "Failed to delete {$deleteDN}\n";
        }
        return $deleteResult;
    }
}
Esempio n. 6
0
check_fields($fields);
//----------------------------------------------------------------------
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY);
if (isset($_REQUEST['serviceid']) && $_REQUEST['serviceid'] > 0) {
    $sql = 'SELECT s.* ' . ' FROM services s ' . ' WHERE (s.triggerid IS NULL OR ' . DBcondition('s.triggerid', $available_triggers) . ') ' . ' AND s.serviceid=' . $_REQUEST['serviceid'];
    if (!($service = DBfetch(DBselect($sql)))) {
        access_deny();
    }
}
/*-------------------------------------------- ACTIONS --------------------------------------------*/
if (isset($_REQUEST['saction'])) {
    $_REQUEST["showsla"] = get_request("showsla", 0);
    $_REQUEST["soft"] = get_request("soft", 0);
    if (isset($_REQUEST["delete"]) && isset($_REQUEST["serviceid"])) {
        $result = delete_service($service["serviceid"]);
        show_messages($result, S_SERVICE_DELETED, S_CANNOT_DELETE_SERVICE);
        add_audit_if($result, AUDIT_ACTION_DELETE, AUDIT_RESOURCE_IT_SERVICE, ' Name [' . $service["name"] . '] id [' . $service['serviceid'] . ']');
        unset($service);
    } else {
        if (isset($_REQUEST["save_service"])) {
            $service_times = get_request('service_times', array());
            $childs = get_request('childs', array());
            $triggerid = isset($_REQUEST["linktrigger"]) ? $_REQUEST["triggerid"] : null;
            DBstart();
            if (isset($service["serviceid"])) {
                $result = update_service($service["serviceid"], $_REQUEST["name"], $triggerid, $_REQUEST["algorithm"], $_REQUEST["showsla"], $_REQUEST["goodsla"], $_REQUEST["sortorder"], $service_times, $_REQUEST['parentid'], $childs);
            } else {
                $result = add_service($_REQUEST["name"], $triggerid, $_REQUEST["algorithm"], $_REQUEST["showsla"], $_REQUEST["goodsla"], $_REQUEST["sortorder"], $service_times, $_REQUEST['parentid'], $childs);
            }
            $result = DBend() ? $result : false;
Esempio n. 7
0
if ($_SESSION['clusterUp'] == 'true' or $_SESSION['clusterUp'] == 'exists') {
    $repcont_count = getRcInfo();
    $service_count = getServiceInfo();
    $node_count = getNodeInfo();
    if (isset($deleteRc)) {
        foreach ($deleteRc as $key => $value) {
            echo "<pre style='background-color: #f5f5f5; border: 0px; color:#337ab7; font-size: 10px;'>";
            delete_rc($value, $_SESSION['imageName'], '/api/v1/namespaces/default/replicationcontrollers/' . $value);
            echo "</pre>";
        }
        $repcont_count = getRcInfo();
    }
    if (isset($deleteService)) {
        foreach ($deleteService as $key => $value) {
            echo "<pre style='background-color: #f5f5f5; border: 0px; color:#337ab7; font-size: 10px;'>";
            delete_service($value, '/api/v1/namespaces/default/services/' . $value);
            echo "</pre>";
        }
        $service_count = getServiceInfo();
    }
    if (isset($podUp)) {
        (int) ($totalPods = $_SESSION['numPods'] += $_POST['numPods']);
        //                                if(!empty($dockerCode)){
        //                                    writeDockerFile($dockerCode);
        //                                   create_docker($docker_name, $app_name);
        //                                    echo 'here';
        //                                }
        //                                echo 'else here';
        //TODO The json ouput doesnt format correctly, cant figure out why
        echo "<pre style='background-color: #f5f5f5; border: 0px; color:#337ab7; font-size: 10px;'>";
        print_r(json_decode(create_rc($_SESSION['podName'], (int) $numPods, $_SESSION['imageName'], '/api/v1/namespaces/default/replicationcontrollers')));
Esempio n. 8
0
require '../../include/easyscp-lib.php';
check_login(__FILE__);
/*******************************************************************************
 * Main program
 */
/**
 * Dispatches the request
 */
// Adds a service port or updates one or more services ports
if (isset($_POST['uaction']) && $_POST['uaction'] != 'reset') {
    add_update_services($_POST['uaction'] == 'add' ? true : false);
    user_goto('settings_ports.php');
}
// Deletes a service port
if (isset($_GET['delete'])) {
    delete_service(clean_input($_GET['delete']));
    user_goto('settings_ports.php');
}
$cfg = EasySCP_Registry::get('Config');
$tpl = EasySCP_TemplateEngine::getInstance();
$template = 'admin/settings_ports.tpl';
show_services($tpl);
// static page messages
$tpl->assign(array('TR_PAGE_TITLE' => tr('EasySCP - Admin/Settings'), 'TR_ACTION' => tr('Action'), 'TR_UDP' => tr('udp'), 'TR_TCP' => tr('tcp'), 'TR_ENABLED' => tr('Yes'), 'TR_DISABLED' => tr('No'), 'TR_APPLY_CHANGES' => tr('Apply changes'), 'TR_SERVERPORTS' => tr('Server ports'), 'TR_SERVICE' => tr('Service'), 'TR_IP' => tr('IP'), 'TR_PORT' => tr('Port'), 'TR_PROTOCOL' => tr('Protocol'), 'TR_SHOW' => tr('Show'), 'TR_ACTION' => tr('Action'), 'TR_DELETE' => tr('Delete'), 'TR_MESSAGE_DELETE' => tr('Are you sure you want to delete %s service port ?', true, '%s'), 'TR_SHOW_UPDATE_SERVICE_PORT' => tr('View / Update service(s) port'), 'TR_ADD_NEW_SERVICE_PORT' => tr('Add new service port'), 'VAL_FOR_SUBMIT_ON_UPDATE' => tr('Update'), 'VAL_FOR_SUBMIT_ON_ADD' => tr('Add'), 'VAL_FOR_SUBMIT_ON_RESET' => tr('Reset')));
gen_admin_mainmenu($tpl, 'admin/main_menu_settings.tpl');
gen_admin_menu($tpl, 'admin/menu_settings.tpl');
gen_page_message($tpl);
if ($cfg->DUMP_GUI_DEBUG) {
    dump_gui_debug($tpl);
}
$tpl->display($template);