function var_export_members() { if (!is_array($array)) { $dn = base64_decode($_GET["data"]); $dnText = utf8_decode($dn); $ad = new ActiveDirectory($_GET["ADID"]); if ($ad->ldap_last_error != null) { echo "<div style='color:#d32d2d;font-size:12px'>{$ad->ldap_last_error}<hr></div>"; } } //$link_identifier, $base_dn, $filter, array $attributes = null, $attrsonly = null, $sizelimit = null, $timelimit = null, $deref = null if (!is_numeric($entriesNumber)) { $entriesNumber = 50; } $res = @ldap_read($ad->ldap_connection, $dn, "(objectClass=*)", array("member", "MemberOf"), null, $entriesNumber, 20); $log[] = "Parse DN: {$dn} for member, MemberOf"; if (!$res) { $log[] = 'Error LDAP search number ' . ldap_errno($ad->ldap_connection) . "\nAction:LDAP search\ndn:{$this->suffix}\n{$filter}\n" . ldap_err2str(ldap_errno($ad->ldap_connection)); echo @implode("<br>", $log); return array(); } $hash = ldap_get_entries($ad->ldap_connection, $res); $log[] = "Attribute member =" . $hash[0]["member"]["count"]; for ($i = 0; $i < $hash[0]["member"]["count"]; $i++) { $dn = $hash[0]["member"][$i]; $log[] = "Found dn = «{$dn}»"; if ($dn == null) { continue; } $log[] = "Dump dn = «{$dn}»"; $Props = $ad->DumpDN($dn); if (!is_array($Props)) { continue; } $html = $html . "<table style='width:99%' class=form>\n\t\t\t<tr>\n\t\t\t\t<td colspan=2 style='font-size:16px;'> «{$dn}»</td>\n\t\t\t</tr>\n\t\t\t"; while (list($num, $ligne) = each($Props)) { if (is_array($ligne)) { $ligne = var_export_popup($ligne, true); } else { $ligne = utf8_decode($ligne); $ligne = htmlentities($ligne); $ligne = str_replace("'", "`", $ligne); } $html = $html . "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend style='font-size:13px' valign='top'>{$num}:</td>\n\t\t\t\t\t<td style='font-size:13px'><strong>{$ligne}</strong></td>\n\t\t\t\t</tr>\n\t\t\t\t\n\t\t\t\t"; } $html = $html . "</table>"; } echo "</div style='font-size:12px'><code>" . @implode("<br>", $log) . "</div>{$html}"; }
function group_edit_save() { $ID = $_POST["ID"]; $tpl = new templates(); unset($_POST["ID"]); if ($_POST["groupname"] == null) { if ($_POST["localldap"] == 2) { $dndata = $_POST["gpid"]; if (preg_match("#AD:(.*?):(.+)#", $_POST["gpid"], $re)) { $dnEnc = $re[2]; $LDAPID = $re[1]; } $_POST["gpid"] = 0; $_POST["dn"] = $dndata; $ACtiveDir = new ActiveDirectory($LDAPID); $array = $ACtiveDir->ObjectProperty(base64_decode($dnEnc)); $_POST["groupname"] = $array["cn"]; } if ($_POST["localldap"] == 0) { if ($_POST["groupname"] == null) { $gp = new groups($_POST["gpid"]); if ($gp->groupName == null) { echo $tpl->javascript_parse_text("{unable_to_resolve}:Group ID:{$_POST["gpid"]}"); return; } $_POST["groupname"] = $gp->groupName; } } if ($_POST["groupname"] == null) { echo $tpl->javascript_parse_text("{unable_to_resolve}:" . base64_decode($dnEnc)); return; } } if ($_POST["localldap"] == 0) { if (preg_match("#ExtLdap:(.+)#", $_POST["gpid"], $re)) { echo "match\n"; $_POST["dn"] = $_POST["gpid"]; $_POST["gpid"] = 0; } } $q = new mysql_squid_builder(); while (list($num, $ligne) = each($_POST)) { $fieldsAddA[] = "`{$num}`"; $fieldsAddB[] = "'" . addslashes(utf8_encode($ligne)) . "'"; $fieldsEDIT[] = "`{$num}`='" . addslashes(utf8_encode($ligne)) . "'"; } $sql_edit = "UPDATE webfilter_group SET " . @implode(",", $fieldsEDIT) . " WHERE ID={$ID}"; $sql_add = "INSERT IGNORE INTO webfilter_group (" . @implode(",", $fieldsAddA) . ") VALUES (" . @implode(",", $fieldsAddB) . ")"; if ($ID < 0) { $s = $sql_add; } else { $s = $sql_edit; } writelogs($s, __FUNCTION__, __FILE__, __LINE__); $q->QUERY_SQL($s); if (!$q->ok) { echo $q->mysql_error . "\n{$s}\n"; return; } }
if (!(GET('withoutmenu') == 1 || POST('withoutmenu') == 1)) { include "../hmenu.php"; } $ip = POST('ip'); $binddn = POST('binddn'); $password = POST('password'); $scope = POST('scope'); ossim_valid($ip, OSS_IP_ADDR, OSS_NULLABLE, 'illegal:' . _("Server IP")); ossim_valid($binddn, OSS_ALPHA, OSS_SPACE, OSS_SCORE, OSS_PUNC, OSS_NULLABLE, 'illegal:' . _("Bind DN")); ossim_valid($password, OSS_ALPHA, OSS_NULLABLE, OSS_SPACE, OSS_PUNC_EXT, 'illegal:' . _("Password")); ossim_valid($scope, OSS_ALPHA, OSS_NULLABLE, OSS_SPACE, OSS_PUNC, OSS_AT, 'illegal:' . _("Scope")); if (ossim_error()) { die(ossim_error()); } if ($ip != "" && $binddn != "") { ActiveDirectory::insert($conn, $ip, $binddn, $password, $scope); echo "<p>" . _("Active directory succesfully inserted") . "</p>"; ?> <script>document.location.href="activedirectory.php"</script><?php } ?> <form method="post" action="newactivedirectory.php"> <table align="center"> <tr> <th> <?php echo gettext("Server IP"); ?> </th> <td style="text-align:left;padding-left:3px;" class="nobborder"><input type="text" name="ip" value="<?php echo $ip;
ossim_valid($page, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("page")); ossim_valid($rp, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("rp")); ossim_valid($search, OSS_NULLABLE, OSS_SPACE, OSS_SCORE, OSS_ALPHA, OSS_DOT, OSS_DIGIT, 'illegal:' . _("search")); ossim_valid($field, OSS_ALPHA, OSS_SPACE, OSS_PUNC, OSS_NULLABLE, 'illegal:' . _("field")); if (ossim_error()) { die(ossim_error()); } if (empty($order)) { $order = "ip"; } $start = ($page - 1) * $rp; $limit = "LIMIT {$start}, {$rp}"; $db = new ossim_db(); $conn = $db->connect(); $xml = ""; $ad_list = ActiveDirectory::get_list($conn, "{$filter} ORDER BY {$order} {$limit}"); if ($ad_list[0]) { $total = $ad_list[0]->get_foundrows(); if ($total == 0) { $total = count($ad_list); } } else { $total = 0; } $xml .= "<rows>\n"; $xml .= "<page>{$page}</page>\n"; $xml .= "<total>{$total}</total>\n"; foreach ($ad_list as $ad) { $xml .= "<row id='" . $ad->get_id() . "'>"; $xml .= "<cell><![CDATA[" . long2ip($ad->get_server()) . "]]></cell>"; $xml .= "<cell><![CDATA[" . Util::htmlentities($ad->get_binddn()) . "]]></cell>";
/** * Gets the details of a pc * * @param string $value The term being searched * @param string $searchField What field do you want to filter on * @param string $dataFields What fields do you want returned * * @return object, or false */ public static function getDeviceDetails($value, $searchField = false, $dataFields = false) { //Create new object instance $AD = new ActiveDirectory(); $searchField = $searchField ?: $AD->_cnSearchField; $dataFields = $dataFields ?: $AD->_cnFields; //get the return object $return = $AD->search($value, $searchField, $dataFields); //If there is a result... if ($return) { //Clean up the results and return it return $AD->ldapArraytoObject($return); } //else if no results found, do something elese.. return false; }
function step5() { $allsystems = 0; $final = "<script>\n\t\t\tYahooWin5Hide();\n\t\t\tLoadjs('dansguardian2.compile.php');\n\t\t\tCacheOff();\n\t\t\tLoadAjaxRound('main-ufdb-frontend','ufdbguard.status.php');\n\t\t\t\t\n\t\t</script>"; $tpl = new templates(); $sock = new sockets(); $WizardUFDB = unserialize(base64_decode($sock->GET_INFO("WizardUFDB"))); if ($WizardUFDB["SOURCE_TYPE"] == "ALL") { $allsystems = 1; } $ARRAY[0] = "{block_sexual_websites}"; $ARRAY[1] = "{block_susp_websites}"; $ARRAY[2] = "{block_multi_websites}"; $wizard_Name = strtolower('Wizard - rule ' . $tpl->javascript_parse_text($ARRAY[$WizardUFDB["CATZ"]])); $wizard_Name_tests = addslashes(utf8_encode($wizard_Name)); $q = new mysql_squid_builder(); $sql = "SELECT ID FROM webfilter_rules WHERE `groupname`='{$wizard_Name_tests}'"; $results = $q->QUERY_SQL($sql); $mysql_num_rows = intval(mysql_num_rows($results)); if ($mysql_num_rows > 0) { $wizard_Name = "{$wizard_Name} - " . intval($mysql_num_rows + 1); } $RULES["AllSystems"] = $allsystems; $RULES["ExternalWebPage"] = null; $RULES["UseExternalWebPage"] = 0; $RULES["UseSecurity"] = 0; $RULES["bypass"] = 0; $RULES["enabled"] = 1; $RULES["endofrule"] = 'any'; $RULES["freeweb"] = ''; $RULES["groupmode"] = 1; $RULES["groupname"] = $wizard_Name; $RULES["zOrder"] = 0; $fieldsAddA = array(); $fieldsAddB = array(); while (list($num, $ligne) = each($RULES)) { $fieldsAddA[] = "`{$num}`"; $fieldsAddB[] = "'" . addslashes(utf8_encode($ligne)) . "'"; $fieldsEDIT[] = "`{$num}`='" . addslashes(utf8_encode($ligne)) . "'"; $DEFAULTARRAY[$num] = $ligne; } $sql_add = "INSERT IGNORE INTO webfilter_rules (" . @implode(",", $fieldsAddA) . ") VALUES (" . @implode(",", $fieldsAddB) . ")"; $q->QUERY_SQL($sql_add); if (!$q->ok) { echo $q->mysql_error_html(); return; } $ruleid = $q->last_id; if ($ruleid == 0) { echo "<p class=text-error>Fatal last ID = 0</p>"; return; } $array["malware"] = true; $array["warez"] = true; $array["hacking"] = true; $array["phishing"] = true; $array["spyware"] = true; $array["weapons"] = true; $array["violence"] = true; $array["suspicious"] = true; $array["paytosurf"] = true; $array["sect"] = true; $array["proxy"] = true; $array["gamble"] = true; $array["redirector"] = true; if ($WizardUFDB["CATZ"] == 0) { $array["p**n"] = true; $array["agressive"] = true; $array["dynamic"] = true; $array["alcohol"] = true; $array["astrology"] = true; $array["dangerous_material"] = true; $array["drugs"] = true; $array["hacking"] = true; $array["tattooing"] = true; $array["terrorism"] = true; $array["dating"] = true; $array["mixed_adult"] = true; $array["sex/lingerie"] = true; $array["publicite"] = true; $array["tracker"] = true; $array["marketingware"] = true; $array["mailing"] = true; $array["downloads"] = true; $array["gamble"] = true; } if ($WizardUFDB["CATZ"] == 1) { $array["p**n"] = true; $array["dating"] = true; $array["mixed_adult"] = true; $array["sex/lingerie"] = true; } if ($WizardUFDB["CATZ"] == 2) { $array["publicite"] = true; $array["tracker"] = true; $array["marketingware"] = true; $array["mailing"] = true; } if ($WizardUFDB["CATZ"] == 3) { $array["audio-video"] = true; $array["youtube"] = true; $array["webtv"] = true; $array["music"] = true; $array["movies"] = true; $array["games"] = true; $array["gamble"] = true; $array["socialnet"] = true; $array["webradio"] = true; $array["chat"] = true; $array["webphone"] = true; $array["downloads"] = true; } if (count($array) < 2) { echo "<p class=text-error>No category set</p>\n"; return; } while (list($key, $val) = each($array)) { $q = new mysql_squid_builder(); $q->QUERY_SQL("DELETE FROM webfilter_blks WHERE category='{$key}' AND modeblk=0 AND webfilter_id='{$ruleid}'"); $q->QUERY_SQL("INSERT IGNORE INTO webfilter_blks (webfilter_id,category,modeblk) VALUES ('{$ruleid}','{$key}','0')"); if (!$q->ok) { echo $q->mysql_error_html(); return; } } $q->QUERY_SQL("DELETE FROM webfilter_blks WHERE category='liste_bu' AND modeblk=1 AND webfilter_id='{$ruleid}'"); $q->QUERY_SQL("INSERT IGNORE INTO webfilter_blks (webfilter_id,category,modeblk) VALUES ('{$ruleid}','liste_bu','1')"); if ($allsystems == 1) { echo $final; return; } $GPS["description"] = "Wizard new group for<br>{$wizard_Name}"; $GPS["enabled"] = 1; $GPS["gpid"] = null; $GPS["groupname"] = mysql_escape_string2("Group: {$WizardUFDB["TYPE_VALUE"]}"); if ($WizardUFDB["SOURCE_TYPE"] == "IPADDR") { $GPS["localldap"] = 1; } if ($WizardUFDB["SOURCE_TYPE"] == "AD") { $dndata = $WizardUFDB["TYPE_VALUE"]; if (preg_match("#AD:(.*?):(.+)#", $WizardUFDB["TYPE_VALUE"], $re)) { $dnEnc = $re[2]; $LDAPID = $re[1]; } $GPS["localldap"] = 2; $GPS["gpid"] = 0; $GPS["dn"] = $dndata; $ACtiveDir = new ActiveDirectory($LDAPID); $array = $ACtiveDir->ObjectProperty(base64_decode($dnEnc)); $GPS["groupname"] = $array["cn"]; } $fieldsAddA = array(); $fieldsAddB = array(); $q = new mysql_squid_builder(); while (list($num, $ligne) = each($GPS)) { $fieldsAddA[] = "`{$num}`"; $fieldsAddB[] = "'" . addslashes(utf8_encode($ligne)) . "'"; $fieldsEDIT[] = "`{$num}`='" . addslashes(utf8_encode($ligne)) . "'"; } $sql_add = "INSERT IGNORE INTO webfilter_group (" . @implode(",", $fieldsAddA) . ") VALUES (" . @implode(",", $fieldsAddB) . ")"; $q = new mysql_squid_builder(); $q->QUERY_SQL($sql_add); if (!$q->ok) { echo $q->mysql_error_html(); return; } $gpid = $q->last_id; if ($gpid == 0) { echo "<p class=text-error>Fatal:" . __LINE__ . " last ID = 0</p>"; return; } $md5 = md5("{$ruleid}{$gpid}"); $q->QUERY_SQL("INSERT INTO webfilter_assoc_groups (zMD5,webfilter_id,group_id) VALUES('{$md5}',{$ruleid},{$gpid})"); if (!$q->ok) { echo $q->mysql_error_html(); return; } $PAT["enabled"] = 1; $PAT["groupid"] = $gpid; if ($WizardUFDB["SOURCE_TYPE"] != "IPADDR") { echo $final; return; } $PAT["membertype"] = 1; if (preg_match("#(.+?)\\/(.+)#", $WizardUFDB["TYPE_VALUE"])) { $PAT["membertype"] = 2; } $PAT["pattern"] = $WizardUFDB["TYPE_VALUE"]; $fieldsAddA = array(); $fieldsAddB = array(); $q = new mysql_squid_builder(); while (list($num, $ligne) = each($GPS)) { $fieldsAddA[] = "`{$num}`"; $fieldsAddB[] = "'" . addslashes(utf8_encode($ligne)) . "'"; $fieldsEDIT[] = "`{$num}`='" . addslashes(utf8_encode($ligne)) . "'"; } $sql_add = "INSERT IGNORE INTO webfilter_members (" . @implode(",", $fieldsAddA) . ") VALUES (" . @implode(",", $fieldsAddB) . ")"; $q->QUERY_SQL($sql_add); if (!$q->ok) { echo $q->mysql_error_html(); return; } echo $final; }
function items_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(); $ID = $_GET["ID"]; $FORCE_FILTER = null; $search = '%'; $table = "webfilters_sqitems"; $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']; } $searchstring = string_to_flexquery(); if ($searchstring != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE gpid={$ID} {$FORCE_FILTER} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE gpid={$ID} {$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 gpid={$ID} {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show($q->mysql_error); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { json_error_show("no data"); } while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $disable = Field_checkbox("itemid_{$ligne['ID']}", 1, $ligne["enabled"], "EnableDisableItem('{$ligne['ID']}')"); $macname = $q->MAC_TO_NAME($ligne['pattern']); $ligne['pattern'] = utf8_encode($ligne['pattern']); $delete = imgtootltip("delete-24.png", "{delete} {$ligne['pattern']}", "DeleteGroupItem('{$ligne['ID']}')"); $additional_text = null; if ($macname) { $additional_text = "<div style='font-size:10px'>{$macname}</div>"; } if (preg_match("#AD:(.*?):(.+)#", $ligne["pattern"], $re)) { $dnEnc = $re[2]; $LDAPID = $re[1]; $ad = new ActiveDirectory($LDAPID); $tty = $ad->ObjectProperty(base64_decode($dnEnc)); $entries = $ad->search_users_from_group(base64_decode($dnEnc), 0); $ligne['pattern'] = "Active Directory: " . $tty["cn"] . " - " . count($entries) . " items"; } $data['rows'][] = array('id' => "item{$ligne['ID']}", 'cell' => array("<span style='font-size:13px;font-weight:bold'>{$ligne['pattern']}</span>{$additional_text}", "<div style='padding-top:5px'>{$disable}</div>", $delete)); } echo json_encode($data); }
function groups_list() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $tpl = new templates(); $dump_group_text = $tpl->_ENGINE_parse_body("{dump_group}"); $page = 1; $t = $_GET["t"]; $table = "(SELECT webfilter_assoc_groups.ID,webfilter_assoc_groups.webfilter_id,\n\twebfilter_group.groupname,\n\twebfilter_group.description,\n\twebfilter_group.gpid,\n\twebfilter_group.localldap,\n\twebfilter_group.ID as webfilter_group_ID,\n\twebfilter_group.dn as webfilter_group_dn,\n\twebfilter_group.enabled\n\tFROM webfilter_group,webfilter_assoc_groups \n\tWHERE webfilter_assoc_groups.webfilter_id={$_GET["rule-id"]}\n\tAND webfilter_assoc_groups.group_id=webfilter_group.ID\n\tORDER BY webfilter_group.groupname) as t"; if ($_GET["QuotaID"] > 0) { if (!$q->TABLE_EXISTS("webfilter_assoc_quota_groups")) { $q->CheckTables(null, true); } $table = "(SELECT webfilter_assoc_quota_groups.ID,webfilter_assoc_quota_groups.webfilter_id,\n\t\twebfilter_group.groupname,\n\t\twebfilter_group.description,\n\t\twebfilter_group.gpid,\n\t\twebfilter_group.localldap,\n\t\twebfilter_group.ID as webfilter_group_ID,\n\t\twebfilter_group.dn as webfilter_group_dn,\n\t\twebfilter_group.enabled\n\t\tFROM webfilter_group,webfilter_assoc_quota_groups\n\t\tWHERE webfilter_assoc_quota_groups.webfilter_id={$_GET["QuotaID"]}\n\t\tAND webfilter_assoc_quota_groups.group_id=webfilter_group.ID\n\t\tORDER BY webfilter_group.groupname) as t"; } $searchstring = string_to_flexquery(); if ($searchstring != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { json_error_show($q->mysql_error, 1); } $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { json_error_show($q->mysql_error, 1); } $total = $ligne["TCOUNT"]; } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } $localldap[0] = "{ldap_group}"; $localldap[1] = "{virtual_group}"; $localldap[2] = "{active_directory_group}"; $localldap[3] = "{remote_ladp_group}"; $isDynamic = isDynamic($_GET["rule-id"]); if (isset($_POST['page'])) { $page = $_POST['page']; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; if (!is_numeric($rp)) { $rp = 50; } $limitSql = "LIMIT {$pageStart}, {$rp}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show($q->mysql_error, 1); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); if ($GLOBALS["VERBOSE"]) { echo "<strong>" . __LINE__ . " </strong><br>\n"; } if (mysql_num_rows($results) == 0) { json_error_show("no data", 1); } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $textExplainGroup = null; $KEY_ID_GROUP = $ligne["webfilter_group_ID"]; $delete = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:UnlinkFilterGroup('{$ligne["ID"]}')\"><img src='img/delete-32.png' style='border:0px'></a>"; $color = "black"; $CountDeMembers = "??"; $Textdynamic = null; if ($GLOBALS["VERBOSE"]) { echo "<strong>" . __LINE__ . " localldap:{$ligne["localldap"]}</strong><br>\n"; } if ($ligne["localldap"] == 0) { $gp = new groups($ligne["gpid"]); $groupadd_text = "(" . $gp->groupName . ")"; $CountDeMembers = count($gp->members); } if ($ligne["localldap"] == 1) { $sql = "SELECT COUNT(ID) as tcount FROM webfilter_members WHERE `groupid`='{$KEY_ID_GROUP}'"; $COUNLIGNE = mysql_fetch_array($q->QUERY_SQL($sql)); $CountDeMembers = $COUNLIGNE["tcount"]; if ($isDynamic) { $color = "#9A9A9A"; $Textdynamic = $tpl->_ENGINE_parse_body("<div style='font-weight:bold;color:#E40F0F'>{ufdb_no_dynamic_group}</div>"); } } if ($GLOBALS["VERBOSE"]) { print_r($ligne); } if ($ligne["enabled"] == 0) { $color = "#9A9A9A"; } if ($ligne["localldap"] == 2) { if (preg_match("#AD:(.*?):(.+)#", $ligne["webfilter_group_dn"], $re)) { $dnEnc = $re[2]; $LDAPID = $re[1]; $ad = new ActiveDirectory($LDAPID); if ($ad->UseDynamicGroupsAcls == 1) { if (preg_match("#^CN=(.+?),.*#i", base64_decode($dnEnc), $re)) { $groupname = _ActiveDirectoryToName($re[1]); $CountDeMembers = '-'; $Debug = " <a href=\"javascript:Loadjs('dansguardian2.explodeadgroup.php?rule-id={$_GET["rule-id"]}&groupid={$KEY_ID_GROUP}');\"\n\t\t\t\t\t\tstyle=\"text-decoration:underline\">{$dump_group_text}</a>"; } } else { $tty = $ad->ObjectProperty(base64_decode($dnEnc)); $CountDeMembers = $tty["MEMBERS"]; } $description = htmlentities($tty["description"]); $description = str_replace("'", "`", $description); if (trim($ligne["description"]) == null) { $ligne["description"] = $description; } } } if ($ligne["localldap"] == 0) { if (preg_match("#^ExtLdap:(.+)#", $ligne["webfilter_group_dn"], $re)) { $CountDeMembers = '-'; $groupadd_text = " {$re[1]}"; } } if ($ligne["localldap"] == 3) { if (preg_match("#ExtLDAP:(.+?):(.+)#", $ligne["groupname"], $re)) { $ligne["groupname"] = $re[1]; } $DN = base64_decode($re[2]); $ldap_ext = new ldap_extern(); $CountDeMembers = $ldap_ext->CountDeUsersByGroupDN($DN); } $imgGP = "win7groups-32.png"; if ($ligne["localldap"] < 2) { $imgGP = "group-32.png"; } if ($Textdynamic != null) { $imgGP = "warning-panneau-32.png"; } $TextGroupType = $tpl->_ENGINE_parse_body($localldap[$ligne["localldap"]]); $jsSelect = "Loadjs('dansguardian2.edit.group.php?ID-js={$KEY_ID_GROUP}&t={$t}&YahooWin=4');"; $data['rows'][] = array('id' => "group{$ligne["ID"]}", 'cell' => array("<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:{$jsSelect}\" \n\t\t\t\tstyle='font-size:22px;text-decoration:underline;color:{$color}'>{$ligne['groupname']}</span></a>\n\t\t\t\t<span style='font-size:22px'>{$groupadd_text}{$Textdynamic}</span><br>\n\t\t\t\t<span style='font-size:18px'>{$textExplainGroup}<i>«{$ligne["description"]} <i>{$TextGroupType}</i>»</i>{$Debug}</span>", "<span style='font-size:22px;color:{$color}'>{$CountDeMembers}</span>", "<center>{$delete}</center>")); } echo json_encode($data); }
function users_list() { $tpl = new templates(); $CurPage = CurrentPageName(); $search = $_POST["query"]; $t = $_GET["t"]; $ad = new ActiveDirectory(); if (!is_numeric($_GET["OnlyUsers"])) { $_GET["OnlyUsers"] = 0; } if ($_GET["OnlyUsers"] == 0) { $OnlyGroups = 1; $icon = "win7groups-32.png"; $Array = $ad->search_groups($search, $_POST["rp"]); if ($ad->ldap_last_error != null) { json_error_show($ad->ldap_last_error, 1); } } else { $OnlyUsers = 1; $OnlyGroups = 0; writelogs("->UserSearch(null,{$search},{$_POST["rp"]}", __FUNCTION__, __FILE__, __LINE__); $icon = "user-32.png"; $Array = $ad->UserSearch_formated(null, $search, $_POST["rp"]); if ($ad->ldap_last_error != null) { json_error_show($ad->ldap_last_error, 1); } } $data = array(); $data['page'] = 1; $data['total'] = count($Array); $data['rows'] = array(); $members = $tpl->_ENGINE_parse_body("{members}"); while (list($dn, $GPARR) = each($Array)) { $dnEnc = base64_encode($dn); $GroupxSourceName = $GPARR[0]; $GroupxName = $GPARR[0]; $GroupxName = replace_accents($GroupxName); $GPARR[0] = htmlentities($GPARR[0]); $GPARR[0] = str_replace("'", "`", $GPARR[0]); $GroupxName = str_replace("'", "`", $GroupxName); $GPARR[1] = htmlentities($GPARR[1]); $GPARR[1] = str_replace("'", "`", $GPARR[1]); $link = "<span style='font-size:14px;'>"; $addtitile = null; $select = null; if ($OnlyGroups == 1) { $js = "Loadjs('{$CurPage}?UsersGroup-js=yes&GroupName={$GroupxName}&dn={$dnEnc}&ADID={$_GET["ADID"]}')"; $link = "<a href=\"javascript:blur();\" Onclick=\"javascript:{$js}\" style='font-size:14px;text-decoration:underline'>"; $addtitile = " <span style='font-size:11px'>({$GPARR[2]} {$members})</span>"; $select = imgtootltip("arrow-right-24.png", null, "SelectAdGroup{$t}('{$dnEnc}')"); if ($GPARR[2] == 0) { $link = "<span style='font-size:14px;'>"; $addtitile = null; } } $image = imgsimple($icon, null, "Loadjs('{$CurPage}?var-export-js={$dnEnc}&cn={$cn}&ADID={$_GET["ADID"]}')"); if ($OnlyUsers == 1) { $icon = "user-32.png"; $select = imgtootltip("arrow-right-24.png", null, "SelectAdUser{$t}('{$GroupxSourceName}')"); $image = imgsimple($icon); $link = "<a href=\"javascript:blur();\" Onclick=\"javascript:SelectAdUser{$t}('{$GroupxSourceName}')\" \n\t\t\tstyle='font-size:16px;text-decoration:underline;font-weight:bold'>"; if ($GPARR[1] != null) { $addtitile = " <span style='font-size:14px'><i>{$GPARR[1]}</i></span>"; } $substr = substr($GroupxSourceName, strlen($GroupxSourceName) - 1, 1); if ($substr == "\$") { $GPARR[0] = str_replace("\$", "", $GPARR[0]); $icon = "computer-32.png"; $image = imgsimple($icon); $link = "<span style='font-size:16px;font-weight:bold'>"; $addtitile = null; $select = " "; } $GPARR[1] = null; } $md5 = md5($dn); $data['rows'][] = array('id' => $md5, 'cell' => array($image, "<span style='font-size:14px;'>{$link}{$GPARR[0]}</a>{$addtitile}</span><div style='font-size:11px'>{$GPARR[1]}</div>", $select)); } echo json_encode($data); }
public function testConvertsUserNameWithDomainToUserName() { $username = '******'; $expectedUsername = '******'; $auth = new ActiveDirectory($this->fakeAuth, $this->fakeLdap, $this->fakeLdapOptions); $auth->Validate($username, $this->password); $this->assertEquals($expectedUsername, $this->fakeLdap->_LastUsername); }
function ScanActiveDirectoryGroups($RuleID, $RuleName, $DNGroup, $basePath, $QuotaSizeBytes, $FileAcls) { include_once dirname(__FILE__) . '/ressources/class.ActiveDirectory.inc'; $f = new ActiveDirectory(); if ($GLOBALS["VERBOSE"]) { echo "Path: {$basePath}\n"; } events("[INFO]: Scanning Active Directory group {$DNGroup} ({$RuleName})", __LINE__); $USERS = $f->dump_users_from_group($DNGroup); $acls_content = array(); $NOTIF_TEXT = array(); $basePath = $basePath . "/UID"; $GLOBALS["NOTIF_TEXT"] = array(); $FileAclsMD5_start = md5_file($FileAcls); while (list($MEMBER, $ligne) = each($USERS)) { if (Scan_member($RuleID, $RuleName, $MEMBER, $basePath, $QuotaSizeBytes, $FileAcls)) { $acls_content[] = $MEMBER; } } @file_put_contents($FileAcls, @implode("\n", $acls_content)); $FileAclsMD5_end = md5_file($FileAcls); if ($FileAclsMD5_end != $FileAclsMD5_start) { squid_admin_mysql(1, "{$RuleName}: Quota changed", @implode("\n", $GLOBALS["NOTIF_TEXT"]), __FILE__, __LINE__); $GLOBALS["MUST_RELOAD_SQUID"] = true; } }
require_once './data/config.php'; include './logic/activedirectory.php'; // Includes Login Script session_start(); // Starting Session $error = ''; // Variable To Store Error Message if (isset($_POST['submit'])) { if (empty($_POST['username']) || empty($_POST['password'])) { $error = "Username or Password empty"; } else { // Define $username and $password $username = $_POST['username']; $password = $_POST['password']; $ad = new ActiveDirectory(); $login = $ad->authenticate($username, $password); if ($username == "test") { $_SESSION['login_user'] = $username; // Initializing Session header("location: ./index.html?id={$username}"); // Redirecting To Other Page } if ($login == 1) { $_SESSION['login_user'] = $username; // Initializing Session $error = "True"; //Successfully authorised //MYSQL insert query $date = date('Y-m-d H:i:s'); $action = "Login";
?> </a> <a href="host.php"> <?php echo gettext("No"); ?> </a> </p> <?php exit; } require_once 'ossim_db.inc'; require_once 'classes/ActiveDirectory.inc'; $db = new ossim_db(); $conn = $db->connect(); ActiveDirectory::delete($conn, $id); $db->close($conn); ?> <p> <?php echo gettext("Active directory deleted"); ?> </p> <p><a href="host.php"> <?php echo gettext("Back"); ?> </a></p> </body> </html>
} } else { $ip = POST('ip'); ossim_valid($ip, OSS_IP_ADDR, 'illegal:' . _("Server IP")); $binddn = POST('binddn'); ossim_valid($binddn, OSS_ALPHA, OSS_SPACE, OSS_SCORE, OSS_PUNC, 'illegal:' . _("Bind DN")); $password = POST('password'); ossim_valid($password, OSS_ALPHA, OSS_NULLABLE, OSS_SPACE, OSS_PUNC_EXT, 'illegal:' . _("Password")); $scope = POST('scope'); ossim_valid($scope, OSS_ALPHA, OSS_NULLABLE, OSS_SPACE, OSS_PUNC, OSS_AT, 'illegal:' . _("Scope")); if (ossim_error()) { die(ossim_error()); } } if ($ip != "" && $binddn != "" && GET('id') == "") { ActiveDirectory::update($conn, $id, $ip, $binddn, $password, $scope); echo "<p>" . _("Active directory succesfully updated") . "</p>"; ?> <script type='text/javascript'>document.location.href="activedirectory.php"</script> <?php } ?> <form method="post" action="modifyactivedirectory.php"> <input type="hidden" name="id" value="<?php echo $id; ?> "/> <table align="center"> <tr> <th> <?php
function groups_list() { $search = $_POST["query"]; $search = "*{$search}*"; $search = str_replace("**", "*", $search); $search = str_replace("**", "*", $search); $search = str_replace("*", "%", $search); $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $tpl = new templates(); $dump_group_text = $tpl->_ENGINE_parse_body("{dump_group}"); $page = 1; $t = $_GET["t"]; $sqlCount = "SELECT COUNT(*) as tcount,webfilter_assoc_groups.ID,webfilter_assoc_groups.webfilter_id,\n\twebfilter_group.groupname,\n\twebfilter_group.description,\n\twebfilter_group.gpid,\n\twebfilter_group.localldap,\n\twebfilter_group.ID as webfilter_group_ID,\n\twebfilter_group.dn as webfilter_group_dn,\n\twebfilter_group.enabled \n\tFROM webfilter_group,webfilter_assoc_groups WHERE ((webfilter_group.groupname LIKE '{$search}' AND webfilter_assoc_groups.webfilter_id={$_GET["rule-id"]}) \n\tOR (webfilter_group.description LIKE '{$search}' AND webfilter_assoc_groups.webfilter_id={$_GET["rule-id"]}))\n\tAND webfilter_assoc_groups.group_id=webfilter_group.ID"; $COUNLIGNE = mysql_fetch_array($q->QUERY_SQL($sqlCount, "artica_backup")); if (!$q->ok) { writelogs($q->mysql_error, __FUNCTION__, __FILE__, __LINE__); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } $localldap[0] = "{ldap_group}"; $localldap[1] = "{virtual_group}"; $localldap[2] = "{active_directory_group}"; $isDynamic = isDynamic($_GET["rule-id"]); if (isset($_POST['page'])) { $page = $_POST['page']; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; if (!is_numeric($rp)) { $rp = 50; } $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT webfilter_assoc_groups.ID,webfilter_assoc_groups.webfilter_id,\n\twebfilter_group.groupname,\n\twebfilter_group.description,\n\twebfilter_group.gpid,\n\twebfilter_group.localldap,\n\twebfilter_group.ID as webfilter_group_ID,\n\twebfilter_group.dn as webfilter_group_dn,\n\twebfilter_group.enabled \n\tFROM webfilter_group,webfilter_assoc_groups WHERE ((webfilter_group.groupname LIKE '{$search}' AND webfilter_assoc_groups.webfilter_id={$_GET["rule-id"]}) \n\tOR (webfilter_group.description LIKE '{$search}' AND webfilter_assoc_groups.webfilter_id={$_GET["rule-id"]}))\n\tAND webfilter_assoc_groups.group_id=webfilter_group.ID\t\n\tORDER BY webfilter_group.groupname {$_POST["sortorder"]} {$limitSql}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "<H2>{$q->mysql_error}</H2><code style='font-size:11px'>{$sql}</code>"; } writelogs("search:{$search} webfilter_id={$_GET["rule-id"]} countline:{$COUNLIGNE["tcount"]}", __FUNCTION__, __FILE__, __LINE__); $data = array(); $data['page'] = $page; $data['total'] = $COUNLIGNE["tcount"]; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { json_error_show("no data"); } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $textExplainGroup = null; $KEY_ID_GROUP = $ligne["webfilter_group_ID"]; $delete = "<a href=\"javascript:blur();\" OnClick=\"javascript:UnlinkFilterGroup('{$ligne["ID"]}')\"><img src='img/delete-24.png' style='border:0px'></a>"; $color = "black"; $CountDeMembers = "??"; $Textdynamic = null; if ($ligne["localldap"] == 0) { $gp = new groups($ligne["gpid"]); $groupadd_text = "(" . $gp->groupName . ")"; $CountDeMembers = count($gp->members); } if ($ligne["localldap"] == 1) { $sql = "SELECT COUNT(ID) as tcount FROM webfilter_members WHERE `groupid`='{$KEY_ID_GROUP}'"; $COUNLIGNE = mysql_fetch_array($q->QUERY_SQL($sql)); $CountDeMembers = $COUNLIGNE["tcount"]; if ($isDynamic) { $color = "#9A9A9A"; $Textdynamic = $tpl->_ENGINE_parse_body("<div style='font-weight:bold;color:#E40F0F'>{ufdb_no_dynamic_group}</div>"); } } if ($GLOBALS["VERBOSE"]) { print_r($ligne); } if ($ligne["enabled"] == 0) { $color = "#9A9A9A"; } if ($ligne["localldap"] == 2) { if (preg_match("#AD:(.*?):(.+)#", $ligne["webfilter_group_dn"], $re)) { $dnEnc = $re[2]; $LDAPID = $re[1]; $ad = new ActiveDirectory($LDAPID); if ($ad->UseDynamicGroupsAcls == 1) { if (preg_match("#^CN=(.+?),.*#i", base64_decode($dnEnc), $re)) { $groupname = _ActiveDirectoryToName($re[1]); $CountDeMembers = '-'; $Debug = " <a href=\"javascript:Loadjs('dansguardian2.explodeadgroup.php?rule-id={$_GET["rule-id"]}');\"\n\t\t\t\t\tstyle=\"text-decoration:underline\">{$dump_group_text}</a>"; } } else { $tty = $ad->ObjectProperty(base64_decode($dnEnc)); $CountDeMembers = $tty["MEMBERS"]; } $description = htmlentities($tty["description"]); $description = str_replace("'", "`", $description); if (trim($ligne["description"]) == null) { $ligne["description"] = $description; } } } if ($ligne["localldap"] == 0) { if (preg_match("#^ExtLdap:(.+)#", $ligne["webfilter_group_dn"], $re)) { $CountDeMembers = '-'; $groupadd_text = " {$re[1]}"; } } $imgGP = "win7groups-32.png"; if ($ligne["localldap"] < 2) { $imgGP = "group-32.png"; } if ($Textdynamic != null) { $imgGP = "warning-panneau-32.png"; } $TextGroupType = $tpl->_ENGINE_parse_body($localldap[$ligne["localldap"]]); $jsSelect = "YahooWin4('712','dansguardian2.edit.group.php?ID={$KEY_ID_GROUP}&t={$t}&YahooWin=4','{$KEY_ID_GROUP}::{$ligne['groupname']}');"; $data['rows'][] = array('id' => "group{$ligne["ID"]}", 'cell' => array("<img src='img/{$imgGP}'>", "<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:{$jsSelect}\" \n\t\t\t\tstyle='font-size:16px;text-decoration:underline;color:{$color}'>{$ligne['groupname']}</span></a>{$groupadd_text}{$Textdynamic}<div style='font-size:10px'>{$textExplainGroup}<i>«{$ligne["description"]} <i>{$TextGroupType}</i>»</i>{$Debug}", "<span style='font-size:16px;color:{$color}'>{$CountDeMembers}</span>", $delete)); } echo json_encode($data); }