Changeset 139

Show
Ignore:
Timestamp:
04/05/08 18:35:40 (5 years ago)
Author:
divagater
Message:

Updated setup.php to support PA 2.x. Added svn:keywords

Location:
trunk
Files:
110 modified

Legend:

Unmodified
Added
Removed
  • trunk/config.php

    • Property svn:keywords set to id
  • trunk/controllers/cacti.php

    • Property svn:keywords set to id
  • trunk/controllers/commands.php

    • Property svn:keywords set to id
  • trunk/controllers/comments.php

    • Property svn:keywords set to id
    r112 r139  
    1212 * @subpackage          npc.controllers 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/controllers/controller.php

    • Property svn:keywords set to id
    r131 r139  
    1010 * @subpackage          npc.controllers 
    1111 * @since               NPC 2.0 
    12  * @version             $Id: $ 
     12 * @version             $Id$ 
    1313 */ 
    1414 
  • trunk/controllers/downtime.php

    • Property svn:keywords set to id
    r107 r139  
    1212 * @subpackage          npc.controllers 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/controllers/hostgroups.php

    • Property svn:keywords set to id
    r97 r139  
    1212 * @subpackage          npc.controllers 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/controllers/hosts.php

    • Property svn:keywords set to id
    r119 r139  
    1212 * @subpackage          npc.controllers 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/controllers/layout.php

    • Property svn:keywords set to id
  • trunk/controllers/layoutDev.php

    • Property svn:keywords set to id
  • trunk/controllers/logentries.php

    • Property svn:keywords set to id
    r97 r139  
    1212 * @subpackage          npc.controllers 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/controllers/nagios.php

    • Property svn:keywords set to id
    r116 r139  
    1414 * @subpackage          npc.controllers 
    1515 * @since               NPC 2.0 
    16  * @version             $Id: $ 
     16 * @version             $Id$ 
    1717 */ 
    1818 
  • trunk/controllers/notifications.php

    • Property svn:keywords set to id
    r97 r139  
    1212 * @subpackage          npc.controllers 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/controllers/servicegroups.php

    • Property svn:keywords set to id
    r97 r139  
    1212 * @subpackage          npc.controllers 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/controllers/services.php

    • Property svn:keywords set to id
    r118 r139  
    1212 * @subpackage          npc.controllers 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/controllers/settings.php

    • Property svn:keywords set to id
    r97 r139  
    1313 * @subpackage          npc.controllers 
    1414 * @since               NPC 2.0 
    15  * @version             $Id: $ 
     15 * @version             $Id$ 
    1616 */ 
    1717 
  • trunk/controllers/statehistory.php

    • Property svn:keywords set to id
    r97 r139  
    1212 * @subpackage          npc.controllers 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/controllers/sync.php

    • Property svn:keywords set to id
    r136 r139  
    1212 * @subpackage          npc.controllers 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/index.php

    • Property svn:keywords set to id
  • trunk/js/src/Portal.js

    • Property svn:keywords set to id
  • trunk/js/src/PortalColumn.js

    • Property svn:keywords set to id
  • trunk/js/src/Portlet.js

    • Property svn:keywords set to id
  • trunk/js/src/monitoring/commandForms.js

    • Property svn:keywords set to id
  • trunk/js/src/monitoring/comments.js

    • Property svn:keywords set to id
  • trunk/js/src/monitoring/downtime.js

    • Property svn:keywords set to id
  • trunk/js/src/monitoring/eventLog.js

    • Property svn:keywords set to id
  • trunk/js/src/monitoring/n2c.js

    • Property svn:keywords set to id
  • trunk/js/src/monitoring/processInfo.js

    • Property svn:keywords set to id
  • trunk/js/src/monitoring/reporting.js

    • Property svn:keywords set to id
  • trunk/js/src/npc.js

    • Property svn:keywords set to id
  • trunk/js/src/overrides/overrides.js

    • Property svn:keywords set to id
  • trunk/js/src/plugins/Ext.state.HttpProvider.js

    • Property svn:keywords set to id
  • trunk/js/src/plugins/Ext.ux.form.XCheckbox.js

    • Property svn:keywords set to id
    r107 r139  
    33  * 
    44  * @author  Ing. Jozef Sakalos 
    5   * @version $Id: Ext.ux.form.XCheckbox.js 704 2008-02-11 04:49:11Z jozo $ 
     5  * @version $Id$ 
    66  * @date    10. February 2008 
    77  * 
  • trunk/js/src/plugins/Ext.ux.grid.Search.js

    • Property svn:keywords set to id
    r107 r139  
    77 * @copyright (c) 2008, by Ing. Jozef Sakalos 
    88 * @date      17. January 2008 
    9  * @version   $Id: Ext.ux.grid.Search.js 634 2008-01-19 17:00:20Z jozo $ 
     9 * @version   $Id$ 
    1010 */ 
    1111 
  • trunk/js/src/portlets/eventlog-portlet.js

    • Property svn:keywords set to id
  • trunk/js/src/portlets/host-problems-portlet.js

    • Property svn:keywords set to id
  • trunk/js/src/portlets/host-summary-portlet.js

    • Property svn:keywords set to id
  • trunk/js/src/portlets/hostgroup-host-status-portlet.js

    • Property svn:keywords set to id
  • trunk/js/src/portlets/hostgroup-service-status-portlet.js

    • Property svn:keywords set to id
  • trunk/js/src/portlets/monitoring-performance-portlet.js

    • Property svn:keywords set to id
  • trunk/js/src/portlets/service-problems-portlet.js

    • Property svn:keywords set to id
  • trunk/js/src/portlets/service-summary-portlet.js

    • Property svn:keywords set to id
  • trunk/js/src/portlets/servicegroup-host-status-portlet.js

    • Property svn:keywords set to id
  • trunk/js/src/portlets/servicegroup-service-status-portlet.js

    • Property svn:keywords set to id
  • trunk/models/NpcAcknowledgements.php

    • Property svn:keywords set to id
  • trunk/models/NpcCommands.php

    • Property svn:keywords set to id
  • trunk/models/NpcCommenthistory.php

    • Property svn:keywords set to id
  • trunk/models/NpcComments.php

    • Property svn:keywords set to id
  • trunk/models/NpcConfigfiles.php

    • Property svn:keywords set to id
  • trunk/models/NpcConfigfilevariables.php

    • Property svn:keywords set to id
  • trunk/models/NpcConninfo.php

    • Property svn:keywords set to id
  • trunk/models/NpcContactAddresses.php

    • Property svn:keywords set to id
  • trunk/models/NpcContactNotificationcommands.php

    • Property svn:keywords set to id
  • trunk/models/NpcContactgroupMembers.php

    • Property svn:keywords set to id
  • trunk/models/NpcContactgroups.php

    • Property svn:keywords set to id
  • trunk/models/NpcContactnotificationmethods.php

    • Property svn:keywords set to id
  • trunk/models/NpcContactnotifications.php

    • Property svn:keywords set to id
  • trunk/models/NpcContacts.php

    • Property svn:keywords set to id
  • trunk/models/NpcContactstatus.php

    • Property svn:keywords set to id
  • trunk/models/NpcCustomvariables.php

    • Property svn:keywords set to id
  • trunk/models/NpcCustomvariablestatus.php

    • Property svn:keywords set to id
  • trunk/models/NpcDbversion.php

    • Property svn:keywords set to id
  • trunk/models/NpcDowntimehistory.php

    • Property svn:keywords set to id
  • trunk/models/NpcEventhandlers.php

    • Property svn:keywords set to id
  • trunk/models/NpcExternalcommands.php

    • Property svn:keywords set to id
  • trunk/models/NpcFlappinghistory.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostContactgroups.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostContacts.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostGraphs.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostParenthosts.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostchecks.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostdependencies.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostescalationContactgroups.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostescalationContacts.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostescalations.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostgroupMembers.php

    • Property svn:keywords set to id
  • trunk/models/NpcHostgroups.php

    • Property svn:keywords set to id
  • trunk/models/NpcHosts.php

    • Property svn:keywords set to id
  • trunk/models/NpcHoststatus.php

    • Property svn:keywords set to id
  • trunk/models/NpcInstances.php

    • Property svn:keywords set to id
  • trunk/models/NpcLogentries.php

    • Property svn:keywords set to id
    r97 r139  
    1212 * @subpackage          npc.models 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/models/NpcNotifications.php

    • Property svn:keywords set to id
  • trunk/models/NpcObjects.php

    • Property svn:keywords set to id
  • trunk/models/NpcProcessevents.php

    • Property svn:keywords set to id
    r97 r139  
    1212 * @subpackage          npc.models 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/models/NpcProgramstatus.php

    • Property svn:keywords set to id
    r97 r139  
    1212 * @subpackage          npc.models 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/models/NpcRuntimevariables.php

    • Property svn:keywords set to id
  • trunk/models/NpcScheduleddowntime.php

    • Property svn:keywords set to id
  • trunk/models/NpcServiceContactgroups.php

    • Property svn:keywords set to id
  • trunk/models/NpcServiceContacts.php

    • Property svn:keywords set to id
  • trunk/models/NpcServiceGraphs.php

    • Property svn:keywords set to id
  • trunk/models/NpcServicechecks.php

    • Property svn:keywords set to id
  • trunk/models/NpcServicedependencies.php

    • Property svn:keywords set to id
  • trunk/models/NpcServiceescalationContactgroups.php

    • Property svn:keywords set to id
  • trunk/models/NpcServiceescalationContacts.php

    • Property svn:keywords set to id
  • trunk/models/NpcServiceescalations.php

    • Property svn:keywords set to id
  • trunk/models/NpcServicegroupMembers.php

    • Property svn:keywords set to id
  • trunk/models/NpcServicegroups.php

    • Property svn:keywords set to id
  • trunk/models/NpcServices.php

    • Property svn:keywords set to id
    r117 r139  
    1212 * @subpackage          npc.models 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/models/NpcServicestatus.php

    • Property svn:keywords set to id
  • trunk/models/NpcSettings.php

    • Property svn:keywords set to id
  • trunk/models/NpcStatehistory.php

    • Property svn:keywords set to id
  • trunk/models/NpcSystemcommands.php

    • Property svn:keywords set to id
  • trunk/models/NpcTimedeventqueue.php

    • Property svn:keywords set to id
  • trunk/models/NpcTimedevents.php

    • Property svn:keywords set to id
  • trunk/models/NpcTimeperiodTimeranges.php

    • Property svn:keywords set to id
  • trunk/models/NpcTimeperiods.php

    • Property svn:keywords set to id
  • trunk/nagioscmd.php

    • Property svn:keywords set to id
    r109 r139  
    1212 * @package             npc 
    1313 * @since               NPC 2.0 
    14  * @version             $Id: $ 
     14 * @version             $Id$ 
    1515 */ 
    1616 
  • trunk/npc.php

    • Property svn:keywords set to id
    r128 r139  
    11<?php 
     2 
     3/* 
     4 +-------------------------------------------------------------------------+ 
     5 | Copyright (C) 2007 Billy Gunn aka divagater  (billy@gunn.org)           | 
     6 |                                                                         | 
     7 | This program is free software; you can redistribute it and/or           | 
     8 | modify it under the terms of the GNU General Public License (GPLv3)     | 
     9 | version 3 as published by the Free Software Foundation.                 | 
     10 |                                                                         | 
     11 | This program is distributed in the hope that it will be useful,         | 
     12 | but WITHOUT ANY WARRANTY; without even the implied warranty of          | 
     13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           | 
     14 | GNU General Public License for more details.                            | 
     15 +-------------------------------------------------------------------------+ 
     16 | Cacti and Nagios are the copyright of their respective owners.          | 
     17 +-------------------------------------------------------------------------+ 
     18*/ 
    219 
    320chdir('../../'); 
  • trunk/perfdata.php

    • Property svn:keywords set to id
  • trunk/setup.php

    • Property svn:keywords set to id
    r132 r139  
    11<?php 
     2/* $Id:$ */ 
    23/* 
    34 +-------------------------------------------------------------------------+ 
     
    2021*/ 
    2122 
    22 function plugin_init_npc() { 
    23     global $plugin_hooks; 
    24     $plugin_hooks['top_header_tabs']['npc'] = 'npc_show_tab'; 
    25     $plugin_hooks['top_graph_header_tabs']['npc'] = 'npc_show_tab'; 
    26     $plugin_hooks['config_arrays']['npc'] = 'npc_config_arrays'; 
    27     $plugin_hooks['draw_navigation_text']['npc'] = 'npc_draw_navigation_text'; 
    28     $plugin_hooks['config_form']['npc'] = 'npc_config_form'; 
    29     $plugin_hooks['api_device_save']['npc'] = 'npc_api_device_save'; 
    30     $plugin_hooks['top_graph_refresh']['npc'] = 'npc_top_graph_refresh'; 
    31     $plugin_hooks['config_settings']['npc'] = 'npc_config_settings'; 
     23/** 
     24 * Called after install 
     25 * 
     26 * if return true, plugin will be installed but disabled 
     27 * if return false, plugin will be waiting configuration 
     28 * 
     29 * @return  bool 
     30 */ 
     31function plugin_npc_check_config () { 
     32    return true; 
    3233} 
    3334 
     35/** 
     36 * compatibility for plugin update 
     37 */ 
    3438function npc_version () { 
     39    return plugin_npc_version (); 
     40} 
     41 
     42/** 
     43 * Version information 
     44 */ 
     45function plugin_npc_version () { 
    3546    return array(   'name'          => 'npc', 
    36                     'version'       => '2.0.0a', 
     47                    'version'       => '2.0.0a-136', 
    3748                    'longname'      => 'Nagios plugin for Cacti', 
    3849                    'author'        => 'Billy Gunn', 
     
    4354} 
    4455 
     56function plugin_npc_install () { 
     57 
     58    npc_setup_tables(); 
     59 
     60    api_plugin_register_realm ('npc', 'npc.php', 'Use NPC', 1); 
     61 
     62    // setup all arrays needed for npc 
     63    api_plugin_register_hook ('npc', 'config_arrays', 'npc_config_arrays', 'setup.php'); 
     64 
     65    // Add the npc tab 
     66    api_plugin_register_hook ('npc', 'top_header_tabs', 'npc_show_tab', 'setup.php'); 
     67    api_plugin_register_hook ('npc', 'top_graph_header_tabs', 'npc_show_tab', 'setup.php'); 
     68 
     69    // Provide navigation texts 
     70    api_plugin_register_hook ('npc', 'draw_navigation_text', 'npc_draw_navigation_text', 'setup.php'); 
     71 
     72    // Add Nagios host mapping select box 
     73    api_plugin_register_hook ('npc', 'config_form', 'npc_config_form', 'setup.php'); 
     74 
     75    // Saves the selection from the host mapping select box 
     76    api_plugin_register_hook ('npc', 'api_device_save', 'npc_api_device_save', 'setup.php'); 
     77 
     78    // Alter the page refresh rate 
     79    api_plugin_register_hook ('npc', 'top_graph_refresh', 'npc_top_graph_refresh', 'setup.php'); 
     80 
     81    // Add a npc tab to the settings page 
     82    api_plugin_register_hook ('npc', 'config_settings', 'npc_config_settings', 'setup.php'); 
     83} 
     84 
     85/** 
     86 * Remove all NPC database changes 
     87 */ 
     88function plugin_npc_uninstall () { 
     89 
     90    // Drop all npc tables 
     91    db_execute("DROP TABLE `npc_acknowledgements`"); 
     92    db_execute("DROP TABLE `npc_commands`"); 
     93    db_execute("DROP TABLE `npc_commenthistory`"); 
     94    db_execute("DROP TABLE `npc_comments`"); 
     95    db_execute("DROP TABLE `npc_configfiles`"); 
     96    db_execute("DROP TABLE `npc_configfilevariables`"); 
     97    db_execute("DROP TABLE `npc_conninfo`"); 
     98    db_execute("DROP TABLE `npc_contact_addresses`"); 
     99    db_execute("DROP TABLE `npc_contact_notificationcommands`"); 
     100    db_execute("DROP TABLE `npc_contactgroup_members`"); 
     101    db_execute("DROP TABLE `npc_contactgroups`"); 
     102    db_execute("DROP TABLE `npc_contactnotificationmethods`"); 
     103    db_execute("DROP TABLE `npc_contactnotifications`"); 
     104    db_execute("DROP TABLE `npc_contacts`"); 
     105    db_execute("DROP TABLE `npc_contactstatus`"); 
     106    db_execute("DROP TABLE `npc_customvariables`"); 
     107    db_execute("DROP TABLE `npc_customvariablestatus`"); 
     108    db_execute("DROP TABLE `npc_dbversion`"); 
     109    db_execute("DROP TABLE `npc_downtimehistory`"); 
     110    db_execute("DROP TABLE `npc_eventhandlers`"); 
     111    db_execute("DROP TABLE `npc_externalcommands`"); 
     112    db_execute("DROP TABLE `npc_flappinghistory`"); 
     113    db_execute("DROP TABLE `npc_host_contactgroups`"); 
     114    db_execute("DROP TABLE `npc_host_contacts`"); 
     115    db_execute("DROP TABLE `npc_host_graphs`"); 
     116    db_execute("DROP TABLE `npc_host_parenthosts`"); 
     117    db_execute("DROP TABLE `npc_hostchecks`"); 
     118    db_execute("DROP TABLE `npc_hostdependencies`"); 
     119    db_execute("DROP TABLE `npc_hostescalation_contactgroups`"); 
     120    db_execute("DROP TABLE `npc_hostescalation_contacts`"); 
     121    db_execute("DROP TABLE `npc_hostescalations`"); 
     122    db_execute("DROP TABLE `npc_hostgroup_members`"); 
     123    db_execute("DROP TABLE `npc_hostgroups`"); 
     124    db_execute("DROP TABLE `npc_hosts`"); 
     125    db_execute("DROP TABLE `npc_hoststatus`"); 
     126    db_execute("DROP TABLE `npc_instances`"); 
     127    db_execute("DROP TABLE `npc_logentries`"); 
     128    db_execute("DROP TABLE `npc_notifications`"); 
     129    db_execute("DROP TABLE `npc_objects`"); 
     130    db_execute("DROP TABLE `npc_processevents`"); 
     131    db_execute("DROP TABLE `npc_programstatus`"); 
     132    db_execute("DROP TABLE `npc_runtimevariables`"); 
     133    db_execute("DROP TABLE `npc_scheduleddowntime`"); 
     134    db_execute("DROP TABLE `npc_service_contactgroups`"); 
     135    db_execute("DROP TABLE `npc_service_contacts`"); 
     136    db_execute("DROP TABLE `npc_service_graphs`"); 
     137    db_execute("DROP TABLE `npc_servicechecks`"); 
     138    db_execute("DROP TABLE `npc_servicedependencies`"); 
     139    db_execute("DROP TABLE `npc_serviceescalation_contactgroups`"); 
     140    db_execute("DROP TABLE `npc_serviceescalation_contacts`"); 
     141    db_execute("DROP TABLE `npc_serviceescalations`"); 
     142    db_execute("DROP TABLE `npc_servicegroup_members`"); 
     143    db_execute("DROP TABLE `npc_servicegroups`"); 
     144    db_execute("DROP TABLE `npc_services`"); 
     145    db_execute("DROP TABLE `npc_servicestatus`"); 
     146    db_execute("DROP TABLE `npc_settings`"); 
     147    db_execute("DROP TABLE `npc_statehistory`"); 
     148    db_execute("DROP TABLE `npc_systemcommands`"); 
     149    db_execute("DROP TABLE `npc_timedeventqueue`"); 
     150    db_execute("DROP TABLE `npc_timedevents`"); 
     151    db_execute("DROP TABLE `npc_timeperiod_timeranges`"); 
     152    db_execute("DROP TABLE `npc_timeperiods`"); 
     153 
     154    db_execute("ALTER TABLE `host` DROP `npc_host_object_id`"); 
     155    db_execute("DELETE FROM `settings` WHERE `name` like 'npc\_%'"); 
     156   
     157    api_plugin_remove_realms ('npc'); 
     158} 
     159 
     160/** 
     161 * Set the page refresh very high 
     162 */ 
    45163function npc_top_graph_refresh() { 
    46     // Don't want to refresh so set very high 
    47164    return('2592000'); 
    48165} 
     
    53170    global $npc_default_settings, $npc_log_level; 
    54171 
    55     $user_auth_realms[32]='View NPC'; 
    56     $user_auth_realm_filenames['npc.php'] = 32; 
    57     $user_auth_realm_filenames['test.php'] = 32; 
    58     $user_auth_realm_filenames['npc_layout.php'] = 32; 
    59     $user_auth_realm_filenames['npc_service_detail.php'] = 32; 
    60  
    61     $npc_log_level = array( 
    62         "0" => "None", 
    63         "1" => "ERROR - Log errors only", 
    64         "2" => "WARN  - Log errors and warnings", 
    65         "3" => "INFO  - Log errors, warnings, and info messages", 
    66         "4" => "DEBUG - Log everything" 
    67     ); 
    68  
    69     $npc_date_format = array( 
    70         "Y-m-d" => "2007-12-27", 
    71         "m-d-Y" => "12-27-2007", 
    72         "d-m-Y" => "27-12-2007", 
    73         "Y/m/d" => "2007/12/27", 
    74         "m/d/Y" => "12/27/2007", 
    75         "d/m/Y" => "27/12/2007", 
    76         "Y.m.d" => "2007.12.27", 
    77         "d.m.Y" => "27.12.2007", 
    78         "m.d.Y" => "12.27.2007" 
    79     ); 
    80  
    81     $npc_time_format = array( 
    82         "H:i:s"  => "23:07", 
    83         "h:i:sa" => "11:07pm", 
    84         "h:i:sA" => "11:07PM", 
    85         "H.i.s"  => "23.07", 
    86         "h.i.sa" => "11.07pm", 
    87         "h.i.sA" => "11.07PM" 
    88     ); 
    89  
    90     $npc_default_settings = array( 
    91         'date_format' => "s%3AY-m-d", 
    92         'time_format' => "s%3AH%3Ai%3As", 
    93  
    94         "serviceProblems" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol1%5Ehidden%3Db%253A0%5Eindex%3Ds%253A0%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
    95         "serviceSummary" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol1%5Ehidden%3Db%253A0%5Eindex%3Ds%253A1%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
    96         "servicegroupServiceStatus" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol1%5Ehidden%3Db%253A0%5Eindex%3Ds%253A2%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
    97         "servicegroupHostStatus" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol1%5Ehidden%3Db%253A0%5Eindex%3Ds%253A3%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
    98         "monitoringPerf" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol1%5Ehidden%3Db%253A1%5Eindex%3Ds%253A4%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
    99  
    100         "hostProblems" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol2%5Ehidden%3Db%253A0%5Eindex%3Ds%253A0%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
    101         "hostSummary" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol2%5Ehidden%3Db%253A0%5Eindex%3Ds%253A1%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
    102         "hostgroupServiceStatus" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol2%5Ehidden%3Db%253A0%5Eindex%3Ds%253A2%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
    103         "hostgroupHostStatus" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol2%5Ehidden%3Db%253A0%5Eindex%3Ds%253A3%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
    104         "eventLog" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol2%5Ehidden%3Db%253A1%5Eindex%3Ds%253A4%5Erefresh%3Dn%253A60%5Erows%3Dn%253A5' 
    105     ); 
    106  
     172      if (isset($_SESSION["sess_user_id"])) { 
     173 
     174        $user_id=$_SESSION["sess_user_id"]; 
     175 
     176        $npc_realm = db_fetch_cell("SELECT id FROM plugin_config WHERE directory = 'npc'"); 
     177        $npc_enabled = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = 'npc'"); 
     178 
     179        if ($npc_enabled == "1") { 
     180 
     181            $user_auth_realm_filenames['npc.php'] = 9000 + $npc_realm; 
     182 
     183            $npc_log_level = array( 
     184                "0" => "None", 
     185                "1" => "ERROR - Log errors only", 
     186                "2" => "WARN  - Log errors and warnings", 
     187                "3" => "INFO  - Log errors, warnings, and info messages", 
     188                "4" => "DEBUG - Log everything" 
     189            ); 
     190 
     191            $npc_date_format = array( 
     192                "Y-m-d" => "2007-12-27", 
     193                "m-d-Y" => "12-27-2007", 
     194                "d-m-Y" => "27-12-2007", 
     195                "Y/m/d" => "2007/12/27", 
     196                "m/d/Y" => "12/27/2007", 
     197                "d/m/Y" => "27/12/2007", 
     198                "Y.m.d" => "2007.12.27", 
     199                "d.m.Y" => "27.12.2007", 
     200                "m.d.Y" => "12.27.2007" 
     201            ); 
     202 
     203            $npc_time_format = array( 
     204                "H:i:s"  => "23:07", 
     205                "h:i:sa" => "11:07pm", 
     206                "h:i:sA" => "11:07PM", 
     207                "H.i.s"  => "23.07", 
     208                "h.i.sa" => "11.07pm", 
     209                "h.i.sA" => "11.07PM" 
     210            );   
     211 
     212            // Initial settings for server side state handling 
     213            $npc_default_settings = array( 
     214                'date_format' => "s%3AY-m-d", 
     215                'time_format' => "s%3AH%3Ai%3As", 
     216 
     217                "serviceProblems" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol1%5Ehidden%3Db%253A0%5Eindex%3Ds%253A0%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
     218                "serviceSummary" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol1%5Ehidden%3Db%253A0%5Eindex%3Ds%253A1%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
     219                "servicegroupServiceStatus" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol1%5Ehidden%3Db%253A0%5Eindex%3Ds%253A2%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
     220                "servicegroupHostStatus" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol1%5Ehidden%3Db%253A0%5Eindex%3Ds%253A3%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
     221                "monitoringPerf" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol1%5Ehidden%3Db%253A1%5Eindex%3Ds%253A4%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
     222 
     223                "hostProblems" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol2%5Ehidden%3Db%253A0%5Eindex%3Ds%253A0%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
     224                "hostSummary" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol2%5Ehidden%3Db%253A0%5Eindex%3Ds%253A1%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
     225                "hostgroupServiceStatus" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol2%5Ehidden%3Db%253A0%5Eindex%3Ds%253A2%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
     226                "hostgroupHostStatus" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol2%5Ehidden%3Db%253A0%5Eindex%3Ds%253A3%5Erefresh%3Dn%253A60%5Erows%3Dn%253A10', 
     227                "eventLog" => 'o%3Acollapsed%3Db%253A0%5Ecolumn%3Ds%253Adashcol2%5Ehidden%3Db%253A1%5Eindex%3Ds%253A4%5Erefresh%3Dn%253A60%5Erows%3Dn%253A5' 
     228            ); 
     229 
     230            api_plugin_load_realms(); 
     231        } 
     232    } 
    107233} 
    108234 
     
    147273} 
    148274 
    149 function npc_setup_table () { 
    150     global $config, $database_default, $npc_default_settings; 
     275function npc_setup_tables() { 
     276    global $config, $database_default; 
    151277 
    152278    include_once($config["library_path"] . "/database.php"); 
     
    13261452    } else { 
    13271453 
    1328         $cUser = db_fetch_assoc('SELECT id FROM user_auth'); 
    1329         $nUser = db_fetch_assoc('SELECT user_id FROM npc_settings'); 
    1330  
    1331         // Add exitsting users to npc_settings 
    1332         for ($i = 0; $i < count($cUser); $i++) { 
    1333             if (!db_fetch_cell('SELECT user_id FROM npc_settings WHERE user_id = ' . $cUser[$i]['id'])) { 
    1334                 db_execute("INSERT INTO npc_settings VALUES(". $cUser[$i]['id'].",'".serialize($npc_default_settings)."')"); 
    1335             } 
    1336         } 
    1337  
    1338         // Delete non existent users from npc_settings 
    1339         for ($i = 0; $i < count($nUser); $i++) { 
    1340             if (isset($nUser[$i]['id']) && !db_fetch_cell('SELECT id FROM user_auth WHERE id = ' . $nUser[$i]['id'])) { 
    1341                 db_execute('DELETE FROM npc_settings WHERE user_id = ' . $nUser[$i]['id']); 
    1342             } 
    1343         } 
    13441454    } 
    13451455 
     
    13521462 
    13531463function npc_show_tab() { 
    1354         global $config; 
    1355         if (api_user_realm_auth('npc.php')) { 
    1356             $cp = false; 
    1357             if (basename($_SERVER["PHP_SELF"]) == "npc.php") 
    1358                 $cp = true; 
    1359  
    1360             print '<a href="' . $config['url_path'] . 'plugins/npc/npc.php"><img src="'  
    1361                   . $config['url_path'] . 'plugins/npc/images/tab_npc'  
    1362                   . ($cp ? "_down": "") . '.gif" alt="npc" align="absmiddle" border="0"></a>'; 
     1464    global $config; 
     1465 
     1466    if (isset($_SESSION["sess_user_id"])) { 
     1467   
     1468        $user_id = $_SESSION["sess_user_id"]; 
     1469 
     1470        $npc_realm = db_fetch_cell("SELECT id FROM plugin_config WHERE directory = 'npc'"); 
     1471        $npc_enabled = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = 'npc'"); 
     1472 
     1473        if ($npc_enabled == "1") { 
     1474            if (api_user_realm_auth('npc.php')) { 
     1475                $cp = false; 
     1476                if (basename($_SERVER["PHP_SELF"]) == "npc.php") { $cp = true; } 
     1477 
     1478                print '<a href="' . $config['url_path'] . 'plugins/npc/npc.php"><img src="'  
     1479                     . $config['url_path'] . 'plugins/npc/images/tab_npc'  
     1480                     . ($cp ? "_down": "") . '.gif" alt="npc" align="absmiddle" border="0"></a>'; 
     1481            } 
    13631482        } 
    1364         npc_check_upgrade (); 
     1483    } 
    13651484} 
    13661485 
    1367 function npc_check_upgrade() { 
    1368     $current = npc_version (); 
    1369     $current = $current['version']; 
    1370     $old = read_config_option('plugin_npc_version'); 
    1371     //if ($current != $old) { 
    1372         npc_setup_table (); 
    1373     //} 
    1374 } 
    1375  
    1376  
    13771486function npc_config_settings() { 
    13781487 
    1379         global $tabs, $settings, $npc_date_format, $npc_time_format, $npc_log_level; 
    1380  
    1381         $tabs["npc"] = " NPC "; 
    1382  
    1383         $settings['npc'] = array( 
     1488    global $tabs, $settings, $npc_date_format, $npc_time_format, $npc_log_level, $npc_default_settings; 
     1489 
     1490    if (isset($_SESSION["sess_user_id"])) { 
     1491   
     1492        $user_id = $_SESSION["sess_user_id"]; 
     1493 
     1494        $npc_realm = db_fetch_cell("SELECT id FROM plugin_config WHERE directory = 'npc'"); 
     1495        $npc_enabled = db_fetch_cell("SELECT status FROM plugin_config WHERE directory = 'npc'"); 
     1496 
     1497        if ($npc_enabled == "1") { 
     1498 
     1499            $tabs["npc"] = " NPC "; 
     1500 
     1501            $cUser = db_fetch_assoc('SELECT id FROM user_auth'); 
     1502            $nUser = db_fetch_assoc('SELECT user_id FROM npc_settings'); 
     1503 
     1504            // Add exitsting users to npc_settings 
     1505            for ($i = 0; $i < count($cUser); $i++) { 
     1506                if (!db_fetch_cell('SELECT user_id FROM npc_settings WHERE user_id = ' . $cUser[$i]['id'])) { 
     1507                    db_execute("INSERT INTO npc_settings VALUES(". $cUser[$i]['id'].",'".serialize($npc_default_settings)."')"); 
     1508                } 
     1509            } 
     1510 
     1511            // Delete non existent users from npc_settings 
     1512            for ($i = 0; $i < count($nUser); $i++) { 
     1513                if (isset($nUser[$i]['id']) && !db_fetch_cell('SELECT id FROM user_auth WHERE id = ' . $nUser[$i]['id'])) { 
     1514                    db_execute('DELETE FROM npc_settings WHERE user_id = ' . $nUser[$i]['id']); 
     1515                } 
     1516            } 
     1517 
     1518            $settings['npc'] = array( 
    13841519                "npc_header" => array( 
    1385                         "friendly_name" => "General Settings", 
    1386                         "method" => "spacer", 
     1520                    "friendly_name" => "General Settings", 
     1521                    "method" => "spacer", 
    13871522                ), 
    13881523                "npc_nagios_commands" => array( 
    1389                         "friendly_name" => "Remote Commands", 
    1390                         "description" => "Allow commands to be written to the Nagios command file.", 
    1391                         "method" => "checkbox", 
     1524                    "friendly_name" => "Remote Commands", 
     1525                    "description" => "Allow commands to be written to the Nagios command file.", 
     1526                    "method" => "checkbox", 
    13921527                ), 
    13931528                "npc_nagios_cmd_path" => array( 
    1394                         "friendly_name" => "Nagios Command File Path", 
    1395                         "description" => "The path to the Nagios command file (nagios.cmd).", 
    1396                         "method" => "textbox", 
    1397                         "max_length" => 255, 
    1398                 ), 
     1529                    "friendly_name" => "Nagios Command File Path", 
     1530                    "description" => "The path to the Nagios command file (nagios.cmd).", 
     1531                    "method" => "textbox", 
     1532                    "max_length" => 255, 
     1533                ),   
    13991534                "npc_nagios_url" => array( 
    1400                         "friendly_name" => "Nagios URL", 
    1401                         "description" => "The full URL to your Nagios installation (http://nagios.company.com/nagios/)", 
    1402                         "method" => "textbox", 
    1403                         "max_length" => 255, 
     1535                    "friendly_name" => "Nagios URL", 
     1536                    "description" => "The full URL to your Nagios installation (http://nagios.company.com/nagios/)", 
     1537                    "method" => "textbox", 
     1538                    "max_length" => 255, 
    14041539                ), 
    14051540                "npc_date_format" => array( 
     
    14181553                ), 
    14191554                "npc_logging_header" => array( 
    1420                         "friendly_name" => "Logging", 
    1421                         "method" => "spacer", 
     1555                    "friendly_name" => "Logging", 
     1556                    "method" => "spacer", 
    14221557                ), 
    14231558                "npc_log_level" => array( 
     
    14281563                    "array" => $npc_log_level, 
    14291564                ) 
    1430         ); 
     1565            ); 
     1566        } 
     1567    } 
    14311568} 
    14321569