Example #1
0
function parseTemplate_sendemail_js()
{
    include_once dirname(__FILE__) . "/ressources/class.sockets.inc";
    include_once dirname(__FILE__) . "/ressources/class.user.inc";
    include_once dirname(__FILE__) . "/ressources/class.external_acl_squid_ldap.inc";
    include_once dirname(__FILE__) . "/ressources/class.templates.inc";
    $tpl = new templates();
    $your_query_was_sent_to_administrator = $tpl->javascript_parse_text("{your_query_was_sent_to_administrator}", 0);
    $ARRAY = unserialize(base64_decode($_GET["serialize"]));
    $client_username = $ARRAY["clientname"];
    $SquidGuardIPWeb = $ARRAY["SquidGuardIPWeb"];
    $email = null;
    $t = time();
    if ($client_username != null) {
        $sock = new sockets();
        $EnableKerbAuth = intval($sock->GET_INFO("EnableKerbAuth"));
        if ($EnableKerbAuth == 1) {
            $ad = new external_acl_squid_ldap();
            $array = $ad->ADLdap_userinfos($client_username);
            $email = $array[0]["mail"][0];
        } else {
            $users = new user($client_username);
            if (count($users->email_addresses) > 0) {
                $email = $users->email_addresses[0];
            }
        }
    }
    if ($email != null) {
        echo "\n\t\t// {$client_username}\n\t\tvar xSMTPNotifValues{$t}= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>3){alert(results);}\n\t\t}\n\t\t\n\t\tfunction SMTPNotifValues{$t}(){\n\t\t\n\t\tvar jqxhr = \$.post( '{$SquidGuardIPWeb}',{'send-smtp-notif':'{$email}','MAIN_ARRAY':'{$_GET["serialize"]}'}, function(result) {\n\t\t\talert( '{$your_query_was_sent_to_administrator}' );\n\t\t})\n\t\t.done(function(result) {\n\t\talert('{$your_query_was_sent_to_administrator}' );\n\t\t})\n\t\t.fail(function() {\n\t\talert( '{$your_query_was_sent_to_administrator}' );\n\t\t})\n\t\t.always(function() {\n\t\t//alert( 'unknown' );\n\t\t});\n\t\t\n\t\t\n\t\t//\tvar XHR = new XHRConnection();\n\t\t//\tXHR.setLockOff();\n\t\t//\tXHR.appendData('send-smtp-notif','{$email}');\n\t\t//\tXHR.appendData('MAIN_ARRAY','{$_GET["serialize"]}');\n\t\t//\tXHR.sendAndLoad('{$SquidGuardIPWeb}', 'POST',xSMTPNotifValues{$t});\n\t\t}\n\t\tSMTPNotifValues{$t}();";
        return;
    }
    $tpl = new templates();
    $title = $tpl->javascript_parse_text("{give_your_email_address}");
    echo " //{$client_username}\n\tvar xSMTPNotifValues{$t}= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);}\n\t}\n\t\n\tfunction SMTPNotifValues{$t}(){\n\t\tvar email=prompt('{$title}');\n\t\tif(!email){return;}\n\t\t\n\t\tvar jqxhr = \$.post( '{$SquidGuardIPWeb}',{'send-smtp-notif':email,'MAIN_ARRAY':'{$_GET["serialize"]}'}, function(result) {\n\t\t\talert( '{$your_query_was_sent_to_administrator}' );\n\t\t})\n\t\t.done(function(result) {\n\t\t\talert('{$your_query_was_sent_to_administrator}' );\n\t\t})\n\t\t.fail(function(xhr, textStatus, errorThrown){\n\t\t\t alert('{$your_query_was_sent_to_administrator}' +xhr.responseText);\n\t\t\t \t\t \n\t\t})\n\t\t.always(function() {\n\t\t //none\n\t\t});\n\t\t\n\t\t\n\t\t//var XHR = new XHRConnection();\n\t\t//XHR.appendData('send-smtp-notif',email);\n\t\t//XHR.appendData('MAIN_ARRAY','{$_GET["serialize"]}');\n\t\t//XHR.sendAndLoad('{$SquidGuardIPWeb}', 'POST',xSMTPNotifValues{$t});\n\t}\n\tSMTPNotifValues{$t}();";
    return;
}
function ufdbguard_checks($id)
{
    LoadSettings();
    if ($GLOBALS["VERBOSE"]) {
        $GLOBALS["output"] = true;
        echo "OPEN: /etc/squid3/ufdb.groups.{$id}.db\n";
    }
    if (!is_file("/etc/squid3/ufdb.groups.{$id}.db")) {
        if ($GLOBALS["output"]) {
            echo "Cannot perform this operation\nYou have to create correctly a Web filtering rule\nIncluding blacklists and whitelists\nAnd compile your Web filtering rules in order to dump groups\n";
        }
        return null;
    }
    $arrayGROUPS = unserialize(@file_get_contents("/etc/squid3/ufdb.groups.{$id}.db"));
    $FINAL = array();
    $Hash = array();
    if ($GLOBALS["VERBOSE"]) {
        echo "DUMP: ARRAY ***********************\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        print_r($arrayGROUPS);
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "***********************************\n";
    }
    if (isset($arrayGROUPS["EXT-LDAP"])) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Found:EXT-LDAP\n";
        }
        $extn_ldap = new ldap_extern();
        while (list($index, $DNS) = each($arrayGROUPS["EXT-LDAP"])) {
            if ($GLOBALS["VERBOSE"]) {
                echo "DN:{$DNS}\n";
            }
            $rr = $extn_ldap->HashUsersFromGroupDN($DNS);
            if ($GLOBALS["output"]) {
                echo "{$DNS} return " . count($rr) . " users\n";
            }
            while (list($a, $b) = each($rr)) {
                $b = trim($b);
                if ($b == null) {
                    continue;
                }
                echo "USER= {$b}\n";
                $MemberArray[$a] = $a;
            }
            while (list($a, $b) = each($MemberArray)) {
                $FINAL[] = $a;
            }
        }
    }
    if (isset($arrayGROUPS["EXTLDAP"])) {
        while (list($index, $CONFS) = each($arrayGROUPS["EXTLDAP"])) {
            $rr = external_ldap_members($CONFS["DN"], $CONFS["CONF"]);
            if ($GLOBALS["output"]) {
                echo "{$CONFS["DN"]} return " . count($rr) . " users\n";
            }
            while (list($a, $b) = each($rr)) {
                echo "USER= {$b}\n";
                $MemberArray[$a] = $a;
            }
        }
        while (list($a, $b) = each($MemberArray)) {
            $FINAL[] = $a;
        }
    }
    if (isset($arrayGROUPS["AD"])) {
        while (list($index, $DNenc) = each($arrayGROUPS["AD"])) {
            $DN = base64_decode($DNenc);
            if ($GLOBALS["output"]) {
                echo "Loading Active Directory groups...\n";
            }
            if ($GLOBALS["output"]) {
                echo "Branch {$DN}\n";
            }
            if ($GLOBALS["VERBOSE"]) {
                echo "DN, {$DN}\n";
            }
            $ldapExt = new external_acl_squid_ldap();
            $members = $ldapExt->AdLDAP_MembersFromGroup($DN);
            if ($GLOBALS["VERBOSE"]) {
                echo "DN, {$DN} -> " . count($members) . "\n";
            }
            while (list($a, $b) = each($members)) {
                $Hash[$b] = $b;
            }
        }
        while (list($a, $b) = each($Hash)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "USER= {$b}\n";
            }
            $FINAL[] = $b;
        }
    }
    if (isset($arrayGROUPS["LDAP"])) {
        while (list($index, $gpid) = each($arrayGROUPS["LDAP"])) {
            $Hash = HashUsersFromGPID($gpid);
            if (count($Hash) == 0) {
                WLOG("[QUERY]: ufdbguard_checks({$id}) GPID:{$gpid} store no user...");
                continue;
            }
            while (list($a, $b) = each($Hash)) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "USER= {$b}\n";
                }
                $FINAL[] = $b;
            }
        }
    }
    if ($GLOBALS["output"]) {
        echo "\nResults\n**********************************\n# # # # # # # # # # # # # # # # # # # # # #\n" . count($FINAL) . " item(s)\n# # # # # # # # # # # # # # # # # # # # # #\n";
    }
    if (count($FINAL) == 0) {
        WLOG("[QUERY]: ufdbguard_checks({$id}) no user...");
        return;
    }
    while (list($a, $Member) = each($FINAL)) {
        $Member = trim($Member);
        if ($Member == null) {
            continue;
        }
        $Member = str_replace(" ", "%20", $Member);
        $FINAL2[] = $Member;
    }
    echo @implode($FINAL2, "\n") . "\n";
}
Example #3
0
function parseTemplate_if_in_ADGroup($adgroup, $client_username)
{
    include_once dirname(__FILE__) . "/ressources/class.external_acl_squid_ldap.inc";
    if (!isset($_SESSION["GROUPES_IN_AD"])) {
        $ad = new external_acl_squid_ldap();
        $groupes = $ad->ADLdap_getgroups($client_username);
        while (list($GroupName, $none) = each($groupes)) {
            $GROUPES_IN_AD[trim(strtolower($GroupName))] = true;
        }
        $_SESSION["GROUPES_IN_AD"] = $GROUPES_IN_AD;
    } else {
        $GROUPES_IN_AD = $_SESSION["GROUPES_IN_AD"];
    }
    if (strpos($adgroup, ",") > 0) {
        $QueriesGroups = explode(",", $adgroup);
    } else {
        $QueriesGroups[] = $adgroup;
    }
    while (list($none, $GroupName) = each($QueriesGroups)) {
        $GROUPES_TO_AD[trim(strtolower($GroupName))] = true;
    }
    while (list($GroupName, $none) = each($GROUPES_TO_AD)) {
        if (isset($GROUPES_IN_AD[$GroupName])) {
            return true;
        }
    }
}
function ufdbguard_checks($id)
{
    LoadSettings();
    if ($GLOBALS["VERBOSE"]) {
        $GLOBALS["output"] = true;
        echo "OPEN: /etc/squid3/ufdb.groups.{$id}.db\n";
    }
    $arrayGROUPS = unserialize(@file_get_contents("/etc/squid3/ufdb.groups.{$id}.db"));
    $FINAL = array();
    $Hash = array();
    if (isset($arrayGROUPS["EXT-LDAP"])) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Found:EXT-LDAP\n";
        }
        $extn_ldap = new ldap_extern();
        while (list($index, $DNS) = each($arrayGROUPS["EXT-LDAP"])) {
            if ($GLOBALS["VERBOSE"]) {
                echo "DN:{$DNS}\n";
            }
            $rr = $extn_ldap->HashUsersFromGroupDN($DNS);
            if ($GLOBALS["output"]) {
                echo "{$DNS} return " . count($rr) . " users\n";
            }
            while (list($a, $b) = each($rr)) {
                $b = trim($b);
                if ($b == null) {
                    continue;
                }
                echo "USER= {$b}\n";
                $MemberArray[$a] = $a;
            }
            while (list($a, $b) = each($MemberArray)) {
                $FINAL[] = $a;
            }
        }
    }
    if (isset($arrayGROUPS["EXTLDAP"])) {
        while (list($index, $CONFS) = each($arrayGROUPS["EXTLDAP"])) {
            $rr = external_ldap_members($CONFS["DN"], $CONFS["CONF"]);
            if ($GLOBALS["output"]) {
                echo "{$CONFS["DN"]} return " . count($rr) . " users\n";
            }
            while (list($a, $b) = each($rr)) {
                echo "USER= {$b}\n";
                $MemberArray[$a] = $a;
            }
        }
        while (list($a, $b) = each($MemberArray)) {
            $FINAL[] = $a;
        }
    }
    if (isset($arrayGROUPS["AD"])) {
        while (list($index, $DNenc) = each($arrayGROUPS["AD"])) {
            $DN = base64_decode($DNenc);
            if ($GLOBALS["VERBOSE"]) {
                echo "DN, {$DN}\n";
            }
            $ldapExt = new external_acl_squid_ldap();
            $members = $ldapExt->AdLDAP_MembersFromGroup($DN);
            if ($GLOBALS["VERBOSE"]) {
                echo "DN, {$DN} -> " . count($members) . "\n";
            }
            while (list($a, $b) = each($members)) {
                $Hash[$b] = $b;
            }
        }
        while (list($a, $b) = each($Hash)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "USER= {$b}\n";
            }
            $FINAL[] = $b;
        }
    }
    if (isset($arrayGROUPS["LDAP"])) {
        while (list($index, $gpid) = each($arrayGROUPS["LDAP"])) {
            $Hash = HashUsersFromGPID($gpid);
            if (count($Hash) == 0) {
                WLOG("[QUERY]: ufdbguard_checks({$id}) GPID:{$gpid} store no user...");
                continue;
            }
            while (list($a, $b) = each($Hash)) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "USER= {$b}\n";
                }
                $FINAL[] = $b;
            }
        }
    }
    if ($GLOBALS["output"]) {
        echo "\nResults\n**********************************\n# # # # # # # # # # # # # # # # # # # # # #\n" . count($FINAL) . " item(s)\n# # # # # # # # # # # # # # # # # # # # # #\n";
    }
    if (count($FINAL) == 0) {
        WLOG("[QUERY]: ufdbguard_checks({$id}) no user...");
        return;
    }
    while (list($a, $Member) = each($FINAL)) {
        $Member = trim($Member);
        if ($Member == null) {
            continue;
        }
        $Member = str_replace(" ", "%20", $Member);
        $FINAL2[] = $Member;
    }
    echo @implode($FINAL2, "\n") . "\n";
}
Example #5
0
<?php

include_once dirname(__FILE__) . "/ressources/class.user.inc";
include_once dirname(__FILE__) . "/ressources/class.groups.inc";
include_once dirname(__FILE__) . "/ressources/class.ldap.inc";
include_once dirname(__FILE__) . "/ressources/class.system.network.inc";
include_once dirname(__FILE__) . "/ressources/class.dansguardian.inc";
include_once dirname(__FILE__) . "/ressources/class.squid.inc";
include_once dirname(__FILE__) . "/ressources/class.squidguard.inc";
include_once dirname(__FILE__) . "/ressources/class.mysql.inc";
include_once dirname(__FILE__) . "/ressources/class.compile.ufdbguard.inc";
include_once dirname(__FILE__) . "/ressources/class.compile.dansguardian.inc";
include_once dirname(__FILE__) . '/framework/class.unix.inc';
include_once dirname(__FILE__) . "/framework/frame.class.inc";
include_once dirname(__FILE__) . '/ressources/class.ufdbguard-tools.inc';
include_once dirname(__FILE__) . "/ressources/class.os.system.inc";
include_once dirname(__FILE__) . "/ressources/class.external_acl_squid_ldap.inc";
$GLOBALS["VERBOSE"] = true;
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
ini_set('error_prepend_string', null);
ini_set('error_append_string', null);
$ad = new external_acl_squid_ldap();
$array = $ad->ADLdap_userinfos("david");
$email = $array[0]["mail"][0];
echo $email . "\n";