Location: PHPKode > projects > Network Managment / Inventory System > clearsite/include/aloe/aloe_details.php
<?php
/*
 +-------------------------------------------------------------------------+
 | Copyright (C) 2006-2008 Xinn.org                                        |
 |                                                                         |
 | This program is free software; you can redistribute it and/or           |
 | modify it under the terms of the GNU General Public License             |
 | as published by the Free Software Foundation; either version 2          |
 | of the License, or (at your option) any later version.                  |
 |                                                                         |
 | This program is distributed in the hope that it will be useful,         |
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | ClearSite/ALOE, A Long Overdue Enterprise network managment solution!   |
 +-------------------------------------------------------------------------+
 | This code is designed, written, and maintained by the Xinn.org. See     |
 | about.php and/or the AUTHORS file for specific developer information.   |
 +-------------------------------------------------------------------------+
 | http://aloeusers.net                                                    |
 | http://clearsite.sourceforge.net                                        |
 | http://aloenms.net                                                      |
 | http://clear-site.net                                                   |
 | http://clear-site.info                                                  |
 | http://xinn.org/ClearSite.html                                          |
 +-------------------------------------------------------------------------+
*/

include_once('../config.php');
include_once("$cs_base_path/include/aloe/aloe_config.php");
include_once("$cs_base_path/include/aloe/graph.php");
extract($_POST);
extract($_GET);

mysql_connect("$DBhost:$DBport",$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");

$detail_table_query  = "SELECT detail_ID, detail, detail_display FROM details_display";
$detail_table_result = mysql_query($detail_table_query) or die('Query failed: ' . mysql_error());
$table_detail         = array();
$table_detail_display = array();
while ($detail_table_row = mysql_fetch_assoc($detail_table_result)) {
  $table_detail[$detail_table_row["detail_ID"]]         = $detail_table_row["detail"];
  $table_detail_display[$detail_table_row["detail_ID"]] = $detail_table_row["detail_display"];
};

if (empty($interface_type)) {
  $interface_type = "interfaces";
};

if ($interface_type == "css_cr") {
  $interface_query = "SELECT t1.cr_name, t1.cr_vip, t1.cr_status, t2.device_ID, t2.device_name, t2.device_IP, t3.owner_name FROM css_cr AS t1, devices AS t2, css_owner AS t3 WHERE t1.cr_ID=\"$cr_ID\" and t1.device_ID = t2.device_ID and t1.owner_ID = t3.owner_ID";
  $detail_name = "cr_ID";
  $detail_ID = $cr_ID;
} else if ($interface_type == "cpus") {
  $interface_query = "SELECT t1.cpu_name, t1.ifindex, t2.device_ID, t2.device_name, t2.device_IP FROM cpus AS t1, devices AS t2 WHERE t1.cpu_ID=\"$cpu_ID\" and t1.device_ID = t2.device_ID";
  $detail_name = "cpu_ID";
  $detail_ID = $cpu_ID;
} else if ($interface_type == "css_sv") {
  $interface_query = "SELECT t1.sv_name, t1.sv_ip, t1.sv_status, t2.device_ID, t2.device_name, t2.device_IP FROM css_sv AS t1, devices AS t2 WHERE sv_ID=\"$sv_ID\" and t1.device_ID = t2.device_ID";
  $detail_name = "sv_ID";
  $detail_ID = $sv_ID;
} else if ($interface_type == "css_owner") {
  $interface_query = "SELECT t1.owner_name, t2.device_ID, t2.device_name, t2.device_IP FROM css_owner AS t1, devices AS t2 WHERE owner_ID=\"$owner_ID\" and t1.device_ID = t2.device_ID";
  $detail_name = "owner_ID";
  $detail_ID = $owner_ID;
} else if ($interface_type == "wap_stats") {
  $interface_query = "SELECT device_ID, device_name, device_IP FROM devices WHERE device_ID = \"$device_ID\"";
  $detail_name = "device_ID";
  $detail_ID = "$device_ID";
} else if ($interface_type == "wap_clients") {
  $interface_query = "SELECT t1.client_name, t1.client_assigned_address, t2.device_ID, t2.device_name, t2.device_IP, t3.client_type FROM wap_clients AS t1, devices AS t2, wap_client_type AS t3 WHERE t1.client_ID=\"$client_ID\" and t1.device_ID = t2.device_ID and t1.client_type_ID = t3.client_type_ID";
  $detail_name = "client_ID";
  $detail_ID = "$client_ID";
} else if ($interface_type == "vpn_stats") {
  $interface_query = "SELECT device_ID, device_name, device_IP FROM devices WHERE device_ID = \"$device_ID\"";
  $detail_name = "device_ID";
  $detail_ID = "$device_ID";
} else if ($interface_type == "vpn_sessions") {
  $interface_query = "SELECT t1.username, t1.pubip, t1.privip, t1.sessionest, t1.sessionlength, t2.device_ID, t2.device_name, t2.device_IP, t3.session_type FROM vpn_sessions AS t1, devices AS t2, vpn_session_type AS t3 WHERE t1.session_ID=\"$session_ID\" and t1.device_ID = t2.device_ID and t1.session_type_ID = t3.session_type_ID";
  $detail_name = "session_ID";
  $detail_ID = "$session_ID";
} else {
  $interface_query = "SELECT t1.ifindex, t1.ifname, t1.ifdescr, t1.ifphysaddress, t1.ifadminstatus, t1.ifoperstatus, t1.iflastchange, t1.ifalias, t1.portname, t1.portoperstatus, t1.portadminspeed, t1.portduplex, t1.porttype, t1.nativevlan, t1.mac, t1.host_ip, t1.host_name, t1.interfaceip, t1.interfacemask, t1.iscdpneighbor, t2.device_ID, t2.device_name, t2.device_IP, t2.device_type_ID, t3.ifspeed_display, t4.iftype, t4.iftype_display FROM interfaces AS t1, devices AS t2, interface_speed AS t3, interface_type AS t4 WHERE t1.interface_ID=\"$interface_ID\" AND t1.device_ID = t2.device_ID AND t1.ifspeed_ID = t3.ifspeed_ID AND t1.iftype_ID = t4.iftype_ID";
  $detail_name = "interface_ID";
  $detail_ID = $interface_ID;
};

$interface_result = mysql_query($interface_query)or die ("<br>MySQL Error: " . mysql_error() . "<p>Query: " . $interface_query . "<p>");
$interface_row    = mysql_fetch_assoc($interface_result);

$location_query = "SELECT t1.city, t1.state FROM location AS t1, devices AS t2 WHERE t2.device_ID = \"$interface_row[device_ID]\" and t2.location_ID = t1.location_ID";
$location_result = mysql_query($location_query);
$location_row = mysql_fetch_assoc($location_result);

if (empty($action)) {
  print "
         <div class=\"odd_cells\">
          <div class=\"table_row\">
           <div class=\"left_cell\">
            <p>Device:</p>
           </div>
           <div class=\"left_center_cell\">
            <p>$interface_row[device_name] ($interface_row[device_IP])</p>
           </div>
           <div class=\"right_center_cell\">
            <p>Location:</p>
           </div>
           <div class=\"right_cell\">
            <p>$location_row[city], $location_row[state]</p>
           </div>
           <div class=\"tbl_spacer\"></div>
          </div>
         </div>
  ";
  
  $tr = "begin";
  $row_class = "even_cells";
  foreach($interface_row as $key => $value) {
    if (!empty($value)) {
      if ($td_key = array_search($key, $table_detail)) { 
        if ($table_detail[$td_key] == "portduplex") {
          $value = $portduplex_trans[$value];
        } else if ($table_detail[$td_key] == "iftype") {
          if (!empty($interface_row['iftype_display'])) {
            $value = $interface_row['iftype_display'];
          };
        } else if ($table_detail[$td_key] == "ifname") {
          $value = str_replace("-", "/", $value);
        };
        if ($tr == "begin") {
          print "
                <div class=\"$row_class\">
                 <div class=\"table_row\">
                  <div class=\"left_cell\">
                   <p>$table_detail_display[$td_key]</p>
                  </div>
                  <div class=\"left_center_cell\">
                   <p>$value</p>
                  </div>
                ";
          $tr = "end";
          if ($row_class == "odd_cells") {
            $row_class = "even_cells";
          } else {
            $row_class = "even_cells";
          };
        } else if ($tr == "end") {
          print "
                  <div class=\"right_center_cell\">
                   <p>$table_detail_display[$td_key]</p>
                  </div>
                  <div class=\"right_cell\">
                   <p>$value</p>
                  </div>
                  <div class=\"tbl_spacer\"></div>
                 </div>
                </div>
          ";
          $tr = "begin";
        };
      };
    };
  };
  
  if ($tr == "end") {
    print "
             <div class=\"tbl_spacer\"></div>
            </div>
           </div>
           ";
  };
  
  print "<br /";
};

if ($interface_type == "css_cr") {
  $rrd_data_file = "$interface_row[device_IP].$interface_row[owner_name].$interface_row[cr_name].cr.rrd";
  if (file_exists("$rrd_data_path/$rrd_data_file")) {
    $ds_detail = array("$rrd_data_path/$rrd_data_file:crbytes:AVERAGE");
    $ds_mult = array("8");
    $ds_label = array("$interface_row[cr_name] Bytes");
    $ds_detail1 = array("$rrd_data_path/$rrd_data_file:crhits:AVERAGE");
    $ds_mult1 = array("1");
    $ds_label1 = array("$interface_row[cr_name] Hits");
    $label = "$interface_row[device_name] $interface_row[cr_name]";
    if (empty($action)) {
      $image_name1 = "$interface_row[device_IP].$interface_row[cr_name].bytes";
      $image_name2 = "$interface_row[device_IP].$interface_row[cr_name].hits";
      $create_graph1 = aloe_graph($ds_detail, $ds_mult, $ds_label, "AREA", "$label Bytes", "bits per second", "1000", "128", "415", $image_name1, $image_path, $rrdtool_path);
      $create_graph2 = aloe_graph($ds_detail1, $ds_mult1, $ds_label1, "AREA", "$label Hits", "number of hits", "1000", "128", "415", $image_name2, $image_path, $rrdtool_path);
      $customgraphlink = "<a class=\"loadinto-customTimeForm\" href=\"$ClearsiteBaseURL/include/aloe/aloe_timeframeform.php?cr_ID=$cr_ID&interface_type=$interface_type&rrd_data_file=$rrd_data_file\">";
      $graphcount = 2;
    } else if ($action == "customtimeframe") {
      $begintime = "$beginday.$beginmonth.$beginyear $beginhour";
      $endtime = "$endday.$endmonth.$endyear $endhour";
      $image_name1 = "$interface_row[device_IP].$interface_row[cr_name].bytes.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
      $image_name2 = "$interface_row[device_IP].$interface_row[cr_name].hits.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
      if (file_exists("$image_path/$image_name1")) {
        unlink("$image_path/$image_name1");
      };
      if (file_exists("$image_path/$image_name2")) {
        unlink("$image_path/$image_name2");
      };
      $create_graph = aloe_graph_cust($ds_detail, $ds_mult, $ds_label, "LINE", $begintime, $endtime, "$label Bytes - $beginmonth.$beginday.$beginyear $endmonth.$endday.$endyear", "bits per second", "1000", "128", "415", $image_name1, "yes", $image_path, $rrdtool_path);
      $create_graph1 = aloe_graph_cust($ds_detail, $ds_mult1, $ds_label1, "LINE", $begintime, $endtime, "$label Hits - $beginmonth.$beginday.$beginyear $endmonth.$endday.$endyear", "number of hits", "1000", "128", "415", $image_name2, "yes", $image_path, $rrdtool_path);
      $graphcount = 2;
    };
  };
} else if ($interface_type == "css_sv") {
  $rrd_data_file = "$interface_row[device_IP].$interface_row[sv_name].sv.rrd";
  if (file_exists("$rrd_data_path/$rrd_data_file")) {
    $ds_detail = array("$rrd_data_path/$rrd_data_file:svavgld:AVERAGE");
    $ds_mult = array("1");
    $ds_label = array("$interface_row[sv_name] Load");
    $ds_detail1 = array("$rrd_data_path/$rrd_data_file:svtcpcon:AVERAGE");
    $ds_mult1 = array("1");
    $ds_label1 = array("$interface_row[sv_name] TCP Connections");
    $label = "$interface_row[device_name] $interface_row[sv_name]";
    if (empty($action)) {
      $image_name1 = "$interface_row[device_IP].$interface_row[sv_name].avg_load";
      $image_name2 = "$interface_row[device_IP].$interface_row[sv_name].tcp_connections";
      $create_graph = aloe_graph($ds_detail, $ds_mult, $ds_label, "AREA", "$label Avg. Load", "AVG Load", "1000", "128", "415", $image_name1, $image_path, $rrdtool_path);
      $create_graph1 = aloe_graph($ds_detail1, $ds_mult1, $ds_label1, "AREA", "$label TCP Connections", "tcp connections", "1000", "128", "415", $image_name2, $image_path, $rrdtool_path);
      $customgraphlink = "<a class=\"loadinto-customTimeForm\" href=\"$ClearsiteBaseURL/include/aloe/aloe_timeframeform.php?sv_ID=$sv_ID&interface_type=$interface_type&rrd_data_file=$rrd_data_file\">";
      $graphcount = 2;
    } else if ($action == "customtimeframe") {
      $begintime = "$beginday.$beginmonth.$beginyear $beginhour";
      $endtime = "$endday.$endmonth.$endyear $endhour";
      $image_name1 = "$interface_row[device_IP].$interface_row[sv_name].avg_load.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
      $image_name2 = "$interface_row[device_IP].$interface_row[sv_name].tcp_connections.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
      if (file_exists("$image_path/$image_name1")) {
        unlink("$image_path/$image_name1");
      };
      if (file_exists("$image_path/$image_name2")) {
        unlink("$image_path/$image_name2");
      };
      $create_graph = aloe_graph_cust($ds_detail, $ds_mult, $ds_label, "AREA", $begintime, $endtime, "$label Avg. Load", "load", "1000", "128", "415", $image_name1, "yes", $image_path, $rrdtool_path);
      $create_graph1 = aloe_graph_cust($ds_detail1, $ds_mult1, $ds_label1, "AREA", $begintime, $endtime, "$label TCP Connections", "tcp connections", "1000", "128", "415", $image_name2, "yes", $image_path, $rrdtool_path);
      $graphcount = 2;
    };
  };
} else if ($interface_type == "cpus") {
  $graphcount = 1;
  $rrd_data_file = "$interface_row[device_IP].$interface_row[ifindex].cpu.rrd";
  if (file_exists("$rrd_data_path/$rrd_data_file")) {
    $ds_detail = array("$rrd_data_path/$rrd_data_file:cpu5min:AVERAGE");
    $ds_mult = array("1");
    $ds_label = array("5 minute");
    $label = "$interface_row[device_name] $interface_row[cpu_name]";
    if (empty($action)) {
      $image_name1 = "$interface_row[device_IP].$interface_row[ifindex].cpu";
      $create_graph = aloe_graph($ds_detail, $ds_mult, $ds_label, "LINE", "$label CPU", "cpu load", "1000", "128", "415", $image_name1, $image_path, $rrdtool_path);
      $customgraphlink = "<a class=\"loadinto-customTimeForm\" href=\"$ClearsiteBaseURL/include/aloe/aloe_timeframeform.php?cpu_ID=$cpu_ID&interface_type=$interface_type&rrd_data_file=$rrd_data_file\">";
    } else if ($action == "customtimeframe") {
      $begintime = "$beginday.$beginmonth.$beginyear $beginhour";
      $endtime = "$endday.$endmonth.$endyear $endhour";
      $image_name1 = "$interface_row[device_IP].$interface_row[ifindex].cpu.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
      if (file_exists("$image_path/$image_name1")) {
        unlink("$image_path/$image_name1");
      };
      $create_graph = aloe_graph_cust($ds_detail, $ds_mult, $ds_label, "LINE", $begintime, $endtime, "$label CPU - $beginmonth.$beginday.$beginyear $endmonth.$endday.$endyear", "cpu load", "1000", "128", "415", "$image_name1", "yes", $image_path, $rrdtool_path);
    };
  };
} else if ($interface_type == "css_owner") {
  $rrd_data_file = "$interface_row[device_IP].$interface_row[owner_name].own.rrd";
  if (file_exists("$rrd_data_path/$rrd_data_file")) {
    $ds_detail = array("$rrd_data_path/$rrd_data_file:ownerbytes:AVERAGE");
    $ds_mult = array("8");
    $ds_label = array("$interface_row[owner_name] Bytes");
    $label = "$interface_row[device_name] $interface_row[owner_name]";
    if (empty($action)) {
      $image_name1 = "$interface_row[device_IP].$interface_row[owner_name].ownerbytes.png";
      $create_graph = aloe_graph($ds_detail, $ds_mult, $ds_label, "AREA", "$label Bytes", "bytes", "1000", "128", "415", $image_name1, $image_path, $rrdtool_path);
      $customgraphlink = "<a class=\"loadinto-customTimeForm\" href=\"$ClearsiteBaseURL/include/aloe/aloe_timeframeform.php?owner_ID=$owner_ID&interface_type=$interface_type&rrd_data_file=$rrd_data_file\">";
      $content_query = "SELECT cr_name FROM css_cr WHERE owner_ID=\"$owner_ID\"";
      $content_result = mysql_query($content_query);
      if (mysql_num_rows($content_result) != 0) {
        $graphcount = 2;
        while($content_row = mysql_fetch_assoc($content_result)) {
          $ds_detail1[] = "$rrd_data_path/$interface_row[device_IP].$interface_row[owner_name].$content_row[cr_name].cr.rrd:crbytes:AVERAGE";
          $ds_mult1[] = "8";
          $ds_label1[] = "$content_row[cr_name]";
        };
        $image_name2 = "$interface_row[device_IP].$interface_row[owner_name].ownercon.png";
        $create_graph1 = aloe_graph($ds_detail1, $ds_mult1, $ds_label1, "STACK", "$label Bytes", "bytes", "1000", "128", "415", $image_name2, $image_path, $rrdtool_path);
      } else {
        $graphcount = 1;
      };
    } else if ($action == "customtimeframe") {
      $begintime = "$beginday.$beginmonth.$beginyear $beginhour";
      $endtime = "$endday.$endmonth.$endyear $endhour";
      $image_name1 = "$interface_row[device_IP].$interface_row[owner_name].ownerbytes.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";$create_graph = aloe_graph($ds_detail, $ds_mult, $ds_label, "AREA", "$interface_row[device_name] $interface_row[owner_name] Bytes", "bytes", "1000", "128", "415", $image_name1, $image_path, $rrdtool_path);
      if (file_exists("$image_path/$image_name1")) {
        unlink("$image_path/$image_name1");
      };
      $create_graph = aloe_graph_cust($ds_detail, $ds_mult, $ds_label, "AREA", $begintime, $endtime, "$label Bytes", "bytes", "1000", "128", "415", $image_name1, "yes", $image_path, $rrdtool_path);
      $content_query = "SELECT cr_name FROM css_cr WHERE owner_ID=\"$owner_ID\"";
      $content_result = mysql_query($content_query);
      if (mysql_num_rows($content_result) != 0) {
        $graphcount = 2;
        while($content_row = mysql_fetch_assoc($content_result)) {
          $ds_detail1[] = "$rrd_data_path/$interface_row[device_IP].$interface_row[owner_name].$content_row[cr_name].cr.rrd:crbytes:AVERAGE";
          $ds_mult1[] = "8";
          $ds_label1[] = "$content_row[cr_name]";
        };
        $image_name2 = "$interface_row[device_IP].$interface_row[owner_name].ownercon.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
        $create_graph1 = aloe_graph_cust($ds_detail1, $ds_mult1, $ds_label1, "STACK", $begintime, $endtime, "$label Bytes", "bytes", "1000", "128", "415", $image_name2, "yes", $image_path, $rrdtool_path);
      } else {
        $graphcount = 1;
      };
    };
  };
} else if ($interface_type == "wap_stats") {
  $graphcount = 1;
  $rrd_data_file = "$interface_row[device_IP].stats.rrd";
  if (file_exists("$rrd_data_path/$rrd_data_file")) {
    $ds_detail = array("$rrd_data_path/$rrd_data_file:active_clients:AVERAGE",
                       "$rrd_data_path/$rrd_data_file:ass_stats:AVERAGE");
    $ds_mult = array("1",
                     "1");
    $ds_label = array("Active Clients",
                      "Client Associations");
    $label = "$interface_row[device_name]";
    if (empty($action)) {
      $image_name1 = "$interface_row[device_IP].stats";
      $create_graph = aloe_graph($ds_detail, $ds_mult, $ds_label, "LINE", "$label Stats", " ", "1000", "128", "415", $image_name1, $image_path, $rrdtool_path);
      $customgraphlink = "<a class=\"loadinto-customTimeForm\" href=\"$ClearsiteBaseURL/include/aloe/aloe_timeframeform.php?interface_type=$interface_type&rrd_data_file=$rrd_data_file\">";
    } else if ($action == "customtimeframe") {
      $begintime = "$beginday.$beginmonth.$beginyear $beginhour";
      $endtime = "$endday.$endmonth.$endyear $endhour";
      $image_name1 = "$interface_row[device_IP].$interface_row[ifindex].cpu.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
      if (file_exists("$image_path/$image_name1")) {
        unlink("$image_path/$image_name1");
      };
      $create_graph = aloe_graph_cust($ds_detail, $ds_mult, $ds_label, "LINE", $begintime, $endtime, "$interface_row[device_IP] $interface_row[cpu_name] CPU - $beginmonth.$beginday.$beginyear $endmonth.$endday.$endyear", "cpu load", "1000", "128", "415", "$image_name1", "yes", $image_path, $rrdtool_path);
    };
  };
} else if ($interface_type == "wap_clients") {
  $graphcount = 2;
  $rrd_data_file = "$interface_row[client_name].wclient.rrd";
  if (file_exists("$rrd_data_path/$rrd_data_file")) {
    $ds_detail = array("$rrd_data_path/$rrd_data_file:BytesReceived:AVERAGE",
                       "$rrd_data_path/$rrd_data_file:BytesSent:AVERAGE");
    $ds_mult = array("8",
                     "8");
    $ds_label = array("Bytes Received",
                      "Bytes Sent");
    $ds_detail2 = array("$rrd_data_path/$rrd_data_file:SignalStrength:AVERAGE",
                        "$rrd_data_path/$rrd_data_file:SigQuality:AVERAGE");
    $ds_mult2 = array("1",
                      "1");
    $ds_label2 = array("Signal Strength",
                       "Signal Quality");
    $label = "$interface_row[client_name]";
    if (empty($action)) {
      $image_name1 = "$interface_row[client_name].bytes.wclient";
      $image_name2 = "$interface_row[client_name].sig.wclient";
      $create_graph1 = aloe_graph($ds_detail, $ds_mult, $ds_label, "LINE", "$label Traffic", "bytes", "1000", "128", "415", $image_name1, $image_path, $rrdtool_path);
      $create_graph2 = aloe_graph($ds_detail2, $ds_mult2, $ds_label2, "LINE", "$label Signal", " ", "1000", "128", "415", $image_name2, $image_path, $rrdtool_path);
      $customgraphlink = "<a class=\"loadinto-customTimeForm\" href=\"$ClearsiteBaseURL/include/aloe/aloe_timeframeform.php?interface_type=$interface_type&rrd_data_file=$rrd_data_file\">";
    } else if ($action == "customtimeframe") {
      $begintime = "$beginday.$beginmonth.$beginyear $beginhour";
      $endtime = "$endday.$endmonth.$endyear $endhour";
      $image_name1 = "$interface_row[device_IP].$interface_row[ifindex].cpu.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
      if (file_exists("$image_path/$image_name1")) {
        unlink("$image_path/$image_name1");
      };
      $create_graph = aloe_graph_cust($ds_detail, $ds_mult, $ds_label, "LINE", $begintime, $endtime, "$interface_row[device_IP] $interface_row[cpu_name] CPU - $beginmonth.$beginday.$beginyear $endmonth.$endday.$endyear", "cpu load", "1000", "128", "415", "$image_name1", "yes", $image_path, $rrdtool_path);
    };
  };
} else if ($interface_type == "vpn_stats") {
  $graphcount = 1;
  $rrd_data_file = "$interface_row[device_IP].stats.rrd";
  if (file_exists("$rrd_data_path/$rrd_data_file")) {
    $ds_detail = array("$rrd_data_path/$rrd_data_file:current_sessions:AVERAGE",
                       "$rrd_data_path/$rrd_data_file:max_sessions:AVERAGE");
    $ds_mult = array("1",
                     "1");
    $ds_label = array("Current Sessions",
                      "Max Sessions");
    $label = "$interface_row[device_name]";
    if (empty($action)) {
      $image_name1 = "$interface_row[device_IP].stats";
      $create_graph = aloe_graph($ds_detail, $ds_mult, $ds_label, "LINE", "$label Stats", " ", "1000", "128", "415", $image_name1, $image_path, $rrdtool_path);
      $customgraphlink = "<a class=\"loadinto-customTimeForm\" href=\"$ClearsiteBaseURL/include/aloe/aloe_timeframeform.php?device_ID=$device_ID&interface_type=$interface_type&rrd_data_file=$rrd_data_file\">";
    } else if ($action == "customtimeframe") {
      $begintime = "$beginday.$beginmonth.$beginyear $beginhour";
      $endtime = "$endday.$endmonth.$endyear $endhour";
      $image_name1 = "$interface_row[device_IP].stats.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
      if (file_exists("$image_path/$image_name1")) {
        unlink("$image_path/$image_name1");
      };
      $create_graph = aloe_graph_cust($ds_detail, $ds_mult, $ds_label, "LINE", $begintime, $endtime, "$label Stats - $beginmonth.$beginday.$beginyear $endmonth.$endday.$endyear", "cpu load", "1000", "128", "415", "$image_name1", "yes", $image_path, $rrdtool_path);
    };
  };
} else if ($interface_type == "vpn_sessions") {
  $graphcount = 1;
  $rrd_data_file = "$interface_row[username].vpn.rrd";
  if (file_exists("$rrd_data_path/$rrd_data_file")) {
    $ds_detail = array("$rrd_data_path/$rrd_data_file:bytesrec:AVERAGE",
                       "$rrd_data_path/$rrd_data_file:bytestrans:AVERAGE");
    $ds_mult = array("8",
                     "8");
    $ds_label = array("Bytes Received",
                      "Bytes Transmitted");
    $label = "$interface_row[username]";
    if (empty($action)) {
      $image_name1 = "$interface_row[username].bytes.vpn";
      $create_graph1 = aloe_graph($ds_detail, $ds_mult, $ds_label, "LINE", "$label Traffic", "bytes", "1000", "128", "415", $image_name1, $image_path, $rrdtool_path);
      $customgraphlink = "<a class=\"loadinto-customTimeForm\" href=\"$ClearsiteBaseURL/include/aloe/aloe_timeframeform.php?interface_type=$interface_type&rrd_data_file=$rrd_data_file\">";
    } else if ($action == "customtimeframe") {
      $begintime = "$beginday.$beginmonth.$beginyear $beginhour";
      $endtime = "$endday.$endmonth.$endyear $endhour";
      $image_name1 = "$interface_row[device_IP].$interface_row[ifindex].cpu.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
      if (file_exists("$image_path/$image_name1")) {
        unlink("$image_path/$image_name1");
      };
      $create_graph = aloe_graph_cust($ds_detail, $ds_mult, $ds_label, "LINE", $begintime, $endtime, "$interface_row[device_IP] $interface_row[cpu_name] CPU - $beginmonth.$beginday.$beginyear $endmonth.$endday.$endyear", "cpu load", "1000", "128", "415", "$image_name1", "yes", $image_path, $rrdtool_path);
    };
  };
} else {
  $graphcount = 1;
  if ($interface_row["device_type_ID"] == "2" or $interface_row["device_type_ID"] == "5" or $interface_row["device_type_ID"] == "10") {
    $identifier = $interface_row["ifindex"];
    $temp_label = $interface_row["ifindex"];
  } else {
    if (!empty($interface_row["ifname"])) {
      $identifier = $interface_row["ifname"];
      $temp_label = str_replace("-", "/", $interface_row["ifname"]);
    } else {
      $identifier = $interface_row["ifdescr"];
      $temp_label = $interface_row["ifindex"];
    };
  };
  $rrd_data_file = "$interface_row[device_IP].$identifier.traffic.rrd";
  if (file_exists("$rrd_data_path/$rrd_data_file")) {
    $ds_detail = array("$rrd_data_path/$rrd_data_file:traffic_in:AVERAGE",
                       "$rrd_data_path/$rrd_data_file:traffic_out:AVERAGE");
    $ds_mult = array("8",
                     "8");
    $ds_label = array("$temp_label In ",
                      "$temp_label Out");
    $label = "$interface_row[device_name] $temp_label";
    if (empty($action)) {
      $image_name1 = "$interface_row[device_IP].$identifier.traffic";
      $create_graph = aloe_graph($ds_detail, $ds_mult, $ds_label, "LINE", "$label Traffic", "bits per second", "1000", "128", "415", $image_name1, $image_path, $rrdtool_path);
      $customgraphlink = "<a class=\"loadinto-customTimeForm\" href=\"$ClearsiteBaseURL/include/aloe/aloe_timeframeform.php?interface_type=interfaces&interface_ID=$interface_ID&rrd_data_file=$rrd_data_file\">";
    } else if ($action == "customtimeframe") {
      $begintime = "$beginday.$beginmonth.$beginyear $beginhour";
      $endtime = "$endday.$endmonth.$endyear $endhour";
      $image_name1 = "$interface_row[device_IP].$identifier.traffic.$beginmonth-$beginday-$beginhour-$beginyear.$endmonth-$endday-$endhour-$endyear.png";
      if (file_exists("$image_path/$image_name1")) {
        unlink("$image_path/$image_name1");
      };
      $create_graph = aloe_graph_cust($ds_detail, $ds_mult, $ds_label, "LINE", $begintime, $endtime, "$label Traffic - $beginmonth.$beginday.$beginyear $endmonth.$endday.$endyear", "bits per second", "1000", "128", "415", $image_name1, "yes", $image_path, $rrdtool_path);
    };
  };
};
mysql_close();
if (empty($action)) {
    print "<div class=\"d_w_m\">
            <div id=\"customTimeForm\">
             <h1>Day:</h1>
            </div>
            <div id=\"customTimeGraph\">
            <div class=\"presets\">
          ";
    for ($x=1; $x<=$graphcount; $x++) {
      print "
                   <ul class=\"presets-list\">
                    <li>Presets</li>
                    <li> <a class=\"loadinto-customTimeGraph\" href=\"$ClearsiteBaseURL/include/aloe/aloe_details.php?interface_type=$interface_type&amp;action=customtimeframe&amp;beginday=" . date("d", strtotime("-6 days")) . "&amp;beginmonth=" . date("m", strtotime("-6 days")) . "&amp;beginyear=" . date("Y", strtotime("-6 days")) . "&amp;beginhour=" . date("G") . "&amp;endday=" . date("d") . "&amp;endmonth=" . date("m") . "&amp;endyear=" . date("Y") . "&amp;endhour=" . date("g") . "&amp;rrd_data_file=$rrd_data_file&amp;$detail_name=$detail_ID\">-6 Days</a></li>
                    <li> <a class=\"loadinto-customTimeGraph\" href=\"$ClearsiteBaseURL/include/aloe/aloe_details.php?interface_type=$interface_type&amp;action=customtimeframe&amp;beginday=" . date("d", strtotime("-5 days")) . "&amp;beginmonth=" . date("m", strtotime("-5 days")) . "&amp;beginyear=" . date("Y", strtotime("-5 days")) . "&amp;beginhour=" . date("G") . "&amp;endday=" . date("d") . "&amp;endmonth=" . date("m") . "&amp;endyear=" . date("Y") . "&amp;endhour=" . date("g") . "&amp;rrd_data_file=$rrd_data_file&amp;$detail_name=$detail_ID\">-5 Days</a></li>
                    <li> <a class=\"loadinto-customTimeGraph\" href=\"$ClearsiteBaseURL/include/aloe/aloe_details.php?interface_type=$interface_type&amp;action=customtimeframe&amp;beginday=" . date("d", strtotime("-4 days")) . "&amp;beginmonth=" . date("m", strtotime("-4 days")) . "&amp;beginyear=" . date("Y", strtotime("-4 days")) . "&amp;beginhour=" . date("G") . "&amp;endday=" . date("d") . "&amp;endmonth=" . date("m") . "&amp;endyear=" . date("Y") . "&amp;endhour=" . date("g") . "&amp;rrd_data_file=$rrd_data_file&amp;$detail_name=$detail_ID\">-4 Days</a></li>
                    <li> <a class=\"loadinto-customTimeGraph\" href=\"$ClearsiteBaseURL/include/aloe/aloe_details.php?interface_type=$interface_type&amp;action=customtimeframe&amp;beginday=" . date("d", strtotime("-3 days")) . "&amp;beginmonth=" . date("m", strtotime("-3 days")) . "&amp;beginyear=" . date("Y", strtotime("-3 days")) . "&amp;beginhour=" . date("G") . "&amp;endday=" . date("d") . "&amp;endmonth=" . date("m") . "&amp;endyear=" . date("Y") . "&amp;endhour=" . date("g") . "&amp;rrd_data_file=$rrd_data_file&amp;$detail_name=$detail_ID\">-72 Hrs</a></li>
                    <li> <a class=\"loadinto-customTimeGraph\" href=\"$ClearsiteBaseURL/include/aloe/aloe_details.php?interface_type=$interface_type&amp;action=customtimeframe&amp;beginday=" . date("d", strtotime("-2 days")) . "&amp;beginmonth=" . date("m", strtotime("-2 days")) . "&amp;beginyear=" . date("Y", strtotime("-2 days")) . "&amp;beginhour=" . date("G") . "&amp;endday=" . date("d") . "&amp;endmonth=" . date("m") . "&amp;endyear=" . date("Y") . "&amp;endhour=" . date("g") . "&amp;rrd_data_file=$rrd_data_file&amp;$detail_name=$detail_ID\">-48 Hrs</a></li>
                    <li> <a class=\"loadinto-customTimeGraph\" href=\"$ClearsiteBaseURL/include/aloe/aloe_details.php?interface_type=$interface_type&amp;action=customtimeframe&amp;beginday=" . date("d", strtotime("-36 hours")) . "&amp;beginmonth=" . date("m", strtotime("-36 hours")) . "&amp;beginyear=" . date("Y", strtotime("-36 hours")) . "&amp;beginhour=" . date("G", strtotime("-36 hours")) . "&amp;endday=" . date("d") . "&amp;endmonth=" . date("m") . "&amp;endyear=" . date("Y") . "&amp;endhour=" . date("g") . "&amp;rrd_data_file=$rrd_data_file&amp;$detail_name=$detail_ID\">-36 Hrs</a></li>
                   </ul>
                   $customgraphlink<b class=\"cust_time_t\">Custom Time Frame</b></a>
                   <img src=\"$ClearsiteBaseURL/include/aloe/graph_images/" . ${"image_name" . $x} . ".day.png\" alt=\"" . ${"image_name" . $x} . ".day.png\"/>
                   ";
      if (isset($_COOKIE['clearsite']['user_ID'])) {
        $user_ID = $_COOKIE['clearsite']['user_ID'];
        print "<div id=\"graph_page\">";
        include("$cs_base_path/include/user/graph_add.php");
        print "</div>";
      };
    };
    print "	</div>
    			</div>
           <h1>Week:</h1><br />
          ";
    for ($x=1; $x<=$graphcount; $x++) {
      print "<img src=\"$ClearsiteBaseURL/include/aloe/graph_images/" . ${"image_name" . $x} . ".week.png\" alt=\"" . ${"image_name" . $x} . ".week.png\"/>";
    };
    print "<p />
           <h1>Month:</h1><br />
          ";
    for ($x=1; $x<=$graphcount; $x++) {
           print "<img src=\"$ClearsiteBaseURL/include/aloe/graph_images/" . ${"image_name" . $x} . ".month.png\" alt=\"" . ${"image_name" . $x} . ".month.png\"/>";
    };
    print "<p />
           </div>";

} else if ($action == "customtimeframe") {
  if (empty($graphcount)) {
    print "<img src=\"$ClearsiteBaseURL/include/aloe/graph_images/$image_name\" alt=\"$image_name\"/><p />";
  } else {
    for ($x=1; $x<=$graphcount; $x++) {
      print "<img src=\"$ClearsiteBaseURL/include/aloe/graph_images/" . ${"image_name" . $x} . "\" alt=\"" . ${"image_name" . $x} . "\"/>";
    };
    print "<p />";
  };
};

?>
Return current item: Network Managment / Inventory System