Source for file allvmps.php

Documentation is available at allvmps.php

  1. <?php
  2. #
  3. #  allvmps.php
  4. #
  5. #  2006.05.25/Sean Boran: Production
  6. #  2006.01.24/Thomas Dagonnier: First prototype
  7. #
  8. #  Copyright (C) 2006 FreeNAC
  9. #  Licensed under GPL, see LICENSE file or http://www.gnu.org/licenses/gpl.html
  10. ####################################
  11.  
  12. chdir(dirname(__FILE__));
  13. set_include_path("./:../");
  14.  
  15. // include configuration
  16. require_once('../../etc/config.inc');
  17. // include functions
  18. require_once('./webfuncs.inc');
  19.  
  20. function allvmps_stuff()
  21. {
  22.    global $dbuser,$dbpass,$conf;
  23.    db_connect($dbuser,$dbpass);
  24.    echo "<br>";
  25.    echo "List all ports used on all switches in the last ".$conf->web_lastdays." days, and which end-devices were seen on each port. For each end device, the node name and associated user is shown.<br>";
  26.    echo "<br>";
  27.  
  28. $sel "SELECT DISTINCT(switch.id) as id, switch.name as name, switch.ip as ip, CONCAT(building.name,' ',location.name) as location
  29.  FROM systems
  30.  LEFT JOIN port ON port.id = systems.LastPort
  31.  LEFT JOIN switch ON port.switch = switch.id
  32.  LEFT JOIN location ON location.id = switch.location
  33.   LEFT JOIN building ON building.id = location.building_id
  34. WHERE  (TO_DAYS(LastSeen)>=TO_DAYS(CURDATE())-".$conf->web_lastdays.") AND port.switch != '' 
  35. ORDER BY switch.name;";
  36.  
  37. $res mysql_query($selor die('Query failed: ' mysql_error());
  38.  
  39.    echo '<table cellspacing=0 cellpadding=5 border=1>';
  40.    while ($swi mysql_fetch_array($res)) {
  41.      if (($swi['ip'== '0.0.0.0'|| ($swi['ip'== ''|| (stristr($swi['ip'],'0.0.0'))) {
  42.     echo '<!-- Not graphed : '.$swi['name']' ('$swi['location']" / "$swi['ip']." -->";
  43.      else {
  44.        echo "<tr><th align=left>"
  45.        $swi['name']' ('
  46.        $swi['location']" / ".
  47.        $swi['ip']." )\n";
  48.        echo "<br><img src=\"vmpsdot.php?sw="$swi['id']"\" border=0>\n";
  49.      };
  50.    };
  51.    echo '</table>';
  52. }
  53.  
  54.  
  55. if ($ad_auth===true)
  56. {
  57.    $rights=user_rights($_SERVER['PHP_AUTH_USER']);
  58.    if ($rights>=1)
  59.    {
  60.       echo header_read();
  61.       echo main_stuff();
  62.       echo "<hr /><br />";
  63.       allvmps_stuff();
  64.       echo read_footer();
  65.    }
  66.    else echo "<h1>ACCESS DENIED</h1>";
  67. }
  68. else
  69. {
  70.    echo header_read();
  71.    echo main_stuff();
  72.    echo "<hr /><br />";
  73.    allvmps_stuff();
  74.    echo read_footer();
  75. }
  76.  
  77. ?>

Documentation generated on Mon, 17 Nov 2008 01:10:22 +0100 by phpDocumentor 1.4.0