Location: PHPKode > projects > Network Managment / Inventory System > clearsite/include/aloe/aloe_config.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                                          |
 +-------------------------------------------------------------------------+
*/

$configpath = str_replace(array("/aloe/aloe_config.php", "\aloe\aloe_config.php"), "", __FILE__) . "/config.php";

include_once($configpath);

$base_path = "$cs_base_path/include/aloe";

$portduplex_trans = array(""  => "unknown",
                          "1" => "half",
                          "2" => "full",
                          "3" => "disagree",
                          "4" => "auto");

function safe_array_merge($a, $b) {
	foreach ($b as $key => $value) {
    if (!isset($a[$key])) {
    	$a[$key] = $value;
    } else {
    	$temp_array = split(", ", $a[$key]);
    	if (!in_array($value, $temp_array)) {
    		$a[$key] = "$a[$key], $value";
    	};
  	};
  };
  return $a;
};

/*
linux
fping -c 1 -r 1 10.1.1.100
10.1.1.100 : [0], 84 bytes, 1.54 ms (1.54 avg, 0% loss)

10.1.1.100 : xmt/rcv/%loss = 1/1/0%, min/avg/max = 1.54/1.54/1.54

windows
C:\fping>fping -c 1 -r 1 10.1.1.100
10.1.1.100 : [0], 84 bytes, 0.00 ms (0.00 avg, 0% loss)

10.1.1.100 : xmt/rcv/%loss = 1/1/0%, min/avg/max = 0.00/0.00/0.00
*/

if ($use_fping == "yes") {
  function php_ping($host) {
    global $fping_path;
    $last_line = exec("$fping_path -c 1 -r 1 $host 2>&1", $list, $test);
    if (strpos($last_line, "1/1/0%") > 0) {
      return true;
    };
    return false;
  };
} else {
  function php_ping($host) {
    exec("ping -c 1 -w 1 $host", $list);
    if (isset($list[4]) and (strpos($list[4],"1 received")>0)) {
      return true;
    };
    return false;
  };
};

?>
Return current item: Network Managment / Inventory System