コード例 #1
0
function PhotoUploaded()
{
    $tmp_file = $_FILES['photo']['tmp_name'];
    $content_dir = dirname(__FILE__) . "/ressources/conf/upload";
    if (!is_dir($content_dir)) {
        @mkdir($content_dir);
    }
    if (!@is_uploaded_file($tmp_file)) {
        writelogs("PHOTO: error_unable_to_upload_file", __FUNCTION__, __FILE__, __LINE__);
        $GLOBALS["Photo_error"] = '{error_unable_to_upload_file} ' . $tmp_file;
        return;
    }
    $name_file = $_FILES['photo']['name'];
    if (file_exists($content_dir . "/" . $name_file)) {
        @unlink($content_dir . "/" . $name_file);
    }
    if (!move_uploaded_file($tmp_file, $content_dir . "/" . $name_file)) {
        $GLOBALS["Photo_error"] = "{error_unable_to_move_file} : " . $content_dir . "/" . $name_file;
        writelogs("PHOTO: {error_unable_to_move_file} : " . $content_dir . "/" . $name_file, __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $file = $content_dir . "/" . $name_file;
    writelogs("PHOTO: {$file}", __FUNCTION__, __FILE__, __LINE__);
    $jpegPhoto_datas = file_get_contents($file);
    $ad = new external_ad_search();
    if (!$ad->SaveUserPhoto($jpegPhoto_datas, $_POST["DN"])) {
        $GLOBALS["Photo_error"] = $ad->ldap_error;
        return;
    }
}
コード例 #2
0
function page_active_directory()
{
    $acl = new squid_acls();
    $ad = new external_ad_search();
    $DNDUMP = $ad->DNDUMP($_GET["LoadGroupSettings"]);
    $GroupName = $DNDUMP["samaccountname"][0];
    $RULES = $acl->GetRulesFromADGroup($GroupName);
    if ($GLOBALS["VERBOSE"]) {
        echo "<span style='color:red;font-size:22px'>{$GroupName}:: " . count($RULES) . " RULES</span><br>\n";
    }
    if (is_array($RULES)) {
        while (list($key, $ligne) = each($RULES)) {
            $MAIN_SQUIDRULES[$key] = $ligne;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "<span style='color:red;font-size:28px'>{$GroupName}:: \$MAIN_SQUIDRULES:" . count($MAIN_SQUIDRULES) . " RULES</span><br>\n";
        }
    }
    $sock = new sockets();
    if ($sock->EnableUfdbGuard() == 1) {
        $MAIN_WEBRULES[0] = "{default}";
        $RULES = $acl->GetWebfilteringRulesFromADGroup($GroupName);
        if ($GLOBALS["VERBOSE"]) {
            echo "<span style='color:red;font-size:22px'>{$GroupName}:: " . count($RULES) . " RULES</span><br>\n";
        }
        if (is_array($RULES)) {
            while (list($key, $ligne) = each($RULES)) {
                $MAIN_WEBRULES[$key] = $ligne;
            }
            if ($GLOBALS["VERBOSE"]) {
                echo "<span style='color:red;font-size:22px'>{$GroupName}:: \$MAIN_WEBRULES:" . count($MAIN_WEBRULES) . " RULES</span><br>\n";
            }
        }
    }
    if (count($MAIN_SQUIDRULES) > 0) {
        $rules_title = "{rules}";
        if (count($MAIN_SQUIDRULES) < 2) {
            $rules_title = "{rule}";
        }
        while (list($aclid, $aclname) = each($MAIN_SQUIDRULES)) {
            $jsGRP = "Loadjs('squid.acls-rules.php?Addacl-js=yes&ID={$aclid}');";
            $XTRGB[] = "<tr>\n\t\t\t<td style='width:48px'><img src='img/folder-script-database-48.png'></td>\n\t\t\t<td style='font-size:22px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\"\n\t\t\tstyle='text-decoration:underline'>{$aclname}</a></td>\n\t\t\t</tr>";
        }
        $proxay_acls = "</tr>\n\t\t<tr style='height:70px'>\n\t\t<td valign=middle style='font-size:30px' class=legend>" . count($MAIN_SQUIDRULES) . " {$rules_title} (Proxy):</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td><table style='width:100%'>" . @implode("", $XTRGB) . "</table></td>\n\t\t</tr>";
    }
    if (count($MAIN_WEBRULES) > 0) {
        $XTRGB = array();
        while (list($aclid, $aclname) = each($MAIN_WEBRULES)) {
            $jsGRP = "YahooWin3('1100','dansguardian2.edit.php?ID={$aclid}&t=0','{$aclid} {$aclname}');";
            $XTRGB[] = "<tr>\n\t<td style='width:48px'><img src='img/folder-script-database-48.png'></td>\n\t<td style='font-size:22px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\"\n\tstyle='text-decoration:underline'>{$aclname}</a></td>\n\t</tr>";
        }
        $rules_title = "{rules}";
        if (count($MAIN_WEBRULES) < 2) {
            $rules_title = "{rule}";
        }
        $webfilter_acls = "</tr>\n\t<tr style='height:70px'>\n\t<td valign=middle style='font-size:30px' class=legend>" . count($MAIN_WEBRULES) . " {$rules_title} ({webfiltering}):</td>\n\t</tr>\n\t<tr>\n\t<td></td>\n\t<td><table style='width:100%'>" . @implode("", $XTRGB) . "</table></td>\n\t</tr>";
    }
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body("<center style='width:98%' class=form><table style='width:100%'>{$proxay_acls}{$webfilter_acls}</table></center>");
}
コード例 #3
0
function parse_object($ID, $GroupName)
{
    $filename = "/etc/squid3/acls/container_{$ID}.txt";
    $md5Source = md5_file($filename);
    $ad = new external_ad_search();
    $members = $ad->MembersFromGroupName($GroupName);
    $MembersCount = count($members);
    if ($GLOBALS["VERBOSE"]) {
        print_r($members);
    }
    if ($MembersCount == 0) {
        squid_admin_mysql(1, "Group {$GroupName} return no member skiping task", null, __FILE__, __LINE__);
        return false;
    }
    squid_admin_mysql(2, "Group {$GroupName} have {$MembersCount} member(s)", null, __FILE__, __LINE__);
    @file_put_contents($filename, @implode("\n", $members) . "\n");
    $md5Dest = md5_file($filename);
    if ($GLOBALS["VERBOSE"]) {
        echo "{$filename}: From \"{$md5Source}\" to \"{$md5Dest}\"\n";
    }
    if ($md5Dest != $md5Source) {
        squid_admin_mysql(2, "Group {$GroupName} container have changed", null, __FILE__, __LINE__);
        return true;
    }
    return false;
}
コード例 #4
0
function EditGroup()
{
    $gid = $_GET["PrivilegesGroup"];
    $ldap = new clladp();
    $update_array = array();
    writelogs("Save privileges for {$gid}", __CLASS__, __FUNCTION__, __FILE__, __LINE__);
    $loadGPID = true;
    if ($gid == -1) {
        $loadGPID = false;
        $Hash = $ldap->OUDatas($_GET["ou"]);
        writelogs("Loading ou datas of \"{$_GET["ou"]}\" ArticaGroupPrivileges=" . strlen($Hash["ArticaGroupPrivileges"]) . " bytes", __FUNCTION__, __FILE__, __LINE__);
        $dn = $Hash["dn"];
    }
    if ($gid == -2) {
        $loadGPID = false;
        $user = new user($_GET["userid"]);
        $Hash["ArticaGroupPrivileges"] = $user->ArticaGroupPrivileges;
        writelogs("Loading datas of \"{$_GET["userid"]}\" ArticaGroupPrivileges={$user->ArticaGroupPrivileges} bytes", __FUNCTION__, __FILE__, __LINE__);
    }
    if ($gid > 0) {
        writelogs("Loading datas of ldap->GroupDatas(\"{$_GET["{$gid}"]}\") ", __FUNCTION__, __FILE__, __LINE__);
        $Hash = $ldap->GroupDatas($gid);
    }
    if (!is_array($Hash["ArticaGroupPrivileges"])) {
        writelogs("ldap->_ParsePrivieleges(...)", __FUNCTION__, __FILE__, __LINE__);
        $ArticaGroupPrivileges = $ldap->_ParsePrivieleges($Hash["ArticaGroupPrivileges"]);
    } else {
        $ArticaGroupPrivileges = $Hash["ArticaGroupPrivileges"];
    }
    if (!is_array($ArticaGroupPrivileges)) {
        writelogs("ArticaGroupPrivileges[] is not an array !", __FUNCTION__, __FILE__, __LINE__);
    }
    if (is_array($ArticaGroupPrivileges)) {
        while (list($num, $val) = each($ArticaGroupPrivileges)) {
            $GroupPrivilege[$num] = $val;
        }
    }
    while (list($num, $val) = each($_GET)) {
        writelogs("ADD GroupPrivilege[{$num}]={$val}", __FUNCTION__, __FILE__, __LINE__);
        $GroupPrivilege[$num] = $val;
    }
    while (list($num, $val) = each($GroupPrivilege)) {
        if ($val == "no") {
            writelogs("[{$num}]=SKIP", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        writelogs("[{$num}]=\"{$val}\"", __FUNCTION__, __FILE__, __LINE__);
        $GroupPrivilegeNew[] = "[{$num}]=\"{$val}\"";
    }
    $values = @implode($GroupPrivilegeNew, "\n");
    if ($gid == -2) {
        writelogs("ArticaGroupPrivileges -> {$gid} -> user->SavePrivileges() values={$values}", __FUNCTION__, __FILE__, __LINE__);
        $user->SavePrivileges($values);
        return;
    }
    if (strpos($gid, ",") > 0) {
        $gp = new external_ad_search();
        $gp->SaveGroupPrivileges($values, $gid);
        return;
    }
    $update_array["ArticaGroupPrivileges"][0] = $values;
    writelogs("ArticaGroupPrivileges ->  {$Hash["dn"]} -> group->SavePrivileges() values={$values}", __FUNCTION__, __FILE__, __LINE__);
    if (!$ldap->Ldap_modify($Hash["dn"], $update_array)) {
        echo basename(__FILE__) . "\nline: " . __LINE__ . "\n" . $ldap->ldap_last_error;
    }
}
コード例 #5
0
function CategoriesCheckGroupsArray()
{
    if (isset($GLOBALS[__CLASS__ . __FUNCTION__])) {
        return $GLOBALS[__CLASS__ . __FUNCTION__];
    }
    $ldap = new clladp();
    $ARRAYPERS = array();
    if ($ldap->IsKerbAuth()) {
        include_once dirname(__FILE__) . "/class.external.ad.inc";
        $ad = new external_ad_search();
        $groups = $ad->GroupsOfMember($_SESSION["uid"]);
        if (!is_array($groups)) {
            $groups = array();
        }
        while (list($dn, $name) = each($groups)) {
            $ARRAYPERS[strtolower($dn)] = true;
        }
    } else {
        $users = new user($_SESSION["uid"]);
        $groups = $users->Groups_list();
        if (!is_array($groups)) {
            $groups = array();
        }
        while (list($gid, $name) = each($groups)) {
            $ARRAYPERS[$gid] = true;
        }
    }
    $GLOBALS[__CLASS__ . __FUNCTION__] = $ARRAYPERS;
    return $ARRAYPERS;
}
コード例 #6
0
ファイル: exec.squidguard.php プロジェクト: BillTheBest/1.6.x
function parseTemplate_unlock_checkcred()
{
    include_once dirname(__FILE__) . "/ressources/class.sockets.inc";
    include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php";
    include_once dirname(__FILE__) . "/ressources/class.tcpip.inc";
    include_once dirname(__FILE__) . "/ressources/class.user.inc";
    include_once dirname(__FILE__) . "/ressources/class.templates.inc";
    include_once dirname(__FILE__) . "/ressources/class.users.menus.inc";
    include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
    include_once dirname(__FILE__) . "/ressources/class.ldap-extern.inc";
    include "ressources/settings.inc";
    $sock = new sockets();
    $UfdbGuardHTTPAllowNoCreds = intval($sock->GET_INFO("UfdbGuardHTTPAllowNoCreds"));
    if ($UfdbGuardHTTPAllowNoCreds == 1) {
        return true;
    }
    if ($_POST["nocreds"] == 1) {
        return true;
    }
    $username = $_POST["username"];
    $password = trim($_POST["password"]);
    if ($sock->SQUID_IS_EXTERNAL_LDAP()) {
        $ldap_extern = new ldap_extern();
        if ($ldap_extern->checkcredentials($username, $password)) {
            return true;
        }
    }
    if (trim(strtolower($username)) == trim(strtolower($_GLOBAL["ldap_admin"]))) {
        if ($password == trim($_GLOBAL["ldap_password"])) {
            return true;
        }
    }
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        $external_ad_search = new external_ad_search();
        if ($external_ad_search->CheckUserAuth($username, $password)) {
            return true;
        }
    }
    $q = new mysql();
    $sql = "SELECT `username`,`value`,id FROM radcheck WHERE `username`='{$username}' AND `attribute`='Cleartext-Password' LIMIT 0,1";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    if (!is_numeric($ligne["id"])) {
        $ligne["id"] = 0;
    }
    if (!$q->ok) {
        writelogs("{$username}:: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
    }
    if ($ligne["id"] > 0) {
        if ($ligne["value"] == $password) {
            return true;
        }
    }
    $u = new user($username);
    if (trim($u->uidNumber) != null) {
        if (trim($password) == trim($u->password)) {
            return true;
        }
    }
    return false;
}
コード例 #7
0
function users_search_directory()
{
    $database = "artica_backup";
    $search = '%';
    $table = "squid_ssl";
    $page = 1;
    $FORCE_FILTER = "AND `type`='ssl-bump-wl'";
    $t = $_GET["t"];
    $dn = urldecode($_GET["dn"]);
    $sock = new sockets();
    if ($_POST["query"] != null) {
        $tofind = $_POST["query"];
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    if (strpos($dn, ",") > 0) {
        $ou = $dn;
    }
    include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
    $ad = new external_ad_search();
    $hash = $ad->find_users($ou, $tofind, $_POST['rp']);
    $number = $hash["count"];
    if (!is_numeric($number)) {
        $number = 0;
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = $number;
    $data['rows'] = array();
    for ($i = 0; $i < $number; $i++) {
        $userARR = $hash[$i];
        $dn = null;
        $uid = $userARR["uid"][0];
        if (isset($userARR["samaccountname"][0])) {
            $uid = $userARR["samaccountname"][0];
        }
        if (isset($userARR["distinguishedname"][0])) {
            $dn = $userARR["distinguishedname"][0];
        }
        if ($uid == "squidinternalauth") {
            continue;
        }
        $js = MEMBER_JS($uid, 1, 1, $dn);
        if ($userARR["sn"][0] == null && $userARR["givenname"][0] == null) {
            $userARR["sn"][0] = $uid;
        }
        $sn = $userARR["sn"][0];
        $givenname = $userARR["givenname"][0];
        $title = $userARR["title"][0];
        $mail = $userARR["mail"][0];
        $telephonenumber = $userARR["telephonenumber"][0];
        if ($userARR["telephonenumber"][0] == null) {
            $userARR["telephonenumber"][0] = "&nbsp;";
        }
        if ($userARR["mail"][0] == null) {
            $userARR["mail"][0] = "&nbsp;";
        }
        $img = imgsimple("contact-24.png", null, $js);
        $href = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='text-decoration:underline'>";
        $dele = "&nbsp;";
        $data['rows'][] = array('id' => $uid, 'cell' => array($img, "<span style='font-size:14px;color:{$color}'>{$href}{$userARR["sn"][0]} {$userARR["givenname"][0]}</a><div><i>{$userARR["title"][0]}</i></span>", "<span style='font-size:14px;color:{$color}'>{$userARR["telephonenumber"][0]}</span>", "<span style='font-size:14px;color:{$color}'>{$href}{$userARR["mail"][0]}</a></span>", $dele));
    }
    echo json_encode($data);
}
コード例 #8
0
function Interface_SearchUsers($DN)
{
    $page = CurrentPageName();
    $tpl = new templates();
    $tt = time();
    $type = $tpl->javascript_parse_text("{type}");
    $from = $tpl->_ENGINE_parse_body("{from}");
    $to = $tpl->javascript_parse_text("{to}");
    $rule = $tpl->javascript_parse_text("{rule}");
    $delete = $tpl->javascript_parse_text("{delete} {zone} ?");
    $rewrite_rules_fdb_explain = $tpl->javascript_parse_text("{rewrite_rules_fdb_explain}");
    $new_group = $tpl->javascript_parse_text("{new_group}");
    $groupname = $tpl->javascript_parse_text("{members}");
    $privilegesandparameters = $tpl->javascript_parse_text("{privilegesandparameters}");
    $rule = $tpl->javascript_parse_text("{rule}");
    $apply = $tpl->javascript_parse_text("{apply}");
    $action = $tpl->javascript_parse_text("{action}");
    $items = $tpl->javascript_parse_text("{items}");
    $select_this_group = $tpl->javascript_parse_text("{select_this_group}");
    $item_add = $tpl->javascript_parse_text("{item_added}");
    $ad = new external_ad_search();
    $hash = $ad->DNinfos($DN);
    $DN_enc = urlencode($DN);
    $tt = md5($DN);
    $DN_ENC = urlencode($DN);
    if (!isset($_GET["CallBack2"])) {
        $_GET["CallBack2"] = null;
    }
    $description = $hash[0]["description"][0];
    $name = $hash[0]["samaccountname"][0];
    $title = "{$name}<br><span style=font-size:10px;font-style:italic>{$description}</span>";
    $field_user = $_GET["field-user"];
    $fieldtype = $_GET["field-type"];
    $FicheGroup = "Loadjs('domains.edit.group.php?ou=ABC&js=yes&group-id={$DN_enc}&field-type={$_GET["field-type"]}',true)";
    if ($_GET["CallBack2"] != null) {
        $CallBack2 = "{$_GET["CallBack2"]}(base64,Name);";
    }
    $OPENBT = false;
    $DN_enc = urlencode($DN);
    $DN_base64 = base64_encode($DN);
    if ($_GET["field-user"] != null) {
        $OPENBT = true;
        $select = "{name: '{$select_this_group}', bclass: 'Down', onpress : Select{$tt}},";
    }
    $buttons = "\n\tbuttons : [\n\t{name: '{$privilegesandparameters}', bclass: 'Group', onpress : Parameters{$tt}},{$select}\n\t],";
    $html = "\n\t<table class='flexRT{$tt}' style='display: none' id='flexRT{$tt}' style='width:100%'></table>\n\t<script>\n\tfunction Start{$tt}(){\n\t\$('#flexRT{$tt}').flexigrid({\n\turl: '{$page}?users-items=yes&tt={$tt}&DN={$DN_ENC}&field-user={$_GET["field-user"]}',\n\tdataType: 'json',\n\tcolModel : [\n\t{display: '{$groupname}', name : 'groupname', width :382, sortable : false, align: 'left'},\n\t{display: '&nbsp;', name : 'link', width : 31, sortable : false, align: 'center'},\n\t{display: '&nbsp;', name : 'delete', width : 31, sortable : false, align: 'center'},\n\t],\n\t{$buttons}\n\tsearchitems : [\n\t{display: '{$groupname}', name : 'groupname'},\n\t],\n\tsortname: 'groupname',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '{$title}',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '500',\n\theight: 450,\n\tsingleSelect: true,\n\trpOptions: [10, 20, 30, 50,100,200]\n\n});\n}\n\nfunction Parameters{$tt}(){\n\t{$FicheGroup}\n}\n\nfunction EditField{$tt}(base64,Name){\n\tvar fieldtype='{$fieldtype}';\n\tvar ADID='{$_GET["ADID"]}';\n\tif(document.getElementById('{$field_user}')){\n\t\tif(fieldtype==2){\n\t\t\tdocument.getElementById('{$field_user}').value='AD:'+ADID+':'+base64;\n\t\t\talert('{$item_add} mode:'+fieldtype+' - '+'`'+Name+'`');\n\t\t\t{$CallBack2}\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif(fieldtype==3){\n\t\t\tdocument.getElementById('{$field_user}').value=Name;\n\t\t\talert('{$item_add} `'+Name+' - '+'`'+Name+'`');\n\t\t\t{$CallBack2}\n\t\t\treturn;\n\t\t}\t\t\n\t\t\n\t\tdocument.getElementById('{$field_user}').value=base64;\n\t\talert('{$item_add} mode:'+fieldtype+' - '+'`'+Name+'`');\n\t\t{$CallBack2}\n\t\t\n\t}\n}\n\nfunction Select{$tt}(){\n\tEditField{$tt}('{$DN_base64}','{$name}');\n}\n\n\nStart{$tt}();\n</script>\n\t\t";
    echo $html;
}
コード例 #9
0
function group_list()
{
    //ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string','');ini_set('error_append_string','');
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $RULEID = $_GET["RULEID"];
    $FORCE_FILTER = null;
    $search = '%';
    $table = "webfilters_sqgroups";
    $page = 1;
    if ($q->COUNT_ROWS($table) == 0) {
        json_error_show("No data");
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    if ($_POST["query"] != null) {
        $_POST["query"] = str_replace("*", "%", $_POST["query"]);
        $search = $_POST["query"];
        $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')";
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        json_error_show($q->mysql_error);
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data");
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $GroupType = $q->acl_GroupType;
    $GroupType["src"] = "{addr}";
    $GroupType["arp"] = "{ComputerMacAddress}";
    $GroupType["dstdomain"] = "{dstdomain}";
    $GroupType["proxy_auth"] = "{members}";
    $GroupType["port"] = "{remote_ports}";
    $GroupType["maxconn"] = "{max_connections}";
    $font_size = "15px";
    $delet_img = "delete-24.png";
    if (isset($_GET["as-big"])) {
        $font_size = "26px;";
        $delet_img = "delete-42.png";
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $val = 0;
        $ligne2['tcount'] = 0;
        $disable = Field_checkbox("groupid_{$ligne['ID']}", 1, $ligne["enabled"], "EnableDisableGroup('{$ligne['ID']}')");
        $ligne['GroupName'] = utf8_encode($ligne['GroupName']);
        $GroupTypeText = $tpl->_ENGINE_parse_body($GroupType[$ligne["GroupType"]]);
        $delete = imgsimple($delet_img, null, "DeleteSquidAclGroup('{$ligne['ID']}')");
        if ($ligne["GroupType"] == "proxy_auth_ads") {
            $p = new external_ad_search();
            $ligne2['tcount'] = $p->CountDeUsersByGroupName($ligne['GroupName']);
        }
        if ($ligne["GroupType"] == "proxy_auth_statad") {
            $p = new external_ad_search();
            $ligne2['tcount'] = $p->CountDeUsersByGroupName($ligne['GroupName']);
        }
        if ($ligne["GroupType"] == "proxy_auth_ldap") {
            $p = new ldap_extern();
            preg_match("#^ExtLDAP:(.+?):(.+)#", $ligne['GroupName'], $re);
            $ligne['GroupName'] = $re[1];
            $DN = base64_decode($re[2]);
            $ligne2['tcount'] = $p->CountDeUsersByGroupDN($DN);
        }
        if ($ligne2['tcount'] == 0) {
            $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(ID) as tcount FROM webfilters_sqitems WHERE gpid='{$ligne['ID']}'"));
        }
        if ($ligne["GroupType"] == "all") {
            $ligne2['tcount'] = "*";
        }
        $CountOfRules = 0;
        $ligne3 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(webfilters_sqacls.ID) as tcount FROM  webfilters_sqacllinks,webfilters_sqacls WHERE webfilters_sqacllinks.gpid='{$ligne['ID']}' AND webfilters_sqacllinks.aclid=webfilters_sqacls.ID"));
        $CountOfRules = $ligne3["tcount"];
        if ($CountOfRules > 0) {
            $CountOfRules = "<a href=\"javascript:blur();\"  OnClick=\"javascript:Loadjs('squid.acls.groups.rules.php?ID={$ligne['ID']}');\" style='font-size:{$font_size};text-decoration:underline'>{$CountOfRules}</a>";
        }
        $data['rows'][] = array('id' => "group{$ligne['ID']}", 'cell' => array("<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('{$MyPage}?AddGroup-js=yes&ID={$ligne['ID']}');\" \n\t\tstyle='font-size:{$font_size};text-decoration:underline'>{$ligne['GroupName']}</span>", "<span style='font-size:{$font_size};'>{$GroupTypeText}</span>", "<center style='font-size:{$font_size};'>{$ligne2['tcount']}</center>", "<center style='font-size:{$font_size};'>{$CountOfRules}</center>", "<center>{$disable}</center>", "<center>{$delete}</center>"));
    }
    echo json_encode($data);
}
コード例 #10
0
function popup_search()
{
    $icon = "win7groups-32.png";
    $ad = new external_ad_search();
    if ($_POST["query"] == null) {
        $_POST["query"] = "*";
    }
    if (strpos(" {$_POST["query"]}", "*") == 0) {
        $_POST["query"] = "*{$_POST["query"]}*";
    }
    $_POST["query"] = str_replace("**", "*", $_POST["query"]);
    $_POST["query"] = str_replace("**", "*", $_POST["query"]);
    $Array = $ad->flexRTGroups($_POST["query"], $_POST["rp"]);
    if ($ad->error != null) {
        json_error_show($ad->error, 1);
    }
    if (count($Array) == 0) {
        json_error_show("No item", 1);
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($Array);
    $data['rows'] = array();
    while (list($dn, $itemname) = each($Array)) {
        $GroupxSourceName = $itemname;
        $GroupxName = $itemname;
        $GroupxName = replace_accents($GroupxName);
        $GroupxName = str_replace("'", "`", $itemname);
        $addtitile = null;
        $select = null;
        $dn_enc = base64_encode($dn);
        $DN_base64 = base64_encode($dn);
        $itemnameenc = base64_encode($itemname);
        $CountDeUsers = $ad->CountDeUsersByGroupDN($dn);
        $link = null;
        $js = "EditField{$_GET["t"]}('{$DN_base64}','{$GroupxSourceName}');";
        $image = imgsimple($icon, null, $js);
        $select = imgsimple("arrow-right-32.png", null, $js);
        if ($CountDeUsers > 0) {
            $link = "<a href=\"javascript:Loadjs('browse-ad-users-dn.php?DN={$DN_base64}')\"\n\t\t\tstyle='text-decoration:underline'>";
        }
        $md5 = md5($dn);
        $data['rows'][] = array('id' => $md5, 'cell' => array("<center>{$image}</center>", "<span style='font-size:20px;'>{$link}{$GroupxName}</a></span>", "<center style='font-size:20px;'>{$CountDeUsers}</center>", "<center>{$select}</center>"));
    }
    echo json_encode($data);
}
コード例 #11
0
function popup_search()
{
    $icon = "win7groups-32.png";
    $ad = new external_ad_search();
    if ($_POST["query"] == null) {
        $_POST["query"] = "*";
    }
    if (strpos(" {$_POST["query"]}", "*") == 0) {
        $_POST["query"] = "*{$_POST["query"]}*";
    }
    $_POST["query"] = str_replace("**", "*", $_POST["query"]);
    $_POST["query"] = str_replace("**", "*", $_POST["query"]);
    $Array = $ad->HashUsersFromGroupDN(base64_decode($_GET["DN"]), false, true);
    ksort($Array);
    if (count($Array) == 0) {
        json_error_show("No item", 1);
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($Array);
    $data['rows'] = array();
    if ($_POST["query"] != null) {
        $searchstring = str_replace("*", ".*?", $searchstring);
    }
    $c = 0;
    while (list($UserName, $itemname) = each($Array)) {
        if ($c > $_POST["rp"]) {
            break;
        }
        if ($searchstring != null) {
            if (!preg_match("#{$searchstring}#", $UserName)) {
                continue;
            }
        }
        $c++;
        $image = imgsimple($icon, null, $js);
        $select = imgsimple("arrow-right-32.png", null, $js);
        $md5 = md5($dn);
        $data['rows'][] = array('id' => $md5, 'cell' => array("<center><img src=img/user-32.png></center>", "<span style='font-size:20px;'>{$UserName}</a></span>"));
    }
    echo json_encode($data);
}
コード例 #12
0
ファイル: dansguardian2.php プロジェクト: articatech/artica
function status_users()
{
    $ldap = new clladp();
    $sock = new sockets();
    if ($ldap->IsKerbAuth()) {
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ad = new external_ad_search();
        $users = $ad->NumUsers();
        return "<tr>\n\t<td width=1%><span id='AdSquidStatusLeft35'><img src='img/member-24.png'></span></td>\n\t<td class=legend nowrap style='font-size:12px'>{members}:</td>\n\t<td><div style='font-size:12px' nowrap>\n\t<a href=\"javascript:blur();\"\n\tOnClick=\"javascript:Loadjs('squid.adker.php',true);\"\n\tstyle='font-size:12px;font-weight:bold;text-decoration:underline'>{$users}</a></td>\n\t</tr>";
    }
    $EnableMacAddressFilter = $sock->GET_INFO("EnableMacAddressFilter");
    if (!is_numeric($EnableMacAddressFilter)) {
        $EnableMacAddressFilter = 1;
    }
    $q = new mysql_squid_builder();
    if ($EnableMacAddressFilter == 1) {
        $sql = "SELECT MAC FROM UserAutDB GROUP BY MAC";
        $results = $q->QUERY_SQL($sql);
        $users = mysql_num_rows($results);
        $js = "Loadjs('squid.UserAutDB.php?filterby=MAC',true);";
    } else {
        $sql = "SELECT ipaddr FROM UserAutDB GROUP BY ipaddr";
        $results = $q->QUERY_SQL($sql);
        $users = mysql_num_rows($results);
        $js = "Loadjs('squid.UserAutDB.php?filterby=ipaddr',true);";
    }
    return "<tr>\n\t<td width=1%><span id='AdSquidStatusLeft35'><img src='img/member-24.png'></span></td>\n\t<td class=legend nowrap style='font-size:12px'>{members}:</td>\n\t<td><div style='font-size:12px' nowrap>\n\t<a href=\"javascript:blur();\"\n\tOnClick=\"javascript:{$js}\"\n\tstyle='font-size:12px;font-weight:bold;text-decoration:underline'>{$users}</a></td>\n\t</tr>";
}
コード例 #13
0
ファイル: splashproxy.php プロジェクト: BillTheBest/1.6.x
function check_auth()
{
    if (isset($_POST["USETERMS"])) {
        setcookie("USETERMS", 1, 3600);
    }
    $tpl = new templates();
    if ($_POST["debugAuth"] == 1) {
        $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);
    }
    $username = $_POST["username"];
    $time = time();
    if ($username == null) {
        echo $tpl->javascript_parse_text("{wrong_password_or_username}");
        return;
    }
    include_once dirname(__FILE__) . '/ressources/class.user.inc';
    $sock = new sockets();
    $tpl = new templates();
    $users = new usersMenus();
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    if (!is_numeric($EnableKerbAuth)) {
        $EnableKerbAuth = 0;
    }
    $HotSpotConfig = unserialize(base64_decode($sock->GET_INFO("HotSpotConfig")));
    if (!isset($HotSpotConfig["FINAL_TIME"])) {
        $HotSpotConfig["FINAL_TIME"] = 0;
    }
    if (!isset($HotSpotConfig["USELDAP"])) {
        $HotSpotConfig["USELDAP"] = 1;
    }
    if (!isset($HotSpotConfig["CACHE_AUTH"])) {
        $HotSpotConfig["CACHE_AUTH"] = 60;
    }
    if (!isset($HotSpotConfig["CACHE_TIME"])) {
        $HotSpotConfig["CACHE_TIME"] = 120;
    }
    if (!isset($HotSpotConfig["USEMYSQL"])) {
        $HotSpotConfig["USEMYSQL"] = 1;
    }
    if (!isset($HotSpotConfig["USEAD"])) {
        $HotSpotConfig["USEAD"] = 0;
    }
    if (!isset($HotSpotConfig["USERAD"])) {
        $HotSpotConfig["USERAD"] = 0;
    }
    if (!is_numeric($HotSpotConfig["USELDAP"])) {
        $HotSpotConfig["USELDAP"] = 1;
    }
    if (!is_numeric($HotSpotConfig["USEMYSQL"])) {
        $HotSpotConfig["USEMYSQL"] = 1;
    }
    if (!is_numeric($HotSpotConfig["CACHE_AUTH"])) {
        $HotSpotConfig["CACHE_AUTH"] = 60;
    }
    if (!is_numeric($HotSpotConfig["CACHE_TIME"])) {
        $HotSpotConfig["CACHE_TIME"] = 120;
    }
    if (!is_numeric($HotSpotConfig["FINAL_TIME"])) {
        $HotSpotConfig["FINAL_TIME"] = 0;
    }
    if (!is_numeric($HotSpotConfig["USERAD"])) {
        $HotSpotConfig["USERAD"] = 0;
    }
    if ($EnableKerbAuth == 0) {
        $HotSpotConfig["USEAD"] = 0;
    }
    if (!$users->CORP_LICENSE) {
        $HotSpotConfig["USEAD"] = 0;
    }
    $CACHE_AUTH = $HotSpotConfig["CACHE_AUTH"];
    $username = $_POST["username"];
    $password = $_POST["password"];
    $passEnc = url_decode_special_tool($_POST["passEnc"]);
    $md5key = trim($_POST["md5key"]);
    if ($password == null) {
        echo "Invalid Password\n";
        die;
    }
    $array = unserialize(base64_decode($_POST["request"]));
    $LOGIN = $array["LOGIN"];
    $IPADDR = $array["IPADDR"];
    $MAC = $array["MAC"];
    $HOST = $array["HOST"];
    if ($MAC == null) {
        $MAC = "00:00:00:00:00:00";
    }
    if ($IPADDR == null) {
        $IPADDR = $_SERVER["REMOTE_ADDR"];
    }
    if ($LOGIN == null) {
        $LOGIN = $username;
    }
    if ($HOST == null) {
        $HOST = gethostbyaddr($IPADDR);
    }
    if ($md5key == null) {
        $md5key = md5("{$LOGIN}{$IPADDR}{$MAC}{$HOST}");
    }
    $auth = false;
    if ($HotSpotConfig["USEAD"] == 1) {
        writelogs("{$username}:: Checks Active Directory..", __FUNCTION__, __FILE__, __LINE__);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$username} AUTH = FALSE continue IF AD... (" . __LINE__ . ")\n";
        }
        $external_ad_search = new external_ad_search();
        if ($external_ad_search->CheckUserAuth($username, $passEnc)) {
            writelogs("{$username}:: Checks Active Directory success...", __FUNCTION__, __FILE__, __LINE__);
            $auth = true;
        }
    }
    if ($HotSpotConfig["USELDAP"] == 1) {
        if (!$auth) {
            writelogs("{$username}:: Checks LDAP connection..", __FUNCTION__, __FILE__, __LINE__);
            $ct = new user($username);
            if (md5($ct->password) == $password) {
                writelogs("{$username}:: Checks LDAP connection success...", __FUNCTION__, __FILE__, __LINE__);
                $auth = true;
            }
        }
    }
    if ($HotSpotConfig["USERAD"] == 1) {
        if (!$auth) {
            writelogs("{$username}:: Checks RADIUS connection..", __FUNCTION__, __FILE__, __LINE__);
            $RAD_SERVER = $HotSpotConfig["RAD_SERVER"];
            $RAD_PORT = $HotSpotConfig["RAD_PORT"];
            $RAD_PASSWORD = $HotSpotConfig["RAD_PASSWORD"];
            if (!is_numeric($RAD_PORT)) {
                $RAD_PORT = 1812;
            }
            include_once "/usr/share/artica-postfix/ressources/class.radius.auth.inc";
            if ($GLOBALS["VERBOSE"]) {
                echo "RADIUS_AUTHENTICATION -> With ({$username},{$password},{$RAD_SERVER},{$RAD_PORT}) (" . __LINE__ . ")\n";
            }
            $retval = RADIUS_AUTHENTICATION($username, $passEnc, $RAD_SERVER, $RAD_PORT, $RAD_PASSWORD);
            if ($retval == 2) {
                writelogs("{$username}:: Checks RADIUS connection success...", __FUNCTION__, __FILE__, __LINE__);
                $auth = true;
            }
        }
    }
    $ASUID = false;
    if ($HotSpotConfig["USEMYSQL"] == 1) {
        $q = new mysql_squid_builder();
        if (!$auth) {
            writelogs("{$username}:: Checks MySQL connection..", __FUNCTION__, __FILE__, __LINE__);
            if (!$q->TABLE_EXISTS("hotspot_members")) {
                $q->CheckTables();
            }
            $sql = "SELECT uid,password,ttl,sessiontime,enabled FROM hotspot_members WHERE uid='{$username}'";
            $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
            if ($ligne["uid"] != null) {
                if ($ligne["password"] == $passEnc) {
                    if ($ligne["sessiontime"] > 0) {
                        $CACHE_AUTH = $ligne["sessiontime"];
                    }
                    if ($ligne["enabled"] == 0) {
                        echo $tpl->javascript_parse_text("{access_to_internet_disabled} ({disabled})");
                        die;
                    }
                    if (intval($ligne["ttl"]) > 0) {
                        if ($time > $ligne["ttl"]) {
                            echo $tpl->javascript_parse_text("{accesstime_to_internet_expired}");
                            die;
                        }
                    }
                    writelogs("{$username}:: Checks MySQL connection success..", __FUNCTION__, __FILE__, __LINE__);
                    $auth = true;
                }
            }
        }
    }
    writelogs("{$username}:: Result = {$auth}", __FUNCTION__, __FILE__, __LINE__);
    if (!$auth) {
        writelogs("{$username}:: Die() authentification failed", __FUNCTION__, __FILE__, __LINE__);
        echo $tpl->javascript_parse_text("{wrong_password_or_username}");
        return;
    }
    $q = new mysql_squid_builder();
    if (!is_numeric($CACHE_AUTH)) {
        $CACHE_AUTH = 60;
    }
    $finaltime = strtotime("+{$CACHE_AUTH} minutes", $time);
    $datelogs = date("Y-m-d H:i:s", $finaltime);
    writelogs("{$username} -> {$HOST} +{$CACHE_AUTH}mn Next checkup time will be {$datelogs} ", __FUNCTION__, __FILE__, __LINE__);
    if ($LOGIN != null) {
        $uid = $LOGIN;
    } else {
        $uid = $username;
    }
    $q->QUERY_SQL("DELETE FROM hotspot_sessions WHERE ipaddr='{$IPADDR}'");
    $q->QUERY_SQL("DELETE FROM hotspot_sessions WHERE MAC='{$MAC}'");
    $q->QUERY_SQL("DELETE FROM hotspot_sessions WHERE uid='{$uid}'");
    $sql = "INSERT IGNORE INTO hotspot_sessions (md5,logintime, maxtime,finaltime,username,uid,MAC,hostname,ipaddr)\n\tVALUES('{$md5key}',{$time},{$finaltime},{$CACHE_AUTH},'{$username}','{$uid}','{$MAC}','{$HOST}','{$IPADDR}')";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        writelogs("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
        echo $q->mysql_error . "\n{$sql}";
        return;
    }
    if ($HotSpotConfig["USEMYSQL"] == 1) {
        if (!$ASUID) {
            $sql = "INSERT IGNORE INTO hotspot_members (uid,MAC,hostname,ipaddr,enabled) VALUES ('{$uid}','{$MAC}','{$HOST}','{$IPADDR}',1)";
        } else {
            $sql = "UPDATE hotspot_members SET MAC='{$MAC}',hostname='{$HOST}',ipaddr='{$IPADDR}' WHERE uid='{$uid}'";
        }
        $q->QUERY_SQL($sql);
    }
}
コード例 #14
0
ファイル: logon.php プロジェクト: brucewu16899/1.6.x
function logon()
{
    include "ressources/settings.inc";
    include_once 'ressources/class.sockets.inc';
    include_once 'ressources/class.ldap.inc';
    include_once 'ressources/class.user.inc';
    include_once 'ressources/class.langages.inc';
    $sock = new sockets();
    $tpl = new templates();
    $_POST["artica_password"] = url_decode_special($_POST["artica_password"]);
    writelogs("Testing logon....{$_POST["artica_username"]}", __FUNCTION__, __FILE__, __LINE__);
    //writelogs("Testing logon.... password:{$_POST["artica_password"]}",__FUNCTION__,__FILE__,__LINE__);
    $_COOKIE["artica-language"] = $_POST["lang"];
    $FileCookyKey = md5($_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"]);
    $sock->SET_INFO($FileCookyKey, $_POST["Changelang"]);
    if (!isset($GLOBALS["FixedLanguage"])) {
        $GLOBALS["FixedLanguage"] = $sock->GET_INFO("FixedLanguage");
    }
    $VIA_API = false;
    if (isset($_POST["VIA_API"])) {
        $VIA_API = true;
    }
    if ($_SESSION["uid"] != null) {
        if (!$VIA_API) {
            echo "location:admin.index.php";
            return;
        }
    }
    $socks = new sockets();
    while (list($index, $value) = each($_SERVER)) {
        $notice[] = "{$index}:{$value}";
    }
    if ($_GLOBAL["ldap_admin"] == null) {
        $sock->getFrameWork("services.php?process1-tenir=yes?MyCURLTIMEOUT=120");
        include "ressources/settings.inc";
    }
    if ($_GLOBAL["ldap_admin"] == null) {
        if ($VIA_API) {
            echo "FALSE";
            return;
        }
        $tpl = new templates();
        echo $tpl->javascript_parse_text("{ldap_username_corrupt_text}");
        return null;
    }
    $md5submitted = $_POST["artica_password"];
    if ($VIA_API) {
        $md5submitted = md5($_POST["artica_password"]);
    }
    $md5Manager = md5(trim($_GLOBAL["ldap_password"]));
    if (trim($GLOBALS["FixedLanguage"]) != null) {
        $_POST["lang"] = $GLOBALS["FixedLanguage"];
    }
    $trimed_artica_username = trim(strtolower($_POST["artica_username"]));
    $trimed_ldap_admin = trim(strtolower($_GLOBAL["ldap_admin"]));
    writelogs("Manager -> {$trimed_artica_username} ?=== {$trimed_ldap_admin}", _FUNCTION__, __FILE__, __LINE__);
    if ($trimed_artica_username == $trimed_ldap_admin) {
        writelogs("Manager: `YES`", __FUNCTION__, __FILE__, __LINE__);
        if ($md5Manager != $md5submitted) {
            $tpl = new templates();
            //writelogs("Testing logon.... password:{$_POST["artica_password"]}!==\"{$_GLOBAL["ldap_password"]}\"",__FUNCTION__,__FILE__,__LINE__);
            artica_mysql_events("Failed to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]}", @implode("\n", $notice), "security", "security");
            if ($VIA_API) {
                echo "FALSE";
                return;
            }
            echo $tpl->javascript_parse_text("{wrong_password_or_username}");
            return null;
        } else {
            $users = new usersMenus();
            artica_mysql_events("Success to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]} as SuperAdmin", @implode("\n", $notice), "security", "security");
            //session_start();
            $_SESSION["uid"] = '-100';
            $_SESSION["groupid"] = '-100';
            $_SESSION["passwd"] = $_GLOBAL["ldap_password"];
            $_SESSION["MINIADM"] = false;
            setcookie("MINIADM", "No", time() + 1000);
            $_SESSION["InterfaceType"] = "{APP_ARTICA_ADM}";
            setcookie("artica-language", $_POST["lang"], time() + 172800);
            $_SESSION["detected_lang"] = $_POST["lang"];
            $_SESSION["CORP"] = $users->CORP_LICENSE;
            $_SESSION["privileges"]["ArticaGroupPrivileges"] = '
			[AllowAddGroup]="yes"
			[AllowAddUsers]="yes"
			[AllowChangeKav]="yes"
			[AllowChangeKas]="yes"
			[AllowChangeUserPassword]="yes"
			[AllowEditAliases]="yes"
			[AllowEditAsWbl]="yes"
			[AsSystemAdministrator]="yes"
			[AsPostfixAdministrator]="yes"
			[AsArticaAdministrator]="yes"
			[AsArticaMetaAdmin]="yes"
			';
            if ($VIA_API) {
                writelogs("VIA API = TRUE -> BUILD SESSION", _FUNCTION__, __FILE__, __LINE__);
                BuildSession($_SESSION["uid"]);
                echo "TRUE";
                return;
            }
            $tpl = new templates();
            $sock->getFrameWork("squid.php?clean-catz-cache=yes");
            writelogs("OK it is a global admin -> location:admin.index.php", _FUNCTION__, __FILE__, __LINE__);
            echo "location:admin.index.php";
            exit;
        }
    }
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        $userPassword = $_POST["artica_password"];
        if (isset($_POST["artica_password_crypted"])) {
            $userPassword = $_POST["artica_password_crypted"];
            include_once dirname(__FILE__) . "/ressources/class.cryptform.inc";
            $userPassword = logon_decrypt($userPassword);
        }
        writelogs("*** TEST Active Directory user {$_POST["artica_username"]} ****", __FUNCTION__, __FILE__, __LINE__);
        $external_ad_search = new external_ad_search();
        if ($external_ad_search->CheckUserAuth($_POST["artica_username"], $userPassword)) {
            writelogs("*** TEST Active Directory user {$_POST["artica_username"]} success ****", __FUNCTION__, __FILE__, __LINE__);
            $_SESSION["MINIADM"] = false;
            setcookie("MINIADM", "No", time() + 1000);
            $_SESSION["InterfaceType"] = "{APP_ARTICA_ADM}";
            setcookie("artica-language", $_POST["lang"], time() + 172800);
            $_SESSION["detected_lang"] = $_POST["lang"];
            $_SESSION["CORP"] = $users->CORP_LICENSE;
            $users = new usersMenus();
            $privs = new privileges($_POST["artica_username"]);
            $privileges_array = $privs->privs;
            DumpPrivileges($_POST["artica_username"], $privileges_array);
            $users->_TranslateRights($privileges_array, true);
            setcookie("mem-logon-user", $_POST["artica_username"], time() + 172800);
            $_SESSION["privileges_array"] = $privs->privs;
            $_SESSION["uid"] = $_POST["artica_username"];
            BuildSession($_POST["artica_username"]);
            $sock->getFrameWork("squid.php?clean-catz-cache=yes");
            $_SESSION["MINIADM"] = false;
            setcookie("MINIADM", "No", time() + 1000);
            if ($VIA_API) {
                BuildSession($_SESSION["uid"]);
                echo "TRUE";
                return;
            }
            echo "location:admin.index.php";
            return;
        } else {
            if (is_array($GLOBALS["CLASS_ACTV"])) {
                while (list($key, $line) = each($GLOBALS["CLASS_ACTV"])) {
                    writelogs("*** Active Directory {$line}", __FUNCTION__, __FILE__, __LINE__);
                }
            }
        }
    }
    if (Radius_admins($_POST["artica_username"], $md5submitted)) {
        writelogs('*** TEST RADIUS USER ****', __FUNCTION__, __FILE__, __LINE__);
        $tpl = new templates();
        $sock->getFrameWork("squid.php?clean-catz-cache=yes");
        writelogs("OK it is a global admin -> location:admin.index.php", _FUNCTION__, __FILE__, __LINE__);
        if ($VIA_API) {
            BuildSession($_SESSION["uid"]);
            echo "TRUE";
            return;
        }
        echo "location:admin.index.php";
        exit;
    }
    writelogs('This is not Global admin, so test user...', __FUNCTION__, __FILE__, __LINE__);
    $u = new user($_POST["artica_username"]);
    $userPassword = $u->password;
    if (trim($u->uidNumber) == null) {
        if ($VIA_API) {
            echo "FALSE";
            return;
        }
        writelogs('Unable to get user infos abort', __FUNCTION__, __FILE__);
        echo $tpl->javascript_parse_text("{wrong_password_or_username}");
        return null;
    }
    $tpl = new templates();
    if (trim($_POST["artica_password"]) == md5(trim($userPassword))) {
        BuildSession($u->uid);
        $ldap = new clladp();
        $users = new usersMenus();
        $privs = new privileges($u->uid);
        $privileges_array = $privs->privs;
        if (trim($FixedLanguage) != null) {
            $_SESSION["detected_lang"] = $FixedLanguage;
        }
        $users->_TranslateRights($privileges_array, true);
        if (!$users->IfIsAnuser(true)) {
            if ($VIA_API) {
                echo "TRUE";
                return;
            }
            artica_mysql_events("Success to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]} as User", @implode("\n", $notice), "security", "security");
            writelogs("[{$_POST["artica_username"]}]: This is not an user =>admin.index.php", __FUNCTION__, __FILE__);
            $sock->getFrameWork("squid.php?clean-catz-cache=yes");
            $_SESSION["MINIADM"] = false;
            setcookie("MINIADM", "No", time() + 1000);
            if ($VIA_API) {
                BuildSession($_SESSION["uid"]);
                echo "TRUE";
                return;
            }
            echo "location:admin.index.php";
            return null;
        }
        if ($VIA_API) {
            BuildSession($_SESSION["uid"]);
            echo "TRUE";
            return;
        }
        writelogs("[{$_POST["artica_username"]}]: IS AN USER =>../user-backup/logon.php", __FUNCTION__, __FILE__);
        $array["USERNAME"] = $_POST["artica_username"];
        $array["PASSWORD"] = md5($_POST["artica_username"]);
        $credentials = base64_encode(serialize($array));
        artica_mysql_events("Success to redirect on the end-user management console from {$_SERVER["REMOTE_HOST"]} as User", @implode("\n", $notice), "security", "security");
        echo "location:../miniadm.logon.php?credentials={$credentials}";
        return null;
        exit;
    } else {
        if ($VIA_API) {
            echo "FALSE";
            return;
        }
        writelogs("[{$_POST["artica_username"]}]: The password typed  is not the same in ldap database...", __FUNCTION__, __FILE__);
        artica_mysql_events("Failed to logon on the management console as user from {$_SERVER["REMOTE_HOST"]} (bad password)", @implode("\n", $notice), "security", "security");
        echo $tpl->javascript_parse_text("{wrong_password_or_username}");
        return null;
    }
}
コード例 #15
0
function COUNT_DE_USERS()
{
    $sock = new sockets();
    $ldap = new clladp();
    $_GET["dn"] = urldecode($_GET["dn"]);
    if ($ldap->IsKerbAuth()) {
        $ad = new external_ad_search();
        echo $ad->CountDeUSerOu($_GET["count-de-users"], $_GET["dn"]);
    }
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $ldap = new ldapAD();
        echo $ldap->CountDeUSerOu($_GET["count-de-users"], $_GET["dn"]);
        return;
    }
    $ldap = new clladp();
    echo $ldap->CountDeUSerOu($_GET["count-de-users"]);
}
コード例 #16
0
ファイル: miniadm.logon.php プロジェクト: brucewu16899/1.6.x
function checklogon($Aspost = false)
{
    include_once dirname(__FILE__) . "/ressources/class.user.inc";
    include "ressources/settings.inc";
    $username = $_POST["username"];
    $_POST["password"] = url_decode_special_tool($_POST["password"]);
    $password = trim($_POST["password"]);
    $users = new usersMenus();
    if ($users->WEBSTATS_APPLIANCE) {
        $users->SQUID_INSTALLED = true;
    }
    //echo $username."\n$password\n";
    if ($password == null) {
        if ($Aspost) {
            MainPage("Bad password");
            return;
        }
        echo "Bad password";
        return;
    }
    if (trim(strtolower($username)) == trim(strtolower($_GLOBAL["ldap_admin"]))) {
        $passwordMD = md5(trim($_GLOBAL["ldap_password"]));
        if ($password == $passwordMD) {
            $_SESSION["uid"] = '-100';
            $_SESSION["groupid"] = '-100';
            $_SESSION["passwd"] = $_GLOBAL["ldap_password"];
            $_SESSION["CORP"] = $users->CORP_LICENSE;
            $_SESSION["privileges"]["ArticaGroupPrivileges"] = '
			[AllowAddGroup]="yes"
			[AllowAddUsers]="yes"
			[AllowChangeKav]="yes"
			[AllowChangeKas]="yes"
			[AllowChangeUserPassword]="yes"
			[AllowEditAliases]="yes"
			[AllowEditAsWbl]="yes"
			[AsSystemAdministrator]="yes"
			[AsPostfixAdministrator]="yes"
			[AsArticaAdministrator]="yes"';
            $_SESSION["InterfaceType"] = "{APP_ARTICA_ADM}";
            $_SESSION["AsWebStatisticsAdministrator"] = true;
            if ($Aspost) {
                header("location:miniadm.index.php");
                return;
            }
            return;
        }
    }
    if ($users->SQUID_INSTALLED) {
        $q = new mysql_squid_builder();
        $passwordMD = md5($password);
        $sql = "SELECT webfilters_sqitems.gpid AS maingpid\n\t\t\tFROM webfilters_sqacllinks, webfilters_sqgroups, webfilters_sqitems, webfilters_sqacls\n\t\t\tWHERE webfilters_sqacllinks.gpid = webfilters_sqgroups.ID\n\t\t\tAND webfilters_sqacllinks.aclid = webfilters_sqacls.ID\n\t\t\tAND webfilters_sqgroups.ID = webfilters_sqitems.gpid\n\t\t\tAND webfilters_sqacls.enabled =1\n\t\t\tAND webfilters_sqgroups.enabled =1\n\t\t\tAND webfilters_sqitems.enabled =1\n\t\t\tAND webfilters_sqgroups.GroupType = 'dynamic_acls'\n\t\t\tAND webfilters_sqitems.pattern = '{$username}:{$passwordMD}'";
        $results = $q->QUERY_SQL($sql);
        if (!$q->mysql_error) {
            echo $q->mysql_error;
        }
        $CountDerules = mysql_num_rows($results);
        writelogs("{$username}::webfilters_sqitems:: {$CountDerules} rules", __FUNCTION__, __FILE__, __LINE__);
        if ($CountDerules > 0) {
            writelogs("{$username}::webfilters_sqitems:: Building rules....", __FUNCTION__, __FILE__, __LINE__);
            while ($ligne = mysql_fetch_assoc($results)) {
                $_SESSION["SQUID_DYNAMIC_ACLS_VIRTUALS"][$ligne["maingpid"]] = true;
            }
            $_SESSION["InterfaceType"] = "{ARTICA_MINIADM}";
            $_SESSION["VirtAclUser"] = true;
            $_SESSION["ou"] = "Proxy Service";
            $_SESSION["CORP"] = $users->CORP_LICENSE;
            setcookie("mem-logon-user", $_POST["username-logon"], time() + 172800);
            $_SESSION["privileges_array"] = $privs->privs;
            $_SESSION["uid"] = $username;
            $_SESSION["privileges"]["ArticaGroupPrivileges"] = array();
            BuildSession($username);
            if ($Aspost) {
                header("location:miniadm.index.php");
                return;
            }
            return;
        }
    }
    writelogs("{$username}:: Continue, processing....", __FUNCTION__, __FILE__, __LINE__);
    $ldap = new clladp();
    $IsKerbAuth = $ldap->IsKerbAuth();
    writelogs("{$username}:: Is AD -> {$IsKerbAuth}", __FUNCTION__, __FILE__, __LINE__);
    if ($ldap->IsKerbAuth()) {
        $external_ad_search = new external_ad_search();
        if ($external_ad_search->CheckUserAuth($username, $password)) {
            $users = new usersMenus();
            $privs = new privileges($_POST["username-logon"]);
            $privileges_array = $privs->privs;
            $_SESSION["InterfaceType"] = "{ARTICA_MINIADM}";
            $_SESSION["VirtAclUser"] = false;
            setcookie("mem-logon-user", $_POST["username-logon"], time() + 172800);
            $_SESSION["privileges_array"] = $privs->privs;
            $_SESSION["uid"] = $_POST["username-logon"];
            $_SESSION["passwd"] = $_POST["username-logon"];
            $_SESSION["privileges"]["ArticaGroupPrivileges"] = $privs->content;
            BuildSession($username);
            if ($Aspost) {
                header("location:miniadm.index.php");
                return;
            }
            return;
        }
        writelogs("{$username}:: Checks Active Directory failed, continue processing...", __FUNCTION__, __FILE__, __LINE__);
    }
    writelogs("{$username}:: Continue, processing....", __FUNCTION__, __FILE__, __LINE__);
    $q = new mysql();
    $sql = "SELECT `username`,`value`,id FROM radcheck WHERE `username`='{$username}' AND `attribute`='Cleartext-Password' LIMIT 0,1";
    writelogs("{$username}:: Is a RADIUS users \"{$sql}\"", __FUNCTION__, __FILE__, __LINE__);
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    if (!is_numeric($ligne["id"])) {
        $ligne["id"] = 0;
    }
    if (!$q->ok) {
        writelogs("{$username}:: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
    }
    writelogs("{$username}:: {$password} <> " . md5($ligne["value"]), __FUNCTION__, __FILE__, __LINE__);
    if ($ligne["id"] > 0) {
        $checkRadiusPass = false;
        if (md5($ligne["value"]) == $password) {
            writelogs("{$username}:: RADIUS Password true for no MD5", __FUNCTION__, __FILE__, __LINE__);
            $checkRadiusPass = true;
        }
        if (md5($ligne["value"]) == $passwordMD) {
            writelogs("{$username}:: RADIUS Password true for yes MD5", __FUNCTION__, __FILE__, __LINE__);
            $checkRadiusPass = true;
        }
        if ($checkRadiusPass) {
            writelogs("{$username}:: Authenticated as a RADIUS users id={$ligne["id"]}", __FUNCTION__, __FILE__, __LINE__);
            $privs = new privileges($_POST["username-logon"], null, $ligne["id"]);
            $privileges_array = $privs->privs;
            $_SESSION["CORP"] = $users->CORP_LICENSE;
            $_SESSION["InterfaceType"] = "{ARTICA_MINIADM}";
            setcookie("mem-logon-user", $username, time() + 172800);
            $_SESSION["privileges_array"] = $privs->privs;
            while (list($key, $val) = each($_SESSION["privileges_array"])) {
                if (!isset($_SESSION[$key])) {
                    $_SESSION[$key] = $val;
                }
            }
            reset($_SESSION["privileges_array"]);
            $_SESSION["uid"] = $username;
            $_SESSION["RADIUS_ID"] = $ligne["id"];
            BuildSession($username);
            if ($Aspost) {
                header("location:miniadm.index.php");
                return;
            }
            return;
        }
    }
    writelogs("{$username}::Finally Is LOCAL LDAP ? -> {$IsKerbAuth}", __FUNCTION__, __FILE__, __LINE__);
    $u = new user($username);
    $tpl = new templates();
    $userPassword = $u->password;
    if (trim($u->uidNumber) == null) {
        writelogs('Unable to get user infos abort', __FUNCTION__, __FILE__);
        if ($Aspost) {
            MainPage("Unknown user (" . __LINE__ . ")");
            return;
        }
        echo "Unknown user (" . __LINE__ . ")";
        die;
    }
    writelogs("{$username}:: Password match ? Aspost = {$Aspost}", __FUNCTION__, __FILE__, __LINE__);
    if ($Aspost) {
        if (trim($password) != trim($userPassword)) {
            writelogs("{$username}:: Password match NO Aspost = {$Aspost}", __FUNCTION__, __FILE__, __LINE__);
            MainPage("Bad password (" . __LINE__ . ")");
            return;
        }
    }
    if (!$Aspost) {
        if (trim($password) != md5(trim($userPassword))) {
            writelogs("{$username}:: Password match NO Aspost = {$Aspost}", __FUNCTION__, __FILE__, __LINE__);
            writelogs("[{$_POST["username"]}]: The password typed  is not the same in ldap database...", __FUNCTION__, __FILE__);
            artica_mysql_events("Failed to logon on the management console as user `{$username}` from {$_SERVER["REMOTE_HOST"]} (bad password)", @implode("\n", $notice), "security", "security");
            if ($Aspost) {
                MainPage("Bad password (" . __LINE__ . ")");
                return;
            }
            echo "Error: (" . __LINE__ . ") bad password";
            return null;
        }
    }
    writelogs("{$username}:: Password match YES Aspost = {$Aspost}", __FUNCTION__, __FILE__, __LINE__);
    $ldap = new clladp();
    $users = new usersMenus();
    $_SESSION["CORP"] = $users->CORP_LICENSE;
    $privs = new privileges($u->uid);
    $privs->SearchPrivileges();
    $privileges_array = $privs->privs;
    $_SESSION["VirtAclUser"] = false;
    $_SESSION["privileges_array"] = $privs->privs;
    $_SESSION["privs"] = $privileges_array;
    if (isset($privileges_array["ForceLanguageUsers"])) {
        $_SESSION["OU_LANG"] = $privileges_array["ForceLanguageUsers"];
    }
    $_SESSION["uid"] = $username;
    $_SESSION["privileges"]["ArticaGroupPrivileges"] = $privs->content;
    $_SESSION["groupid"] = $ldap->UserGetGroups($_POST["username"], 1);
    $_SESSION["DotClearUserEnabled"] = $u->DotClearUserEnabled;
    $_SESSION["MailboxActive"] = $u->MailboxActive;
    $_SESSION["InterfaceType"] = "{APP_ARTICA_ADM}";
    $_SESSION["ou"] = $u->ou;
    $_SESSION["UsersInterfaceDatas"] = trim($u->UsersInterfaceDatas);
    include_once dirname(__FILE__) . "/ressources/class.translate.rights.inc";
    $cr = new TranslateRights(null, null);
    $r = $cr->GetPrivsArray();
    while (list($key, $val) = each($r)) {
        if ($users->{$key}) {
            $_SESSION[$key] = $users->{$key};
        }
    }
    if (is_array($_SESSION["privs"])) {
        $r = $_SESSION["privs"];
        while (list($key, $val) = each($r)) {
            $t[$key] = $val;
            $_SESSION[$key] = $val;
        }
    }
    if (!isset($_SESSION["OU_LANG"])) {
        $_SESSION["OU_LANG"] = null;
    }
    if (!isset($_SESSION["ASDCHPAdmin"])) {
        $_SESSION["ASDCHPAdmin"] = false;
    }
    if (trim($_SESSION["OU_LANG"]) != null) {
        $_SESSION["detected_lang"] = $_SESSION["OU_LANG"];
    } else {
        include_once dirname(__FILE__) . "/ressources/class.langages.inc";
        $lang = new articaLang();
        $_SESSION["detected_lang"] = $lang->get_languages();
    }
    if (isset($GLOBALS["FixedLanguage"])) {
        $sock = new sockets();
        $GLOBALS["FixedLanguage"] = $sock->GET_INFO("FixedLanguage");
    }
    if (trim($GLOBALS["FixedLanguage"]) != null) {
        $_SESSION["detected_lang"] = $GLOBALS["FixedLanguage"];
    }
    if ($Aspost) {
        header("location:miniadm.index.php");
        return;
    }
}
コード例 #17
0
function users_list()
{
    $tpl = new templates();
    $CurPage = CurrentPageName();
    $search = $_POST["query"];
    $t = $_GET["t"];
    $ad = new external_ad_search($_GET["ConnectionEnc"]);
    if (!is_numeric($_GET["OnlyUsers"])) {
        $_GET["OnlyUsers"] = 0;
    }
    $icon = "user-32.png";
    if ($_GET["OnlyGroups"] == 1) {
        $OnlyGroups = 1;
        $icon = "win7groups-32.png";
        $Array = $ad->flexRTGroups($search, $_POST["rp"]);
        if ($ad->error != null) {
            json_error_show($ad->error, 1);
        }
    }
    if ($_GET["OnlyUsers"] == 1) {
        $OnlyGroups = 0;
        $icon = "win7groups-32.png";
        $Array = $ad->flexRTUsers($search, $_POST["rp"]);
        if ($ad->error != null) {
            json_error_show($ad->error, 1);
        }
    }
    if (count($Array) == 0) {
        json_error_show("No item", 1);
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($Array);
    $data['rows'] = array();
    $members = $tpl->_ENGINE_parse_body("{members}");
    while (list($dn, $itemname) = each($Array)) {
        $GroupxSourceName = $itemname;
        $GroupxName = $itemname;
        $GroupxName = replace_accents($GroupxName);
        $GroupxName = str_replace("'", "`", $itemname);
        $link = "<span style='font-size:14px;'>";
        $addtitile = null;
        $select = null;
        $dn_enc = base64_encode($dn);
        $itemnameenc = base64_encode($itemname);
        $image = imgsimple($icon, null, "PutDN{$t}('{$dn_enc}')");
        $select = imgsimple("arrow-right-24.png", null, "PutDN{$t}('{$dn_enc}')");
        if ($_GET["CallBack"] != null) {
            $select = imgsimple("arrow-right-24.png", null, "YahooSearchUserHide();{$_GET["CallBack"]}('{$dn_enc}','{$itemnameenc}')");
            $image = imgsimple($icon, null, "YahooSearchUserHide();{$_GET["CallBack"]}('{$dn_enc}','{$itemnameenc}')");
        }
        $md5 = md5($dn);
        $data['rows'][] = array('id' => $md5, 'cell' => array($image, "<span style='font-size:14px;'>{$link}{$GroupxName}</a>", $select));
    }
    echo json_encode($data);
}
コード例 #18
0
ファイル: exec.adusers.php プロジェクト: articatech/artica
function impcomputers()
{
    $sock = new sockets();
    $ldap = new clladp();
    $users = new usersMenus();
    $EnableKerbAuth = 1;
    if (!$ldap->IsKerbAuth()) {
        $EnableKerbAuth = 0;
    }
    if (!is_numeric($EnableKerbAuth)) {
        $EnableKerbAuth = 0;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "EnableKerbAuth={$EnableKerbAuth}\n";
    }
    if ($EnableKerbAuth == 0) {
        return;
    }
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $timefile = "/etc/artica-postfix/pids/exec.adusers.php.impcomputers.time";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, __FILE__)) {
        return;
    }
    $ztime = $unix->file_time_min($timefile);
    if ($ztime < 240) {
        die;
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    array('a', 'b', 'c', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
    $iptcp = new IP();
    while (list($num, $letter) = each($array)) {
        $ad = new external_ad_search();
        $CMPS = $ad->find_computers("{$letter}*");
        $count = $CMPS["count"];
        if ($GLOBALS["VERBOSE"]) {
            echo "{$letter}* == {$count}\n";
        }
        for ($i = 0; $i < $count; $i++) {
            $arraCMP = $CMPS[$i];
            $hostname = null;
            $domain = null;
            $operatingsystem = null;
            $uid = $arraCMP["samaccountname"][0];
            $computer = new computers($uid);
            if ($computer->IsExists) {
                continue;
            }
            if (isset($arraCMP["dnshostname"][0])) {
                $hostname = $arraCMP["dnshostname"][0];
            }
            if (isset($arraCMP["operatingsystem"][0])) {
                $operatingsystem = $arraCMP["operatingsystem"][0];
            }
            if ($hostname == null) {
                if (isset($arraCMP["name"])) {
                    $hostname = $arraCMP["name"][0];
                }
            }
            if ($hostname == null) {
                if (isset($arraCMP["cn"])) {
                    $hostname = $arraCMP["cn"][0];
                }
            }
            if ($hostname == null) {
                continue;
            }
            if (strpos($hostname, ".") > 0) {
                $DD = explode(".", $hostname);
                unset($DD[0]);
                $domain = @implode(".", $DD);
            }
            $ipaddr = gethostbyname($hostname);
            if (!$iptcp->isIPAddress($ipaddr)) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$hostname} - > {$ipaddr} -> abort\n";
                }
                continue;
            }
            $computer->ComputerIP = $ipaddr;
            $computer->uid = "{$uid}";
            if ($domain != null) {
                $computer->DnsZoneName = $domain;
            }
            $computer->ComputerRealName = $arraCMP["name"];
            $computer->ComputerOS = $operatingsystem;
            if ($GLOBALS["VERBOSE"]) {
                echo "Add {$hostname}/{$ipaddr} {$operatingsystem}\n";
            }
            $computer->Add();
        }
    }
}
コード例 #19
0
ファイル: exec.kerbauth.php プロジェクト: BillTheBest/1.6.x
function GetUsersNumber()
{
    include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
    $ad = new external_ad_search();
    $users = $ad->NumUsers();
    echo "Users: {$users}\n";
}
コード例 #20
0
function find_member()
{
    if ($_POST["qtype"] == "find-member") {
        $tofind = $_POST["query"];
    }
    if ($_SESSION["uid"] == -100) {
        $ou = $_GET["ou"];
    } else {
        $ou = $_SESSION["ou"];
    }
    $sock = new sockets();
    if (is_base64_encoded($ou)) {
        $ou = base64_decode($ou);
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $tofind = str_replace('***', '*', $tofind);
    $tofind = str_replace('**', '*', $tofind);
    $tofind = str_replace('**', '*', $tofind);
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    writelogs("FIND {$tofind} IN OU \"{$ou}\"", __FUNCTION__, __FILE__, __LINE__);
    $ldap = new clladp();
    if (!$ldap->IsOUUnderActiveDirectory($ou)) {
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $cc = new ldapAD();
            $hash = $cc->find_users($ou, $tofind);
        } else {
            $ldap = new clladp();
            $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind}) ))";
            $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
            $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
            $hash = $ldap->Ldap_search($dn, $filter, $attrs, 20);
        }
    } else {
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $p = new external_ad_search();
        $hash = $p->find_users($ou, $tofind);
        $ldap->EnableManageUsersTroughActiveDirectory = true;
    }
    $users = new user();
    $number = $hash["count"];
    $data = array();
    $data['page'] = 0;
    $data['total'] = $number;
    $data['rows'] = array();
    for ($i = 0; $i < $number; $i++) {
        $user = $hash[$i];
        $data['rows'][] = formatUser($user, $ldap->EnableManageUsersTroughActiveDirectory);
    }
    echo json_encode($data);
}
コード例 #21
0
function notadmin_status()
{
    $curs = "OnMouseOver=\"this.style.cursor='pointer';\"\n\tOnMouseOut=\"this.style.cursor='auto'\"";
    include_once dirname(__FILE__) . "/ressources/class.user.inc";
    $users = new usersMenus();
    if (!$users->SQUID_INSTALLED) {
        $_SESSION["ACLS_PRIVILEGES"] = null;
    }
    $icon = "member-128.png";
    $ct = new user($_SESSION["uid"]);
    $squid_acls = null;
    if ($ct->AsActiveDirectoryMember) {
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ad = new external_ad_search();
        $DN = $ad->GetDNFromUserid($_SESSION["uid"]);
        $groupsArray = $ad->GroupsOfMember($DN);
        $MyGroups = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:30px;text-decoration:underline'\n\t\t\t\tOnClick=\"javascript:{$js}\" {$curs}>{$ct->mail}\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='font-size:18px;vertical-align:top'>{gidNumber} " . count($groupsArray) . " {groups2}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td style='font-size:18px;vertical-align:top'>{organization} <strong>{$ct->ou}</strong></td>\n\t\t</tr>\n\t\t";
    } else {
        $MEMBER_JS = "javascript:blur();";
        $OU_js = "javascript:blur();";
        $OU_decoration = "none";
        $OU_curs = null;
        if ($users->AllowChangeUserPassword) {
            $MEMBER_JS = MEMBER_JS($_SESSION["uid"]);
        }
        if (VerifyRights_ou()) {
            $OU_js = "javascript:Loadjs('domains.manage.org.index.php?js=yes&ou={$ct->ou}');";
            $OU_decoration = "underline";
            $OU_curs = $curs;
        }
        $MyGroups = "\n\t\t<tr>\n\t\t<td style='font-size:16px;text-decoration:underline'\n\t\tOnClick=\"{$MEMBER_JS}\" {$curs}>{myaccount}: {$ct->mail}\n\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td style='font-size:18px;vertical-align:top'>{my_organization} <strong OnClick=\"{$OU_js}\" {$curs} style='text-decoration:{$OU_decoration}'>{$ct->ou}</strong></td>\n\t\t</tr>\n\t\t";
    }
    if ($users->SQUID_INSTALLED) {
        if (!isset($_SESSION["ACLS_PRIVILEGES"])) {
            include_once dirname(__FILE__) . "/ressources/class.squid.acls.privileges.inc";
            $f = new squid_acls_privileges();
            $_SESSION["ACLS_PRIVILEGES"] = $f->build();
        }
        $squid_acls = $_SESSION["ACLS_PRIVILEGES"];
        if ($squid_acls != null) {
            $squid_acls = "<tr><td>{$squid_acls}</td></tr>";
        }
    }
    $html = "\n\t<table style='width:100%'>\n\t<tr>\n\t<td valign='top' style='width:128px'>\n\t<img src='img/{$icon}'>\n\t</td>\n\t<td style='width:99%'>\n\t<table style='width:100%'>\n\t<tr>\n\t<td style='font-size:30px;vertical-align:top'>{$ct->DisplayName}</td>\n\t</tr>\n\t{$MyGroups}\n\t{$squid_acls}\n\n\t</table>\n\t</td>\n\t</tr>\n\t</table>\n\t";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
コード例 #22
0
ファイル: domains.index.php プロジェクト: BillTheBest/1.6.x
function ORGANISATIONS_LIST()
{
    $tpl = new templates();
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        return ORGANISATIONS_LIST_ACTIVE_DIRECTORY();
    }
    include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
    $Mypage = CurrentPageName();
    $users = new usersMenus();
    $sock = new sockets();
    $ou_nozarafa_explain = $tpl->_ENGINE_parse_body("{ou_nozarafa_explain}");
    $t = $_GET["t"];
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    $AllowInternetUsersCreateOrg = $sock->GET_INFO("AllowInternetUsersCreateOrg");
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $ldap = new ldapAD();
        $hash = $ldap->hash_get_ou(true);
    } else {
        $ldap = new clladp();
        $hash = $ldap->hash_get_ou(true);
    }
    if (!is_array($hash)) {
        json_error_show("No data...");
    }
    ksort($hash);
    if ($EnableManageUsersTroughActiveDirectory == 0) {
        if (!$ldap->BuildOrganizationBranch()) {
            json_error_show("{GENERIC_LDAP_ERROR}<br>{$ldap->ldap_last_error}");
        }
    }
    if ($_POST["query"] != null) {
        $search = $_POST["query"];
        $search = str_replace(".", "\\.", $search);
        $search = str_replace("*", ".*?", $search);
    }
    if (isset($_GET["ajaxmenu"])) {
        $ajax = true;
    }
    $pic = "32-environement.png";
    $style = "style='font-size:16px;'";
    $c = 0;
    $ldap2 = new clladp();
    if (count($hash) == 0) {
        json_error_show("no data");
    }
    while (list($num, $ligne) = each($hash)) {
        $ou = $ligne;
        $ou_encoded = base64_encode($ou);
        if (!preg_match("#{$search}#i", $ligne)) {
            writelogs("'{$ligne}' NO MATCH {$search}", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        $md = md5(serialize($hash) . time());
        $md5S = $md;
        $uri = "javascript:Loadjs('domains.manage.org.index.php?js=yes&ou={$ligne}');";
        if ($ajax) {
            $uri = "javascript:Loadjs('{$Mypage}?LoadOrgPopup={$ligne}');";
        }
        $IsOUUnderActiveDirectory = $ldap2->IsOUUnderActiveDirectory($ou);
        $GroupsNB = 0;
        if ($EnableManageUsersTroughActiveDirectory == 0) {
            $img = $ldap->get_organization_picture($ligne, 32);
            writelogs("ldap->CountDeUSerOu({$ligne})", __FUNCTION__, __FILE__, __LINE__);
            $usersNB = $ldap->CountDeUSerOu($ligne);
            $usersNB = "{$usersNB}";
        } else {
            $img = $pic;
            if ($IsOUUnderActiveDirectory) {
                $ad = new external_ad_search();
                writelogs("ldap->CountDeUSerOu({$ligne})", __FUNCTION__, __FILE__, __LINE__);
                $usersNB = $ad->CountDeUSerOu($ligne);
            } else {
                writelogs("ldap->CountDeUSerOu({$ligne})", __FUNCTION__, __FILE__, __LINE__);
                $usersNB = $ldap->CountDeUSerOu($ligne);
                $usersNB = "{$usersNB}";
            }
        }
        $delete = imgtootltip("delete-32-grey.png", "<b>{delete_ou} {$ligne}</b><br><i>{delete_ou_text}</i>");
        if ($users->AsArticaAdministrator) {
            $delete = Paragraphe('64-cancel.png', "{delete_ou} {$ligne}", '{delete_ou_text}', "javascript:Loadjs('domains.delete.org.php?ou={$ligne}');", null, 210, 100, 0, true);
            $delete = imgsimple("delete-32.png", "<b>{delete_ou} {$ligne}</b><br><i>{delete_ou_text}</i>", "javascript:Loadjs('domains.delete.org.php?ou={$ligne}&t={$t}&id-table={$md5S}');");
        }
        $DomainsNB = $ldap->CountDeDomainsOU($ligne);
        if ($GroupsNB == 0) {
            if ($IsOUUnderActiveDirectory) {
                $ad = new external_ad_search();
                writelogs("->CountDeGroups({$ou})", __FUNCTION__, __FILE__, __LINE__);
                $GroupsNB = $ad->CountDeGroups($ou);
            } else {
                writelogs("->CountDeGroups({$ou})", __FUNCTION__, __FILE__, __LINE__);
                $GroupsNB = $ldap->CountDeGroups($ou);
            }
        }
        Paragraphe('folder-useradd-64.png', '{create_user}', '{create_user_text}', "javascript:Loadjs('domains.add.user.php?ou={$ou}')", null, 210, null, 0, true);
        Paragraphe('64-folder-group-add.png', '{create_user}', '{create_user_text}', "javascript:Loadjs('domains.add.user.php?ou={$ou}')", null, 210, null, 0, true);
        Paragraphe("64-folder-group-add.png", "{$ou}:{add_group}", "{add_a_new_group_in_this_org}:<b>{$ou}</b>", "javascript:Loadjs('domains.edit.group.php?popup-add-group=yes&ou={$ou}&t={$t}')");
        $select = imgsimple("domain-32.png", "{manage_organisations_text}", $uri);
        $adduser = imgsimple("folder-useradd-32.png", "{$ou}<hr><b>{create_user}</b><br><i>{create_user_text}</i>", "Loadjs('domains.add.user.php?ou={$ou_encoded}&encoded=yes');");
        $addgroup = imgsimple("32-folder-group-add.png", "{$ou}<hr><b>{add_group}</b><br><i>{add_a_new_group_in_this_org}</i>", "Loadjs('domains.edit.group.php?popup-add-group=yes&ou={$ou}&t={$t}');");
        $SearchUser = imgsimple("loupe-32.png", "{$ou}<hr><b>{search}</b>:<i>{members}</i>", "Loadjs('domains.find.user.php?ou={$ou_encoded}&encoded=yes');");
        $SearchGroup = imgsimple("loupe-32.png", "{$ou}<hr><b>{search}</b>:<i>{groups}</i>", "Loadjs('domains.find.groups.php?ou={$ou_encoded}&encoded=yes&t={$t}');");
        $searchDomain = imgsimple("loupe-32.png", "{$ou}<hr><b>{localdomains}</b>:<i>{localdomains_text}</i>", "Loadjs('domains.edit.domains.php?js=yes&ou={$ou}&master-t={$t}');");
        $NOZARAFA = 0;
        $OuZarafaText = null;
        if ($IsOUUnderActiveDirectory) {
            $delete = imgtootltip("delete-24-grey.png", "", "");
            $adduser = imgsimple("folder-useradd-32-grey.png");
            $addgroup = imgsimple("32-folder-group-add-grey.png");
        }
        if ($_GET["zarafaF"] == 1) {
            $info = $ldap->OUDatas($ou);
            if (!$info["objectClass"]["zarafa-company"]) {
                $NOZARAFA = 1;
                $OuZarafaText = "<br><a href=\"javascript:blur()\" style='color:#B20808;text-decoration:underline;font-style:italic' \n\t\t\t\tOnClick=\"javascript:Loadjs('domains.edit.zarafa.php?ou={$ou_encoded}&t={$t}')\">{$ou_nozarafa_explain}</a>";
            }
        }
        $array = array();
        $array[] = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"{$uri}\" style='font-size:26px;font-weight:bolder;text-transform:capitalize;\n\t\ttext-decoration:underline'>{$ligne}</strong></a>{$OuZarafaText}";
        if ($_GET["zarafaF"] == 1) {
            $zarafaEnabled = "zarafa-logo-32.png";
            if ($NOZARAFA == 1) {
                $zarafaEnabled = "zarafa-logo-32-grey.png";
            }
            $array[] = "<center>" . imgsimple($zarafaEnabled, "<strong style=font-size:26px>{$ou}:{APP_ZARAFA}</strong>\n\t\t\t\t\t<br>{ZARAFA_OU_ICON_TEXT}", "Loadjs('domains.edit.zarafa.php?ou={$ou_encoded}&t={$t}')") . "</center>";
        } else {
            $array[] = "&nbsp;";
        }
        $array[] = "<strong style='font-size:26px'>{$usersNB}</strong>";
        $array[] = "<center style='font-size:16px'>{$SearchUser}</center>";
        $array[] = "<strong style='font-size:26px'>{$GroupsNB}</strong>";
        $array[] = "<center style='font-size:16px'>{$SearchGroup}</center>";
        $array[] = "<strong style='font-size:26px'>{$DomainsNB}</strong>";
        $array[] = "<center style='font-size:16px'>{$searchDomain}</center>";
        $array[] = "<center style='font-size:16px'>{$adduser}</center>";
        $array[] = "<center style='font-size:16px'>{$addgroup}</center>";
        $array[] = "<center style='font-size:16px'>{$delete}</center>";
        $c++;
        $data['rows'][] = array('id' => $md5S, 'cell' => $array);
    }
    $total = $c;
    $data['page'] = 1;
    $data['total'] = $total;
    echo json_encode($data);
}
コード例 #23
0
ファイル: MembersBrowse.php プロジェクト: brucewu16899/1.6.x
function query_members_ad()
{
    include_once dirname(__FILE__) . '/class.external.ad.inc';
    $sock = new sockets();
    $config = unserialize(base64_decode($sock->GET_INFO("SambaAdInfos")));
    $ldap = new external_ad_search($config);
    $query = $_POST["query"];
    if ($query == null) {
        $query = "*";
    }
    $hash = $ldap->find_users(null, $query, $_POST["rp"]);
    writelogs("COUNT={$hash["count"]}", __FUNCTION__, __FILE__, __LINE__);
    $data = array();
    $data['page'] = 1;
    $data['total'] = $hash["count"];
    $data['rows'] = array();
    $c = 0;
    for ($i = 0; $i < $hash["count"]; $i++) {
        $ligne = $hash[$i];
        $samaccountname = $ligne["samaccountname"][0];
        if ($samaccountname == null) {
            continue;
        }
        $gid = 0;
        $Displayname = $samaccountname;
        $img = "user-18.png";
        $prepend = "user:"******"NOComputers"] == 1) {
                continue;
            }
            $Displayname = str_replace('$', '', $Displayname);
            $img = "base.gif";
            $prepend = "computer:";
        }
        $js = "SambaBrowseSelect('{$samaccountname}','{$prepend}',{$gid})";
        if ($_GET["callback"] != null) {
            $js = "{$_GET["callback"]}('{$samaccountname}','{$prepend}',{$gid})";
        }
        if (isset($ligne["displayname"][0])) {
            $Displayname = $ligne["displayname"][0];
        }
        $c++;
        if ($c > $_POST["rp"]) {
            break;
        }
        $data['rows'][] = array('id' => md5(serialize($ligne["displayname"])), 'cell' => array("<img src='img/{$img}'>", "<span style='font-size:14px;font-weight:bolder'>{$Displayname}</span> <span style='font-size:11px'>({$samaccountname})</span>", "<span style='font-size:14px'>" . imgsimple("arrow-right-24.png", "{add}", $js) . "</span>"));
    }
    $data['total'] = $c;
    echo json_encode($data);
}
コード例 #24
0
ファイル: exec.clientad.php プロジェクト: BillTheBest/1.6.x
function tests()
{
    $ad = new external_ad_search();
    print_r($ad->GroupsOfMember("CN=Jerome JB. Beunel,OU=AFEONLINE,OU=AFE,DC=afeonline,DC=net"));
}
コード例 #25
0
ファイル: miniadm.php プロジェクト: brucewu16899/1.6.x
function auth_verif()
{
    $tpl = new templates();
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        $external_ad_search = new external_ad_search();
        if (!$external_ad_search->CheckUserAuth($_POST["username-logon"], $_POST["username-password"])) {
            echo $tpl->_ENGINE_parse_body("<center><H2 style='color:red'>{unknown_user}</H2></center>");
            return null;
        }
        $users = new usersMenus();
        $privs = new privileges($_POST["username-logon"]);
        $privileges_array = $privs->privs;
        $_SESSION["InterfaceType"] = "{ARTICA_MINIADM}";
        setcookie("mem-logon-user", $_POST["username-logon"], time() + 172800);
        $_SESSION["privileges_array"] = $privs->privs;
        $_SESSION["uid"] = $_POST["username-logon"];
        $_SESSION["passwd"] = $_POST["username-logon"];
        $_SESSION["privileges"]["ArticaGroupPrivileges"] = $privs->content;
        BuildSession($_POST["username-logon"]);
        echo "<script>YahooWinHide();LoadAjax('BodyContent','miniadm.index.php');</script>\n\t\t";
        return;
    }
    $u = new user($_POST["username-logon"]);
    $userPassword = $u->password;
    if (trim($u->uidNumber) == null) {
        writelogs('Unable to get user infos abort', __FUNCTION__, __FILE__);
        echo $tpl->_ENGINE_parse_body("<center><H2 style='color:red'>{unknown_user}</H2></center>");
        return null;
    }
    if (trim($_POST["username-password"]) == trim($userPassword)) {
        $ldap = new clladp();
        $users = new usersMenus();
        $privs = new privileges($u->uid);
        $privileges_array = $privs->privs;
        $_SESSION["InterfaceType"] = "{ARTICA_MINIADM}";
        setcookie("mem-logon-user", $_POST["username-logon"], time() + 172800);
        $_SESSION["privileges_array"] = $privs->privs;
        $_SESSION["privs"] = $privileges_array;
        $_SESSION["OU_LANG"] = $privileges_array["ForceLanguageUsers"];
        $_SESSION["uid"] = $_POST["username-logon"];
        $_SESSION["passwd"] = $_POST["username-logon"];
        $_SESSION["privileges"]["ArticaGroupPrivileges"] = $privs->content;
        $_SESSION["groupid"] = $ldap->UserGetGroups($_POST["artica_username"], 1);
        $_SESSION["DotClearUserEnabled"] = $u->DotClearUserEnabled;
        $_SESSION["MailboxActive"] = $u->MailboxActive;
        $_SESSION["ou"] = $u->ou;
        $_SESSION["UsersInterfaceDatas"] = trim($u->UsersInterfaceDatas);
        $lang = new articaLang();
        writelogs("[{$_POST["username-logon"]}]: Default organization language={$_SESSION["OU_LANG"]}", __FUNCTION__, __FILE__);
        if (trim($_SESSION["OU_LANG"]) != null) {
            $_SESSION["detected_lang"] = $_SESSION["OU_LANG"];
            setcookie("artica-language", $_SESSION["OU_LANG"], time() + 172800);
        } else {
            setcookie("artica-language", $_POST["lang"], time() + 172800);
            $_SESSION["detected_lang"] = $lang->get_languages();
        }
        echo "<script>\n\t\t\tYahooWinHide();\n\t\t\tLoadAjax('BodyContent','miniadm.index.php');\n\t\t</script>\n\t\t";
        return;
    } else {
        echo $tpl->_ENGINE_parse_body("<center><H2 style='color:red'>{bdu}</H2></center>");
    }
}
コード例 #26
0
function privileges()
{
    $tpl = new templates();
    $sock = new sockets();
    if ($GLOBALS["VERBOSE"]) {
        echo "<H1>" . __FUNCTION__ . "(line " . __LINE__ . ")</H1>\n";
    }
    $EnableSambaVirtualsServers = 0;
    include_once dirname(__FILE__) . "/ressources/class.translate.rights.inc";
    $cr = new TranslateRights(null, null);
    $r = $cr->GetPrivsArray();
    $users = new usersMenus();
    $ldap = new clladp();
    $ht = array();
    $ht[] = "<div style='width:98%' class=form>";
    $ht[] = "<table style='width:99%'>";
    if ($ldap->IsKerbAuth()) {
        if ($GLOBALS["VERBOSE"]) {
            echo "<li><strong>IsKerbAuth = TRUE (line " . __LINE__ . ")</strong></li>\n";
        }
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ht[] = "<div style='font-size:18px;font-weight:bold'>{my_microsoft_groups}</div>";
        $ad = new external_ad_search();
        $groups = $ad->GroupsOfMember($_SESSION["uid"]);
        while (list($dn, $name) = each($groups)) {
            $ht[] = "<tr>\n\t\t\t\t\t<td width=1% valign='top'><img src='img/arrow-right-16.png'></td>\n\t\t\t\t\t<td><span style='font-size:14px;font-weight:bold'>{$name}</span>\n\t\t\t\t\t\t<br><span style='font-size:10px'>&nbsp;({$dn})</span></td>\n\t\t\t\t</tr>";
        }
    }
    while (list($key, $val) = each($r)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "<li>{$key} = \"{$val}\"</li>\n";
        }
        if ($users->{$key}) {
            $ht[] = "<tr><td width=1%><img src='img/arrow-right-16.png'></td><td><span style='font-size:14px'>{{$key}}</span></td></tr>";
        }
    }
    $users = new usersMenus();
    if ($users->SAMBA_INSTALLED) {
        $EnableSambaVirtualsServers = $sock->GET_INFO("EnableSambaVirtualsServers");
        if (!is_numeric($EnableSambaVirtualsServers)) {
            $EnableSambaVirtualsServers = 0;
        }
    }
    if ($EnableSambaVirtualsServers == 1) {
        if (count($_SESSION["VIRTUALS_SERVERS"]) > 0) {
            $ht[] = "<tr><td colspan=2 style='font-size:16px;font-weight:bolder'>{virtual_servers}</td></tr>";
            while (list($key, $val) = each($_SESSION["VIRTUALS_SERVERS"])) {
                $ht[] = "<tr><td width=1%><img src='img/arrow-right-16.png'></td><td><span style='font-size:14px'>{$key}</span></td></tr>";
            }
        }
    }
    $ht[] = "</table></div>";
    echo $tpl->_ENGINE_parse_body(@implode("\n", $ht));
}
コード例 #27
0
function squid_frontend_status()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $TITLE_REQUESTS = null;
    $SquidCacheLevel = $sock->GET_INFO("SquidCacheLevel");
    if (!is_numeric($SquidCacheLevel)) {
        $SquidCacheLevel = 4;
    }
    $LogsWarninStop = $sock->GET_INFO("LogsWarninStop");
    if ($LogsWarninStop == 1) {
        echo FATAL_ERROR_SHOW_128("<div style='font-size:20px'>{squid_logs_urgency}</div>\n\t\t\t\t<div style='text-align:right;font-size:22px;text-align:right;text-decoration:underline;margin-top:20px'>\n\t\t\t\t\t<a href=\"javascript:Loadjs('system.log.emergency.php')\">{squid_logs_urgency_section}</a>\n\t\t\t\t</div>\n\t\t\t\t\n\t\t\t\t");
    }
    $squid5mn = unserialize(base64_decode($sock->getFrameWork("squid.php?5mncounter=yes")));
    //$realMemory=unserialize(base64_decode($sock->getFrameWork("services.php?realMemory=yes")));
    $CounterInfos = unserialize(base64_decode($sock->getFrameWork("squid.php?CounterInfos=yes")));
    $StorageCapacity = unserialize(base64_decode($sock->getFrameWork("squid.php?StorageCapacity=yes")));
    $SquidMonitorParms = unserialize(base64_decode($sock->GET_INFO("SquidMonitorParms")));
    $t = time();
    $server_all_kbytes_in = $SquidMonitorParms["server_all_kbytes_in"];
    $server_all_kbytes_out = $SquidMonitorParms["server_all_kbytes_out"];
    $HttpRequests = $SquidMonitorParms["HttpRequests"];
    $ActiveRequests = $SquidMonitorParms["ActiveRequests"];
    $TITLE_USERS = null;
    $TITLE_COMPUTERS = null;
    $EnableKerbAuth = intval($sock->GET_INFO("EnableKerbAuth"));
    if ($EnableKerbAuth == 1) {
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ldap = new external_ad_search();
        $NET_RPC_INFOS = $ldap->NET_RPC_INFOS();
        $NumBerOfUsers = intval($NET_RPC_INFOS["Num users"]);
        if ($NumBerOfUsers > 0) {
            $TITLE_USERS = "&nbsp;|&nbsp;<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:AnimateDiv('BodyContent');LoadAjax('BodyContent','squid.adker.php?tabs=yes');\" \n\t\t\tstyle='text-decoration:underline'>{$NumBerOfUsers} {members}</a>";
        }
    }
    $q = new mysql_squid_builder();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(MAC) as tcount FROM (SELECT MAC FROM UserAutDB GROUP BY MAC) as t"));
    $Nodes = $ligne["tcount"];
    if ($Nodes > 0) {
        $TITLE_COMPUTERS = "&nbsp;|&nbsp;<a href=\"javascript:blur();\"\n\t\tOnClick=\"Loadjs('squid.computer-browse.php')\"\n\t\tstyle='text-decoration:underline'>{$Nodes} {computers}</a>";
    }
    $CACHES_RATES = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/TOTAL_CACHED"));
    $TOTALS_NOT_CACHED = intval($CACHES_RATES["TOTALS_NOT_CACHED"]);
    $TOTALS_CACHED = intval($CACHES_RATES["TOTALS_CACHED"]);
    $TOTALS_DOWNLOAD = $TOTALS_NOT_CACHED + $TOTALS_CACHED;
    $TOTALS_NOT_CACHED = intval(@file_get_contents("/usr/share/artica-postfix/ressources/logs/stats/NOT_CACHED"));
    if ($TOTALS_NOT_CACHED > 0) {
        $TOTALS_NOT_CACHED_TEXT = "&nbsp;|&nbsp;<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('admin.index.loadvg.squid.notcached-week.php');\"\n\t\tstyle='text-decoration:underline;font-weight:bold'>{not_cached_this_week}: " . FormatBytes($TOTALS_NOT_CACHED / 1024) . "</a>";
    }
    $Status_cache = "&nbsp;|&nbsp;{downloaded} " . FormatBytes($TOTALS_DOWNLOAD / 1024) . "&nbsp;|&nbsp;{cached}:" . FormatBytes($TOTALS_CACHED / 1024) . $TOTALS_NOT_CACHED_TEXT;
    $RATE = $TOTALS_CACHED / $TOTALS_DOWNLOAD * 100;
    $RATE = round($RATE, 1);
    $TITLE_RATE = "&nbsp;|&nbsp;{cache_rate} <strong>{$RATE}%</strong>";
    if (!is_numeric($server_all_kbytes_in)) {
        $server_all_kbytes_in = 1000;
    }
    if (!is_numeric($server_all_kbytes_out)) {
        $server_all_kbytes_out = 250;
    }
    if (!is_numeric($HttpRequests)) {
        $HttpRequests = 150;
    }
    if (!is_numeric($ActiveRequests)) {
        $ActiveRequests = 150;
    }
    if (!isset($squid5mn["cpu_usage"])) {
        $squid5mn["cpu_usage"] = 0;
    }
    $squid5mn["cpu_usage"] = round($squid5mn["cpu_usage"], 2);
    $squid5mn["client_http.requests"] = round($squid5mn["client_http.requests"], 2);
    $squid5mn["server.all.kbytes_in"] = round($squid5mn["server.all.kbytes_in"], 2);
    $squid5mn["server.all.kbytes_out"] = round($squid5mn["server.all.kbytes_out"], 2);
    $ActiveRequestsR = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/active_requests.inc"));
    $ActiveRequestsNumber = count($ActiveRequestsR["CON"]);
    $ActiveRequestsIpaddr = count($ActiveRequestsR["IPS"]);
    $ActiveRequestsMembers = count($ActiveRequestsR["USERS"]);
    if ($ActiveRequestsNumber > 0) {
        $TITLE_REQUESTS = "&nbsp;|&nbsp;<a href=\"javascript:blur();\"\n\t\tOnClick=\"Loadjs('squid.active.requests.php')\"\n\t\tstyle='text-decoration:underline'>{$ActiveRequestsNumber} {active_requests}</a>";
    }
    if (!is_numeric($ActiveRequestsNumber)) {
        $ActiveRequestsNumber = 0;
    }
    if (!is_numeric($ActiveRequestsIpaddr)) {
        $ActiveRequestsIpaddr = 0;
    }
    if (!is_numeric($ActiveRequestsMembers)) {
        $ActiveRequestsMembers = 0;
    }
    $server_all_kbytes_in_text = $tpl->javascript_parse_text("{server_all_kbytes_in}");
    $server_all_kbytes_out_text = $tpl->javascript_parse_text("{server_all_kbytes_out}");
    $active_requests = $tpl->javascript_parse_text("{active_requests}");
    $proxy_status = $tpl->javascript_parse_text("{proxy_status}");
    $second = $tpl->javascript_parse_text("{second}");
    $requests = $tpl->javascript_parse_text("{requests}");
    $countStorages = count($StorageCapacity);
    for ($i = 0; $i < $countStorages; $i++) {
        $tS[] = "<div id='squid-s{$i}-{$t}' style='width:160px; height:100px'>";
        $js[] = " var s{$i} = new JustGage({\n\t\tid: 'squid-s{$i}-{$t}',\n\t\tvalue: {$StorageCapacity[$i]},\n\t\tmin: 0,\n\t\tmax: 100,\n\t\ttitle: 'Storage Capacity Kid " . ($i + 1) . "',\n\t\tlabel: '%',\n\t\tlevelColorsGradient: true\n\t});      ";
    }
    $storages = CompileTr4($tS, true, null, true);
    $ini = new Bs_IniHandler();
    $color = "black";
    $ini->loadFile("/usr/share/artica-postfix/ressources/databases/ALL_SQUID_STATUS");
    if ($ini->_params["SQUID"]["running"] == 0) {
        $color = "#d32d2d";
        $status = "{stopped}";
    } else {
        if ($ini->_params["SQUID"]["master_time"]) {
            $status2 = " {running} {since} " . distanceOfTimeInWords($ini->_params["SQUID"]["master_time"], time());
        }
    }
    $version = @file_get_contents("/usr/share/artica-postfix/ressources/databases/SQUID.version");
    if ($version != null) {
        $version = " v.{$version}";
    }
    if ($SquidCacheLevel == 0) {
        $nocache = " <span style='color:#d32d2d'>{no_cached_sites_warn}</span>";
    }
    $squi1_text = $tpl->javascript_parse_text("{monitor}");
    $squi1_onmouse = "OnMouseOver=\"javascript:AffBulle('{$squi1_text}');this.style.cursor='pointer'\" OnMouseOut=\"javascript:HideBulle();this.style.cursor='default'\"";
    $squi1_onClick = "OnClick=\"javascript:Loadjs('squid.task.monitor.php')\"";
    echo $tpl->_ENGINE_parse_body("\n<table  style='width:99%' >\n\t<tr>\n\t\t<td colspan=4 style='font-size:22px'>\n\t\t\t<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:LoadAjax('BodyContent','squid.caches.status.php?tabs=yes')\" \n\t\t\tstyle='text-decoration:underline;color:{$color}'>{$proxy_status} {$status} {$version}</a>\n\t\t\t{$TITLE_RATE}{$TITLE_USERS}{$TITLE_REQUESTS}{$TITLE_COMPUTERS}\n\t\t\t<br>\n\t\t\t<div style='font-size:11px'><i>{$status2}{$nocache}{$Status_cache}</i></div>\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t\t<td valign='top' width=25%>\n\t\t\t\t<div id='squid-1-{$t}' style='width:160px; height:100px' {$squi1_onmouse} {$squi1_onClick}></div>\n\t\t\t\n\t\t\t</td>\n\t\t\t<td valign='top' width=25%><div id='squid-2-{$t}' style='width:170px; height:100px'></div></td>\n\t\t\t<td valign='top' width=25%><div id='squid-3-{$t}' style='width:170px; height:100px'></div></td>\n\t\t\t<td valign='top' width=25%><div id='squid-4-{$t}' style='width:170px; height:100px'></div></td>\n\t</tr>\n\t\n</table>{$storages}\n\t\t\t\n" . "<div style='text-align:right'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjaxTiny('squid-front-end-status','{$page}?squid-front-end-status=yes');") . "</div>\n<script>\nvar g = new JustGage({\n\tid: 'squid-1-{$t}',\n\tvalue: {$squid5mn["cpu_usage"]},\n\tmin: 0.1,\n\tmax: 100,\n\ttitle: 'Proxy CPU Usage',\n\tlabel: '%',\n\tlevelColorsGradient: true\n});\n\t\nvar g2 = new JustGage({\n\tid: 'squid-2-{$t}',\n\tvalue: {$squid5mn["client_http.requests"]},\n\tmin: 0.1,\n\tmax: {$HttpRequests},\n\ttitle: 'HTTP {$requests}/{$second}',\n\tlabel: 'RQ/s',\n\tlevelColorsGradient: true\n});\n\nvar g3 = new JustGage({\n\tid: 'squid-3-{$t}',\n\tvalue: {$squid5mn["server.all.kbytes_in"]},\n\tmin: 0,\n\tmax: {$server_all_kbytes_in},\n\ttitle: '{$server_all_kbytes_in_text}',\n\tlabel: 'KB',\n\tlevelColorsGradient: true\n\t});\nvar g4 = new JustGage({\n\tid: 'squid-4-{$t}',\n\tvalue: {$squid5mn["server.all.kbytes_out"]},\n\tmin: 0,\n\tmax: {$server_all_kbytes_out},\n\ttitle: '{$server_all_kbytes_out_text}',\n\tlabel: 'KB',\n\tlevelColorsGradient: true\n});\n" . @implode("\n", $js) . "\nif(document.getElementById('squid-rttrqs-status')){\n\tLoadAjaxSilent('squid-rttrqs-status','admin.index.loadavg.squidrtt.php');\n}\n\n\t</script>\n\t");
}
コード例 #28
0
function finduser_list()
{
    $keycached = "{$_GET["finduser"]}";
    header("Pragma: no-cache");
    header("Expires: 0");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-cache, must-revalidate");
    $GLOBALS["OUTPUT_DEBUG"] = false;
    $stringtofind = trim($_GET["finduser"]);
    if ($_POST["query"] != null) {
        $stringtofind = $_POST["query"];
    }
    if (!isset($_POST["rp"])) {
        $_POST["rp"] = 15;
    }
    $users = new usersMenus();
    $sock = new sockets();
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    if (preg_match("#debug:(.+)#", $stringtofind, $re)) {
        $GLOBALS["OUTPUT_DEBUG"] = true;
        $stringtofind = trim($re[1]);
    }
    if ($GLOBALS["OUTPUT_DEBUG"]) {
        echo "Want to search {$stringtofind}<br>";
    }
    $tpl = new templates();
    $usermenu = new usersMenus();
    $ldap = new clladp();
    if (!$ldap->IsKerbAuth()) {
        if ($usermenu->AsAnAdministratorGeneric == true) {
            if ($GLOBALS["OUTPUT_DEBUG"]) {
                echo "It is an administrator search in the entire tree<br>";
            }
            $hash_full = $ldap->UserSearch(null, $stringtofind, $_POST["rp"]);
        } else {
            $us = $ldap->UserDatas($_SESSION["uid"]);
            if ($GLOBALS["OUTPUT_DEBUG"]) {
                echo "It is an user search in the {$us["ou"]} tree<br>";
            }
            $hash_full = $ldap->UserSearch($us["ou"], $stringtofind, $_POST["rp"]);
        }
        $hash1 = $hash_full[0];
        $hash2 = $hash_full[1];
        if ($GLOBALS["OUTPUT_DEBUG"]) {
            echo "Search results " . count($hash1) . " users and " . count($hash2) . " contacts<br>";
        }
    } else {
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ad = new external_ad_search();
        $hash_full = $ad->UserSearch(null, $stringtofind, $_POST["rp"]);
        $hash1 = $hash_full[0];
        $hash2 = $hash_full[1];
        if ($GLOBALS["OUTPUT_DEBUG"]) {
            echo "Search results " . count($hash1) . " users and " . count($hash2) . " contacts<br>";
        }
    }
    $hash = array();
    $count = 0;
    $data = array();
    $data['page'] = 1;
    $data['total'] = 0;
    $data['rows'] = array();
    if (is_array($hash1)) {
        if ($GLOBALS["OUTPUT_DEBUG"]) {
            echo "<strong>Search results ->HASH1</strong><br>\n";
        }
        while (list($num, $ligne) = each($hash1)) {
            if (isset($ligne["samaccountname"][0])) {
                $ligne["uid"][0] = $ligne["samaccountname"][0];
            }
            if ($ligne["uid"][0] == null) {
                if (preg_match("#^CN=(.+?),#i", $ligne["dn"], $re)) {
                    $ligne["uid"][0] = $re[1];
                    $hash[$count]["displayname"][0] = $re[1];
                }
            }
            if ($EnableManageUsersTroughActiveDirectory == 0) {
                if ($ligne["uid"][0] == null && $ligne["employeenumber"][0] == null) {
                    continue;
                }
            }
            if (strpos($ligne["dn"], "dc=pureftpd,dc=organizations") > 0) {
                continue;
            }
            $hash[$count]["displayname"][0] = trim($ligne["displayname"][0]);
            $hash[$count]["givenname"][0] = $ligne["givenname"][0];
            if ($EnableManageUsersTroughActiveDirectory == 1) {
                $hash[$count]["uid"][0] = $ligne["samaccountname"][0];
            } else {
                $hash[$count]["uid"][0] = $ligne["uid"][0];
            }
            if (substr($hash[$count]["uid"][0], strlen($hash[$count]["uid"][0]) - 1, 1) == '$') {
                continue;
            }
            $hash[$count]["employeenumber"][0] = $ligne["employeenumber"][0];
            $hash[$count]["title"][0] = $ligne["title"][0];
            $hash[$count]["uri"][0] = $ligne["uri"][0];
            $hash[$count]["mail"][0] = $ligne["mail"][0];
            $hash[$count]["phone"][0] = $ligne["telephonenumber"][0];
            $hash[$count]["sn"][0] = $ligne["sn"][0];
            $hash[$count]["dn"] = $ligne["dn"];
            $count++;
        }
    } else {
        if ($GLOBALS["OUTPUT_DEBUG"]) {
            echo "<strong>Search results ->HASH1 NOT AN ARRAY</strong><br>\n";
        }
    }
    if (is_array($hash2)) {
        if ($GLOBALS["OUTPUT_DEBUG"]) {
            echo "<strong>Search results ->HASH2</strong><br>\n";
        }
        while (list($num, $ligne) = each($hash2)) {
            if (isset($ligne["samaccountname"][0])) {
                $ligne["uid"][0] = $ligne["samaccountname"][0];
            }
            if ($ligne["uid"][0] == null && $ligne["employeenumber"][0] == null) {
                continue;
            }
            if (strpos($ligne["dn"], "dc=pureftpd,dc=organizations") > 0) {
                continue;
            }
            $hash[$count]["displayname"][0] = $ligne["displayname"][0];
            $hash[$count]["givenname"][0] = $ligne["givenname"][0];
            $hash[$count]["uid"][0] = $ligne["uid"][0];
            $hash[$count]["employeenumber"][0] = $ligne["employeenumber"][0];
            $hash[$count]["title"][0] = $ligne["title"][0];
            $hash[$count]["uri"][0] = $ligne["uri"][0];
            $hash[$count]["mail"][0] = $ligne["mail"][0];
            $hash[$count]["phone"][0] = $ligne["telephonenumber"][0];
            $hash[$count]["sn"][0] = $ligne["sn"][0];
            $hash[$count]["dn"] = $ligne["dn"];
            $count = $count + 1;
        }
    } else {
        if ($GLOBALS["OUTPUT_DEBUG"]) {
            echo "<strong>Search results ->HASH2 NOT AN ARRAY</strong><br>\n";
        }
    }
    $count = count($hash);
    $data['total'] = $count;
    if ($count == 0) {
        json_error_show("no data", 1);
    }
    if ($GLOBALS["OUTPUT_DEBUG"]) {
        echo "<strong>Search results {$count} items</strong><br>\n";
    }
    if (is_array($hash)) {
        while (list($num, $ligne) = each($hash)) {
            if ($GLOBALS["OUTPUT_DEBUG"]) {
                echo "dn:{$ligne["dn"]}<br>";
            }
            if ($GLOBALS["OUTPUT_DEBUG"]) {
                echo "uid:{$ligne["uid"][0]}<br>";
            }
            if ($GLOBALS["OUTPUT_DEBUG"]) {
                echo "employeenumber:{$ligne["employeenumber"][0]}<br>";
            }
            if ($ligne["uid"][0] == null && $ligne["employeenumber"][0] == null) {
                if ($GLOBALS["OUTPUT_DEBUG"]) {
                    echo "null twice, aborting...<br>";
                }
                continue;
            }
            if ($ligne["uid"][0] == "squidinternalauth") {
                $count = $count - 1;
                continue;
            }
            if ($GLOBALS["OUTPUT_DEBUG"]) {
                echo "edit_config_user={$ligne["uid"][0]}<br>";
            }
            $edit_config_user = MEMBER_JS($ligne["uid"][0], 1, 0, $ligne["dn"]);
            if ($usermenu->AllowAddUsers == true) {
                $uri = $edit_config_user;
            } else {
                $uri = null;
            }
            if ($usermenu->AsOrgAdmin == true) {
                $uri = $edit_config_user;
            } else {
                $uri = null;
            }
            if ($usermenu->AsArticaAdministrator == true) {
                $uri = $edit_config_user;
            } else {
                $uri = null;
            }
            $displayname = trim($ligne["displayname"][0]);
            $givenname = $ligne["givenname"][0];
            $mail = $ligne["mail"][0];
            if ($displayname == null) {
                $displayname = $ligne["uid"][0];
            }
            if ($givenname == null) {
                $givenname = '{unknown}';
            }
            if ($mail == null) {
                $mail = '{unknown}';
            }
            if ($ligne["employeenumber"][0] != null) {
                $array["employeenumber"] = $ligne["employeenumber"][0];
                $user = new contacts($_SESSION["uid"], $ligne["employeenumber"][0]);
                $array["title"] = $user->displayName;
                $uri = "javascript:Loadjs('contact.php?employeeNumber={$ligne["employeenumber"][0]}')";
            } else {
                if ($ligne["uid"][0] != null) {
                    $array["title"] = $ligne["uid"][0];
                    $user = new user($ligne["uid"][0]);
                }
            }
            if (strlen($user->jpegPhoto) > 0) {
                $array["img"] = $user->img_identity;
            } else {
                $array["img"] = "img/contact-unknown-user.png";
            }
            writelogs("identity:{$user->img_identity} ", __FUNCTION__, __FILE__);
            $array["uri"] = $uri;
            $array["mail"] = $ligne["mail"][0];
            $array["phone"] = $ligne["telephonenumber"][0];
            $array["sn"] = $ligne["sn"][0];
            if (!$ldap->EnableManageUsersTroughActiveDirectory) {
                if ($displayname == null) {
                    $displayname = "{$givenname} {$ligne["sn"][0]}";
                }
            }
            $array["displayname"] = $displayname;
            $array["givenname"] = $givenname;
            $array["JS"] = $edit_config_user;
            $array["title"] = $ligne["title"][0];
            $array["ou"] = $user->ou;
            $array["uid"] = $ligne["uid"][0];
            $data['rows'][] = finduser_format($array);
        }
    }
    echo json_encode($data);
}
コード例 #29
0
function popup()
{
    $users = new usersMenus();
    $ad = new external_ad_search();
    $DNDUMP = $ad->DNDUMP($_GET["DN"]);
    $tpl = new templates();
    if (isset($DNDUMP["description"][0])) {
        $description = $DNDUMP["description"][0];
    }
    $title = $DNDUMP["samaccountname"][0];
    if (isset($DNDUMP["givenname"][0])) {
        $title = "{$DNDUMP["givenname"][0]} {$DNDUMP["sn"][0]}";
    }
    $MAIN_SQUIDRULES = array();
    $MAIN_WEBRULES = array();
    for ($i = 0; $i < $DNDUMP["memberof"]["count"]; $i++) {
        $DN = $DNDUMP["memberof"][$i];
        $XGRP = $ad->DNinfos($DN);
        $GroupName = $XGRP[0]["samaccountname"][0];
        if ($users->SQUID_INSTALLED) {
            $acl = new squid_acls();
            $RULES = $acl->GetRulesFromADGroup($GroupName);
            if ($GLOBALS["VERBOSE"]) {
                echo "<span style='color:red;font-size:22px'>{$GroupName}:: " . count($RULES) . " RULES</span><br>\n";
            }
            if (is_array($RULES)) {
                while (list($key, $ligne) = each($RULES)) {
                    $MAIN_SQUIDRULES[$key] = $ligne;
                }
                if ($GLOBALS["VERBOSE"]) {
                    echo "<span style='color:red;font-size:22px'>{$GroupName}:: \$MAIN_SQUIDRULES:" . count($MAIN_SQUIDRULES) . " RULES</span><br>\n";
                }
            }
            $sock = new sockets();
            if ($sock->EnableUfdbGuard() == 1) {
                $MAIN_WEBRULES[0] = "{default}";
                $RULES = $acl->GetWebfilteringRulesFromADGroup($GroupName);
                if ($GLOBALS["VERBOSE"]) {
                    echo "<span style='color:red;font-size:22px'>{$GroupName}:: " . count($RULES) . " RULES</span><br>\n";
                }
                if (is_array($RULES)) {
                    while (list($key, $ligne) = each($RULES)) {
                        $MAIN_WEBRULES[$key] = $ligne;
                    }
                    if ($GLOBALS["VERBOSE"]) {
                        echo "<span style='color:red;font-size:22px'>{$GroupName}:: \$MAIN_WEBRULES:" . count($MAIN_WEBRULES) . " RULES</span><br>\n";
                    }
                }
            }
        }
        $jsGRP = "Loadjs('domains.edit.group.php?js=yes&group-id=" . urlencode($DN) . "',true)";
        $XTRG[] = "<tr>\n\t\t\t\t\t<td style='width:16px'><img src='img/wingroup.png'></td>\n\t\t\t\t\t<td style='font-size:16px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\" style='text-decoration:underline'>{$GroupName}</a></td>\n\t\t\t\t</tr>";
    }
    if (count($MAIN_SQUIDRULES) > 0) {
        $rules_title = "{rules}";
        if (count($MAIN_SQUIDRULES) < 2) {
            $rules_title = "{rule}";
        }
        while (list($aclid, $aclname) = each($MAIN_SQUIDRULES)) {
            $jsGRP = "Loadjs('squid.acls-rules.php?Addacl-js=yes&ID={$aclid}');";
            $XTRGB[] = "<tr>\n\t\t\t<td style='width:16px'><img src='img/scripts-16.png'></td>\n\t\t\t<td style='font-size:16px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\" \n\t\t\t\tstyle='text-decoration:underline'>{$aclname}</a></td>\n\t\t\t</tr>";
        }
        $proxay_acls = "</tr>\n\t\t<tr style='height:70px'>\n\t\t<td valign=middle style='font-size:26px' class=legend>" . count($MAIN_SQUIDRULES) . " {$rules_title} (Proxy):</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td></td>\n\t\t<td><table style='width:100%'>" . @implode("", $XTRGB) . "</table></td>\n\t\t</tr>";
    }
    if (count($MAIN_WEBRULES) > 0) {
        $XTRGB = array();
        while (list($aclid, $aclname) = each($MAIN_WEBRULES)) {
            $jsGRP = "YahooWin3('1100','dansguardian2.edit.php?ID={$aclid}&t=0','{$aclid} {$aclname}');";
            $XTRGB[] = "<tr>\n\t\t\t<td style='width:16px'><img src='img/scripts-16.png'></td>\n\t\t\t<td style='font-size:16px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\"\n\t\t\tstyle='text-decoration:underline'>{$aclname}</a></td>\n\t\t\t</tr>";
        }
        $rules_title = "{rules}";
        if (count($MAIN_WEBRULES) < 2) {
            $rules_title = "{rule}";
        }
        $webfilter_acls = "</tr>\n\t\t<tr style='height:70px'>\n\t\t<td valign=middle style='font-size:26px' class=legend>" . count($MAIN_WEBRULES) . " {$rules_title} ({webfiltering}):</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td></td>\n\t\t<td><table style='width:100%'>" . @implode("", $XTRGB) . "</table></td>\n\t\t</tr>";
    }
    $picture_link = "img/impersonate-photo.png";
    $html = "\n\t\t\t\n\t<div style='width:98%' class=form>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td style='width:190px;vertical-align:top'>\n\t\t<center style='margin-top:15px'>\n\t\t<img style='border-radius: 50% 50% 50% 50%;\n    \t\tbox-shadow: 0 0 5px silver;height: 180px;margin: 0 32px;width: 180px;' src='{$picture_link}'></a>\n    <center style='font-size: 24px;line-height: 1.2;word-wrap: break-word;margin-top:30px;margin-bottom:30px'>{$title}</center>\n\n    \n    </center>\t\n\t</td>\n\t\t<td style='width:80%;vertical-aglin:top'>\n\t\t\t<table style='width:100%'>\n\t\t\t\t\t</tr>\t\t\t\n\t\t\t\t<tr style='height:70px'>\n\t\t\t\t<td valign=middle style='font-size:26px' class=legend><div>{Contact_Information}:</div><i style='font-size:16px'>{$description}</i></td>\n\t\t\t</tr>\n\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{member}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["givenname"][0]} {$DNDUMP["sn"][0]}</strong></td>\n\t\t\t</tr>\t\t\t\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{name}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["name"][0]}</strong></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{account}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["samaccountname"][0]}</strong></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{email}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["mail"][0]}</strong></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{telephoneNumber}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["telephonenumber"][0]}</strong></td>\n\t\t\t</tr>\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{mobile}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["mobile"][0]}</strong></td>\n\t\t\t</tr>\t\t\t\n\t\t\t\t<tr style='height:70px'>\n\t\t\t\t<td valign=middle style='font-size:26px' class=legend>{$DNDUMP["memberof"]["count"]} {groups}:</td>\n\t\t\t</tr>\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td><table style='width:100%'>" . @implode("", $XTRG) . "</table></td>\n\t\t\t</tr>\n\t\t\t{$proxay_acls}\n\t\t\t{$webfilter_acls}\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n\t</table>\n\t<p>&nbsp;</p>\n\t</div>\n\t\t\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
コード例 #30
0
function register()
{
    if ($GLOBALS["VERBOSE"]) {
        echo __FUNCTION__ . "() in line " . __LINE__ . "\n";
    }
    $sock = new sockets();
    $unix = new unix();
    $URIBASE = $unix->MAIN_URI();
    $URIBASE = str_replace("articatech.net", "artica.fr", $URIBASE);
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $cachetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid)) {
        WriteMyLogs("Already executed PID:{$pid}, die()", __FUNCTION__, __FILE__, __LINE__);
        die;
    }
    $sock = new sockets();
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    if (!is_numeric("{$EnableKerbAuth}")) {
        $EnableKerbAuth = 0;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Loading WizardSavedSettings " . __FUNCTION__ . "() in line " . __LINE__ . "\n";
    }
    $WizardSavedSettings = unserialize(base64_decode($sock->GET_INFO("WizardSavedSettings")));
    $WizardSavedSettingsSend = $sock->GET_INFO("WizardSavedSettingsSend");
    if (count($WizardSavedSettings) < 2) {
        if ($GLOBALS["VERBOSE"]) {
            echo "WizardSavedSettings array is less than 2" . __FUNCTION__ . "() in line " . __LINE__ . "\n";
        }
        return;
    }
    if (!isset($WizardSavedSettings["company_name"])) {
        $WizardSavedSettings["company_name"] = null;
    }
    if ($WizardSavedSettings["company_name"] == null) {
        return;
    }
    if (!is_numeric($WizardSavedSettingsSend)) {
        $WizardSavedSettingsSend = 0;
    }
    if ($WizardSavedSettingsSend == 1) {
        if (!$GLOBALS["FORCE"]) {
            if ($GLOBALS["VERBOSE"]) {
                echo "WizardSavedSettingsSend == 1, aborting.. (use --force)" . __FUNCTION__ . "() in line " . __LINE__ . "\n";
            }
            return;
        }
    }
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        if ($GLOBALS["VERBOSE"]) {
            echo "No system ID !\n";
        }
        return;
    }
    $WizardSavedSettings["ACTIVE_DIRECTORY"] = $EnableKerbAuth;
    if ($EnableKerbAuth == 1) {
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ldap = new external_ad_search();
        $NET_RPC_INFOS = $ldap->NET_RPC_INFOS();
        while (list($a, $b) = each($NET_RPC_INFOS)) {
            $WizardSavedSettings[$a] = $b;
        }
    }
    $WizardSavedSettings["UUID"] = $uuid;
    $WizardSavedSettings["CPUS_NUMBER"] = $unix->CPU_NUMBER();
    $WizardSavedSettings["MEMORY"] = $unix->SYSTEM_GET_MEMORY_MB() . "MB";
    $WizardSavedSettings["LINUX_DISTRI"] = $unix->LINUX_DISTRIBUTION();
    $WizardSavedSettings["ARTICAVERSION"] = @file_get_contents("/usr/share/artica-postfix/VERSION");
    $WizardSavedSettings["STATS_APPLIANCE"] = 0;
    if (is_file("/etc/artica-postfix/STATS_APPLIANCE")) {
        $WizardSavedSettings["APPLIANCE"] = "Artica Stats Appliance";
        $WizardSavedSettings["STATS_APPLIANCE"] = 1;
    }
    $zarafa_server = $unix->find_program("zarafa-server");
    if (is_file($zarafa_server)) {
        $WizardSavedSettings["ZARAFA APPLIANCE"] = "YES";
    }
    $squid = $unix->find_program("squid");
    if (is_file($squid)) {
        $WizardSavedSettings["PROXY INSTALLED"] = "YES";
    }
    if (is_file("/etc/artica-postfix/FROM_ISO")) {
        $WizardSavedSettings["FROM ISO"] = "YES";
    }
    if (is_file("/etc/artica-postfix/SQUID_APPLIANCE")) {
        $WizardSavedSettings["APPLIANCE"] = "Artica Proxy";
        $WizardSavedSettings["PROXY APPLIANCE"] = "YES";
    }
    if (is_file("/etc/artica-postfix/SAMBA_APPLIANCE")) {
        $WizardSavedSettings["APPLIANCE"] = "Artica NAS";
        $WizardSavedSettings["N.A.S APPLIANCE"] = "YES";
    }
    if (is_file("/etc/artica-postfix/artica-iso-first-reboot")) {
        $zDate = filemtime("/etc/artica-postfix/artica-iso-first-reboot");
        $WizardSavedSettings["INSTALL_DATE"] = date("Y-m-d H:i:s", $zDate);
    } else {
        $zDate = filemtime("/etc/artica-postfix/.");
        $WizardSavedSettings["INSTALL_DATE"] = date("Y-m-d H:i:s", $zDate);
    }
    if (is_file("/etc/artica-postfix/dmidecode.cache.url")) {
        $final_array = unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/dmidecode.cache.url")));
        while (list($a, $b) = each($final_array)) {
            $WizardSavedSettings[$a] = $b;
        }
    }
    @file_put_contents("/etc/artica-postfix/settings/Daemons/WizardSavedSettings", base64_encode(serialize($WizardSavedSettings)));
    if ($GLOBALS["VERBOSE"]) {
        echo "Send order to {$URIBASE}/shalla-orders.php " . __FUNCTION__ . "() in line " . __LINE__ . "\n";
    }
    $curl = new ccurl("{$URIBASE}/shalla-orders.php", false, null);
    $curl->parms["REGISTER"] = base64_encode(serialize($WizardSavedSettings));
    if ($GLOBALS["VERBOSE"]) {
        $curl->parms["VERBOSE"] = true;
    }
    $curl->NoLocalProxy();
    $curl->get();
    if ($GLOBALS["VERBOSE"]) {
        echo $curl->data;
    }
    if (preg_match("#GOOD#s", $curl->data)) {
        $sock->SET_INFO("WizardSavedSettingsSend", 1);
    }
}