function computer_add()
{
    $userid = $_GET["userid"];
    $computer = new computers($_GET["add-computer"]);
    if (!IsPhysicalAddress($computer->ComputerMacAddress)) {
        $tpl = new templates();
        echo $tpl->javascript_parse_text("{computer}:{$computer->ComputerRealName}\n\t\t{MAC}:{$computer->ComputerMacAddress}\n\t\t--------------------\n\t\t{WARNING_MAC_ADDRESS_CORRUPT}\n\t\t");
        return;
    }
    $user = new user($userid);
    $user->add_computer($computer->ComputerMacAddress, $computer->uid);
}
function changecomputername()
{
    if (substr($_POST["userid"], strlen($_POST["userid"]) - 1, 1) != "\$") {
        $_POST["userid"] = $_POST["userid"] . "\$";
    }
    $comp = new computers($_POST["userid"]);
    $MAC = $comp->ComputerMacAddress;
    $_POST["NewHostname"] = trim(strtolower($_POST["NewHostname"]));
    $_POST["NewHostname"] = str_replace('$', '', $_POST["NewHostname"]);
    $actualdn = $comp->dn;
    $newrdn = "cn={$_POST["NewHostname"]}\$";
    $ldap = new clladp();
    if (!preg_match("#^cn=(.+?),[a-zA-Z\\s]+#", $actualdn, $re)) {
        echo "Unable to preg_match {$actualdn}\n";
        return;
    }
    $newDN = str_replace($re[1], $_POST["NewHostname"] . '$', $actualdn);
    if ($newDN == null) {
        echo "Unable to preg_match {$actualdn} -> {$re[1]}\n";
        return;
    }
    if ($ldap->ExistsDN("{$newrdn},ou=Computer,dc=samba,dc=organizations,{$ldap->suffix}")) {
        $ldap->ldap_delete("{$newrdn},ou=Computer,dc=samba,dc=organizations,{$ldap->suffix}");
    }
    $newParent = "ou=Computer,dc=samba,dc=organizations,{$ldap->suffix}";
    if (!$ldap->Ldap_rename_dn($newrdn, $actualdn, $newParent)) {
        echo "Rename failed {$ldap->ldap_last_error}\nFunction:" . __FUNCTION__ . "\nFile:" . __FILE__ . "\nLine" . __LINE__ . "\n\nActual DN:{$actualdn}\nExpected DN:{$newrdn}";
        return;
    }
    $upd["uid"][0] = $_POST["NewHostname"] . '$';
    if (!$ldap->Ldap_modify($newDN, $upd)) {
        echo "Update UID {$upd["uid"][0]} failed:\n{$ldap->ldap_last_error}\nFunction:" . __FUNCTION__ . "\nFile:" . __FILE__ . "\nLine" . __LINE__ . "\nExpected DN:{$newDN}\nExpected value:{$_POST["NewHostname"]}";
        return;
    }
    $ocs = new ocs($MAC);
    $ocs->ComputerName = $_POST["NewHostname"];
    $ocs->ComputerIP = $comp->ComputerIP;
    $ocs->EditComputer();
    if (IsPhysicalAddress($comp->ComputerMacAddress)) {
        include_once dirname(__FILE__) . "/ressources/class.mysql.inc";
        $uid = $comp->ComputerIDFromMAC($comp->ComputerMacAddress);
        $comp = new computers($uid);
        $sql = "UPDATE dhcpd_fixed SET `hostname`='{$comp->ComputerRealName}' WHERE `mac`='{$comp->ComputerMacAddress}'";
        $q = new mysql();
        $q->QUERY_SQL($sql, "artica_backup");
    }
}
function blocked_macuid($tablename)
{
    $q = new mysql_squid_builder();
    $sql = "SELECT * FROM webfilters_ipaddr WHERE LENGTH(uid)>1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$ligne["ipaddr"]} = {$ligne["uid"]}\n";
        }
        $array2[$ligne["ipaddr"]] = $ligne["uid"];
    }
    $sql = "SELECT * FROM webfilters_nodes WHERE LENGTH(uid)>1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($ligne["MAC"] == "00:00:00:00:00:00") {
            continue;
        }
        if (!IsPhysicalAddress($ligne["MAC"])) {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$ligne["MAC"]} = {$ligne["uid"]}\n";
        }
        $array[$ligne["MAC"]] = $ligne["uid"];
    }
    while (list($mac, $uid) = each($array)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$tablename}, {$mac} -> {$uid}\n";
        }
        $uid = mysql_escape_string2($uid);
        $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE MAC='{$mac}'");
    }
}
示例#4
0
function selection_list()
{
    if ($_GET["selection-list"] == '*') {
        $_GET["selection-list"] = null;
    }
    if ($_GET["selection-list"] == null) {
        $tofind = "*";
    } else {
        $tofind = "*{$_GET["selection-list"]}*";
    }
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    $ldap = new clladp();
    $attrs = array("uid", "ComputerIP", "ComputerOS", "ComputerMachineType", "ComputerMacAddress");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs, 20);
    $html = "<table>";
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = str_replace('$', '', $hash[$i]["uid"][0]);
        $js_show = MEMBER_JS($realuid, 1);
        if ($_GET["callback"] != null) {
            $js_selection = "{$_GET["callback"]}('{$realuid}');";
        }
        $ip = $hash[$i][strtolower("ComputerIP")][0];
        $os = $hash[$i][strtolower("ComputerOS")][0];
        $type = $hash[$i][strtolower("ComputerMachineType")][0];
        $mac = $hash[$i][strtolower("ComputerMacAddress")][0];
        $name = $hash[$i]["uid"][0];
        if (strlen($name) > 25) {
            $name = substr($name, 0, 23) . "...";
        }
        if ($os == "Unknown") {
            if ($type != "Unknown") {
                $os = $type;
            }
        }
        if (strlen($os) > 20) {
            $os = texttooltip(substr($os, 0, 17) . '...', $os, null, null, 1);
        }
        if (strlen($ip) > 20) {
            $ip = texttooltip(substr($ip, 0, 17) . '...', $ip, null, null, 1);
        }
        $img = "<img src='img/base.gif'>";
        $roolover = CellRollOver($js_selection, "{select}");
        if (!IsPhysicalAddress($mac)) {
            $img = imgtootltip("status_warning.gif", "{WARNING_MAC_ADDRESS_CORRUPT}");
            $roolover = CellRollOver($js_show, "{edit}<hr>{WARNING_MAC_ADDRESS_CORRUPT}");
            $js_selection = null;
        }
        $html = $html . "<tr {$roolover}>\n\t<td width=1% {$roolover}>{$img}</td>\n\t<td nowrap><strong>{$name}</strong></td>\n\t<td ><strong>{$ip}</strong></td>\n\t<td><strong>{$mac}</strong></td>\n\t{$js_add}\n\t</tr>\n\t";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
示例#5
0
function AJAX_COMPUTER()
{
    if ($_GET["userid"] == "newcomputer\$") {
        $add_computer = true;
    }
    $computer = new computers($_GET["userid"]);
    $group = new groups($computer->gidNumber);
    $gpslist = $computer->Groups_list();
    $users = new usersMenus();
    $sock = new sockets();
    $page = CurrentPageName();
    $EnableDHCPServer = $sock->GET_INFO('EnableDHCPServer');
    if (is_array($gpslist)) {
        while (list($num, $val) = each($gpslist)) {
            $a_gpr[] = $val;
        }
    }
    $computer->uid = str_replace('$', '', $computer->uid);
    $delete = Paragraphe('delete-64.png', '{delete_this_computer}', "{delete_this_computer}", "javascript:DeleteComputer('{$_GET["userid"]}')");
    $bind9 = new bind9();
    if ($EnableDHCPServer == 1) {
        $dhcp_fix = Field_checkbox("dhcpfixed", 1, $computer->dhcpfixed, "Loadjs('{$page}?dhcpfixedForm=yes')", '{enable_disable}');
    } else {
        $dhcp_fix = Field_checkbox("dhcpfixed", 1, $computer->dhcpfixed, null, '{no_feature_dhcp_server_not_enabled}');
    }
    $VolatileIPAddress = Field_checkbox("VolatileIPAddress", 1, $computer->VolatileIPAddress, "Loadjs('{$page}?VolatileIPForm=yes')", '{enable_disable}');
    if ($users->KAV4SAMBA_INSTALLED) {
        $scan_computer = Paragraphe("64-find-virus.png", "{AV_REMOTE_SCAN}", "{AV_REMOTE_SCAN_TEXT}", "javascript:Loadjs('computer.scan.php?uid={$computer->uid}');");
    }
    $ini_USER = new Bs_IniHandler();
    $ini_USER->loadString($computer->ComputerCryptedInfos);
    $USERNAME_REMOTE = $ini_USER->_params["ACCOUNT"]["USERNAME"];
    if (!preg_match("#([0-9]+)\\.([0-9]+)\\.([0-9]+)#", $computer->DisplayName)) {
        if (preg_match("#(.+?)\\.#", $computer->DisplayName, $re)) {
            $Diplayname = $re[1];
        } else {
            $Diplayname = $computer->DisplayName;
        }
    } else {
        $Diplayname = $computer->DisplayName;
    }
    $password = Paragraphe("cyrus-password-64.png", "{credentials_informations}", "{credentials_informations_text}", "javascript:Loadjs('computer.passwd.php?uid={$_GET["userid"]}')");
    $computer_infos_services = Paragraphe("computer-tour-64.png", "{COMPUTER_INFOS_SERVICES}", "{COMPUTER_INFOS_SERVICES_TEXT}", "javascript:Loadjs('computer.infos.php?uid={$computer->uid}');");
    if (is_array($a_gpr)) {
        $groups = "\n\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend>{groups}:</strong></td>\n\t\t\t\t<td align=left><strong>" . implode(', ', $a_gpr) . "</strong></td>\n\t\t\t</tr>\t";
    }
    $MacField = Field_text('ComputerMacAddress', $computer->ComputerMacAddress, 'width:100%');
    if (IsPhysicalAddress($computer->ComputerMacAddress)) {
        $MacField = "<input type='hidden' name='ComputerMacAddress' id='ComputerMacAddress' value='{$computer->ComputerMacAddress}'>\n\t\t<code style='font-size:11px'>{$computer->ComputerMacAddress}</code>";
    } else {
        $mac_warn = imgtootltip("status_warning.gif", "{WARNING_MAC_ADDRESS_CORRUPT}");
    }
    $dns = AJAX_COMPUTER_DNS_FORM($_GET["userid"]);
    if ($add_computer) {
        $scan_computer = null;
        $delete = null;
        $backup_icon = null;
        $computer_icon = null;
        $password = null;
    }
    $html = "\n\t<input type='hidden' name='Yahoowin' id='Yahoowin' value='{$_GET["Yahoowin"]}'>\n\t<form name='FFM34567-{$_GET["userid"]}'>\n\t<input type='hidden' name='userid' id='userid' value='{$_GET["userid"]}'>\n\t<input type='hidden' name='gpid' value='{$_GET["gpid"]}'>\n\t<input type='hidden' name='SaveComputerInfo' value='yes'>\n\t\n\t\n\t<table style='width:100%'>\n\t<td width=1% valign='top'>\n\t\t<div id='computer_refresh_div'>{$computer_icon}</div>\n\t\t{$password}\n\t\t{$computer_infos_services}\n\t\t{$scan_computer}\n\t\t{$delete}\n\t\t</td>\n\t<td valign='top' width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=3><H5>{network_information}</H5></td>\n\t\t\t\t\t\n\t\t\t\t</tr>\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td class=legend>{computer_name}:</strong></td>\n\t\t\t\t\t<td width=1%>&nbsp;</td>\n\t\t\t\t\t<td align=left>" . Field_text('uid', $computer->uid, 'width:100%;font-size:14px;padding:3px;font-weight:bold') . "</strong></td>\n\t\t\t\t</tr>\t\t\t\t\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td class=legend>{computer_ip}:</strong></td>\n\t\t\t\t\t<td width=1%>&nbsp;</td>\n\t\t\t\t\t<td align=left>" . Field_text('ComputerIP', $computer->ComputerIP, 'width:100%') . "</strong></td>\n\t\t\t\t</tr>\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td class=legend>{ComputerMacAddress}:</strong></td>\n\t\t\t\t\t<td width=1%>{$mac_warn}</td>\n\t\t\t\t\t<td align=left>{$MacField}</strong></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td class=legend>{uid_number}:</strong></td>\n\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t<td align=left><strong>{$computer->uidNumber}</strong></td>\n\t\t\t\t</tr>\t\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td class=legend>{dhcpfixed}:</strong></td>\n\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t<td align=left>{$dhcp_fix}</td>\n\t\t\t\t</tr>\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<td class=legend>{VolatileIPAddress}:</strong></td>\n\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t<td align=left>{$VolatileIPAddress}</td>\n\t\t\t\t</tr>\t\n\t\t\t\t</table>\n\t\t\t\t<div id='computerdnsinfos'>{$dns}</div>\n\t\t\t\t<table style='width:100%'>\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=3 align='right'><hr style='border-color:#005447'>" . button("{edit}", "SaveComputerForm('FFM34567-{$_GET["userid"]}');") . "\n\t\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t{$computer_infos}\n\t\t\t\t\n\t\t\t\t</table>\n\t\t</td>\n\t\t</tr>\t\t\n\t\t</table>\n\t</form>\n\t";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
示例#6
0
function macuid()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $unix = new unix();
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Already executed pid {$pid}\n";
        }
        return;
    }
    $mypid = getmypid();
    @file_put_contents($pidfile, $mypid);
    $q = new mysql_squid_builder();
    $sql = "SELECT * FROM webfilters_nodes WHERE LENGTH(uid)>1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($ligne["MAC"] == "00:00:00:00:00:00") {
            continue;
        }
        if (!IsPhysicalAddress($ligne["MAC"])) {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$ligne["MAC"]} = {$ligne["uid"]}\n";
        }
        $array[$ligne["MAC"]] = $ligne["uid"];
    }
    $sql = "SELECT * FROM webfilters_ipaddr WHERE LENGTH(uid)>1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        $array2[$ligne["ipaddr"]] = $ligne["uid"];
    }
    $tablesBrutes = $q->LIST_TABLES_HOURS();
    while (list($tablename, $none) = each($tablesBrutes)) {
        reset($array);
        while (list($mac, $uid) = each($array)) {
            $uid = mysql_escape_string2($uid);
            if ($GLOBALS["VERBOSE"]) {
                echo "{$tablename}, {$mac} -> {$uid}\n";
            }
            $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE MAC='{$mac}'");
        }
        reset($array2);
        while (list($ipaddr, $uid) = each($array)) {
            $uid = mysql_escape_string2($uid);
            if ($GLOBALS["VERBOSE"]) {
                echo "{$tablename}, {$mac} -> {$uid}\n";
            }
            $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE client='{$ipaddr}' AND LENGTH(uid)=0");
        }
    }
    $tablesBrutes = $q->LIST_TABLES_dansguardian_events();
    while (list($tablename, $none) = each($tablesBrutes)) {
        reset($array);
        while (list($mac, $uid) = each($array)) {
            $uid = mysql_escape_string2($uid);
            if ($GLOBALS["VERBOSE"]) {
                echo "{$tablename}, {$mac} -> {$uid}\n";
            }
            if (IsCompressed($tablename)) {
                Uncompress($tablename);
            }
            $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE MAC='{$mac}'");
        }
        reset($array2);
        while (list($ipaddr, $uid) = each($array)) {
            $uid = mysql_escape_string2($uid);
            if ($GLOBALS["VERBOSE"]) {
                echo "{$tablename}, {$mac} -> {$uid}\n";
            }
            $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE CLIENT='{$ipaddr}' AND LENGTH(uid)=0");
        }
    }
    $tablesBrutes = $q->LIST_TABLES_BLOCKED_DAY();
    while (list($tablename, $none) = each($tablesBrutes)) {
        reset($array);
        while (list($mac, $uid) = each($array)) {
            $uid = mysql_escape_string2($uid);
            if ($GLOBALS["VERBOSE"]) {
                echo "{$tablename}, {$mac} -> {$uid}\n";
            }
            if (IsCompressed($tablename)) {
                Uncompress($tablename);
            }
            $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE MAC='{$mac}'");
        }
    }
    $tablesBrutes = $q->LIST_TABLES_BLOCKED_WEEK();
    while (list($tablename, $none) = each($tablesBrutes)) {
        reset($array);
        while (list($mac, $uid) = each($array)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$tablename}, {$mac} -> {$uid}\n";
            }
            if (IsCompressed($tablename)) {
                Uncompress($tablename);
            }
            $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE MAC='{$mac}'");
        }
    }
    $tablesBrutes = $q->LIST_TABLES_YOUTUBE_DAYS();
    while (list($tablename, $none) = each($tablesBrutes)) {
        reset($array);
        while (list($mac, $uid) = each($array)) {
            $uid = mysql_escape_string2($uid);
            if ($GLOBALS["VERBOSE"]) {
                echo "{$tablename}, {$mac} -> {$uid}\n";
            }
            if (IsCompressed($tablename)) {
                Uncompress($tablename);
            }
            $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE MAC='{$mac}'");
        }
        reset($array2);
        while (list($ipaddr, $uid) = each($array)) {
            $uid = mysql_escape_string2($uid);
            if ($GLOBALS["VERBOSE"]) {
                echo "{$tablename}, {$mac} -> {$uid}\n";
            }
            $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE ipaddr='{$ipaddr}' AND LENGTH(uid)=0");
        }
    }
    $tablesBrutes = $q->LIST_TABLES_YOUTUBE_WEEK();
    while (list($tablename, $none) = each($tablesBrutes)) {
        reset($array);
        while (list($mac, $uid) = each($array)) {
            $uid = mysql_escape_string2($uid);
            if ($GLOBALS["VERBOSE"]) {
                echo "{$tablename}, {$mac} -> {$uid}\n";
            }
            if (IsCompressed($tablename)) {
                Uncompress($tablename);
            }
            $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE MAC='{$mac}'");
        }
        reset($array2);
        while (list($ipaddr, $uid) = each($array)) {
            $uid = mysql_escape_string2($uid);
            if ($GLOBALS["VERBOSE"]) {
                echo "{$tablename}, {$mac} -> {$uid}\n";
            }
            $q->QUERY_SQL("UPDATE {$tablename} SET uid='{$uid}' WHERE ipaddr='{$ipaddr}' AND LENGTH(uid)=0");
        }
    }
    uid_resets();
}
function ComputersList(){
$q=new mysql();
$sock=new sockets();
	$sql="SELECT ID,pattern,uid FROM dansguardian_files WHERE filename='bannediplist' AND RuleID=1 ORDER BY ID DESC";
	$results=$q->QUERY_SQL($sql,"artica_backup");
	if(!$q->ok){
		$mysql_error="::$q->mysql_error";
		if(preg_match("#doesn't exist#",$q->mysql_error)){
			$q->CheckTable_dansguardian();
			if(!$q->ok){$mysql_error=$mysql_error."::$q->mysql_error";}else{$mysql_error=null;}
		}
	}
	
	$style=CellRollOver();
	$html="<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>
<thead class='thead'>
	<tr>
		<th colspan=4>{black_ip_group}$mysql_error</th>
	</tr>
</thead>
<tbody class='tbody'>";	
	
	while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){	
		if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";}
		$MAC=null;$uid=null;
		if($ligne["uid"]<>null){
			$cmp=new computers($ligne["uid"]);
			$MAC=$cmp->ComputerMacAddress;
			$uid="<br><i style='font-size:9px'>$cmp->ComputerRealName</i>";
		}
		
		if(!IsPhysicalAddress($MAC)){
			$MAC=$sock->getFrameWork("cmd.php?ip-to-mac={$ligne["pattern"]}");
		}
		
		if(!IsPhysicalAddress($MAC)){$MAC=null;}
		
		$html=$html."
		<tr class=$classtr>
			<td width=1% ><img src='img/computer-32.png'></td>
			<td  nowrap><strong style='font-size:14px'>{$ligne["pattern"]}$uid</strong></td>
			<td  nowrap><strong style='font-size:14px'>&nbsp;$MAC</strong></td>
			<td ><strong>". imgtootltip("delete-24.png","{delete}","DelDansGuardianExceptionipList('{$ligne["ID"]}');")."</strong></td>
		</tr>
	";
	}
	$html=$html . "
		</tbody>
	</table>";	
	$html="<center><div style='height:450px;overflow:auto'>$html</div></center>";		
	$tpl=new templates();
	return  $tpl->_ENGINE_parse_body($html);		
	
	
}
function build()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, __FILE__)) {
        echo "Already PID running {$pid} (" . basename(__FILE__) . ")\n";
        die;
    }
    $time = $unix->file_time_min($timefile);
    if (!$GLOBALS["FORCE"]) {
        if ($time < 5) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$time}mn < 5mn\n";
            }
            die;
        }
    }
    @mkdir(dirname($pidfile), 0755, true);
    @file_put_contents($pidfile, getmypid());
    @unlink($timefile);
    @file_put_contents($timefile, time());
    $php = $unix->LOCATE_PHP5_BIN();
    $MD5_SRC = @md5_file("/etc/squid3/usersMacs.db");
    @unlink("/etc/squid3/usersMacs.db");
    @unlink("/usr/share/artica-postfix/ressources/databases/usersMacs.db");
    $sock = new sockets();
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    if ($EnableRemoteStatisticsAppliance == 1) {
        download_mydb();
        return;
    }
    if (!function_exists("IsPhysicalAddress")) {
        include_once dirname(__FILE__) . "/ressources/class.templates.inc";
    }
    if (!class_exists("mysql_squid_builder")) {
        include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php";
    }
    build_progress("{starting}", 10);
    $unix = new unix();
    $arpd = $unix->find_program("arpd");
    $chmod = $unix->find_program("chmod");
    if (is_file($arpd)) {
        exec("{$arpd} -l 2>&1", $results);
        while (list($num, $line) = each($results)) {
            if (preg_match("#([0-9]+)\\s+([0-9\\.]+)\\s+([0-9a-z\\:]+)#", $line, $re)) {
                build_progress("{$re[3]} = {$re[2]}", 15);
                $MACS["MACS"][$re[3]]["IP"] = $re[2];
                $MACS["IPS"][$re[2]] = $re[3];
            }
        }
    }
    $q = new mysql_squid_builder();
    $sql = "SELECT * FROM webfilters_nodes WHERE LENGTH(uid)>1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($ligne["MAC"] == "00:00:00:00:00:00") {
            continue;
        }
        if (!IsPhysicalAddress($ligne["MAC"])) {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$ligne["MAC"]} = {$ligne["uid"]}\n";
        }
        $MACS["MACS"][$ligne["MAC"]]["UID"] = $ligne["uid"];
        $MACS["MACS"][$ligne["MAC"]]["GROUP"] = $ligne["group"];
        build_progress($ligne["MAC"], 20);
        UPDATE_HOURS_MAC($ligne["MAC"], $ligne["uid"]);
        if ($ligne["hostname"] != null) {
            $MACS["MACS"][$ligne["MAC"]]["HOST"] = $ligne["hostname"];
        }
    }
    $q = new mysql();
    $sql = "SELECT * FROM hostsusers";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($ligne["MacAddress"] == "00:00:00:00:00:00") {
            continue;
        }
        if (!IsPhysicalAddress($ligne["MacAddress"])) {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$ligne["MacAddress"]} = {$ligne["uid"]}\n";
        }
        if (preg_match("#group:@(.+?):([0-9]+)#", $ligne["uid"], $re)) {
            build_progress($ligne["MacAddress"], 30);
            $MACS["MACS"][$ligne["MacAddress"]]["UID"] = $re[1];
            UPDATE_HOURS_MAC($ligne["MacAddress"], $re[1]);
            continue;
        }
        UPDATE_HOURS_MAC($ligne["MacAddress"], $ligne["uid"], 30);
        $MACS["MACS"][$ligne["MacAddress"]]["UID"] = $ligne["uid"];
    }
    $q = new mysql_squid_builder();
    $sql = "SELECT * FROM webfilters_ipaddr WHERE LENGTH(uid)>1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        build_progress($ligne["ipaddr"], 40);
        $MACS["MACS"][$ligne["ipaddr"]]["UID"] = $ligne["uid"];
        $MACS["MACS"][$ligne["ipaddr"]]["GROUP"] = $ligne["group"];
        UPDATE_HOURS_IP($ligne["ipaddr"], $ligne["uid"], 40);
        if ($ligne["hostname"] != null) {
            $MACS["MACS"][$ligne["ipaddr"]]["HOST"] = $ligne["hostname"];
        }
    }
    $q = new mysql_squid_builder();
    $sql = "SELECT uid,MAC,ipaddr FROM hotspot_sessions WHERE LENGTH(uid)>1";
    $results = $q->QUERY_SQL($sql);
    while ($ligne = mysql_fetch_assoc($results)) {
        $MACS["MACS"][$ligne["MAC"]]["UID"] = $ligne["uid"];
        $MACS["MACS"][$ligne["MAC"]]["GROUP"] = "hotspot";
        $MACS["MACS"][$ligne["ipaddr"]]["UID"] = $ligne["uid"];
        $MACS["MACS"][$ligne["ipaddr"]]["GROUP"] = "hotspot";
    }
    $CountDeMac = count($MACS["MACS"]);
    $CountDeIP = count($MACS["IPS"]);
    build_progress("{saving}...", 50);
    @file_put_contents("/etc/squid3/usersMacs.db", serialize($MACS));
    $MD5_DEST = @md5_file("/etc/squid3/usersMacs.db");
    @file_put_contents("/usr/share/artica-postfix/ressources/databases/usersMacs.db", serialize($MACS));
    shell_exec("{$chmod} 755 /etc/squid3/usersMacs.db");
    shell_exec("{$chmod} 755 /usr/share/artica-postfix/ressources/databases/usersMacs.db");
    if ($CountDeMac == 0) {
        if ($CountDeIP == 0) {
            @unlink("/etc/squid3/usersMacs.db");
            if (IfInSquidConf()) {
                build_progress("{reconfigure_proxy_service}...", 80);
                shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
            }
            build_progress("{done} no item...", 100);
            return;
        }
    }
    if ($MD5_DEST == $MD5_SRC) {
        build_progress("{done}...", 100);
        return;
    }
    build_progress("{$CountDeMac} MACs, {$CountDeIP} Ips", 70);
    squid_admin_mysql(2, "Translation members database updated {$CountDeMac} MACs, {$CountDeIP} Ips", null, __FILE__, __LINE__);
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    if (!IfInSquidConf()) {
        build_progress("{reconfigure_proxy_service}...", 80);
        shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
        build_progress("{done}...", 100);
        return;
    }
    build_progress("{reloading}...", 80);
    ReloadMacHelpers();
    build_progress("{done}...", 100);
}
function search_records()
{
    //SELECT MacAddress, uid FROM hostsusers
    $search = '%';
    $q = new mysql_squid_builder();
    $page = CurrentPageName();
    $tpl = new templates();
    $q2 = new mysql();
    $limitSql = "LIMIT 0,150";
    $t = time();
    $searchstring = string_to_flexquery("search-records");
    $sql = "SELECT *  FROM webfilters_nodes WHERE 1 {$searchstring}  ORDER BY uid {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $sock = new sockets();
    $boot = new boostrap_form();
    if (!$q->ok) {
        echo "<p class=text-error>{$q->mysql_error}<hr><code>{$sql}</code></p>";
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $id = md5(serialize($ligne));
        $explainthis = null;
        $articasrv = null;
        $aliases_text = null;
        $explainMac = null;
        $OS = null;
        $macencoded = urlencode($ligne["MAC"]);
        $delete = imgsimple("delete-24.png", null, "Loadjs('{$page}?delete-mac-js={$macencoded}&id={$id}')");
        $jshost = "NewPDNSEntry{$t}({$id});";
        if (!IsPhysicalAddress($ligne["MAC"])) {
            continue;
        }
        if ($ligne["nmap"] == 1) {
            $array = unserialize(base64_decode($ligne["nmapreport"]));
            $OS = $array["OS"];
            $tt = array();
            if (count($array["PORTS"]) > 0) {
                while (list($port, $explain) = each($array["PORTS"])) {
                    $tt[] = "{$port} ({$explain})";
                }
                $ports = @implode(", ", $tt);
                $explainMac = "<div><i style='font-size:11px'>{$OS} {$ports}</i></div>";
            }
        }
        if ($ligne["uid"] == null) {
            $ligne2 = mysql_fetch_array($q2->QUERY_SQL("SELECT uid FROM hostsusers WHERE MacAddress='{$ligne["MAC"]}'", "artica_backup"));
            if ($ligne2["uid"] != null) {
                $q->QUERY_SQL("UPDATE webfilters_nodes SET uid='{$ligne2["uid"]}' WHERE MAC='{$ligne["MAC"]}'");
                $ligne["uid"] = $ligne2["uid"];
            }
        }
        $ips = array();
        $results2 = $q->QUERY_SQL("SELECT ipaddr FROM members_macip WHERE MAC='{$ligne["MAC"]}' ORDER BY ipaddr");
        while ($ligne2 = mysql_fetch_assoc($results2)) {
            $ips[] = $ligne2["ipaddr"];
        }
        if (count($ips) > 0) {
            $explainMac = "{$explainMac}<div><i style='font-size:11px'>" . @implode(", ", $ips) . "</i></div>";
        }
        $linkMAC = $boot->trswitch("Loadjs('{$page}?NewMacLink-js=yes&MAC={$macencoded}')");
        $linkVisit = $boot->trswitch("Loadjs('miniadm.squid.macbrowser.php?visits-day-js={$macencoded}')");
        $tr[] = "\n\t\t<tr id='{$id}'>\n\t\t<td {$linkMAC}><i class='icon-user'></i> {$ligne["MAC"]}</a>{$explainMac}</td>\n\t\t<td {$linkVisit} nowrap><i class='icon-user'></i> {$ligne["hostname"]}</a></td>\n\t\t<td {$linkVisit} nowrap><i class='icon-user'></i> {$ligne["uid"]}</td>\n\t\t<td style='text-align:center'>{$delete}</td>\n\t\t</tr>";
    }
    echo $tpl->_ENGINE_parse_body("\n\t\t<table class='table table-bordered table-hover'>\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{MAC}</th>\n\t\t\t\t\t<th>{hostname}</th>\n\t\t\t\t\t<th>{uid}</th>\n\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("\n", $tr) . " </tbody>\n\t\t\t</table>\n\t\t\t";
}
示例#10
0
function host_new()
{
    $_POST["new-mac"] = str_replace("-", ":", $_POST["new-mac"]);
    $mac = trim(strtolower($_POST["new-mac"]));
    if (!IsPhysicalAddress($mac)) {
        echo "{$mac}!! failed\n";
        return;
    }
    $tpl = new templates();
    $q = new mysql();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM dhcpd_fixed WHERE `mac`='{$mac}'", "artica_backup"));
    if ($ligne["hostname"] != null) {
        echo $tpl->javascript_parse_text("host_new():: {already_exists}: {$mac} [{$ligne["ipaddr"]}] ({$ligne["hostname"]})");
        return;
    }
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM dhcpd_fixed WHERE `ipaddr`='{$_POST["ipaddr"]}'", "artica_backup"));
    if ($ligne["mac"] != null) {
        echo $tpl->javascript_parse_text("host_new():: {already_exists}: [{$ligne["ipaddr"]}] ({$ligne["mac"]})");
        return;
    }
    $sql = "INSERT IGNORE INTO dhcpd_fixed (\n\t\t`hostname`,\n\t\t`ipaddr`,\n\t\t`domain`,\n\t\t`mac`,\n\t\t`routers`,\n\t\t`domain-name-servers`,\n\t\t`domain-name-servers-2`\n\t\t\n\t\t) VALUES\n\t\t\t(\n\t\t\t'{$_POST["hostname"]}',\n\t\t\t'{$_POST["ipaddr"]}',\n\t\t\t'{$_POST["domain"]}',\n\t\t\t'{$mac}',\n\t\t\t'{$_POST["routers"]}',\n\t\t\t'{$_POST["domain-name-servers"]}',\n\t\t\t'{$_POST["domain-name-servers2"]}'\n\t\t\t\n\t)";
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error . "\n\n{$sql}\n";
        return;
    }
    if (!isset($GLOBALS["APPLY_DHCP"])) {
        $GLOBALS["APPLY_DHCP"] = true;
        $sock = new sockets();
        $sock->getFrameWork("cmd.php?apply-dhcpd=yes");
    }
}
function host_new()
{
    $ip = new IP();
    $tpl = new templates();
    $mac = $_POST["new-mac"];
    if (!IsPhysicalAddress($mac)) {
        echo $tpl->javascript_parse_text("{invalid_mac}: {$mac}");
        return;
    }
    $sql = "SELECT * FROM dhcpd_fixed WHERE `mac`='{$mac}'";
    $q = new mysql();
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    if ($ligne["hostname"] != null) {
        echo $tpl->_ENGINE_parse_body("{already_exists}: {$mac} [{$ligne["ipaddr"]}] ({$ligne["hostname"]})");
        return;
    }
    $sql = "INSERT IGNORE INTO dhcpd_fixed (hostname,ipaddr,domain,mac) VALUES\n\t('{$_POST["hostname"]}','{$_POST["ipaddr"]}','{$_POST["domain"]}','{$mac}')";
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?apply-dhcpd=yes");
}
示例#12
0
function selection_list(){
	if($_GET["selection-list"]=='*'){$_GET["selection-list"]=null;}
	if($_GET["selection-list"]==null){$tofind="*";}else{$tofind="*{$_GET["selection-list"]}*";}
	$filter_search="(&(objectClass=ArticaComputerInfos)(|(cn=$tofind)(ComputerIP=$tofind)(uid=$tofind))(gecos=computer))";
	$ldap=new clladp();
	$attrs=array("uid","ComputerIP","ComputerOS","ComputerMachineType","ComputerMacAddress");
	$dn="$ldap->suffix";
	$hash=$ldap->Ldap_search($dn,$filter_search,$attrs,20);


$html="
<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='margin-top:8px'>
<thead class='thead'>
	<tr>
	<th colspan=4>$tofind&nbsp;</th>
	</tr>
</thead>
<tbody class='tbody'>";

for($i=0;$i<$hash["count"];$i++){
	$realuid=$hash[$i]["uid"][0];
	$hash[$i]["uid"][0]=str_replace('$','',$hash[$i]["uid"][0]);
	$js_show=MEMBER_JS($realuid,1);
	if($_GET["callback"]<>null){$js_selection="{$_GET["callback"]}('$realuid');";}
	

	
	$ip=$hash[$i][strtolower("ComputerIP")][0];
	$os=$hash[$i][strtolower("ComputerOS")][0];
	$type=$hash[$i][strtolower("ComputerMachineType")][0];
	$mac=$hash[$i][strtolower("ComputerMacAddress")][0];
	$name=$hash[$i]["uid"][0];
	if(strlen($name)>25){$name=substr($name,0,23)."...";}
	
	
	if($os=="Unknown"){if($type<>"Unknown"){$os=$type;}}
	
	if(strlen($os)>20){$os=texttooltip(substr($os,0,17).'...',$os,null,null,1);}
	if(strlen($ip)>20){$ip=texttooltip(substr($ip,0,17).'...',$ip,null,null,1);}
	if(!preg_match("#^[0-9]+\.[0-9]+\.[0-9]+#",$ip)){$ip=$ip="0.0.0.0";}
	$img=imgtootltip("computer-32.png","{view}",MEMBER_JS($realuid,1,1));
	
	$roolover=CellRollOver($js_selection,"{select}");
	
	
	if(!IsPhysicalAddress($mac)){
		$img=imgtootltip("computer-warning-32.png","{WARNING_MAC_ADDRESS_CORRUPT}");
		$roolover=CellRollOver($js_show,"{edit}<hr>{WARNING_MAC_ADDRESS_CORRUPT}");
		$js_selection=null;
	}
if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";}
	$html=$html . 
	"<tr class=$classtr>
	<td width=1%>$img</td>
	<td nowrap $roolover><strong style='font-size:13px'>$name</strong></td>
	<td $roolover><strong style='font-size:13px'>$ip</strong></td>
	<td $roolover><strong style='font-size:13px'>$mac</strong></td>
	$js_add
	</tr>
	";
	}
$html=$html . "</tbody></table>";
$tpl=new templates();
echo  $tpl->_ENGINE_parse_body($html);
	
}
示例#13
0
function computer_list()
{
    $tofindorg = $_GET["tofind"];
    if ($_GET["tofind"] == '*') {
        $_GET["tofind"] = null;
    }
    if ($_GET["tofind"] == null) {
        $tofind = "*";
    } else {
        $tofind = "*{$_GET["tofind"]}*";
    }
    $tofind = str_replace("**", "*", $tofind);
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    $ldap = new clladp();
    $attrs = array("uid", "ComputerIP", "ComputerOS", "ComputerMachineType", "ComputerMacAddress");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs, 20);
    if (IsPhysicalAddress($tofindorg)) {
        $tofind = strtolower($tofindorg);
        $tofind = str_replace('-', ":", $tofind);
        $patternMac = "(&(objectclass=posixAccount)(ComputerMacAddress={$tofind}))";
        $hash2 = $ldap->Ldap_search($dn, $patternMac, $attrs, 20);
    }
    $PowerDNS = "<td width=1%><h3>&nbsp;|&nbsp;</h3></td><td><h3>" . texttooltip('{APP_PDNS}', '{APP_PDNS_TEXT}', "javascript:Loadjs('pdns.php')") . "</h3></td>";
    if ($_GET["mode"] == "selection") {
        $PowerDNS = null;
    }
    $html = "\n\n<input type='hidden' id='mode' value='{$_GET["mode"]}' name='mode'>\n<input type='hidden' id='value' value='{$_GET["value"]}' name='value'>\n<input type='hidden' id='callback' value='{$_GET["callback"]}' name='callback'>\n<table style='width:100%'>\n\t<tr>\n\t\t<td width=1% nowrap><H3>{$hash["count"]} {computers}</H3></td>\n\t\t{$PowerDNS}\n\t</tr>\n</table>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView'>\n<thead class='thead'>\n\t<tr>\n\t<th colspan=4>{$tofind}</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = str_replace('$', '', $hash[$i]["uid"][0]);
        $js = MEMBER_JS($realuid, 1);
        $Alreadyrealuid[$realuid] = true;
        if ($_GET["mode"] == "dansguardian-ip-group") {
            $js_add = "<td width=1%>" . imgtootltip('add-18.gif', "{add_computer}", "AddComputerToDansGuardian('{$realuid}','{$_GET["value"]}')") . "</td>";
        }
        if ($_GET["mode"] == "selection") {
            $js = "{$_GET["callback"]}('{$realuid}');";
        }
        $ip = $hash[$i][strtolower("ComputerIP")][0];
        $os = $hash[$i][strtolower("ComputerOS")][0];
        $type = $hash[$i][strtolower("ComputerMachineType")][0];
        $name = $hash[$i]["uid"][0];
        if (strlen($name) > 25) {
            $name = substr($name, 0, 23) . "...";
        }
        if ($os == "Unknown") {
            if ($type != "Unknown") {
                $os = $type;
            }
        }
        if (strlen($os) > 20) {
            $os = texttooltip(substr($os, 0, 17) . '...', $os, null, null, 1);
        }
        if (strlen($ip) > 20) {
            $ip = texttooltip(substr($ip, 0, 17) . '...', $ip, null, null, 1);
        }
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $js = str_replace("javascript:", '', $js);
        $html = $html . "<tr>\n\t<td width=1% class={$classtr}><img src='img/computer-32.png'></td>\n\t<td {$roolover} nowrap><a href='#' OnClick=\"javascript:{$js}\" style='font-size:13px;text-decoration:underline'>{$name}</a></td>\n\t<td {$roolover} style='font-size:13px'>{$ip}</a></td>\n\t<td {$roolover} style='font-size:13px'>{$os}</a></td>\n\t{$js_add}\n\t</tr>\n\t";
    }
    if (is_array($hash2)) {
        for ($i = 0; $i < $hash2["count"]; $i++) {
            $realuid = $hash2[$i]["uid"][0];
            if (isset($Alreadyrealuid[$realuid])) {
                continue;
            }
            $hash2[$i]["uid"][0] = str_replace('$', '', $hash2[$i]["uid"][0]);
            $js = MEMBER_JS($realuid, 1);
            $Alreadyrealuid[$realuid] = true;
            if ($_GET["mode"] == "dansguardian-ip-group") {
                $js_add = "<td width=1%>" . imgtootltip('add-18.gif', "{add_computer}", "AddComputerToDansGuardian('{$realuid}','{$_GET["value"]}')") . "</td>";
            }
            if ($_GET["mode"] == "selection") {
                $js = "{$_GET["callback"]}('{$realuid}');";
            }
            $ip = $hash2[$i][strtolower("ComputerIP")][0];
            $os = $hash2[$i][strtolower("ComputerOS")][0];
            $type = $hash2[$i][strtolower("ComputerMachineType")][0];
            $name = $hash2[$i]["uid"][0];
            if (strlen($name) > 25) {
                $name = substr($name, 0, 23) . "...";
            }
            if ($os == "Unknown") {
                if ($type != "Unknown") {
                    $os = $type;
                }
            }
            if (strlen($os) > 20) {
                $os = texttooltip(substr($os, 0, 17) . '...', $os, null, null, 1);
            }
            if (strlen($ip) > 20) {
                $ip = texttooltip(substr($ip, 0, 17) . '...', $ip, null, null, 1);
            }
            if ($classtr == "oddRow") {
                $classtr = null;
            } else {
                $classtr = "oddRow";
            }
            $js = str_replace("javascript:", '', $js);
            $html = $html . "<tr>\n\t\t\t<td width=1% class={$classtr}><img src='img/computer-32.png'></td>\n\t\t\t<td {$roolover} nowrap><a href='#' OnClick=\"javascript:{$js}\" style='font-size:13px;text-decoration:underline'>{$name}</a></td>\n\t\t\t<td {$roolover} style='font-size:13px'>{$ip}</a></td>\n\t\t\t<td {$roolover} style='font-size:13px'>{$os}</a></td>\n\t\t\t{$js_add}\n\t\t\t</tr>\n\t\t\t";
        }
    }
    $html = $html . "</tbody></table>";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
function MacToUid()
{
    $array = array();
    $q = new mysql_squid_builder();
    $sql = "SELECT * FROM webfilters_nodes WHERE LENGTH(uid)>1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($ligne["MAC"] == "00:00:00:00:00:00") {
            continue;
        }
        if (!IsPhysicalAddress($ligne["MAC"])) {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$ligne["MAC"]} = {$ligne["uid"]}\n";
        }
        $array[$ligne["MAC"]] = $ligne["uid"];
    }
    $sql = "SELECT * FROM webfilters_ipaddr WHERE LENGTH(uid)>1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        $array[$ligne["ipaddr"]] = $ligne["uid"];
    }
    $q = new mysql();
    $sql = "SELECT MacAddress, uid FROM hostsusers";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        $mac = strtolower(trim($ligne["MacAddress"]));
        if (!IsPhysicalAddress($mac)) {
            continue;
        }
        $uid = strtolower(trim($ligne["uid"]));
        $array[$mac] = $uid;
    }
    @file_put_contents("/etc/squid3/MacToUid.ini", serialize($array));
    if (count($array) > 0) {
        iFBuildMacToUid();
    }
}
function computers_search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $boot = new boostrap_form();
    $q = new mysql();
    $sock = new sockets();
    $fontsize = "14px";
    $page = 1;
    if (!$q->DATABASE_EXISTS("ocsweb")) {
        $sock->getFrameWork("services.php?mysql-ocs=yes");
    }
    if (!$q->TABLE_EXISTS("hardware", "ocsweb")) {
        $sock->getFrameWork("services.php?mysql-ocs=yes");
    }
    if (!$q->TABLE_EXISTS("networks", "ocsweb", true)) {
        $sock->getFrameWork("services.php?mysql-ocs=yes");
    }
    $EnableScanComputersNet = $sock->GET_INFO("EnableScanComputersNet");
    if (!is_numeric($EnableScanComputersNet)) {
        $EnableScanComputersNet = 0;
    }
    if (!$q->FIELD_EXISTS("networks", "isActive", "ocsweb")) {
        $q->QUERY_SQL("ALTER TABLE `networks` ADD `isActive` SMALLINT( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `isActive` ) ", "ocsweb");
    }
    $ORDER = $boot->TableOrder(array("NAME" => "ASC"));
    $searchstring = string_to_flexquery("computer-search");
    $table = "(SELECT networks.MACADDR,networks.IPADDRESS,\n\t\t\thardware.OSNAME,\n\t\t\thardware.LASTDATE,\n\t\t\thardware.NAME,\n\t\t\thardware.IPADDR,\n\t\t\thardware.IPSRC\n\t\t\tFROM networks,hardware WHERE networks.HARDWARE_ID=hardware.ID) as t";
    $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250";
    $results = $q->QUERY_SQL($sql, "ocsweb");
    if (!$q->ok) {
        echo $q->mysql_error . "<br>{$sql}\n";
    }
    $computer = new computers();
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($ligne["MACADDR"] == "unknown") {
            continue;
        }
        $uid = null;
        $OSNAME = null;
        if ($ligne["OSNAME"] == "Unknown") {
            $ligne["OSNAME"] = null;
        }
        $color = "#7D7D7D";
        $md = md5($ligne["MACADDR"]);
        $uri = strtolower($ligne["NAME"]);
        $uid = $computer->ComputerIDFromMAC($ligne["MACADDR"]);
        $view = "&nbsp;";
        $jsfiche = MEMBER_JS($uid, 1, 1);
        $js = null;
        if ($uid != null) {
            $js = $boot->trswitch($jsfiche);
        }
        if ($ligne["OSNAME"] != null) {
            $OSNAME = "<div style='font-size:9px'><i>{$ligne["OSNAME"]}</i></div>";
        }
        $isActive = "img/unknown24.png";
        if ($EnableScanComputersNet == 1) {
            if ($ligne["isActive"] == 1) {
                $isActive = "img/ok24.png";
            } else {
                $isActive = "img/danger24.png";
            }
        }
        if (!IsPhysicalAddress($ligne["MACADDR"])) {
            if ($_GET["CorrectMac"] == 1) {
                continue;
            }
        }
        $AlreadyMAC[$ligne["MACADDR"]] = true;
        $zdate = null;
        if (isset($ligne["zDate"])) {
            $zdate = "<div style='font-size:11px;color:#7D7D7D'>{$ligne["zDate"]}</div>";
        }
        $tr[] = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px' nowrap  width=1% {$js}>{$ligne["LASTDATE"]}</td>\n\t\t\t<td style='font-size:18px' nowrap {$js}>{$ligne["NAME"]}</td>\n\t\t\t<td style='font-size:18px' nowrap width=1% {$js}>{$ligne["IPADDRESS"]}</td>\n\t\t\t<td style='font-size:18px' nowrap width=1% {$js}>{$ligne["MACADDR"]}</td>\n\t\t\t<td style='font-size:18px' nowrap width=1% {$js}><img src='{$isActive}'></td>\t\t\t\n\t\t\t\t\n\t\t</tr>";
    }
    echo $boot->TableCompile(array("LASTDATE" => "{date}", "NAME" => "{hostname}", "IPADDRESS" => "{ipaddr}", "MACADDR" => "{MAC}"), $tr);
}
示例#16
0
function SearchComputers()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $sock = new sockets();
    $EnableIntelCeleron = intval($sock->GET_INFO("EnableIntelCeleron"));
    $q = new mysql();
    $sock = new sockets();
    $fontsize = "14px";
    $cs = 0;
    $page = 1;
    if (!$q->DATABASE_EXISTS("ocsweb")) {
        $sock->getFrameWork("services.php?mysql-ocs=yes");
    }
    if (!$q->TABLE_EXISTS("hardware", "ocsweb")) {
        $sock->getFrameWork("services.php?mysql-ocs=yes");
    }
    if (!$q->TABLE_EXISTS("networks", "ocsweb", true)) {
        $sock->getFrameWork("services.php?mysql-ocs=yes");
    }
    if (!$q->FIELD_EXISTS("networks", "isActive", "ocsweb")) {
        $q->QUERY_SQL("ALTER TABLE `networks` ADD `isActive` SMALLINT( 1 ) NOT NULL DEFAULT '0',ADD INDEX ( `isActive` ) ", "ocsweb");
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $table = "(SELECT networks.HARDWARE_ID,networks.MACADDR,networks.STATUS,networks.IPADDRESS,networks.isActive,\n\t\t\thardware.* FROM networks,hardware WHERE networks.HARDWARE_ID=hardware.ID) as t";
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "ocsweb"));
        if (!$q->ok) {
            json_error_show($q->mysql_error . "<br>{$sql}");
        }
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "ocsweb"));
        if (!$q->ok) {
            json_error_show($q->mysql_error . "<br>{$sql}");
        }
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql, "ocsweb");
    if (!$q->ok) {
        json_error_show($q->mysql_error . "<hr>{$sql}");
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data");
    }
    $users = new usersMenus();
    $DHC_MAIN = false;
    if ($users->dhcp_installed) {
        $EnableDHCPServer = intval($sock->GET_INFO('EnableDHCPServer'));
        if ($EnableDHCPServer == 1) {
            $DHC_MAIN = true;
        }
    }
    $SQUID_MAIN = false;
    if ($users->SQUID_INSTALLED) {
        $SQUID_MAIN = true;
    }
    $fontsize = "22px";
    $computer = new computers();
    $q2 = new mysql_squid_builder();
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($ligne["MACADDR"] == "unknown") {
            continue;
        }
        $ligne["MACADDR"] = strtolower($ligne["MACADDR"]);
        $HARDWARE_ID = $ligne["HARDWARE_ID"];
        $uid = null;
        $OSNAME = null;
        if ($ligne["OSNAME"] == "Unknown") {
            $ligne["OSNAME"] = null;
        }
        $color = "#7D7D7D";
        $md = md5($ligne["MACADDR"]);
        $uri = strtolower($ligne["NAME"]);
        if ($EnableIntelCeleron == 0) {
            $uid = $computer->ComputerIDFromMAC($ligne["MACADDR"]);
        }
        $view = "&nbsp;";
        $jslink = null;
        $jsfiche = null;
        $ISDB = "ok32-grey.png";
        $DHCP = "ok32-none.png";
        $SQUID = "ok32-none.png";
        if ($DHC_MAIN) {
            $DHCP = "ok32-grey.png";
            if ($computer->dhcpfixedFromMac($ligne["MACADDR"])) {
                $DHCP = "ok32.png";
            }
        }
        if ($SQUID_MAIN) {
            $ligne2 = mysql_fetch_array($q2->QUERY_SQL("SELECT enabled FROM computers_time WHERE `MAC`='{$ligne["MACADDR"]}'", "artica_backup"));
            if (intval($ligne2["enabled"]) != 0) {
                $SQUID = "warning24.png";
            }
        }
        if ($uid != null) {
            $ISDB = "ok32.png";
            $jsfiche = MEMBER_JS($uid, 1, 1);
            $view = "<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:{$jsfiche}\" \n\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>" . str_replace("\$", "", strtolower($uid)) . "</a>";
            $jslink = "<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:{$jsfiche}\" \n\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>";
        } else {
            $uid = $ligne["NAME"];
            if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+#", $uid)) {
                $q = new mysql_squid_builder();
                $NAME2 = $q->UID_FROM_MAC($ligne["MACADDR"]);
                if ($NAME2 != null) {
                    $uid = $NAME2;
                }
            }
            if ($uid == null) {
                $uid = "Unknown";
            }
            $jsfiche = "Loadjs('domains.computer.autoadd.php?mac=" . urlencode($ligne["MACADDR"]) . "&ipaddr=" . urlencode($ligne["IPADDRESS"]) . "&computername=" . urlencode($uid) . "&t={$_GET["t"]}')";
            if ($EnableIntelCeleron == 1) {
                $jsfiche = "Loadjs('domains.computer.mysql.php?HARDWARE_ID={$HARDWARE_ID}&t={$_GET["t"]}')";
            }
            $jslink = "<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:{$jsfiche}\"\n\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>";
            $view = "<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:{$jsfiche}\"\n\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>{$uid}</a>";
        }
        $js[] = "LoadAjaxTiny('cmp-{$md}','{$page}?compt-status={$ligne["IPADDRESS"]}');";
        $icon = "<img src='img/{$ISDB}'>";
        if ($ligne["OSNAME"] != null) {
            $OSNAME = "<div style='font-size:9px'><i>{$ligne["OSNAME"]}</i></div>";
        }
        if ($_GET["callback"] != null) {
            $color = "black";
            if ($_GET["fullvalues"] == 1) {
                $viewjs = "{$_GET["callback"]}('{$uid}','{$ligne["IPADDRESS"]}','{$ligne["MACADDR"]}')";
            } else {
                $viewjs = "{$_GET["callback"]}('{$uid}')";
            }
            $view = "<a href=\"javascript:blur();\" \n\t\t\t\t\t\tOnClick=\"javascript:{$viewjs}\" \n\t\t\t\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>" . str_replace("\$", "", strtolower($uid)) . "</a>";
            $icon = imgtootltip("arrow-blue-left-32.png", null, $viewjs);
        }
        if (!IsPhysicalAddress($ligne["MACADDR"])) {
            if ($_GET["CorrectMac"] == 1) {
                continue;
            }
        }
        $AlreadyMAC[$ligne["MACADDR"]] = true;
        $zdate = null;
        if (isset($ligne["zDate"])) {
            $zdate = "<div style='font-size:11px;color:#7D7D7D'>{$ligne["zDate"]}</div>";
        }
        $macenc = urlencode($ligne["MACADDR"]);
        $ipenc = urlencode($ligne["IPADDRESS"]);
        $jsDelete = "Loadjs('{$MyPage}?delete-computer-js=yes&MAC={$macenc}&t={$_GET["t"]}');";
        $alias = $q2->UID_FROM_MAC($ligne["MACADDR"]);
        if ($alias != null) {
            $alias_uri = "Loadjs('squid.nodes.php?node-infos-js=yes&MAC={$macenc}');";
        }
        if ($alias == null) {
            $alias = $q2->UID_FROM_IP($ligne["IPADDRESS"]);
            if ($alias != null) {
                $alias_uri = "Loadjs('squid.nodes.php?node-infos-js=yes&ipaddr={$ipenc}');";
            }
        }
        if ($alias == null) {
            $alias = "<center><img src='img/32-plus.png'></center>";
            $alias_uri = "Loadjs('squid.nodes.php?link-user-js=yes&MAC={$macenc}&ipaddr={$ipenc}',true)";
        }
        if ($EnableIntelCeleron == 1) {
            $jsfiche = "Loadjs('domains.computer.mysql.php?HARDWARE_ID={$HARDWARE_ID}&t={$_GET["t"]}')";
        }
        $cs++;
        $data['rows'][] = array('id' => md5(serialize($ligne)), 'cell' => array($view . $zdate, "<span style='font-size:{$fontsize}'>{$jslink}{$ligne["IPADDRESS"]}</a></span>", "<span style='font-size:{$fontsize}'>{$jslink}{$ligne["MACADDR"]}</a></span>", "<span style='font-size:{$fontsize}'><a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:{$alias_uri}\" style='text-decoration:underline'>{$alias}</a></span>", "<center><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsfiche}\">{$icon}</a></center>", "<center><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsfiche}\"><img src='img/{$DHCP}'></center></a>", "<center><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsfiche}\"><img src='img/{$SQUID}'></center></a>", "<center><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsDelete}\"><img src='img/delete-32.png'></center></a>"));
    }
    if ($cs > $_POST["rp"]) {
        $data['total'] = $cs;
        echo json_encode($data);
        return;
    }
    if ($cs == 0) {
        json_error_show("no item");
    }
    $data['total'] = $cs;
    echo json_encode($data);
}
示例#17
0
function computer_list()
{
    $tofindorg = $_POST["query"];
    $tpl = new templates();
    $_GET["tofind"] = $_POST["query"];
    $MyPage = CurrentPageName();
    if ($_GET["tofind"] == '*') {
        $_GET["tofind"] = null;
    }
    if ($_GET["tofind"] == null) {
        $tofind = "*";
    } else {
        $tofind = "*{$_GET["tofind"]}*";
    }
    $tofind = str_replace("**", "*", $tofind);
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    $ldap = new clladp();
    $attrs = array("uid", "ComputerIP", "ComputerOS", "ComputerMachineType", "ComputerMacAddress");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs, $_POST["rp"]);
    if (IsPhysicalAddress($tofindorg)) {
        $tofind = strtolower($tofindorg);
        $tofind = str_replace('-', ":", $tofind);
        $patternMac = "(&(objectclass=posixAccount)(ComputerMacAddress={$tofind}))";
        $hash2 = $ldap->Ldap_search($dn, $patternMac, $attrs, $_POST["rp"]);
    }
    $spanStyle = "<span style='font-size:14px;font-weight:bold'>";
    $data['page'] = 1;
    $data['total'] = $hash["count"];
    $data['rows'] = array();
    $c = 0;
    $unknown = $tpl->_ENGINE_parse_body("{unknown}");
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = str_replace('$', '', $hash[$i]["uid"][0]);
        $js = MEMBER_JS($realuid, 1);
        $Alreadyrealuid[$realuid] = true;
        if ($_GET["mode"] == "dansguardian-ip-group") {
            $js_add = "<td width=1%>" . imgtootltip('add-18.png', "{add_computer}", "AddComputerToDansGuardian('{$realuid}','{$_GET["value"]}')") . "</td>";
        }
        if ($_GET["mode"] == "selection") {
            $js = "{$_GET["callback"]}('{$realuid}');";
        }
        $ip = $hash[$i][strtolower("ComputerIP")][0];
        $os = $hash[$i][strtolower("ComputerOS")][0];
        $type = $hash[$i][strtolower("ComputerMachineType")][0];
        $name = $hash[$i]["uid"][0];
        if ($os == "Unknown") {
            if ($type != "Unknown") {
                $os = $type;
            }
        }
        $js = str_replace("javascript:", '', $js);
        $md5S = md5(serialize($hash[$i]));
        if (!preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $ip)) {
            $ip = gethostbyname($hash[$i]["uid"][0]);
            if (!preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $ip)) {
                $ip = $unknown;
            } else {
                $computer = new computers($realuid);
                $computer->update_ipaddr($ip);
            }
        }
        if ($os == "UnKnown") {
            $os = $unknown;
        }
        $c++;
        $delete = imgsimple("delete-24.png", null, "Loadjs('{$MyPage}?computer-delete-js=yes&uid={$realuid}&id={$md5S}')");
        $data['rows'][] = array('id' => $md5S, 'cell' => array("<img src='img/computer-32.png'>", "<a href='#' OnClick=\"javascript:{$js}\" style='font-size:14px;text-decoration:underline;font-weight:bold'>{$name}</a>", "{$spanStyle}{$ip}</span>", "{$spanStyle}{$os}</span>", $delete));
    }
    if (is_array($hash2)) {
        for ($i = 0; $i < $hash2["count"]; $i++) {
            $realuid = $hash2[$i]["uid"][0];
            if (isset($Alreadyrealuid[$realuid])) {
                continue;
            }
            $hash2[$i]["uid"][0] = str_replace('$', '', $hash2[$i]["uid"][0]);
            $js = MEMBER_JS($realuid, 1);
            $Alreadyrealuid[$realuid] = true;
            if ($_GET["mode"] == "dansguardian-ip-group") {
                $js_add = "<td width=1%>" . imgtootltip('add-18.png', "{add_computer}", "AddComputerToDansGuardian('{$realuid}','{$_GET["value"]}')") . "</td>";
            }
            if ($_GET["mode"] == "selection") {
                $js = "{$_GET["callback"]}('{$realuid}');";
            }
            $ip = $hash2[$i][strtolower("ComputerIP")][0];
            $os = $hash2[$i][strtolower("ComputerOS")][0];
            $type = $hash2[$i][strtolower("ComputerMachineType")][0];
            $name = $hash2[$i]["uid"][0];
            if (strlen($name) > 25) {
                $name = substr($name, 0, 23) . "...";
            }
            if ($os == "Unknown") {
                if ($type != "Unknown") {
                    $os = $type;
                }
            }
            if (strlen($os) > 20) {
                $os = texttooltip(substr($os, 0, 17) . '...', $os, null, null, 1);
            }
            if (strlen($ip) > 20) {
                $ip = texttooltip(substr($ip, 0, 17) . '...', $ip, null, null, 1);
            }
            $js = str_replace("javascript:", '', $js);
            $md5S = md5(serialize($hash2[$i]));
            $delete = imgsimple("delete-24.png", null, "Loadjs('{$MyPage}?computer-delete-js=yes&uid={$realuid}&id={$md5S}');");
            $c++;
            $data['rows'][] = array('id' => $md5S, 'cell' => array("<img src='img/computer-32.png'>", "<a href='#' OnClick=\"javascript:{$js}\" style='font-size:13px;text-decoration:underline'>{$name}</a>", "{$spanStyle}{$ip}</span>", "{$spanStyle}{$os}</span>", $delete));
        }
    }
    $data['total'] = $c;
    if ($c == 0) {
        json_error_show("no item");
    }
    echo json_encode($data);
}
示例#18
0
function AddComputer_save()
{
    $q = new mysql();
    $tpl = new templates();
    $mac = trim($_POST["computer-mac"]);
    $mac = strtolower($mac);
    $mac = str_replace("-", ":", $mac);
    $_POST["computer-name"] = trim($_POST["computer-name"]);
    $_POST["computer-name"] = strtolower($_POST["computer-name"]);
    $_POST["userid"] = trim($_POST["userid"]);
    $_POST["userid"] = strtolower($_POST["userid"]);
    if (trim($_POST["userid"] == null)) {
        echo $tpl->javascript_parse_text("{error_no_member_set}");
        return;
    }
    if (!IsPhysicalAddress($mac)) {
        echo $tpl->javascript_parse_text("{WARNING_MAC_ADDRESS_CORRUPT}");
        return;
    }
    $zmd5 = md5($_POST["userid"] . $mac);
    $sql = "INSERT IGNORE INTO hostsusers (`zmd5`,`uid`,`computerid`,`MacAddress`) VALUES('{$zmd5}','{$_POST["userid"]}','{$_POST["computer-name"]}','{$mac}')";
    $q->QUERY_SQL($sql, 'artica_backup');
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("squid.php?reconfigure-quotas=yes");
}
示例#19
0
function COMPUTER_CHECK_MAC()
{
    $tpl = new templates();
    $mac = $_GET["ComputerMacAddressFindUid"];
    $comp = new computers();
    $uid = trim($comp->ComputerIDFromMAC($mac));
    if ($uid != null) {
        if ($uid != $_GET["userid"]) {
            echo $tpl->_ENGINE_parse_body(imgtootltip("status_warning.png", "{this_mac_address_is_already_used_by}:{$uid}"));
            return;
        }
    }
    if (!IsPhysicalAddress($_GET["ComputerMacAddressFindUid"])) {
        echo $tpl->_ENGINE_parse_body(imgtootltip("status_warning.png", "{WARNING_MAC_ADDRESS_CORRUPT}"));
        return;
    }
    echo "<img src='img/ok16.png'>";
}
示例#20
0
function apr_edit()
{
    $tpl = new templates();
    $page = CurrentPageName();
    if (!IsPhysicalAddress($_POST["ARP_MAC"])) {
        echo $tpl->javascript_parse_text("{WARNING_MAC_ADDRESS_CORRUPT}");
        return;
    }
    $sock = new sockets();
    $datas = urlencode(base64_encode(serialize($_POST)));
    $sock->getFrameWork("network.php?arp-edit={$datas}");
}
function members_mac_from_dansguardian_events($tablename, $time)
{
    $zdate = date("Y-m-d", $time);
    $q = new mysql_squid_builder();
    $sql = "SELECT MAC, SUM(QuerySize) as size,SUM(hits) as hits FROM {$tablename} GROUP BY MAC\n\tHAVING LENGTH(MAC)>0";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        if ($GLOBALS["VERBOSE"]) {
            echo "############# ERROR #########\n{$q->mysql_error}\\Line:" . __LINE__ . "\n#############\n";
        }
        return false;
    }
    $prefix = "INSERT IGNORE INTO `members_mac` (zmd5,zDate,MAC,size,hits) VALUES ";
    if (mysql_num_rows($results) == 0) {
        return true;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $MAC = $ligne["MAC"];
        if (!IsPhysicalAddress($MAC)) {
            continue;
        }
        $size = $ligne["size"];
        $hits = $ligne["hits"];
        $md5 = md5("{$MAC}{$zdate}");
        $f[] = "('{$md5}','{$zdate}','{$MAC}','{$size}','{$hits}')";
        if (count($f) > 500) {
            $q->QUERY_SQL($prefix . @implode(",", $f));
            if ($GLOBALS["VERBOSE"]) {
                echo "From: {$tablename} " . count($f) . " items\n";
            }
            $f = array();
            if (!$q->ok) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "############# ERROR #########\n{$q->mysql_error}\\Line:" . __LINE__ . "\n#############\n";
                }
                return false;
            }
        }
    }
    if (count($f) > 0) {
        $q->QUERY_SQL($prefix . @implode(",", $f));
        if ($GLOBALS["VERBOSE"]) {
            echo "From: {$tablename} " . count($f) . " items\n";
        }
        $f = array();
        if (!$q->ok) {
            if ($GLOBALS["VERBOSE"]) {
                echo "############# ERROR #########\n{$q->mysql_error}\\Line:" . __LINE__ . "\n#############\n";
            }
            return false;
        }
    }
    return true;
}
function members_macip_from_hourtable($tablename, $time)
{
    $zdate = date("Y-m-d", $time);
    $q = new mysql_squid_builder();
    $sql = "SELECT MAC, client FROM {$tablename} GROUP BY MAC,client HAVING LENGTH(MAC)>0";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        if ($GLOBALS["VERBOSE"]) {
            echo "############# ERROR #########\n{$q->mysql_error}\\Line:" . __LINE__ . "\n#############\n";
        }
        return false;
    }
    $prefix = "INSERT IGNORE INTO `members_macip` (zmd5,MAC,ipaddr) VALUES ";
    if (mysql_num_rows($results) == 0) {
        return true;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $MAC = $ligne["MAC"];
        if (!IsPhysicalAddress($MAC)) {
            continue;
        }
        $client = $ligne["client"];
        $md5 = md5("{$MAC}{$client}");
        $f[] = "('{$md5}','{$MAC}','{$client}')";
        if (count($f) > 500) {
            $q->QUERY_SQL($prefix . @implode(",", $f));
            if ($GLOBALS["VERBOSE"]) {
                echo "From: {$tablename} " . count($f) . " items\n";
            }
            if (!$q->ok) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "############# ERROR #########\n{$q->mysql_error}\\Line:" . __LINE__ . "\n#############\n";
                }
            }
            $f = array();
            if (!$q->ok) {
                return false;
            }
        }
    }
    if (count($f) > 0) {
        $q->QUERY_SQL($prefix . @implode(",", $f));
        if ($GLOBALS["VERBOSE"]) {
            echo "From: {$tablename} " . count($f) . " items\n";
        }
        $f = array();
        if (!$q->ok) {
            if ($GLOBALS["VERBOSE"]) {
                echo "############# ERROR #########\n{$q->mysql_error}\\Line:" . __LINE__ . "\n#############\n";
            }
        }
        if (!$q->ok) {
            return false;
        }
    }
    return true;
}