Beispiel #1
0
function formulaire()
{
    $users = new usersMenus();
    $ldap = new clladp();
    $tpl = new templates();
    $page = CurrentPageName();
    if ($users->AsAnAdministratorGeneric) {
        $hash = $ldap->hash_get_ou(false);
    } else {
        $hash = $ldap->Hash_Get_ou_from_users($_SESSION["uid"], 1);
    }
    if (count($hash) == 1) {
        $org = $hash[0];
        $hash_groups = $ldap->hash_groups($org, 1);
        $hash_domains = $ldap->hash_get_domains_ou($org);
        $groups = Field_array_Hash($hash_groups, 'groupid', null, null, null, 0, "font-size:14px;padding:3px");
        $domains = Field_array_Hash($hash_domains, 'domain', null, null, null, 0, "font-size:14px;padding:3px");
    }
    $artica = new artica_general();
    $EnableVirtualDomainsInMailBoxes = $artica->EnableVirtualDomainsInMailBoxes;
    while (list($num, $ligne) = each($hash)) {
        $ous[$ligne] = $ligne;
    }
    $ou = Field_array_Hash($ous, 'organization', null, "ChangeFormValues()", null, 0, "font-size:14px;padding:3px");
    $form = "\n\t\n\t<input type='hidden' id='EnableVirtualDomainsInMailBoxes' value='{$EnableVirtualDomainsInMailBoxes}'>\n\t<table style='width:100%' class=form>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:14px'>{organization}:</td>\n\t\t\t<td>{$ou}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:14px'>{group}:</td>\n\t\t\t<td><span id='select_groups'>{$groups}</span>\n\t\t</tr>\n\t\t<tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:14px'>{firstname}:</td>\n\t\t\t<td>" . Field_text('firstname', null, 'width:120px;font-size:14px;padding:3px', null, 'ChangeFormValues()') . "</td>\n\t\t</tr>\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:14px'>{lastname}:</td>\n\t\t\t<td>" . Field_text('lastname', null, 'width:120px;font-size:14px;padding:3px', null, "ChangeFormValues()") . "</td>\n\t\t</tr>\t\t\n\t\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:14px'>{email}:</td>\n\t\t\t<td>" . Field_text('email', null, 'width:120px;font-size:14px;padding:3px', null, "ChangeFormValues()") . "@<span id='select_domain'>{$domains}</span></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:14px'>{uid}:</td>\n\t\t\t<td>" . Field_text('login', null, 'width:120px;font-size:14px;padding:3px') . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:14px'>{password}:</td>\n\t\t\t<td>" . Field_password('password', null, "font-size:14px;padding:3px") . "</td>\n\t\t</tr>\t\n\t\t<tr><td colspan=2>&nbsp;</td></tr>\n\t\t<tr>\n\t\t\t<td colspan=2 align='right'><hr>" . button("{add}", "SaveAddUser()") . "\n\t\t\t\t\n\t\t\t</td>\n\t\t</tr>\n\t\t\n\t\t</table>\n\t";
    $html = "\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top' width=1%><div id='ffform'><img src='img/identity-add-96.png'></div></td>\n\t\t<td valign='top' width=99%><div>{$form}</div></td>\n\t</tr>\n\t</table>\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
function export($ou, $path)
{
    @file_put_contents($pidfile, getmypid());
    //if(strlen($GLOBALS["USER_QUERY"])>0){$filter="(uid={$GLOBALS["USER_QUERY"]})";}
    $ldap = new clladp();
    $pattern = "(&(objectclass=userAccount){$filter})";
    $attr = array();
    $sr = @ldap_search($ldap->ldap_connection, "ou={$ou},dc=organizations,{$ldap->suffix}", $pattern, $attr);
    $hash = ldap_get_entries($ldap->ldap_connection, $sr);
    $unix = new unix();
    $gzip = $unix->find_program("gzip");
    $users_array = array();
    if (is_array($hash)) {
        for ($i = 0; $i < $hash["count"]; $i++) {
            $usersArray[] = $hash[$i]["uid"][0];
        }
    }
    if (is_array($usersArray)) {
        while (list($index, $uid) = each($usersArray)) {
            echo "Parsing {$uid}\n";
            $u = new user($uid);
            $array_user = array();
            foreach ($u as $key => $value) {
                $array_user[$key] = $value;
            }
            $array_users_final[] = $array_user;
            unset($array_user);
        }
    }
    $groups = $ldap->hash_groups($ou, 1);
    while (list($num, $line) = each($groups)) {
        echo "Parsing group {$num} {$line}\n";
        $u = new groups($num);
        $array_group = array();
        foreach ($u as $key => $value) {
            $array_group[$key] = $value;
        }
        $array_group_final[] = $array_group;
        unset($array_group);
    }
    $array_final["USERS"] = $array_users_final;
    $array_final["GROUPS"] = $array_group_final;
    $tempfile = $unix->FILE_TEMP();
    $datas = base64_encode(serialize($array_final));
    @file_put_contents($tempfile, $datas);
    if (is_dir($path)) {
        compress($tempfile, $path . "/{$ou}.gz");
        echo "Saved in " . $path . "/{$ou}.gz\n";
        @chmod($path . "/{$ou}.gz", 0755);
    } else {
        echo $path . " no such directory...\n";
    }
    @unlink($tempfile);
}
function INDEX_CREATE()
{
    $ldap = new clladp();
    if ($_GET["ou"] == null) {
        die;
    }
    $_GET["ou"] = base64_decode($_GET["ou"]);
    $hash = $ldap->hash_groups($_GET["ou"], 1);
    $domains = $ldap->hash_get_domains_ou($_GET["ou"]);
    if (count($domains) == 0) {
        $users = new usersMenus();
        if ($users->POSTFIX_INSTALLED) {
            $field_domains = Field_text('user_domain', "{$_GET["ou"]}.com", "width:85px");
        } else {
            if (!preg_match("#(.+?)\\.(.+)#", $_GET["ou"])) {
                $dom = "{$_GET["ou"]}.com";
            } else {
                $dom = "{$_GET["ou"]}";
            }
            $field_domains = "<code><strong>{$dom}</strong></code>" . Field_hidden('user_domain', "{$dom}", "width:120px");
        }
    } else {
        $field_domains = Field_array_Hash($domains, 'user_domain', "style:font-size:18px;padding:3px");
    }
    $tpl = new templates();
    $hash[null] = "{select}";
    $groups = Field_array_Hash($hash, 'group_id', $_GET["gpid"], "style:font-size:18px;padding:3px");
    $error_no_password = $tpl->javascript_parse_text("{error_no_password}");
    $error_no_userid = $tpl->javascript_parse_text("{error_no_userid}");
    $t = time();
    $title = "{$_GET["ou"]}:{create_user}";
    $step1 = "\n\t<div style='width:98%' class=form>\n\t<table style='width:99%' class='TableRemove' OnMouseOver=\"javascript:HideExplainAll(1)\">\n\t<tr>\n\t<td valign='top' width=1%><img src='img/chiffre1_32.png'></td>\n\t<td valign='top'>\n\t<div style='font-size:18px;font-weight:bold;margin-bottom:5px'>{name_the_new_account_title}:</div>\n\t" . Field_text('new_userid', null, "font-size:18px;padding:3px;font-weight:bold;color:#C80000", null, "UserAutoChange_eMail()", null, false, "UserADDCheck(event)") . "\n\n\t</td>\n\t</tr>\n\t</table></div>";
    $step2 = "\n\t<div style='width:98%' class=form>\n\t<table style='width:99%' class='TableRemove' OnMouseOver=\"javascript:HideExplainAll(2)\">\n\t<tr>\n\t<td valign='top' width=1%><img src='img/chiffre2_32.png'></td>\n\t<td valign='top'>\n\t<div style='font-size:18px;font-weight:bold;margin-bottom:5px'>{email}</div><br>\n\t<input type='hidden' name='email' value='' id='email'>\n\t<span id='prefix_email' style='width:90px;border:1px solid #CCCCCC;padding:2px;font-size:18px;font-weight:bold;margin:2px'>\n\t</span>@{$field_domains}&nbsp;\n\t<div style='text-align:right;font-size:14px;'><i><a href='javascript:ChangeAddUsereMail();'>{change}</a></i>\n\t\n\t</td>\n\t</tr>\n\t</table></div>";
    $step3 = "\n\t<div style='width:98%' class=form>\n\t<table style='width:99%' class='TableRemove' OnMouseOver=\"javascript:HideExplainAll(4)\">\n\t<tr>\n\t<td valign='top' width=1%><img src='img/chiffre3_32.png'></td>\n\t<td valign='top'>\n\t<div style='font-size:18px;font-weight:bold;margin-bottom:5px'>{password}</div>\n\t" . Field_password("password-{$t}", null, "font-size:18px;padding:3px;width:190px;letter-spacing:3px", null, null, null, false, "UserADDCheck(event)") . "\n\t</td>\n\t</tr>\n\t</table>\n\t</div>\n\t";
    $step4 = "\n\t<div style='width:98%' class=form>\n\t<table style='width:99%' class='TableRemove' OnMouseOver=\"javascript:HideExplainAll(3)\">\n\t<tr>\n\t<td valign='top' width=1%><img src='img/chiffre4_32.png'></td>\n\t<td valign='top'>\n\t<div style='font-size:18px;font-weight:bold;margin-bottom:5px'>{group}</div>\n\t<div style='font-size:18px;margin-bottom:5px'>{select_user_group_title}:</div><br>{$groups}\n\t</td>\n\t</tr>\n\t</table></div>\n\t";
    if ($_GET["gpid"] > 0) {
        $step4 = "<input type='hidden' id='group_id' value='{$_GET["gpid"]}'>";
    }
    $html = "\n\t<input type='hidden' id='ou-mem-add-form-user' value='{$_GET["ou"]}'>\n\t<input type='hidden' id='ou' value='{$_GET["ou"]}'>\n\t<div id='adduser_ajax_newfrm' style='margin-top:5px'>\n\t<div style='width:98%' class=form>\n\t<table style='width:100%' class=TableRemove>\n\t<tr>\n\t<td valign='top' style='width:450px;vertical-align:top'>\n\t\t<table style='width:450px'>\n\t\t<tr>\n\t\t\t<td valign='top' width=290px>{$step1}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td valign='top'>{$step2}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td valign='top'><br>{$step3}</td>\n\t\t</tr>\n\t\t\t<td valign='top'><br>{$step4}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right'>\n\t\t\t\t<hr>" . button("{add}", "UserADDSubmit()", 26) . "\n\t\t\t</td>\n\t\t</tr>\t\t\t\n\t\t</table>\n\t</td>\n\t<td valign='top' style='width:50%'>\n\t\t\t<center style='margin-bottom:8px'><img src='img/add-woman-256.png'></center>\n\t\t\t<div style='padding-left:10px'>\t\t\n\t\t\t\t<div class=text-info id='text-1' style='font-size:16px'>{name_the_new_account_explain}</div>\n\t\t\t\t<div class=text-info id='text-2' style='font-size:16px'>{user_email_text}</div>\n\t\t\t\t<div class=text-info id='text-3' style='font-size:16px'>{select_user_group_text}</div>\n\t\t\t\t<div class=text-info id='text-4' style='font-size:16px'>{give_password_text}</div>\n\t\t\t</div>\n\t\t\t\n\t</td>\n\t</tr>\t\n\t</table>\n\t</div>\n\t</div>\n\t<input type='hidden' id='flexRTMEM' value='{$_GET["flexRT"]}'>\n\t<script>\n\t\tfunction VerifyFormAddUserCheck(){\n\t\t\tvar pass;\n\t\t\tvar uid;\n\t\t\tpass=document.getElementById('password-{$t}').value;\n\t\t\tuid=document.getElementById('new_userid').value;\n\t\t\tif(uid.length<1){alert('{$error_no_userid}');return false;}\n\t\t\tif(pass.length<1){alert('{$error_no_password}');return false;}\n\t\t\treturn true;\n\t\t\t}\n\t\t\n\t\tfunction UserADDSubmit(){\n\t\t\tif(!VerifyFormAddUserCheck()){return;}\n\t\t\tUserADD{$t}();\n\t\t}\n\t\n\t\n\t\tfunction UserADDCheck(e){\n\t\t\tif(checkEnter(e)){UserADDSubmit();}\n\t\t}\n\t\t\n\t\tfunction HideExplainAll(id){\n\t\t\tdocument.getElementById('text-1').style.display='none';\n\t\t\tdocument.getElementById('text-2').style.display='none';\n\t\t\tdocument.getElementById('text-3').style.display='none';\n\t\t\tdocument.getElementById('text-4').style.display='none';  \n\t\t\tif(document.getElementById('text-'+id)){\n\t\t\t\tdocument.getElementById('text-'+id).style.display='block';\n\t\t\t\t} \n\t\t\t\n\t\t}\n\t\t\nfunction UserADD{$t}(){\n\t\tvar XHR = new XHRConnection();\n\t\tvar ou=document.getElementById('ou').value;\n\t\tif(ou.length==0){if(document.getElementById('ou-mem-add-form-user')){ou=document.getElementById('ou-mem-add-form-user').value;}}\n\t\tif(ou.length==0){Alert('Unable to stat Organization name (ou field is empty)');return;}\n\t\t\n\t\tXHR.appendData('ou',ou);\n\t\tXHR.appendData('new_userid',document.getElementById('new_userid').value);\n\t\tXHR.appendData('password',document.getElementById('password-{$t}').value);\n\t\tXHR.appendData('group_id',document.getElementById('group_id').value);\n\t\tXHR.appendData('email',document.getElementById('email').value);\n\t\tXHR.appendData('user_domain',document.getElementById('user_domain').value);\n\t\t\n\t\tif(document.getElementById('adduser_ajax_newfrm')){AnimateDiv('adduser_ajax_newfrm');}\n\t\tif(document.getElementById('bglego')){document.getElementById('bglego').src='img/wait_verybig.gif';}\n\t\tif(document.getElementById('member_add_to_wait')){AnimateDiv('member_add_to_wait');}\n\t\tXHR.sendAndLoad('domains.edit.user.php', 'POST',X_UserADD);\t\n\t}\t\t\n\t\n\t\n\t\t\n\t\tHideExplainAll();\n</script>\t\n\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
function INDEX_CREATE()
{
    $ldap = new clladp();
    if ($_GET["ou"] == null) {
        die;
    }
    $_GET["ou"] = base64_decode($_GET["ou"]);
    $hash = $ldap->hash_groups($_GET["ou"], 1);
    $domains = $ldap->hash_get_domains_ou($_GET["ou"]);
    if (count($domains) == 0) {
        $users = new usersMenus();
        if ($users->POSTFIX_INSTALLED) {
            $field_domains = Field_text('user_domain', "{$_GET["ou"]}.com", "width:85px");
        } else {
            if (!preg_match("#(.+?)\\.(.+)#", $_GET["ou"])) {
                $dom = "{$_GET["ou"]}.com";
            } else {
                $dom = "{$_GET["ou"]}";
            }
            $field_domains = "<code><strong>{$dom}</strong></code>" . Field_hidden('user_domain', "{$dom}", "width:120px");
        }
    } else {
        $field_domains = Field_array_Hash($domains, 'user_domain');
    }
    $hash[null] = "{select}";
    $groups = Field_array_Hash($hash, 'group_id', $_GET["gpid"]);
    $title = "{$_GET["ou"]}:{create_user}";
    $step1 = "<table style='width:100%'>\n\t<tr>\n\t<td valign='top' width=1%><img src='img/chiffre1.png'></td>\n\t<td valign='top'>\n\t<H3>{name_the_new_account_title}</H3><br>\n\t<strong>{name_the_new_account_field}:</strong>\n\t<br>" . Field_text('new_userid', null, null, null, "UserAutoChange_eMail()") . "\n\t<div class=caption>{name_the_new_account_explain}</div>\n\t</td>\n\t</tr>\n\t</table>";
    $step2 = "\n\t<table style='width:100%'>\n\t<tr>\n\t<td valign='top' width=1%><img src='img/chiffre2.png'></td>\n\t<td valign='top'>\n\t<H3>{email}</H3><br>\n\t<strong>{email}:</strong>\n\t<br><input type='hidden' name='email' value='' id='email'>\n\t<span id='prefix_email' style='width:90px;border:1px solid #CCCCCC;padding:2px;font-size:11px;font-weight:bold;margin:2px'></span>@{$field_domains}&nbsp;<a href='javascript:ChangeAddUsereMail();'>[{change}]</a>\n\t<div class=caption>{user_email_text}</div>\n\t</td>\n\t</tr>\n\t</table>";
    $step3 = "\n\t<table style='width:100%'>\n\t<tr>\n\t<td valign='top' width=1%><img src='img/chiffre3.png'></td>\n\t<td valign='top'>\n\t<H3>{password}</H3><br>\n\t<strong>{give_password}:</strong>\n\t<br>" . Field_password('password') . "\n\t<div class=caption>{give_password_text}</div>\n\t</td>\n\t</tr>\n\t</table>\n\t";
    $step4 = "\n\t<table style='width:100%'>\n\t<tr>\n\t<td valign='top' width=1%><img src='img/chiffre4.png'></td>\n\t<td valign='top'>\n\t<H3>{group}</H3><br>\n\t<strong>{select_user_group_title}:</strong>{$groups}\n\t<div class=caption>{select_user_group_text}</div>\n\t</td>\n\t</tr>\n\t</table>\n\t";
    if ($_GET["gpid"] > 0) {
        $step4 = "<input type='hidden' id='group_id' value='{$_GET["gpid"]}'>";
    }
    $html = "\n\t<input type='hidden' id='ou-mem-add-form-user' value='{$_GET["ou"]}'>\n\t<input type='hidden' id='ou' value='{$_GET["ou"]}'>\n\t<div style='float:right'><img src='img/64_bg_lego.png'></div><H1>{$title}</H1>\n\t<p class=caption>{create_user_text}</p>\n\t<div id='adduser_ajax_newfrm'>\n\t<table style='width:100%'>\n\t<tr>\n\t<td valign='top'>{$step1}</td>\n\t<td valign='top'>{$step2}</td>\n\t</tr>\n\t<tr>\n\t<td valign='top'><br>{$step3}\n\t</td>\n\t<td valign='top'><br>{$step4}</td>\n\t</tr>\n\t<tr>\n\t<td colspan=2>\n\t<hr>\n\t<div style='padding:10px;text-align:right'>\n\t\t" . button("{add}", "UserADD()") . "\n\t\n\t</td>\n\t</tr>\t\t\n\t\n\t</table>\n\t</div>\n\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Beispiel #5
0
function export_all_groups()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $oldpid = @file_get_contents($pidfile);
    if ($unix->process_exists($oldpid)) {
        events("{$oldpid} already running", __FUNCTION__, __FILE__, __LINE__);
        die;
    }
    @file_put_contents($pidfile, getmypid());
    $ldap = new clladp();
    $ous = $ldap->hash_get_ou(true);
    while (list($ou, $ou2) = each($ous)) {
        if (trim($ou) == null) {
            continue;
        }
        $hash = $ldap->hash_groups($ou);
        if (!is_array($hash)) {
            return;
        }
        while (list($gid, $groupname) = each($hash)) {
            $array_final[$gid] = array("ou" => $ou, "name" => $groupname);
        }
    }
    if (!is_array($array_final)) {
        return null;
    }
    echo "exporting " . count($array_final) . " groups in \"/etc/artica-postfix/metagroups.cache\"\n";
    $datas = base64_encode(serialize($array_final));
    @file_put_contents("/etc/artica-postfix/metagroups.cache", $datas);
    $http = new httpget();
    $sock = new sockets();
    $meta = new artica_meta();
    $http->uploads["ALL_GROUPS"] = "/etc/artica-postfix/metagroups.cache";
    $body = $http->send("{$meta->ArticaMetaHostname}/lic.users.import.php", "post", array("DATAS" => base64_encode(serialize($meta->GLOBAL_ARRAY))));
    events(count($array_final) . " groups exported to global Management console", __FUNCTION__, __FILE__, __LINE__);
    send_email_events(count($array_final) . " groups exported to global Management console", $body, "CLOUD");
    echo $body;
}
Beispiel #6
0
function time_groups(){
	$ldap=new clladp();
	$gprs=$ldap->hash_groups($_GET["connection-time-showgroup"],1);
	$gprs[null]="{select}";
	$tpl=new templates();
	return  $tpl->_ENGINE_parse_body(Field_array_Hash($gprs,'gpid',null,"ConnectionTimeSelectGroup()"));
	
	
}
function LoadGroupsAjax($ou)
{
    $ldap = new clladp();
    echo $ldap->hash_groups($ou, 2);
}
function move_user($userid)
{
    $ldap = new clladp();
    $usersData = $ldap->UserDatas($userid);
    $ou = $usersData["ou"];
    if (is_array($usersData["groups"])) {
        $gp = "<table style='width:100%'>";
        while (list($num, $ligne) = each($usersData["groups"])) {
            $gp = $gp . "\n\t\t\t<tr>\n\t\t\t<td width=1%><img src='img/fw_bold.gif'></td>\n\t\t\t<td valign='top'>{$num}</td>\n\t\t\t<td valign='top'>" . imgtootltip('x.gif', '{delete} ' . $num, "DeleteUserGroup({$ligne},'{$userid}')") . "</td>\n\t\t\t</tr>";
        }
        $gp = $gp . "</table>";
    }
    $hash_group = $ldap->hash_groups($ou, 1);
    $add = Field_array_Hash($hash_group, 'group_add', null, null, null, 0, 'width:150px');
    $html = "<fieldset style='width:400px'>\n\t<legend>{move_member}</legend>\n\t<form name='ffm1'>\n\t<input type='hidden' name='userid' id='userid' value='{$userid}'>\n\t<strong>{add_member_to_group}:&nbsp;</strong>{$add}&nbsp;<input type='button' value='{add}&nbsp;&raquo;' OnClick=\"javascript:AddMemberGroup();\" style='margin-bottom:0px'><br>\n\t</form>\n\t<h4>{member_of_group}:</H4>\n\t{$gp}\n\t\n\t\n\t</fieldset>";
    $tpl = new Templates();
    return $tpl->_ENGINE_parse_body($html);
}
function main_step2()
{
    $ous = $ad->table_ou();
    $ous[null] = "{select}";
    $ous["Users"] = "Users";
    $ldap = new clladp();
    $hgp = $ldap->hash_groups($_POST["ou"], 1);
    $html = "<table style='width:100%'>\n\t<tr><td colspan=3><hr></td></tr>\n\t<tr>\n\t\t<td width=1% valign='top'><img src='img/chiffre3.png'></td>\n\t\t<td valign='top'><H3>{remote_org}</H3>\n\t\t<p class=caption>{remote_org_text}</p>\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td align='right' style='font-weight:bold;font-size:12px'>{remote_org}:</td>\n\t\t\t<td align='left'>" . Field_array_Hash($ous, 'dn_ou', $ad->dn_ou) . "</td>\n\t\t</tr>\n\t\t</table>\n\t\t</td>\n\t</tr>\n\t</table>\n<table style='width:100%'>\n\t<tr><td colspan=3><hr></td></tr>\n\t<tr>\n\t\t<td width=1% valign='top'><img src='img/chiffre4.png'></td>\n\t\t<td valign='top'><H3>{local_group}</H3>\n\t\t<p class=caption>{local_group_text}</p>\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td align='right' style='font-weight:bold;font-size:12px'>{local_group}:</td>\n\t\t\t<td align='left'>" . Field_array_Hash($hgp, 'target_group', $ad->target_group) . "</td>\n\t\t</tr>\n\t\t</table>\n\t\t</td>\n\t</tr>\n\t</table>\n<table style='width:100%'>\n\t<tr><td><hr></td></tr>\n\t<tr><td align='right'><input type='button' value='{perform_importation}&nbsp;&raquo;' OnClick=\"javascript:AddStep2('{$_POST["ou"]}');\"></td>\n\t</tr>\n\t</table>\t\t\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
function add_user_popup()
{
    $ldap = new clladp();
    if ($_GET["ou"] == null) {
        senderror("{ERROR_NO_ORGANISATION_SELECTED}");
    }
    $hash = $ldap->hash_groups($_GET["ou"], 1);
    $domains = $ldap->hash_get_domains_ou($_GET["ou"]);
    $boot = new boostrap_form();
    $boot->set_hidden("ou", $_GET["ou"]);
    $boot->set_hidden("encpass", 1);
    $boot->set_field("new_userid", "{name_the_new_account_title}", null, array("MANDATORY" => true));
    $boot->set_field("password", "{password}", null, array("MANDATORY" => true));
    $boot->set_field("email", "{email}", null, array("MANDATORY" => true));
    $boot->set_field("password", "{password}", null, array("MANDATORY" => true, "ENCODE" => true));
    $boot->set_list("group_id", "{group}", $hash);
    $boot->set_button("{add}");
    $boot->set_CloseYahoo("YahooWin2");
    $boot->set_RefreshSearchs();
    $boot->setAjaxPage("domains.edit.user.php");
    $boot->set_formtitle("{$_GET["ou"]}:: {new_member}");
    echo $boot->Compile();
}
function find_member()
{
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        find_member_active_directory();
        return;
    }
    if ($_POST["qtype"] == "find-member") {
        $tofind = $_POST["query"];
    }
    $t = $_GET["t"];
    $tt = $_GET["tt"];
    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;
    }
    $tofind = str_replace(".", '\\.', $tofind);
    $tofind = str_replace("*", '.*?', $tofind);
    $ldap = new clladp();
    writelogs("FIND {$tofind} IN OU \"{$ou}\"", __FUNCTION__, __FILE__, __LINE__);
    if (!$ldap->IsOUUnderActiveDirectory($ou)) {
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $GLOBALS["NOUSERSCOUNT"] = true;
            $ldap = new ldapAD();
            writelogs("[{$tofind}]: ->hash_get_groups_from_ou_mysql({$ou},{$tofind}) ", __FUNCTION__, __FILE__);
            $hash = $ldap->hash_get_groups_from_ou_mysql($ou, $tofind, true);
        } else {
            $ldap = new clladp();
            $hash = $ldap->hash_groups($ou, 1);
        }
    } else {
        $hash = find_member_active_directory();
        $ldap->EnableManageUsersTroughActiveDirectory = true;
        $GLOBALS["NOUSERSCOUNT"] = true;
    }
    $number = count($hash);
    $data = array();
    $data['page'] = 0;
    $data['total'] = $number;
    $data['rows'] = array();
    $styla = "style='font-size:14px;text-decoration:underline;font-weight:bold'";
    $styleNum = "style='font-size:16px;font-weight:bold'";
    $search = string_to_flexregex();
    if (is_array($hash)) {
        while (list($num, $line) = each($hash)) {
            if (strtolower($line) == 'default_group') {
                continue;
            }
            if (strlen($search) > 2) {
                if (!preg_match("#{$search}#", $line)) {
                    continue;
                }
            }
            $text = null;
            $js = "javascript:Loadjs('domains.edit.group.php?js=yes&group-id={$num}&ou={$_GET["ou"]}&encoded=yes&tt={$t}&ttt={$tt}')";
            $delete = imgsimple("delete-24.png", "{delete} {$num}", "Loadjs('domains.delete.group.php?gpid={$num}')");
            if (!$GLOBALS["NOUSERSCOUNT"]) {
                $delete = "&nbsp;";
                $gp = new groups($num);
                $members = count($gp->members_array);
                if ($gp->description != null) {
                    $text = $gp->description;
                }
                $data['rows'][] = array('id' => $line, 'cell' => array("<a href=\"javascript:blur();\" OnClick=\"{$js}\" {$styla}>{$line}</a>", "<span {$styleNum}>{$members}</span>", "<span style='font-size:14px'>{$text}</span>", $delete));
            } else {
                if (is_array($line)) {
                    if ($line["description"] != null) {
                        $text = $line["description"];
                    }
                    if (strlen($search) > 2) {
                        if (!preg_match("#{$search}#", $line["groupname"])) {
                            continue;
                        }
                    }
                    if (!is_numeric($line["gid"])) {
                        $delete = imgsimple("delete-24-grey.png");
                    }
                    $js = "javascript:Loadjs('domains.edit.group.php?js=yes&group-id={$line["gid"]}&ou={$_GET["ou"]}&encoded=yes&tt={$t}&ttt={$tt}')";
                    $data['rows'][] = array('id' => md5($line["groupname"]), 'cell' => array("<a href=\"javascript:blur();\" OnClick=\"{$js}\" {$styla}>{$line["groupname"]}</a>", "<span {$styleNum}>{$line["UsersCount"]}</span>", "<span style='font-size:14px'>{$text}</span>", $delete));
                } else {
                    $data['rows'][] = array('id' => $line, 'cell' => array("<a href=\"javascript:blur();\" OnClick=\"{$js}\" {$styla}>{$line}</a>", "<span {$styleNum}>?</span>", "<span style='font-size:14px'></span>", $delete));
                }
            }
        }
    }
    echo json_encode($data);
}
function browse_groups_for_ou()
{
    $ou = $_GET["browse-ou"];
    $t = $_GET["t"];
    $function = $_GET["function"];
    $ldap = new clladp();
    $tpl = new templates();
    $groups = $ldap->hash_groups($ou, 1);
    $id = md5($ou);
    if ($GLOBALS["VERBOSE"]) {
        print_r($groups);
    }
    if (!is_array($groups)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "<H1>Not an array</H1>";
        }
        return null;
    }
    $style = " OnMouseOver=\";this.style.cursor='pointer';\" OnMouseOut=\";this.style.cursor='default';\"";
    $f[] = "<ul id='{$id}' class='jqueryFileTree'>";
    ksort($groups);
    $group = $tpl->_ENGINE_parse_body("{group2}");
    while (list($num, $groupname) = each($groups)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$num} -> {$groupname}<br>\n";
        }
        $id = $num;
        $CLASS = "group";
        $f[] = "<li class={$CLASS} collapsed id='{$id}'>\n\t\t\t<a href=\"#\" OnClick=\"javascript:{$function}('{$num}','{$groupname}');YahooWinBrowseHide();\">{$groupname}</a></li>";
    }
    $f[] = "</ul>";
    echo @implode("\n", $f);
}
function groups_fields()
{
    $ou = $_GET["choose-group"];
    if ($ou == null) {
        return null;
    }
    $ldap = new clladp();
    $tpl = new templates();
    $hash = $ldap->hash_groups($ou, 1);
    $hash[null] = $tpl->_ENGINE_parse_body("{select}");
    $groups = Field_array_Hash($hash, 'gpid', null, null, null, 0, "font-size:15px;padding:4px");
    echo $groups;
}
Beispiel #14
0
function BuildLevel2($ou)
{
    $ldap = new clladp();
    $privileges = new usersMenus($_GET["PRIVS"]);
    $HashDomains = $ldap->hash_get_domains_ou($ou);
    $hash_group = $ldap->hash_groups($ou);
    $hash_transport = $ldap->hash_load_transport();
    $hash_users = $ldap->hash_get_users_Only_ou($ou);
    writelogs("BuildLevel2 ->{$ou} users number=" . count($hash_users), __FUNCTION__, basename(__FILE__));
    if ($privileges->AllowChangeDomains == true) {
        if (is_array($HashDomains)) {
            while (list($num, $ligne) = each($HashDomains)) {
                $items = $items . "{\n";
                $items = $items . "\t\t\t'id' : 'domain:{$ou},{$num}',\n";
                $items = $items . "\t\t\t'txt' : '{$ligne}',\n";
                if (isset($hash_transport[$ligne])) {
                    $items = $items . "\t\t\t'img' : 'alias-18.gif',\n";
                } else {
                    $items = $items . "\t\t\t'img' : 'globe.gif',\n";
                }
                $items = $items . "\t\t\t'editable' : false,\n";
                $items = $items . "\t\t\t'draggable' : false\n";
                $items = $items . "\t\t\t},";
            }
        }
    }
    if (is_array($hash_users)) {
        if (count($hash_users) > 50) {
            $count = count($hash_users);
            $items = $items . "{\n";
            $items = $items . "\t\t\t'id' : 'users:{$ou}',\n";
            $items = $items . "\t\t\t'txt' : '{$count} users',\n";
            $items = $items . "\t\t'openlink' : 'ldapTree.php',\n";
            $items = $items . "\t\t'draggable' : true,\n";
            $items = $items . "\t\t\t'img' : 'family-20.gif'\n";
            $items = $items . "\t\t\t},";
        }
    }
    if (is_array($hash_group)) {
        while (list($num, $ligne) = each($hash_group)) {
            $num = str_replace("'", "`", $num);
            if (strlen($num) > 20) {
                $num = substr($num, 0, 17) . "...";
            }
            $items = $items . "{\n";
            $items = $items . "\t\t\t'id' : 'group:{$ligne["gid"]}',\n";
            $items = $items . "\t\t\t'txt' : '{$num}',\n";
            $items = $items . "\t\t\t'img' : 'tree-groups',\n";
            $items = $items . "\t\t\t'editable' : true,\n";
            $items = $items . "\t\t\t'draggable' : false,\n";
            $items = $items . "\t\t'onopenpopulate' : myOpenPopulate,\n";
            $items = $items . "\t\t'openlink' : 'ldapTree.php',\n";
            $items = $items . "\t\t'canhavechildren' : true\n";
            $items = $items . "\t\t\t},";
        }
    }
    if (is_array($hash_users)) {
        if (count($hash_users) < 50) {
            while (list($num, $ligne) = each($hash_users)) {
                $userdatas = $ldap->UserDatas($ligne);
                $ligne = str_replace("'", "\\'", $ligne);
                $name = $userdatas["displayName"];
                $name = str_replace("'", "`", $name);
                $items = $items . "{\n";
                $items = $items . "\t\t\t'id' : 'user:{$ligne}',\n";
                $items = $items . "\t\t\t'txt' : '{$name}',\n";
                $items = $items . "\t\t'openlink' : 'ldapTree.php',\n";
                $items = $items . "\t\t'draggable' : true,\n";
                $items = $items . "\t\t\t'img' : 'outicon_1002.gif'\n";
                $items = $items . "\t\t\t},";
            }
        }
    }
    if ($items[strlen($items) - 1] == ',') {
        $items = substr($items, 0, strlen($items) - 1);
    }
    return $items;
}
function add_group_list()
{
    $ldap = new clladp();
    $groups = $ldap->hash_groups($_GET["ou-search"], 1);
    $groups[null] = "{select}";
    $ou_field = Field_array_Hash($groups, 'group-selected', null, null, null, 0, "font-size:14px");
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($ou_field);
}
Beispiel #16
0
function database_migrate_popup(){
		$tpl=new templates();
	$users=new usersMenus();
	if(!$users->AllowAddUsers){
		echo "<H2>".$tpl->_ENGINE_parse_body("{ERROR_NO_PRIVS}")."</H2>";exit;
	}
	
	$ID=$_GET["database-migrate"];
	$ou=$_GET["ou"];
	$ou=base64_decode($ou);
	$emailing=new emailings($ID);
	$ldap=new clladp();
	$group=$ldap->hash_groups($ou,1);
	$group[null]="{select}";
	
	
	$field=Field_array_Hash($group,'emailing_gpid_migr',trim($emailing->array_options["gpid"]),null,null,0,"font-size:14px;padding:4px");
	$page=CurrentPageName();
	$confirm=$tpl->javascript_parse_text('{confirm}?');
	
	
	$ldap=new clladp();
	$domains=$ldap->Hash_domains_table($ou);
	while (list ($domain, $no) = each ($domains) ){
		$DOMAINS_ARRAY[$domain]=$domain;
	}	
	$DOMAINS_ARRAY[null]="{select}";
	$domains_field=Field_array_Hash($DOMAINS_ARRAY,'export_domain',$emailing->array_options["export_domain"],null,null,0,"font-size:14px;padding:4px");
	
	$html="
	<div id='database_migrate_popup_id'>
	<table style='width:100%'>
	<tr>
	<td valign='top' width=1%><img src='img/user-migrate-90.png'></td>
	<td valign='top'>
	<div style='font-size:13px'>{migrate_user_text}</div>
	<table style='width:100%'>
	<tr>
		<td class=legend style='font-size:14px'>{group}:</td>
		<td>$field</td>
	</tr>
	<tr>
		<td class=legend style='font-size:14px'>{domain}:</td>
		<td>$domains_field</td>
	</tr>
	<tr>
		<td class=legend style='font-size:14px'>{default_password}:</td>
		<td>". Field_password("export_default_password",$emailing->array_options["export_default_password"],"font-size:14px;padding:4px;width:120px")."</td>
	</tr>			
	<tr>
		<td colspan=2 align='right'><hr>". button("{import}","MigrateUsersToLdapPerform()")."</td>
	</tr>
	
	</table>
	
	
	
	</td>
	</tr>
	</table>
	</div>
	
	<script>
		var x_MigrateUsersToLdapPerform= function (obj) {
			var tempvalue=obj.responseText;
			if(tempvalue.length>0){alert(tempvalue);}
			YahooWin5Hide();
			RefreshTab('emailing_campaigns');	
		}		
	
		function MigrateUsersToLdapPerform(){
			if(confirm('$confirm')){
				var XHR = new XHRConnection();
	      		XHR.appendData('database-migrate-perform','$ID');
	      		XHR.appendData('ou','{$_GET["ou"]}');
	      		XHR.appendData('gpid',document.getElementById('emailing_gpid_migr').value);
	      		XHR.appendData('export_domain',document.getElementById('export_domain').value);
	      		XHR.appendData('export_default_password',document.getElementById('export_default_password').value);
	      		if(document.getElementById('database_migrate_popup_id')){document.getElementById('database_migrate_popup_id').innerHTML='<center style=\"margin:20px;padding:20px\"><img src=\"img/wait_verybig.gif\"></center>';}
		  		XHR.sendAndLoad('$page', 'GET',x_MigrateUsersToLdapPerform);	
				}
			
			}	

	</script>
	
	";
		echo $tpl->_ENGINE_parse_body("$html");
	
	
}
function GROUPS_LIST($OU)
{
    writelogs("startup ou={$OU}", __FUNCTION__, __FILE__);
    $page = CurrentPageName();
    $ou = $OU;
    if (is_base64_encoded($ou)) {
        $ou = base64_decode($ou);
    }
    writelogs("Encoded ou ? =\"{$ou}\" {$_SESSION["uid"]}", __FUNCTION__, __FILE__);
    $ldap = new clladp();
    $users = new usersMenus();
    if ($users->AsArticaAdministrator) {
        writelogs("AsArticaAdministrator privileges", __FUNCTION__, __FILE__);
        $org = $ldap->hash_get_ou(true);
        while (list($ou1, $ou2) = each($org)) {
            $orgs_encoded[base64_encode($ou1)] = $ou2;
        }
        //$orgs=Field_array_Hash($orgs_encoded,'SelectOuList',base64_encode($ou),"LoadGroupList()",null,0,'width:250px');
        $hash = $ldap->hash_groups($ou, 1);
        writelogs("AsArticaAdministrator:: Load " . count($hash) . " groups from ou {$ou}", __FUNCTION__, __FILE__);
    } else {
        $ou = ORGANISTATION_FROM_USER();
        //$orgs="<strong>$ou</strong><input type='hidden' name=SelectOuList id='SelectOuList' value='$ou'>";
        if (!$users->AsOrgAdmin) {
            $hash = $ldap->UserGetGroups($_SESSION["uid"], 1);
        }
        if ($users->AsOrgAdmin) {
            $hash = $ldap->hash_groups($ou, 1);
        }
    }
    if (is_array($hash)) {
        while (list($num, $line) = each($hash)) {
            if (strtolower($line) == 'default_group') {
                unset($hash["{$num}"]);
            }
            $tr[] = $num;
        }
    }
    $orgs = Field_hidden("SelectOuList", base64_encode($ou));
    writelogs("Load " . count($hash) . " groups from ou {$ou}", __FUNCTION__, __FILE__);
    $hash[null] = "{select_group}";
    reset($hash);
    $field = Field_array_Hash($hash, 'SelectGroupList', null, "LoadGroupSettings()", null, 0, 'width:250px');
    $html = "\n\t{$orgs}\n\t<table style='width:300px'>\n\t<td width=80%>{$field}</td>\n\t<td width=1%>" . imgtootltip('20-refresh.png', '{refresh}', "RefreshGroupList()") . "</td>\n\t<td width=1%>" . button("{add}", "Loadjs('{$page}?popup-add-group=yes&ou={$ou}')") . "</td>\n\t</tr>\n\t</table>\n\t\n\t<script>\n\tfunction RefreshGroupList(){\n\t\t\tLoadAjax('grouplist','{$page}?LoadGroupList={$ou}')\n\t\t\n\t\t}\n\t\n\tLoadGroupSettings('{$tr[0]}');\t\n\t</script>\n\t\n\t\n\t";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
Beispiel #18
0
function formulaire()
{
    $users = new usersMenus();
    $ldap = new clladp();
    $tpl = new templates();
    $page = CurrentPageName();
    $lang = null;
    $t = $_GET["t"];
    if ($users->AsAnAdministratorGeneric) {
        $hash = $ldap->hash_get_ou(false);
    } else {
        if ($_GET["ou"] == null) {
            $hash = $ldap->Hash_Get_ou_from_users($_SESSION["uid"], 1);
            if (count($hash) == 0) {
                if (isset($_SESSION["ou"])) {
                    $hash[0] = $_SESSION["ou"];
                }
            }
        } else {
            $hash[0] = $_GET["ou"];
            if (count($hash) == 0) {
                if (isset($_SESSION["ou"])) {
                    $hash[0] = $_SESSION["ou"];
                }
            }
        }
    }
    if (count($hash) == 0) {
        echo $tpl->_ENGINE_parse_body(FATAL_ERROR_SHOW_128("{error_no_ou_created}<center style='margin-top:30px'>" . button("{create_a_new_organization}", "loadjs('organization.js.php?add-ou=yes');", 22) . "</center>"));
        return;
    }
    if (count($hash) == 1) {
        $org = $hash[0];
        $hash_groups = $ldap->hash_groups($org, 1);
        $hash_domains = $ldap->hash_get_domains_ou($org);
        $groups = Field_array_Hash($hash_groups, "groupid-{$t}", null, null, null, 0, "font-size:28px;padding:3px");
        $domains = Field_array_Hash($hash_domains, "domain-{$t}", null, null, null, 0, "font-size:28px;padding:3px");
    }
    $artica = new artica_general();
    $EnableVirtualDomainsInMailBoxes = $artica->EnableVirtualDomainsInMailBoxes;
    if ($users->ZARAFA_INSTALLED) {
        $sock = new sockets();
        $languages = unserialize(base64_decode($sock->getFrameWork("zarafa.php?locales=yes")));
        while (list($index, $data) = each($languages)) {
            if (preg_match("#cannot set#i", $data)) {
                continue;
            }
            $langbox[$data] = $data;
        }
        $ZARAFA_LANG = $sock->GET_INFO("ZARAFA_LANG");
        $mailbox_language = Field_array_Hash($langbox, "ZARAFA_LANG-ZARAFA_LANG", $ZARAFA_LANG, "style:font-size:28px;padding:3px");
        $lang = "\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:28px'>{language}:</td>\n\t\t\t\t<td><span id='MAILBOX_ZARAFA_LANG_LIST'>{$mailbox_language}</span>\n\t\t\t\t<div style='float:right;margin-top:5px'>" . button("{build_languages}", "BuildLocalesCreateUser()") . "</div>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t";
    }
    while (list($num, $ligne) = each($hash)) {
        $ous[$ligne] = $ligne;
    }
    $ou = Field_array_Hash($ous, "organization-{$t}", $_GET["ou"], "ChangeFormValues()", null, 0, "font-size:28px;padding:3px");
    $form = "\n\t\n\t<input type='hidden' id='EnableVirtualDomainsInMailBoxes-{$t}' value='{$EnableVirtualDomainsInMailBoxes}'>\n\t<div style='width:98%' class=form>\n\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{organization}:</td>\n\t\t\t<td>{$ou}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{group}:</td>\n\t\t\t<td><span id='select_groups-{$t}'>{$groups}</span>\n\t\t</tr>\n\t\t<tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{firstname}:</td>\n\t\t\t<td>" . Field_text("firstname-{$t}", null, 'width:531px;font-size:28px;padding:3px', null, 'ChangeFormValues()') . "</td>\n\t\t</tr>\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{lastname}:</td>\n\t\t\t<td>" . Field_text("lastname-{$t}", null, 'width:531px;font-size:28px;padding:3px', null, "ChangeFormValues()") . "</td>\n\t\t</tr>\t\t\n\t\t\t{$lang}\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{email}:</td>\n\t\t\t<td style='font-size:28px'>" . Field_text("email-{$t}", null, 'width:220px;font-size:28px;padding:3px', null, "ChangeFormValues()") . "&nbsp;@&nbsp;<span id='select_domain-{$t}'>{$domains}</span></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px' nowrap>{uid}:</td>\n\t\t\t<td>" . Field_text("login-{$t}", null, 'width:320px;font-size:28px;padding:3px') . "</td>\n\t\t</tr>\n\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{password}:</td>\n\t\t\t<td>" . Field_password("password-{$t}", null, "font-size:28px;padding:3px", null, null, null, false, "SaveAddUserCheck(event)") . "</td>\n\t\t</tr>\t\n\t\t<tr><td colspan=2>&nbsp;</td></tr>\n\t\t<tr>\n\t\t\t<td colspan=2 align='right' style='padding:10px'><hr>" . button("{add}", "SaveAddUser()", 34) . "\n\t\t\t\t\n\t\t\t</td>\n\t\t</tr>\n\t\t\n\t\t</table>\n\t</div>\n\t";
    $html = "<div id='ffform-{$t}'>\n\t<div>{$form}</div>\n\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Beispiel #19
0
function import($ligne)
{
    $unix = new unix();
    $Tmpdir = $unix->TEMP_DIR();
    $connection = $ligne["connection"];
    $username = $ligne["username"];
    $password = $ligne["password"];
    $folder = $ligne["folder"];
    $filename = $ligne["filename"];
    $ID = $ligne["ID"];
    $folder = str_replace("\\", "/", $folder);
    if (strpos($folder, "/") > 0) {
        $FF = explode("/", $folder);
        $SharedDir = $FF[0];
        unset($FF[0]);
        $folder = @implode("/", $FF);
    }
    $mountpoint = "{$Tmpdir}/{$ligne["ID"]}";
    if ($folder != null) {
        $targetdir = "{$mountpoint}/{$folder}";
    } else {
        $targetdir = $mountpoint;
    }
    if (!is_file("{$targetdir}/{$filename}")) {
        system_admin_events("{$connection}: {$targetdir}/{$filename}, no such file", __FUNCTION__, __FILE__, __LINE__, "import", $GLOBALS["SCHEDULE_ID"]);
        $mount = new mount();
        $mount->umount($mountpoint);
        return false;
    }
    if (is_file("{$targetdir}/{$filename}.scanned")) {
        $SCANNED = unserialize(@file_get_contents("{$targetdir}/{$filename}.scanned"));
    }
    $md5file = md5_file("{$targetdir}/{$filename}");
    if ($md5file == $ligne["lastmd5"]) {
        return true;
    }
    $handle = @fopen("{$targetdir}/{$filename}", "r");
    if (!$handle) {
        system_admin_events("{$connection}: {$targetdir}/{$filename}, fatal error", __FUNCTION__, __FILE__, __LINE__, "import", $GLOBALS["SCHEDULE_ID"]);
        return;
    }
    $c = 0;
    $ldap = new clladp();
    $OUS = $ldap->hash_get_ou(true);
    $defaultgroup = $ligne["ldapgroup"];
    if ($defaultgroup > 0) {
        $gp = new groups($defaultgroup);
        $DefaultOu = $gp->ou;
        $defaultGroupName = $gp->groupName;
        if ($GLOBALS["VERBOSE"]) {
            echo "Default group: {$defaultgroup}/ {$gp->groupName}/{$DefaultOu}\n";
        }
    }
    $t1 = time();
    $c = 0;
    $d = 0;
    while (!feof($handle)) {
        $line = trim(fgets($handle, 1024));
        $line = str_replace("\"", "", $line);
        if ($line == null) {
            continue;
        }
        if (strpos($line, ";") == 0) {
            continue;
        }
        $SCANMD = md5($line);
        $tr = explode(";", $line);
        $account = $tr[0];
        $password = $tr[1];
        $email = $tr[2];
        $groupname = $tr[3];
        $organization = $tr[4];
        if ($organization == "organization") {
            continue;
        }
        if ($account == "account") {
            continue;
        }
        $Telephon = $tr[5];
        $mobile = $tr[6];
        $d++;
        if (isset($SCANNED[$SCANMD])) {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "--------------- {$d} ----------------- {$SCANMD}\n";
        }
        if ($organization == null) {
            if ($defaultgroup == 0) {
                continue;
            }
        }
        if ($organization == null) {
            if ($DefaultOu != null) {
                $organization = $DefaultOu;
            }
        }
        if ($groupname == null) {
            $groupname = $defaultGroupName;
        }
        if ($groupname == null) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$organization} NO GroupName !!\n";
            }
            continue;
        }
        if (!isset($OUS[$organization])) {
            if (!$ldap->AddOrganization($organization)) {
                system_admin_events("fatal error failed to create entry {$organization}", __FUNCTION__, __FILE__, __LINE__, "import", $GLOBALS["SCHEDULE_ID"]);
                return;
            }
            $OUS = $ldap->hash_get_ou(true);
        }
        if (!isset($GLOBALS["GROUPS"][$organization])) {
            $GLOBALS["GROUPS"][$organization] = $ldap->hash_groups($organization);
        }
        if (!isset($GLOBALS["GROUPS"][$organization][$groupname])) {
            $gp = new groups();
            $gp->ou = $organization;
            $gp->groupName = $groupname;
            if (!$gp->add_new_group($groupname, $organization)) {
                system_admin_events("fatal error failed to create entry {$groupname}/{$organization}", __FUNCTION__, __FILE__, __LINE__, "import", $GLOBALS["SCHEDULE_ID"]);
                return;
            }
            $GLOBALS["GROUPS"][$organization] = $ldap->hash_groups($organization);
        }
        if (!isset($GLOBALS["GROUPS"][$organization][$groupname]["gid"])) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$groupname}/{$organization} NO GID!!\n";
            }
            continue;
        }
        $gid = $GLOBALS["GROUPS"][$organization][$groupname]["gid"];
        if ($password == null) {
            $password = $account;
        }
        $UPDATE = FALSE;
        $user = new user($account);
        if (!is_numeric($user->uidNumber)) {
            $UPDATE = true;
        }
        if ($email != null) {
            if ($user->mail != $email) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "mail {$email}\n";
                }
                $user->mail = $email;
                $UPDATE = true;
            }
        }
        if ($password != null) {
            if ($user->password != $password) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "password {$password}\n";
                }
                $user->password = $password;
                $UPDATE = true;
            }
        }
        if ($Telephon != null) {
            if ($user->telephoneNumber != $Telephon) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "telephoneNumber {$Telephon}\n";
                }
                $user->telephoneNumber = $Telephon;
                $UPDATE = true;
            }
        }
        if ($mobile != null) {
            if ($user->mobile != $mobile) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "mobile {$mobile}\n";
                }
                $user->mobile = $mobile;
                $UPDATE = true;
            }
        }
        if ($user->ou != $organization) {
            if ($GLOBALS["VERBOSE"]) {
                echo "ou {$organization}\n";
            }
            $user->ou = $organization;
            $UPDATE = true;
        }
        $user->group_id = $gid;
        if ($UPDATE) {
            $c++;
            if (!$user->SaveUser()) {
                continue;
            }
        }
        $SCANNED[$SCANMD] = time();
        @file_put_contents("{$targetdir}/{$filename}.scanned", serialize($SCANNED));
        if ($d > 500) {
            if (system_is_overloaded()) {
                system_admin_events("{$connection}: Overloaded system, aborting task", __FUNCTION__, __FILE__, __LINE__);
                return false;
            }
            $distance = $unix->distanceOfTimeInWords($t1, time(), true);
            system_admin_events("{$connection}: {$c} lines processed in {$distance}", __FUNCTION__, __FILE__, __LINE__);
            $d = 0;
        }
    }
    $date = date("Y-m-d H:i:s");
    $q = new mysql();
    $q->QUERY_SQL("UPDATE `texttoldap` SET `lastmd5`='{$md5file}',`lastscan`='{$date}' WHERE ID='{$ID}'", "artica_backup");
    $distance = $unix->distanceOfTimeInWords($t1, time(), true);
    system_admin_events("{$connection}: {$c} lines processed in {$distance}", __FUNCTION__, __FILE__, __LINE__);
    $umount = $unix->find_program("umount");
    shell_exec("{$umount} -l {$mountpoint}");
    return true;
}
Beispiel #20
0
function formulaire()
{
    $users = new usersMenus();
    $ldap = new clladp();
    $tpl = new templates();
    $page = CurrentPageName();
    $TT = time();
    $add_new_organisation_text = $tpl->javascript_parse_text("{add_new_organisation_text}");
    $lang = null;
    $t = $_GET["t"];
    if ($users->AsAnAdministratorGeneric) {
        $hash = $ldap->hash_get_ou(false);
    } else {
        if ($_GET["ou"] == null) {
            $hash = $ldap->Hash_Get_ou_from_users($_SESSION["uid"], 1);
            if (count($hash) == 0) {
                if (isset($_SESSION["ou"])) {
                    $hash[0] = $_SESSION["ou"];
                }
            }
        } else {
            $hash[0] = $_GET["ou"];
            if (count($hash) == 0) {
                if (isset($_SESSION["ou"])) {
                    $hash[0] = $_SESSION["ou"];
                }
            }
        }
    }
    if (count($hash) == 0) {
        echo $tpl->_ENGINE_parse_body(FATAL_ERROR_SHOW_128("{error_no_ou_created}<center style='margin-top:30px'>" . button("{create_a_new_organization}", "Loadjs('organization.js.php?add-ou=yes');", 22) . "</center>"));
        return;
    }
    if (count($hash) == 1) {
        $org = $hash[0];
        $hash_groups = $ldap->hash_groups($org, 1);
        $hash_domains = $ldap->hash_get_domains_ou($org);
        $groups = Field_array_Hash($hash_groups, "groupid-{$t}", null, null, null, 0, "font-size:28px;padding:3px");
        $domains = Field_array_Hash($hash_domains, "domain-{$t}", null, null, null, 0, "font-size:28px;padding:3px");
    }
    $artica = new artica_general();
    $EnableVirtualDomainsInMailBoxes = $artica->EnableVirtualDomainsInMailBoxes;
    if ($users->ZARAFA_INSTALLED) {
        $sock = new sockets();
        $languages = unserialize(base64_decode($sock->getFrameWork("zarafa.php?locales=yes")));
        while (list($index, $data) = each($languages)) {
            if (preg_match("#cannot set#i", $data)) {
                continue;
            }
            $langbox[$data] = $data;
        }
        $ZARAFA_LANG = $sock->GET_INFO("ZARAFA_LANG");
        $mailbox_language = Field_array_Hash($langbox, "ZARAFA_LANG-ZARAFA_LANG", $ZARAFA_LANG, "style:font-size:28px;padding:3px");
        $lang = "\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:28px'>{language}:</td>\n\t\t\t\t<td><span id='MAILBOX_ZARAFA_LANG_LIST'>{$mailbox_language}</span>\n\t\t\t\t<div style='float:right;margin-top:5px'>" . button("{build_languages}", "BuildLocalesCreateUser()") . "</div>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t";
    }
    while (list($num, $ligne) = each($hash)) {
        $ous[$ligne] = $ligne;
    }
    $ouenc = urlencode($_GET["ou"]);
    $ADMIN = false;
    if ($users->AsSquidAdministrator) {
        $ADMIN = true;
    }
    if ($users->AsDebianSystem) {
        $ADMIN = true;
    }
    if ($users->AsSystemAdministrator) {
        $ADMIN = true;
    }
    if ($ADMIN) {
        $add_ou = "<div style='float:right'>" . imgtootltip("32-plus.png", "{create_a_new_organization}", "TreeAddNewOrganisation{$TT}()") . "</div>";
        $add_group = "<div style='float:right'>" . imgtootltip("32-plus.png", "{new_group}", "CreateGroup{$TT}()") . "</div>";
    }
    $ou = Field_array_Hash($ous, "organization-{$t}", $_GET["ou"], "ChangeFormValues()", null, 0, "font-size:28px;padding:3px");
    $form = "\n\t\n\t<input type='hidden' id='EnableVirtualDomainsInMailBoxes-{$t}' value='{$EnableVirtualDomainsInMailBoxes}'>\n\t<div style='width:98%' class=form>\n\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{organization}:</td>\n\t\t\t<td>{$add_ou}<span id='ou-{$TT}'></span></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{group}:</td>\n\t\t\t<td>{$add_group}<span id='select_groups-{$t}'>{$groups}</span>\n\t\t</tr>\n\t\t<tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{firstname}:</td>\n\t\t\t<td>" . Field_text("firstname-{$t}", null, 'width:531px;font-size:28px;padding:3px', null, 'ChangeFormValues()') . "</td>\n\t\t</tr>\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{lastname}:</td>\n\t\t\t<td>" . Field_text("lastname-{$t}", null, 'width:531px;font-size:28px;padding:3px', null, "ChangeFormValues()") . "</td>\n\t\t</tr>\t\t\n\t\t\t{$lang}\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{email}:</td>\n\t\t\t<td style='font-size:28px'>" . Field_text("email-{$t}", null, 'width:220px;font-size:28px;padding:3px', null, "ChangeFormValues()") . "&nbsp;@&nbsp;<span id='select_domain-{$t}'>{$domains}</span></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px' nowrap>{uid}:</td>\n\t\t\t<td>" . Field_text("login-{$t}", null, 'width:320px;font-size:28px;padding:3px') . "</td>\n\t\t</tr>\n\t\t\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:28px'>{password}:</td>\n\t\t\t<td>" . Field_password("password-{$t}", null, "font-size:28px;padding:3px", null, null, null, false, "SaveAddUserCheck(event)") . "</td>\n\t\t</tr>\t\n\t\t<tr><td colspan=2>&nbsp;</td></tr>\n\t\t<tr>\n\t\t\t<td colspan=2 align='right' style='padding:10px'><hr>" . button("{add}", "SaveAddUser()", 34) . "\n\t\t\t\t\n\t\t\t</td>\n\t\t</tr>\n\t\t\n\t\t</table>\n\t</div>\n\t";
    $html = "<div id='ffform-{$t}'>\n\t<div>{$form}</div>\n\t<script>\n\tvar xTreeAddNewOrganisation{$TT}= function (obj) {\n\t\tvar response=obj.responseText;\n\t\tif(response){alert(response);}\n\t\tOpenOU{$TT}();\n\t\tChangeFormValues();\n\t\t\$('#table-{$t}').flexReload();\n\t}\t\n\t\n\tfunction TreeAddNewOrganisation{$TT}(){\n\t\tvar org=prompt('{$add_new_organisation_text}','');\n\t\tif(!org){return;}\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('TreeAddNewOrganisation',org);\n\t\tXHR.sendAndLoad('domains.php', 'GET',xTreeAddNewOrganisation{$TT});\n\t}\n\t\n\tfunction OpenOU{$TT}(){\n\t\tLoadAjaxSilent('ou-{$TT}','{$page}?ou-field=yes&t={$t}&ou={$ouenc}');\n\t}\n\t\n\tfunction CreateGroup{$TT}(){\n\t\tvar ou=document.getElementById('organization-{$t}').value;\n\t\tLoadjs('domains.edit.group.php?popup-add-group=yes&ou='+ou+'&t={$t}&tt={$_GET["tt"]}&CallBackFunction=ChangeFormValues');\n\t}\n\tOpenOU{$TT}();\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Beispiel #21
0
function GroupLists()
{
    $ldap = new clladp();
    $hash = $ldap->hash_groups($_GET["GroupLists"]);
    if (!is_array($hash)) {
        return null;
    }
    $html = "<table>\n\t<tr class=rowT>\n\t<td colspan=4>{group list}</td>\n\t</tr>";
    while (list($num, $ligne) = each($hash)) {
        if ($class == 'rowA') {
            $class = 'rowB';
        } else {
            $class = "rowA";
        }
        $html = $html . "<tr class={$class} OnMouseOver=\"javascript:this.className='rowH'\" onmouseout=\"javascript:this.className='{$class}'\">\n\t\t<td width=1%'><img src='img/user-group-22.gif'></td>\n\t\t<td><a href='#' OnClick=\"javascript:GroupEdit({$ligne["gid"]},0);\"> {$num}</td>\n\t\t<td>{$ligne["description"]}</td>\n\t\t<td width=1%'><a href='#' OnClick=\"javascript:GroupDelete({$ligne["gid"]});\"><img src='img/x.gif'></a></td>\n\t\t</tr>\n\t\t";
    }
    $tpl = new templates();
    echo $tpl->_parse_body($html);
}