Changeset 209


Ignore:
Timestamp:
May 6, 2009, 7:37:16 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Zobrazení zařízení a spojů pomocí google maps API.
  • Smazáno: Staré nepoužité soubory.
Location:
trunk
Files:
5 added
6 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/config.sample.php

    r205 r209  
    3535      'Count' => 5,
    3636    ),     
     37    'GoogleMapsApiKey' => '',
    3738  ),
    3839  'Finance' => array
  • trunk/error.php

    r203 r209  
    5050    $err .= "\n";
    5151    //echo('Uvnitř'.$errno);
    52     error_log($err, 3, $Config['Web']['ErrorLogFile']);                         // Ulož do chybového protokolu
     52    if($Config['Web']['ErrorLogFile'] != '')
     53      error_log($err, 3, $Config['Web']['ErrorLogFile']);                               // Ulož do chybového protokolu
    5354          //$err = "Datum: ".$dt."\nHlášení: ".$errmsg."\nSkript: ".$filename."\nŘádek: ".$linenum;
    5455    // mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $err);          // Pošli mi zprávu (pokud je to kritická chyba)
  • trunk/index.php

    r208 r209  
    121121    $TotalUser = $DbRow[0];
    122122
    123     $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(Member)) FROM NetworkDevice LEFT JOIN HostType ON HostType.Id = NetworkDevice.Type WHERE HostType.ShowOnline = 1 AND NetworkDevice.Online = 1');
     123    $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(Member)) FROM NetworkDevice LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDeviceType.ShowOnline = 1 AND NetworkDevice.Online = 1');
    124124    $DbRow = $DbResult->fetch_array();
    125125    $OnlineUser = $DbRow[0];
  • trunk/map/index.php

    r4 r209  
    11<?php
    2 include_once('../style.php');
    3 ShowHeader('Mapa Zdìchova', 'Mapa', 'onload="load()" onunload="GUnload()"');
    4 ?>
    5    
    6     <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAc4xkN_94jkn2t2iN-ZATpxSU_LfcMbvQb2CfcG3YCVl7_yTkCRR3Ey664GMzlmT-I4dZ8VEShvo7Rw"
    7       type="text/javascript"></script>
    8    
    9     <script type="text/javascript">
    10    
    11     //<![CDATA[
     2include_once('../global.php');
    123
    13     function load() {
    14           if (GBrowserIsCompatible()) {
     4class NetworkMap extends Page
     5{
     6  var $FullTitle = 'Mapa sítě';
     7  var $ShortTitle = 'Mapa sítě';
     8  var $Load = 'initialize()';
     9  var $Unload = 'GUnload()';
     10
     11  function Show()
     12  {
     13    global $Config;
     14    $Output = '<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;key='.$Config['Web']['GoogleMapsApiKey'].'"
     15    type="text/javascript">
     16  </script>';
     17    $Output .= '<script type="text/javascript">
     18
     19    function initialize()
     20    {
     21      if (GBrowserIsCompatible())
     22      {
     23        var map = new GMap2(document.getElementById("map_canvas"));
     24        map.setMapType(G_SATELLITE_MAP);
     25        map.setCenter(new GLatLng(49.260422, 18.081179), 15);
     26        map.setUIToDefault();
     27
     28// Create our "tiny" marker icon
     29var tinyIcon = new GIcon();
     30tinyIcon.image = "point.gif";
     31tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
     32tinyIcon.iconSize = new GSize(10, 10);
     33tinyIcon.shadowSize = new GSize(10, 10);
     34tinyIcon.iconAnchor = new GPoint(5, 5);
     35tinyIcon.infoWindowAnchor = new GPoint(5, 1);
     36
     37// Set up our GMarkerOptions object literal
     38markerOptions = { icon:tinyIcon };';
    1539
    1640
    17       var map = new GMap(document.getElementById("map"));
    18       map.addControl(new GLargeMapControl());
    19       map.addControl(new GScaleControl());
    20        //map.setCenter(new GLatLng(37.4419, -122.1419), 13);
    21        
    22 function initArray() {
    23     this.length = initArray.arguments.length;
    24     for (var i = 0; i < this.length; i++)
    25         this[i] = initArray.arguments[i];
    26 }
    27 
    28 function from10toradix(value,radix){
    29     var retval = '';
    30     var ConvArray = new initArray(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F');
    31     var intnum;
    32     var tmpnum;
    33     var i = 0;
    34 
    35     intnum = parseInt(value,10);
    36     if (isNaN(intnum)){
    37         retval = 'NaN';
    38     }else{
    39         while (intnum > 0.9){
    40             i++;
    41             tmpnum = intnum;
    42             // cancatinate return string with new digit:
    43             retval = ConvArray[tmpnum % radix] + retval; 
    44             intnum = Math.floor(tmpnum / radix);
    45             if (i > 100){
    46                 // break infinite loops
    47                 retval = 'NaN';
    48                 break;
    49             }
    50         }
     41    $DbResult = $this->Database->query('SELECT * FROM NetworkDevice');
     42    while($Device = $DbResult->fetch_assoc())
     43    {
     44      $Output .= 'map.addOverlay(new GMarker(new GLatLng('.$Device['PositionLatitude'].', '.$Device['PositionLongitude'].'), markerOptions)); ';
    5145    }
    52     return retval;
    53 }
    54 
    55       // ============================================================
    56       // == We now have to write our own getTileUrl function ========
    57       CustomGetTileUrl=function(a,b)
     46   
     47    $DbResult = $this->Database->query('SELECT * FROM NetworkLink WHERE Interface1 <> 0 AND Interface2 <> 0');
     48    while($Link = $DbResult->fetch_assoc())
     49    {
     50      $DbResult2 = $this->Database->query('SELECT * FROM NetworkDevice WHERE NetworkDevice.Id = (SELECT Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface1'].')');
     51      $DbResult3 = $this->Database->query('SELECT * FROM NetworkDevice WHERE NetworkDevice.Id = (SELECT Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface2'].')');
     52      if(($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))
    5853      {
    59        
    60         k = Math.pow(2, (b-5)) - 1;
    61 
    62         b = b-2;
    63         var c=Math.pow(2, (28-b));
    64         var x = from10toradix((a.x+1)* c - 0x1c000000, 16);
    65         var y = from10toradix(0x1c000000 - (a.y-k) * c, 16);
    66         return "http://mapserver.mapy.cz/ophoto/"+b+"_"+x+"_"+y+"";
     54        $Device1 = $DbResult2->fetch_assoc();
     55        $Device2 = $DbResult3->fetch_assoc();
     56        $Output .= 'map.addOverlay(new GPolyline([new GLatLng('.$Device1['PositionLatitude'].', '.$Device1['PositionLongitude'].'),new GLatLng('.$Device2['PositionLatitude'].', '.$Device2['PositionLongitude'].')], "#FFFFFF", 3, 0.8)); ';
    6757      }
    68 
    69       // ============================================================
    70       // ====== Create a single layer "Old OSS" custom maptype ======
    71       //
    72       // == Create the GTileLayer ==
    73       var tilelayers = [new GTileLayer(new GCopyrightCollection(""),5,18)];
    74       tilelayers[0].getTileUrl = CustomGetTileUrl;
    75       tilelayers[0].getCopyright = function(a,b) {
    76         return {prefix:"Mapové podklady: ", copyrightTexts:[" GEODIS BRNO, s.r.o."]};
    77       }
    78      
    79       // == Create the GMapType, copying most things from G_SATELLITE_MAP ==
    80       var custommap = new GMapType(tilelayers, G_SATELLITE_MAP.getProjection(), "Letecká",{errorMessage:_mMapError});
    81      
    82       // == Add the maptype to the map ==
    83       map.addMapType(custommap);
    84 
    85       // ============================================================
    86       // ====== Create a two layer  "OSS Hybrid" layer ==============
    87 
    88       // === It has two layers one is the "Old OSS" map and the other is the top layer from G_HYBRID_MAP
    89       var htilelayers = [
    90          tilelayers[0],                  // a reference to the tile layer from the first custom map
    91          G_HYBRID_MAP.getTileLayers()[1] // a reference to the upper tile layer fo the hybrid map
    92       ];
    93      
    94       var custommap2 = new GMapType(htilelayers, G_SATELLITE_MAP.getProjection(), "Letecká+", {maxResolution:18,minResolution:1,errorMessage:_mMapError});
    95 
    96       // === Add it to the list of map types ===
    97       map.addMapType(custommap2);
    98 
    99       // ============================================================
    100       map.addControl(new GMapTypeControl());
    101      
    102       map.setCenter(new GLatLng(47.5172, 14.5019), 5, custommap);
    103      
    104       GEvent.addListener(map, "moveend", function() {
    105         var center = map.getCenter();
    106         var b = map.getZoom();
    107         var a = map.getCenter();
    108         document.getElementById("message").innerHTML = center.toString() + CustomGetTileUrl(a, b) + " "+(b-5);
    109       });
    110    }
    111    
    112     // display a warning if the browser was not compatible
    113     else {
    114       alert("Sorry, the Google Maps API is not compatible with this browser");
    11558    }
    116 
    117     // This Javascript is based on code provided by the
    118     // Blackpool Community Church Javascript Team
    119     // http://www.commchurch.freeserve.co.uk/   
    120     // http://www.econym.demon.co.uk/googlemaps/
    121    
     59    $Output .= '   
     60       }     
    12261    }
    123 
    124     //]]>
    125     </script>
    126   <div align="center">
    127     <div id="map" style="width: 800px; height: 500px"></div>
     62    </script>';
     63    $Output .= '<div align="center">
     64    <div id="map_canvas" style="width: 800px; height: 500px;"></div>
    12865    <div id="message"></div>
    12966    <div id="message2"></div>
    130   </div>
     67    </div>';
     68    return($Output);
     69  }
     70}
    13171 
    132 <?php
    133   ShowFooter();
     72$System->AddModule(new NetworkMap());
     73$System->Modules['NetworkMap']->GetOutput();
     74
    13475?>
  • trunk/page.php

    r202 r209  
    107107  }
    108108
    109   function ShowHeader($Title, $Path, $BodyParam = '')
     109  function ShowHeader($Title, $Path)
    110110  {
    111111    $ScriptName = $_SERVER['SCRIPT_NAME'];
     
    138138    $Navigation = substr($Navigation, 0, -6);
    139139
     140    $BodyParam = '';
     141    if(isset($this->Load)) $BodyParam .= ' onload="'.$this->Load.'"';
     142    if(isset($this->Unload)) $BodyParam .= ' onunload="'.$this->Unload.'"';
    140143    $Output = '<?xml version="1.0" encoding="'.$this->System->Config['Web']['Charset'].'"?>'."\n".
    141144    '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
Note: See TracChangeset for help on using the changeset viewer.