/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
function discover_service($device, $service)
{
    if (!dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE `service_type`= ? AND `device_id` = ?", array($service, $device['device_id']))) {
        add_service($device, $service, "(自动发现) {$service}");
        log_event("自动发现服务: 类型 {$service}", $device, 'service');
        echo "+";
    }
    echo "{$service} ";
}
Example #2
0
function discover_service($device, $service)
{
    if (!dbFetchCell('SELECT COUNT(service_id) FROM `services` WHERE `service_type`= ? AND `device_id` = ?', array($service, $device['device_id']))) {
        add_service($device, $service, "(Auto discovered) {$service}");
        log_event('Autodiscovered service: type ' . mres($service), $device, 'service');
        echo '+';
    }
    echo "{$service} ";
}
Example #3
0
function Draw_Page($Page_Type)
{
    // Read only pages - these pages don't strictly require user authentication.
    // Therefore, to enable permit-all page viewing, comment out the call
    // to rejectIfNotAuthenticated() in the relevant case block. Note, some of
    // these pages will replace sensitive info such as telephone/email with
    // the string 'PROTECTED'
    // ************************************************************************
    switch ($Page_Type) {
        case "default":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/start_page.php';
            startPage();
            break;
        case "View_Service_Endpoint":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/view_service_endpoint.php';
            view_endpoint();
            break;
        case "Service_Groups":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/view_all.php';
            showAllServiceGroups();
            break;
        case "Service_Group":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/view_sgroup.php';
            showServiceGroup();
            break;
        case "Site":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/site/view_site.php';
            view_site();
            break;
        case "NGI":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/ngi/view_ngi.php';
            view_ngi();
            break;
        case "Service":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/view_service.php';
            view_se();
            break;
        case "Services":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/view_all.php';
            drawSEs();
            break;
        case "NGIs":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/ngi/view_ngis.php';
            view_ngis();
            break;
        case "Sites":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/site/view_all.php';
            showAllSites();
            break;
        case "Projects":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/project/view_all.php';
            show_all_projects();
            break;
        case "Project":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/project/view_project.php';
            show_project();
            break;
        case "Scope_Help":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/scope_help.php';
            show_help();
            break;
        case "Site_Geo_xml":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/sitesForGoogleMapXML.php';
            show_xml();
            break;
        case "Error_Redirect":
            //rejectIfNotAuthenticated();
            show_view('error.php', $_REQUEST['error']);
            break;
        case "Static_HTML":
            //rejectIfNotAuthenticated();
            Draw_Static_HTML();
            break;
        case "Search":
            //rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/search.php';
            search();
            break;
            // CrUD Pages - These pages MUST have authentication enabled so
            // the calls to rejectIfNotAuthenticated() must be used.
            // *********************************************************************
        // CrUD Pages - These pages MUST have authentication enabled so
        // the calls to rejectIfNotAuthenticated() must be used.
        // *********************************************************************
        case "Revoke_Role":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/political_role/revoke_request.php';
            view_revoke_request();
            break;
        case "Accept_Role_Request":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/political_role/accept_request.php';
            view_accept_request();
            break;
        case "Deny_Role_Request":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/political_role/deny_request.php';
            view_deny_request();
            break;
        case "Role_Requests":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/political_role/view_requests.php';
            view_requests();
            break;
        case "Request_Role":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/political_role/request_role.php';
            request_role();
            break;
        case "Edit_Site":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/site/edit_site.php';
            edit_site();
            break;
        case "Edit_Service":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/edit_service.php';
            edit_service();
            break;
        case "SE_Downtimes":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/se_downtimes.php';
            se_downtimes();
            break;
        case "Add_Service":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/add_service.php';
            add_service();
            break;
        case "Add_Service_Endpoint":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/add_service_endpoint.php';
            add_service_endpoint();
            break;
        case "Delete_Service":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/delete_service.php';
            delete();
            break;
        case "Edit_User":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/user/edit_user.php';
            edit_user();
            break;
        case "User":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/user/view_user.php';
            view_user();
            break;
        case "Downtime":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/downtime/view_downtime.php';
            view();
            break;
        case "My_Sites":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/my_sites.php';
            my_sites();
            break;
        case "Edit_NGI":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/ngi/edit_ngi.php';
            edit_ngi();
            break;
        case "Edit_Service_Group":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/edit_service_group.php';
            edit_service_group();
            break;
        case "Add_Service_Group_SEs":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/add_ses.php';
            add_ses();
            break;
        case "Search_SEs":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/search_ses.php';
            search_ses();
            break;
        case "Remove_Service_Group_SEs":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/remove_ses.php';
            remove_ses();
            break;
        case "Add_Site":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/site/add_site.php';
            add_site();
            break;
        case "SGroup_Downtimes":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/view_sgroup_downtimes.php';
            view_sgroup_downtimes();
            break;
        case "Add_Service_Group":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/add_service_group.php';
            add_service_group();
            break;
        case "Site_Downtimes":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/site/site_downtimes.php';
            site_downtimes();
            break;
        case "Register":
            rejectIfNotAuthenticated('Access denied - ' . 'you need to be pre-authenticated before you can register a new account');
            require_once __DIR__ . '/controllers/user/register.php';
            register();
            break;
        case "Add_Downtime":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/downtime/add_downtime.php';
            //require_once __DIR__.'/controllers/downtime/add_downtime_old.php';
            add();
            break;
        case "Edit_Downtime":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/downtime/edit_downtime.php';
            //require_once __DIR__.'/controllers/downtime/edit_downtime_old.php';
            edit();
            break;
        case "End_Downtime":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/downtime/end_downtime.php';
            endDt();
            break;
        case "Downtime_view_endpoint_tree":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/downtime/view_endpoint_tree.php';
            getServiceandEndpointList();
            break;
        case "Edit_Downtime_view_endpoint_tree":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/downtime/view_endpoint_tree.php';
            editDowntimePopulateEndpointTree();
            break;
        case "Downtime_View_Services":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/downtime/view_services.php';
            getSitesServices();
            break;
        case "Delete_Site":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/site/delete_site.php';
            delete();
            break;
        case "Delete_Downtime":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/downtime/delete_downtime.php';
            delete();
            break;
        case "Downtimes_Overview":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/downtime/downtimes_overview.php';
            view();
            break;
        case "Delete_Service_Group":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/delete_service_group.php';
            delete();
            break;
        case "Delete_User":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/user/delete_user.php';
            delete();
            break;
        case "Edit_Certification_Status":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/site/edit_cert_status.php';
            edit();
            break;
        case "Retrieve_Account":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/user/retrieve_account.php';
            retrieve();
            break;
        case "Remove_Project_NGIs":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/project/remove_ngis.php';
            remove_ngis_project();
            break;
        case "Add_Project_NGIs":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/project/add_ngis.php';
            add_ngis_to_project();
            break;
        case "Edit_Project":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/project/edit_project.php';
            edit_project();
            break;
        case "Delete_Project":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/project/delete_project.php';
            delete_project();
            break;
        case "Admin_Move_Site":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/move_site.php';
            move_site();
            break;
        case "Admin_Move_SEP":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/move_service_end_point.php';
            move_service_end_point();
            break;
        case "Admin_Service_Types":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/view_service_types.php';
            show_all();
            break;
        case "Admin_Service_Type":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/view_service_type.php';
            view_service_type();
            break;
        case "Admin_Edit_Service_Type":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/edit_service_type.php';
            edit_type();
            break;
        case "Admin_Add_Service_Type":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/add_service_type.php';
            add_type();
            break;
        case "Admin_Delete_Service_Type":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/delete_service_type.php';
            delete_service_type();
            break;
        case "Admin_Delete_Service_Type_Denied":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/delete_service_type_denied.php';
            deny_delete_type();
            break;
        case "Admin_Add_NGI":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/add_ngi.php';
            add_ngi();
            break;
        case "Admin_Users":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/users.php';
            show_users();
            break;
        case "Admin_Edit_User_DN":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/edit_user_dn.php';
            edit_dn();
            break;
            //        case "Admin_Change_User_Admin_Status":
            //            rejectIfNotAuthenticated();
            //            require_once __DIR__.'/controllers/admin/edit_user_isadmin.php';
            //            make_admin();
            //            break;
        //        case "Admin_Change_User_Admin_Status":
        //            rejectIfNotAuthenticated();
        //            require_once __DIR__.'/controllers/admin/edit_user_isadmin.php';
        //            make_admin();
        //            break;
        case "Admin_Add_Project":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/add_project.php';
            add_project();
            break;
        case "Admin_Scopes":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/scopes.php';
            show_scopes();
            break;
        case "Admin_Remove_Scope":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/delete_scope.php';
            remove_scope();
            break;
        case "Admin_Add_Scope":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/add_scope.php';
            add_scope();
            break;
        case "Admin_Scope":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/scope.php';
            view_scope();
            break;
        case "Admin_Edit_Scope":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/edit_scope.php';
            edit_scope();
            break;
        case "Admin_Delete_NGI":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/admin/delete_ngi.php';
            delete_ngi();
            break;
        case "User_Validate_DN_Change":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/user/retrieve_account_user_validate.php';
            validate_dn_change();
            break;
        case "Add_Site_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/site/add_site_property.php';
            add_site_property();
            break;
        case "Add_Service_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/add_service_property.php';
            add_service_property();
            break;
        case "Add_Endpoint_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/add_endpoint_property.php';
            add_endpoint_property();
            break;
        case "Delete_Site_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/site/delete_site_property.php';
            delete();
            break;
        case "Delete_Service_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/delete_service_property.php';
            delete();
            break;
        case "Delete_Endpoint_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/delete_endpoint_property.php';
            delete();
            break;
        case "Edit_Site_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/site/edit_site_property.php';
            edit_property();
            break;
        case "Edit_Service_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/edit_service_property.php';
            edit_property();
            break;
        case "Edit_Endpoint_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/edit_endpoint_property.php';
            edit_property();
            break;
        case "Add_Service_Group_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/add_service_group_property.php';
            add_service_group_property();
            break;
        case "Edit_Service_Group_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/edit_service_group_property.php';
            edit_property();
            break;
        case "Delete_Service_Group_Property":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service_group/delete_service_group_property.php';
            delete();
            break;
        case "Delete_Service_Endpoint":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/delete_service_endpoint.php';
            delete_endpoint();
            break;
        case "Edit_Service_Endpoint":
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/service/edit_service_endpoint.php';
            edit_endpoint();
            break;
        default:
            // require auth by default
            rejectIfNotAuthenticated();
            require_once __DIR__ . '/controllers/start_page.php';
            startPage();
            break;
    }
}
Example #4
0
function add_host_to_services($hostid, $serviceid)
{
    $result = DBselect('SELECT distinct h.host,t.triggerid,t.description,t.expression ' . ' FROM triggers t,hosts h,items i,functions f ' . ' WHERE h.hostid=' . $hostid . ' AND h.hostid=i.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ' . ' AND ' . DBin_node('t.triggerid', get_current_nodeid(false)));
    while ($row = DBfetch($result)) {
        $serviceid2 = add_service(expand_trigger_description_by_data($row), $row["triggerid"], "on", 0, "off", 99);
        add_service_link($serviceid2, $serviceid, 0);
    }
    return 1;
}
Example #5
0
<?php

if ($_SESSION['userlevel'] < '10') {
    include 'includes/error-no-perm.inc.php';
} else {
    if ($vars['addsrv']) {
        if ($_SESSION['userlevel'] >= '10') {
            $updated = '1';
            $service_id = add_service($vars['device'], $vars['type'], $vars['descr'], $vars['ip'], $vars['params'], 0);
            if ($service_id) {
                $message .= $message_break . 'Service added (' . $service_id . ')!';
                $message_break .= '<br />';
            }
        }
    }
    if ($handle = opendir($config['nagios_plugins'])) {
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..' && !strstr($file, '.') && strstr($file, 'check_')) {
                list(, $check_name) = explode('_', $file, 2);
                $servicesform .= "<option value='{$check_name}'>{$check_name}</option>";
            }
        }
        closedir($handle);
    }
    foreach (dbFetchRows('SELECT * FROM `devices` ORDER BY `hostname`') as $device) {
        $devicesform .= "<option value='" . $device['device_id'] . "'>" . $device['hostname'] . '</option>';
    }
    if ($updated) {
        print_message('Device Settings Saved');
    }
    $pagetitle[] = 'Add service';
Example #6
0
<?php

$updated = '1';
$service_id = add_service(mres($_POST['device']), mres($_POST['type']), mres($_POST['descr']), mres($_POST['ip']), mres($_POST['params']));
if ($service_id) {
    $message .= $message_break . "Service added (" . $service_id . ")!";
    $message_break .= "<br />";
}
	//new serviceMinecraft("Vanilla", 25564, "http://minecraft.d4rk.co", "mc.d4rk.co"),
	//new serviceMinecraft("Bevo Tech Pack", 25565, "http://minecraft.d4rk.co")
);
*/
//I'm experimenting with using objects to track services in funcitons.php
global $services;
function add_service($instances)
{
    global $services;
    foreach ($instances as $instance) {
        $temp_object = new service(array_values($instance)[0], array_values($instance)[1], array_values($instance)[2], array_values($instance)[3]);
        $services[] = $temp_object;
    }
}
foreach ($service_instances as $service_instance) {
    add_service($service_instance);
}
?>
<table class="center">
	<?php 
foreach ($services as $service) {
    ?>
		<tr>
			<td style="text-align: right; padding-right:5px;" class="exoextralight"><?php 
    echo $service->name;
    ?>
</td>
			<td style="text-align: left;"><?php 
    echo $service->makeButton();
    ?>
</td>
    }
    $connectionOptions['password'] = trim($passwordFileData);
}
$ldapConnection = connect_and_bind($connectionOptions);
$hostGroups = get_machines_and_services();
if (isset($options['list'])) {
    display_services();
    exit;
}
if (isset($options['add-service'])) {
    if (!(isset($options['s']) and isset($options['m']))) {
        echo "Error - service name and machine name must be specified!\n";
        exit;
    }
    $force = isset($options['force']) ? true : false;
    $add_service_result = add_service($options['s'], $options['m'], $force);
    if ($add_service_result !== false) {
        echo "dn: cn=" . $options['s'] . ",ou=" . $options['m'] . ",ou=machines,dc=netsoc,dc=dit,dc=ie";
        echo "\nPassword: {$add_service_result}\n";
    }
    exit;
}
if (isset($options['add-machine'])) {
    if (!isset($options['m'])) {
        echo "Error - machine name must be specified!\n";
        exit;
    }
    $add_machine_result = add_machine($options['m']);
    if ($add_machine_result !== false) {
        echo "Machine creation successful!\n";
        echo "dn: ou=" . $options['m'] . ",ou=machines,dc=netsoc,dc=dit,dc=ie\n";
Example #9
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;
         if (isset($serrvice['serviceid'])) {
             show_messages($result, S_SERVICE_UPDATED, S_CANNOT_UPDATE_SERVICE);
             $serviceid = $service["serviceid"];
             $audit_acrion = AUDIT_ACTION_UPDATE;
         } else {
             show_messages($result, S_SERVICE_ADDED, S_CANNOT_ADD_SERVICE);
             $serviceid = $result;
             $audit_acrion = AUDIT_ACTION_ADD;
         }
         add_audit_if($result, $audit_acrion, AUDIT_RESOURCE_IT_SERVICE, ' Name [' . $_REQUEST["name"] . '] id [' . $serviceid . ']');
     } else {
         if (isset($_REQUEST["add_server"])) {
             $sql = 'SELECT h.* ' . ' FROM hosts h ' . ' WHERE ' . DBin_node('h.hostid') . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND h.hostid=' . $_REQUEST["serverid"];
Example #10
0
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
if (is_admin() === false) {
    die('ERROR: You need to be admin');
}
$service_id = $vars['service_id'];
$type = mres($vars['stype']);
$desc = mres($vars['desc']);
$ip = mres($vars['ip']);
$param = mres($vars['param']);
$device_id = mres($vars['device_id']);
if (is_numeric($service_id) && $service_id > 0) {
    // Need to edit.
    $update = array('service_desc' => $desc, 'service_ip' => $ip, 'service_param' => $param);
    if (edit_service($update, $service_id)) {
        $status = array('status' => 0, 'message' => 'Modified Service: <i>' . $service_id . ': ' . $type . '</i>');
    } else {
        $status = array('status' => 1, 'message' => 'ERROR: Failed to modify service: <i>' . $service_id . '</i>');
    }
} else {
    // Need to add.
    $service_id = add_service($device_id, $type, $desc, $ip, $param);
    if ($service_id == false) {
        $status = array('status' => 1, 'message' => 'ERROR: Failed to add Service: <i>' . $type . '</i>');
    } else {
        $status = array('status' => 0, 'message' => 'Added Service: <i>' . $service_id . ': ' . $type . '</i>');
    }
}
header('Content-Type: application/json');
echo _json_encode($status);
Example #11
0
            foreach ($_POST['check_list'] as $selected) {
                if (isset($_POST['check_list'])) {
                    str_replace("green", "checked", $_POST['check_list']);
                }
                $num[$i] = intval($selected);
                $i++;
            }
            $total = array_sum($num);
            $add = $total;
        }
    }
    $qry = "SELECT Email FROM guest ORDER BY ID DESC LIMIT 1";
    $result = mysqli_query($link, $qry) or die(mysql_error());
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        $email = $row['Email'];
        $qry = "INSERT INTO invoice (ID,Email,ExtraExpenses,TotalExpenses,PaymentDate) VALUES (Null,'{$email}','{$add}',NULL, NOW() )";
        mysqli_query($link, $qry);
    }
}
if (isset($_POST['submit'])) {
    add_service();
    echo "<script>window.open('hotel_form.php','_SELF' )</script>";
}
?>
            
            
        </table>

    </form>