]> git.pld-linux.org Git - packages/nagios.git/blobdiff - nagios-googlemap.patch
- fix spool dir
[packages/nagios.git] / nagios-googlemap.patch
index f61da13286401332707ef5add217eb1b57aa5b36..12cdd1e321f9920183f7e8a65f20162cdedcf65e 100644 (file)
@@ -1,5 +1,5 @@
---- nagios-3.2.0/cgi/statusmap.c       2009-10-22 14:54:22.000000000 +0300
-+++ nagios-3.2.0/cgi/statusmap.c       2009-10-22 16:11:22.450924994 +0300
+--- nagios-3.2.0/cgi/statusmap.c       2009-10-22 18:19:21.913340828 +0300
++++ nagios-3.2.0.googlemap/cgi/statusmap.c     2009-10-22 18:19:06.830007817 +0300
 @@ -27,6 +27,10 @@
   *
   *****************************************************************************/
  #include "../include/config.h"
  #include "../include/common.h"
  #include "../include/objects.h"
-@@ -88,13 +92,29 @@
+@@ -93,13 +97,27 @@
  #define LAYOUT_CIRCULAR                 4
  #define LAYOUT_CIRCULAR_MARKUP          5
  #define LAYOUT_CIRCULAR_BALLOON         6
+-
 +#define LAYOUT_GOOGLEMAP                              7
  
-+/*#define DEBUG 1*/
  typedef struct layer_struct{
        char *layer_name;
        struct layer_struct *next;
@@ -41,7 +40,7 @@
  
  void document_header(int);
  void document_footer(void);
-@@ -112,6 +132,10 @@
+@@ -117,6 +135,10 @@
  void draw_background_image(void);
  void draw_background_extras(void);
  void draw_host_links(void);
  void draw_hosts(void);
  void draw_host_text(char *,int,int);
  void draw_text(char *,int,int,int);
-@@ -333,9 +357,14 @@
+@@ -288,12 +310,11 @@
+       /* initialize macros */
+       init_macros();
+-
+-      document_header(TRUE);
+-
+       /* get authentication information */
+       get_authentication_information(&current_authdata);
++      document_header(TRUE);
++
+       /* display the network map... */
+       display_map();
+@@ -345,9 +366,14 @@
                /* write JavaScript code for popup window */
                write_popup_code();
-+              if ( layout_method == LAYOUT_GOOGLEMAP ) 
++              if (layout_method == LAYOUT_GOOGLEMAP)
 +                      write_google_head_code();
  
                printf("</head>\n");
                
--              printf("<body CLASS='statusmap' name='mappage' id='mappage'>\n");
-+              if ( layout_method == LAYOUT_GOOGLEMAP ) { 
++              if (layout_method == LAYOUT_GOOGLEMAP) {
 +                      printf("<body onload='load()' onunload='GUnload()' CLASS='statusmap' name='mappage' id='mappage'>\n");
 +              } else 
-+                      printf("<body CLASS='statusmap' name='mappage' id='mappage'>\n");
+               printf("<body CLASS='statusmap' name='mappage' id='mappage'>\n");
  
                /* include user SSI header */
-               include_ssi_files(STATUSMAP_CGI,SSI_HEADER);
-@@ -703,7 +732,7 @@
+@@ -703,7 +729,7 @@
                /* right hand column of top row */
                printf("<td align=right valign=top>\n");
  
@@ -77,7 +90,7 @@
                printf("<table border=0 CLASS='optBox'>\n");
                printf("<tr><td valign=top>\n");
                printf("<input type='hidden' name='host' value='%s'>\n",escape_string(host_name));
-@@ -717,6 +746,7 @@
+@@ -725,6 +751,7 @@
                printf("<option value=%d %s>Circular\n",LAYOUT_CIRCULAR,(layout_method==LAYOUT_CIRCULAR)?"selected":"");
                printf("<option value=%d %s>Circular (Marked Up)\n",LAYOUT_CIRCULAR_MARKUP,(layout_method==LAYOUT_CIRCULAR_MARKUP)?"selected":"");
                printf("<option value=%d %s>Circular (Balloon)\n",LAYOUT_CIRCULAR_BALLOON,(layout_method==LAYOUT_CIRCULAR_BALLOON)?"selected":"");
@@ -85,7 +98,7 @@
                printf("</select>\n");
                printf("</td>\n");
                printf("<td CLASS='optBoxItem'>\n");
-@@ -794,6 +824,11 @@
+@@ -821,6 +848,11 @@
        /* display page header */
        display_page_header();
  
        initialize_graphics();
        draw_background_image();
        draw_background_extras();
-@@ -848,6 +883,13 @@
-   
-       /******************************/
-+      /***** GOOGLEMAP LAYOUT MODE *****/
-+      /******************************/
-+      if(layout_method==LAYOUT_GOOGLEMAP){
-+                      
-+      }
-+
-+      /******************************/
-       /***** MANUAL LAYOUT MODE *****/
-       /******************************/
-@@ -1535,10 +1577,19 @@
+@@ -1563,10 +1602,19 @@
        return;
          }
  
        host *temp_host;
        int x1, x2;
        int y1, y2;
-@@ -1558,6 +1609,8 @@
+@@ -1586,6 +1634,8 @@
        int translated_x;
        int translated_y;
  
-+      if (layout_method==LAYOUT_GOOGLEMAP)
++      if (layout_method == LAYOUT_GOOGLEMAP)
 +              return;
        
        /* user didn't supply any coordinates for hosts, so display a warning */
        if(coordinates_were_specified==FALSE){
-@@ -2213,6 +2266,301 @@
+@@ -2241,6 +2291,197 @@
  /************************* MISC FUNCTIONS *************************/
  /******************************************************************/
  
-+int check_auth_location_host(char* name)
-+{
-+      int retVal=FALSE;
-+      host *this_host;
-+
-+      //printf("false=%d,true=%d\n",FALSE,TRUE);
-+      this_host=find_host(name);
-+      // printf("this_host=%s\n",this_host->name);
-+      // printf("current_auth=%s\n",&current_authdata);
-+      retVal=is_authorized_for_host(this_host,&current_authdata);
-+      // printf("is_auth=%d\n",retVal);
-+      return retVal;
-+}     
-+
 +char* get_status_code(char* name)
 +{
 +      char* retVal;
 +      char line[1024];        
 +      char key[1024]; 
 +      char value[1024];       
-+      char buf[256]; 
++      char buf[256];
 +      char* filename;
 +      int state = 0;
 +      int counter = 0;
 +                      if ( state == 1 ) {
 +                              if ( strcmp(key,"host_name") == 0) {
 +                                      loc->name=strdup(value);
-+                              } 
++                              }
 +                              if ( strcmp(key,"notes") == 0) {
 +                                      loc->note = strdup(value);
 +                              }
 +      }
 +      fclose(fp);
 +
-+      printf("<script src='http://maps.google.com/maps?file=api&amp;v=2&key=%s&amp;sensor=false' type='text/javascript'></script>\n",gen_loc.key);
-+
-+      printf("<script type='text/javascript'>\n"
-+      "//<![CDATA[ \n");
-+
-+      // printf("<script type=javascript src="webbserverfil" />);
-+
-+      printf("function setMapCookie(map) {"
-+              "document.cookie = 'googlemaplng='+map.getCenter().lng();\n"
-+              "document.cookie = 'googlemaplat='+map.getCenter().lat();\n"
-+              "var zoom = map.getZoom();\n"
-+              "document.cookie = 'googlemapzoom='+zoom;\n"
-+              "document.layoutform.scaling_factor.value=+zoom;\n"
-+      "}\n"
-+      
-+      "function readCookie(name) {\n"
-+              "var nameEQ = name + \"=\";\n"
-+              "var ca = document.cookie.split(';');\n"
-+              "for(var i=0;i < ca.length;i++)\n"
-+              "{\n"
-+                      "var c = ca[i];\n"
-+                      "while (c.charAt(0)==' ') c = c.substring(1,c.length);\n"
-+                      "if (c.indexOf(nameEQ) == 0)\n"
-+                      "{\n"
-+                              "c=c.substring(nameEQ.length,c.length);\n"
-+                              "while (c.substring(c.length-1, c.length) == ' ')\n"
-+                                      "c = c.substring(0,c.length-1);\n"
-+                              "return c;\n"
-+                      "}\n"
-+              "}\n"
-+              "return null;\n"
-+      "}\n"
-+
-+      "function createMarker(hostname, comment, lat, long, state) {\n"
-+      " var point = new GLatLng(lat,long);\n"
-+      "var marker;\n"
-+      "if ( state==\"Up\" ) {\n"
-+              "var baseIcon = new GIcon();\n"
-+              "baseIcon.shadow = \"../images/shadow.png\";\n"
-+              "baseIcon.iconSize = new GSize(20, 34);\n"
-+              "baseIcon.shadowSize = new GSize(37, 34);\n"
-+              "baseIcon.iconAnchor = new GPoint(9, 34);\n"
-+              "baseIcon.infoWindowAnchor = new GPoint(9, 2);\n"
-+              "baseIcon.infoShadowAnchor = new GPoint(18, 25);\n"
-+              "var okicon = new GIcon(baseIcon);\n"
-+              "okicon.image = \"../images/green.png\";\n"
-+              "marker = new GMarker(point,okicon);\n"
-+      "} else {\n"
-+              "marker = new GMarker(point);\n"
-+      "}\n"
-+              
-+      "GEvent.addListener(marker, \"click\", function() { \n"
-+                                               "marker.openInfoWindowHtml(\"<b>\"+hostname+\"</b><br>\"+comment+\"<br>State: \"+state+\"\");\n"
-+      "});\n"
-+      "return marker;\n"
-+      "}\n"
-+
-+      "function load() {\n"
-+      "if (GBrowserIsCompatible()) {\n"
-+              "var map = new GMap2(document.getElementById(\"map\"));\n"
-+              "map.addControl(new GSmallMapControl());\n"
-+              "map.addControl(new GMapTypeControl());\n"
-+              
-+              "GEvent.addListener(map, \"click\", function () {\n"
-+                      "setMapCookie(map);\n"
-+              "});\n"
-+
-+              "GEvent.addListener(map, \"move\", function () {\n"
-+                      "setMapCookie(map);\n"
-+              "});\n"
-+
-+              "GEvent.addListener(map, \"zoom\", function () {\n"
-+                      "setMapCookie(map);\n"
-+              "});\n"
 +
-+              "var googlemaplat = readCookie('googlemaplat');\n"
-+        "var googlemaplng = readCookie('googlemaplng');\n"
-+
-+              "var centerPoint;\n"
-+              "if(  googlemaplng!=null && googlemaplat!=null ) \n"
-+                      "centerPoint = new GLatLng(googlemaplat,googlemaplng);\n"
-+              "else\n");
-+                      printf("centerPoint = new GLatLng(%s,%s);\n",gen_loc.latitude,gen_loc.longitude);
-+
-+              printf("var zoom = map.getZoom();\n"
-+              "document.layoutform.scaling_factor.value=+zoom;\n");
-+
-+
-+      if ( user_supplied_scaling==TRUE ) 
-+      {
-+              printf("map.setCenter(centerPoint, %2.1f);\n",user_scaling_factor);
-+              printf("document.layoutform.scaling_factor.value=%2.1f;\n",user_scaling_factor);
++      printf("<script type='text/javascript'>\n");
++      printf("gstatusmap = {\n");
++      printf("lat:%s,\n", gen_loc.latitude);
++      printf("lng:%s,\n", gen_loc.longitude);
++      if (user_supplied_scaling==TRUE) {
++              printf("scale: '%2.1f',\n", user_scaling_factor);
 +      } else {
-+              printf("var googlemapzoom = readCookie('googlemapzoom');\n"
-+              "if ( googlemapzoom != null ) \n"
-+              "{\n"
-+                      "map.setCenter(centerPoint,parseInt(googlemapzoom));\n"
-+                      "document.layoutform.scaling_factor.value=googlemapzoom;\n"
-+              "} else\n"
-+              "{\n");
-+              printf("map.setCenter(centerPoint, %s);\n",gen_loc.zoom);
-+                      printf("document.layoutform.scaling_factor.value=%s;\n",gen_loc.zoom);
-+              printf("}\n");
++              printf("scale: '%2.1f',\n", gen_loc.zoom);
 +              user_scaling_factor = atof(gen_loc.zoom);
 +      }
-+                      
++      printf("markers: [\n");
++
 +      loc = loc_list;
 +      while (loc) {
 +              // check if allowed to show hostname first
 +                      free(ptr);
 +
 +      
-+                      printf("map.addOverlay(createMarker('%s','",loc->name);
++                      printf("['%s','",loc->name);
 +                      ptr = loc->note;
 +                      while ((ch = *ptr++)) {
 +                              if (ch == '\'') printf("\\'");
 +                              else printf("%c", ch);
 +                      }
-+                      printf("',%s,%s,'%s'))\n",loc->latitude,loc->longitude,stateinfo);
++                      printf("',%s,%s,'%s'],\n",loc->latitude,loc->longitude,stateinfo);
 +
 +                      loc = loc->next;
 +              }
 +      }
-+                      
-+      printf("}\n"
-+      "}\n"
-+      "//]]>\n"
-+      "</script>\n");
++
++      printf("0], \n");
++      printf("images_url: '%s'\n", url_images_path);
++      printf("};\n");
++      printf("</script>\n");
++
++      printf("<script src='http://maps.google.com/maps?file=api&amp;v=2&key=%s&amp;sensor=false' type='text/javascript'></script>\n",gen_loc.key);
++      printf("<script src='%sgooglemap.js' type='text/javascript'></script>\n", url_images_path);
 +}
  
  /* write JavaScript code an layer for popup window */
This page took 0.039038 seconds and 4 git commands to generate.