Example #1
0
// verify that user has write access
$subnetPerm = checkSubnetPermission($_POST['subnetId']);
if ($subnetPerm < 2) {
    echo _("error") . ":" . _("Insufficient permissions");
    die;
}
//get IP address details
$ip = getIpAddrDetailsById($_POST['id']);
//verify that pign path is correct
if (!file_exists($pathPing)) {
    $pingError = true;
}
//try to ping it
if (pingHost($ip['ip_addr'], 1) == '0') {
    $status = "Online";
    @updateLastSeen($_POST['id']);
    // <eNovance>
    // Set the new state of an ip addresse
    if (intval($ip['state']) == 0) {
        $database = new database($db['host'], $db['user'], $db['pass'], $db['name']);
        $query = 'UPDATE ipaddresses SET state = 1 WHERE id = ' . $ip['id'] . ';';
        $database->executeQuery($query);
    }
} else {
    $status = "Offline";
    if (intval($ip['state']) == 1) {
        $database = new database($db['host'], $db['user'], $db['pass'], $db['name']);
        $query = 'UPDATE ipaddresses SET state = 0 WHERE id = ' . $ip['id'] . ';';
        $database->executeQuery($query);
    }
    // </eNovance>
$m = 0;
if (sizeof($result) > 0) {
    foreach ($result as $k => $r) {
        foreach ($r as $ip) {
            # get details
            $ipdet = getIpAddrDetailsByIPandSubnet($ip, $_POST['subnetId']);
            # format output
            $res[$ip]['ip_addr'] = $ip;
            $res[$ip]['description'] = $ipdet['description'];
            $res[$ip]['dns_name'] = $ipdet['dns_name'];
            //online
            if ($k == "alive") {
                $res[$ip]['status'] = "Online";
                $res[$ip]['code'] = 0;
                //update alive time
                @updateLastSeen($ipdet['id']);
            } elseif ($k == "dead") {
                $res[$ip]['status'] = "Offline";
                $res[$ip]['code'] = 1;
            } elseif ($k == "excluded") {
                $res[$ip]['status'] = "Excluded form check";
                $res[$ip]['code'] = 100;
            } else {
                $res[$ip]['status'] = "Error";
                $res[$ip]['code'] = 2;
            }
            $m++;
        }
    }
}
#  errors
         checkAnnoucements();
     }
     if ($processFurther) {
         fetchMessages();
     }
 }
 $time = getTimeStamp();
 if ($processFurther) {
     if (empty($_SESSION['cometchat']['cometchat_lastlactivity']) || $time - $_SESSION['cometchat']['cometchat_lastlactivity'] >= REFRESH_BUDDYLIST / 4) {
         $sql = updateLastActivity($userid);
         if (function_exists('hooks_updateLastActivity')) {
             hooks_updateLastActivity($userid);
         }
         $query = mysqli_query($GLOBALS['dbh'], $sql);
         if (empty($_SESSION['cometchat']['user']) || !empty($_SESSION['cometchat']['user']) && $_SESSION['cometchat']['user']['s'] != 'invisible') {
             $sql = updateLastSeen($userid);
             $query = mysqli_query($GLOBALS['dbh'], $sql);
         }
         if (defined('DEV_MODE') && DEV_MODE == '1') {
             echo mysqli_error($GLOBALS['dbh']);
         }
         $_SESSION['cometchat']['cometchat_lastlactivity'] = $time;
     }
     if (!empty($_REQUEST['typingto']) && $_REQUEST['typingto'] != 0 && DISABLE_ISTYPING != 1) {
         $sql = "insert into cometchat_status (userid,typingto,typingtime) values ('" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], $_REQUEST['typingto']) . "','" . mysqli_real_escape_string($GLOBALS['dbh'], getTimeStamp()) . "') on duplicate key update typingto = '" . mysqli_real_escape_string($GLOBALS['dbh'], $_REQUEST['typingto']) . "', typingtime = '" . mysqli_real_escape_string($GLOBALS['dbh'], getTimeStamp()) . "'";
         $query = mysqli_query($GLOBALS['dbh'], $sql);
         if (defined('DEV_MODE') && DEV_MODE == '1') {
             echo mysqli_error($GLOBALS['dbh']);
         }
     }
 }
Example #4
0
         $threads[$z] = new Thread('pingHost');
         $threads[$z]->start(Transform2long($addresses[$z]['ip_addr']), $count, true);
         $z++;
         //next index
     }
 }
 // wait for all the threads to finish
 while (!empty($threads)) {
     foreach ($threads as $index => $thread) {
         if (!$thread->isAlive()) {
             //get exit code
             $exitCode = $thread->getExitCode();
             //online, check diff
             if ($exitCode == "0") {
                 //update IP status
                 @updateLastSeen($addresses[$index]['id']);
                 //set new seen
                 $addresses[$index]['newSeen'] = date("Y-m-d H:i:s");
                 //if old is offline than check for time diff
                 if ($addresses[$index]['oldStatus'] == 2) {
                     //calculate diff since last alive
                     $tDiff2 = time() - strtotime($addresses[$index]['lastSeen']);
                     //set New status
                     if ($tDiff2 >= $statuses[1]) {
                         $stateDiff[] = $addresses[$index];
                         //change
                     }
                 }
             } else {
                 //now offline
                 $exitCode = 2;