Example #1
0
function importcomputersFromList(){
	cpulimit(20);
	$sock=new sockets();
	$tbl=explode("\n",$sock->GET_INFO("ComputerListToImport"));
	writelogs("ComputerListToImport=" . count($tbl)." values",__FUNCTION__,__FILE__,__LINE__);
	$i=0;
	$max=count($tbl);
	while (list ($num, $computername) = each ($tbl)){
		$z=$z+1;
		$computername=trim($computername);
		$ip=null;
		$mac=null;
		if($computername==null){continue;}
		$ip_arp=unserialize(base64_decode($sock->getFrameWork("cmd.php?arp-ip=".$_GET["arp-ip"])));
		if(is_array($ip_arp)){
			$ip=$ip_arp[0];
			$mac=$ip_arp[1];
			unset($ip_arp);
		}
		$pourc=round(($z/$max)*100);
		writelogs("$pourc) $computername",__FUNCTION__,__FILE__,__LINE__);
		
		WriteCOmputerBrowseProgress($pourc,"{import}: $computername ($ip/$mac)");
		
		if($mac<>null){$uid=$cmp->ComputerIDFromMAC($mac);}else{$uid="$computername$";}
		if($uid==null){$uid="$computername$";}
		
		$cmp=new computers($uid);
		if($ip<>null){$cmp->ComputerIP=$ip;}
		if($mac<>null){$cmp->ComputerMacAddress=$mac;}
		$cmp->ComputerRealName=$computername;
		$cmp->Add();
		$i=$i+1;
		}
		WriteCOmputerBrowseProgress(0,"{waiting}");
	
}
function importcomputersFromList()
{
    $sock = new sockets();
    $ipClass = new IP();
    $tbl = explode("\n", $sock->GET_INFO("ComputerListToImport"));
    writelogs("ComputerListToImport=" . count($tbl) . " values", __FUNCTION__, __FILE__, __LINE__);
    $i = 0;
    $max = count($tbl);
    while (list($num, $computername) = each($tbl)) {
        $z = $z + 1;
        $computername = trim($computername);
        $ip = null;
        $mac = null;
        if ($computername == null) {
            continue;
        }
        if (strpos($computername, " ") > 0) {
            $TRB = explode(" ", $computername);
            $computername = $TRB[0];
            unset($TRB[0]);
            while (list($a, $b) = each($TRB)) {
                if ($b == null) {
                    continue;
                }
                if ($ipClass->isValid($b)) {
                    $ip = $b;
                    continue;
                }
                if ($ipClass->IsvalidMAC($b)) {
                    $mac = $b;
                    continue;
                }
            }
        }
        if (isset($_GET["arp-ip"])) {
            $ip_arp = unserialize(base64_decode($sock->getFrameWork("cmd.php?arp-ip=" . $_GET["arp-ip"])));
            if (is_array($ip_arp)) {
                $ip = $ip_arp[0];
                $mac = $ip_arp[1];
                unset($ip_arp);
            }
        }
        $pourc = round($z / $max * 100);
        writelogs("{$pourc}) {$computername}", __FUNCTION__, __FILE__, __LINE__);
        WriteCOmputerBrowseProgress($pourc, "{import}: {$computername} ({$ip}/{$mac})");
        $cmp = new computers();
        if ($mac != null) {
            $uid = $cmp->ComputerIDFromMAC($mac);
        } else {
            $uid = "{$computername}\$";
        }
        if ($uid == null) {
            $uid = "{$computername}\$";
        }
        $cmp = new computers($uid);
        if ($ip != null) {
            $cmp->ComputerIP = $ip;
        }
        if ($mac != null) {
            $cmp->ComputerMacAddress = $mac;
        }
        $cmp->ComputerRealName = $computername;
        $cmp->Add();
        $i = $i + 1;
    }
    WriteCOmputerBrowseProgress(0, "{waiting}");
}