function ROUNDCUBE($database, $ou) { $ldap = new clladp(); $users = $ldap->hash_users_ou($ou); if (!is_array($users)) { return; } reset($users); while (list($uid, $displayname) = each($users)) { if ($uid == null) { continue; } echo "Starting......: Groupware Checking roundcube {$database}:: {$uid} - {$displayname}\n"; $id = ROUNDCUBE_GetidFromUser($database, $uid); $u = new user($uid); if ($id == 0) { ROUNDCUBE_CreateRoundCubeUser($database, $uid, $u->mail, '127.0.0.1'); $id = ROUNDCUBE_GetidFromUser($database, $uid); } if ($id == 0) { continue; } $identity_id = ROUNDCUBE_GetidentityFromuser_id($database, $id); if ($identity_id == 0) { ROUNDCUBE_CreateRoundCubeIdentity($database, $id, $displayname, $u->mail, $ou); $identity_id = ROUNDCUBE_GetidentityFromuser_id($database, $id); } if ($identity_id == 0) { continue; } $count = $count + 1; ROUNDCUBE_UpdateRoundCubeIdentity($bd, $identity_id, $u->mail); } }
function sync($ou){ if(!Build_pid_func(__FILE__,__FUNCTION__)){ writelogs(basename(__FILE__).":Already executed.. aborting the process",basename(__FILE__),__FILE__,__LINE__); return; } $unix=new unix(); $imapsync=$unix->find_program("imapsync"); if(!is_file($unix->find_program("imapsync"))){ writelogs("Unable to stat imapsync",__FUNCTION__,__FILE__,__LINE__); send_email_events("Could not migrate from cyrus to zarafa","Unable to stat imapsync tool,aborting","mailbox"); return; } $ou=base64_decode($ou); $ldap=new clladp(); $members=$ldap->hash_users_ou($ou); writelogs("Loading $ou organization ".count($members)." members imapsync=$imapsync",__FUNCTION__,__FILE__,__LINE__); send_email_events("migration from cyrus to zarafa starting","Cyrus to zarafa starting (". count($members)." members)","mailbox"); while (list ($uid, $name) = each ($members) ){ if($uid==null){continue;} $user=new user($uid); send_email_events("migration from cyrus to zarafa starting","Cyrus to zarafa starting (". count($members)." members)","mailbox"); $cmdline="$imapsync --noauthmd5 --subscribe --host1 127.0.0.1 --port1 1143"; $cmdline=$cmdline." --user1 $uid --password1 $user->password --delete --expunge1"; $cmdline=$cmdline." --sep2 / --prefix2 \"\" --host2 127.0.0.1 --user2 $uid --password2 $user->password >/root/imapsync.$uid 2>&1"; writelogs("$cmdline",__FUNCTION__,__FILE__,__LINE__); shell_exec($cmdline); $datas=@file_get_contents("/root/imapsync.$uid"); if($GLOBALS["VERBOSE"]){ echo "$datas"; } if(strlen($datas)>0){ send_email_events("$uid migration status",@file_get_contents("/root/imapsync.$uid"),"mailbox"); } @unlink("/root/imapsync.$uid"); } }
function DeleteMailboxesOU($ou) { $ldap = new clladp(); $hash = $ldap->hash_users_ou($ou); if (!is_array($hash)) { return true; } while (list($num, $ligne) = each($hash)) { if (trim($num) == null) { continue; } error_log("PHP Infos: Delete {$num} mailbox", 0); system("/usr/share/artica-postfix/bin/artica-install --delete-mailbox \"{$num}\""); } }
function start() { $sock = new sockets(); $ZarafaAdbksWhiteTask = $sock->GET_INFO("ZarafaAdbksWhiteTask"); $ZarafaWhiteSentItems = $sock->GET_INFO("ZarafaWhiteSentItems"); $ZarafaJunkItems = $sock->GET_INFO("ZarafaJunkItems"); if (!is_numeric($ZarafaAdbksWhiteTask)) { $ZarafaAdbksWhiteTask = 0; } if (!is_numeric($ZarafaWhiteSentItems)) { $ZarafaWhiteSentItems = 1; } if (!is_numeric($ZarafaJunkItems)) { $ZarafaJunkItems = 0; } if ($ZarafaAdbksWhiteTask == 0) { return; } $q = new mysql(); $q->BuildTables(); $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($unix->process_exists($unix->get_pid_from_file($pidfile))) { system_admin_events("Already exists in memory, aborting task", __FUNCTION__, __FILE__, __LINE__, "zarafa"); return; } @file_put_contents($pidfile, getmypid()); $ZarafaServerListenIP = $sock->GET_INFO("ZarafaServerListenIP"); if ($ZarafaServerListenIP == null) { $ZarafaServerListenIP = "127.0.0.1"; } if ($ZarafaServerListenIP == "0.0.0.0") { $ZarafaServerListenIP = "127.0.0.1"; } $TimeFile = $unix->file_time_min($pidtime); if ($TimeFile < 240) { return; } @unlink($pidtime); @file_put_contents($pidtime, time()); $ldap = new clladp(); $ous = $ldap->hash_get_ou(true); $countDeOu = count($ous); system_admin_events("Parsing {$countDeOu} organization(s)", __FUNCTION__, __FILE__, __LINE__, "zarafa"); $GLOBALS["ITEMSC"] = 0; while (list($ou, $none) = each($ous)) { $users = $ldap->hash_users_ou($ou); $CountDeUsers = count($users); system_admin_events("{$ou} {$CountDeUsers} users", __FUNCTION__, __FILE__, __LINE__, "zarafa"); if (!is_array($users)) { continue; } if (count($users) == 0) { continue; } while (list($uid, $none2) = each($users)) { if (trim($uid) == null) { continue; } import_contacts($uid, $ZarafaServerListenIP); if ($ZarafaWhiteSentItems == 1) { import_sentitems($uid); } if ($ZarafaJunkItems == 1) { inject_blacklists($uid); } } } system_admin_events("Adding {$GLOBALS["ITEMSC"]} contacts in white list", __FUNCTION__, __FILE__, __LINE__, "zarafa"); $EnableAmavisDaemon = $sock->GET_INFO("EnableAmavisDaemon"); if (!is_numeric($EnableAmavisDaemon)) { $EnableAmavisDaemon = 0; } $php5 = $unix->LOCATE_PHP5_BIN(); $users = new usersMenus(); if ($users->AMAVIS_INSTALLED) { if ($EnableAmavisDaemon == 1) { shell_exec("{$php5} " . dirname(__FILE__) . "/exec.amavis.php >/dev/null 2>&1"); shell_exec("/etc/init.d/amavis reload"); } } if ($users->MILTERGREYLIST_INSTALLED) { shell_exec("{$php5} " . dirname(__FILE__) . "/exec.milter-greylist.php >/dev/null 2>&1"); } }
function CountDeUsers(){ $ldap=new clladp(); $arr=$ldap->hash_users_ou(null); @file_put_contents("/etc/artica-postfix/UsersNumber",count($arr)); }
function GroupUsers($gid) { $tabs = GroupTabs($gid); $gid = $_GET["GroupEdit"]; $ldap = new clladp(); $hash = $ldap->GroupDatas($gid); $ou = $hash["ou"]; $users = $ldap->hash_users_ou($ou); if (is_array($users)) { $USER_LIST = "<table>\n\t\t<tr class=rowT>\n\t\t\t<td>{domain} {users}</TD>\n\t\t</tr>\n\t\t<tr class='rowH'>\n\t\t<td colspan=2>{group how to add user}</td>\n\t\t</tr>\n\t\t"; while (list($num, $ligne) = each($users)) { if ($class = "rowA") { $class = "rowB"; } else { $class = "rowA"; } if ($hash["members"][$num] == null) { $USER_LIST = $USER_LIST . "<tr class={$class}>\n\t\t\t<td><a href='#' OnClick=\"javascript:GroupUserAdd({$gid},'{$num}');\">{$ligne}</td>\n\t\t\t<tr>"; } } $USER_LIST = $USER_LIST . "</table>"; } if (is_array($hash["members"])) { $USER_GLIST = "<table>\n\t\t<tr class=rowT>\n\t\t\t<td>{group} {users}</TD>\n\t\t</tr>\n\t\t<tr class='rowH'>\n\t\t<td colspan=2>{group how to del user}</td>\n\t\t</tr>\n\t\t"; while (list($num, $ligne) = each($hash["members"])) { if ($class = "rowA") { $class = "rowB"; } else { $class = "rowA"; } $USER_GLIST = $USER_GLIST . "<tr class={$class}>\n\t\t\t<td><a href='#' OnClick=\"javascript:GroupUserDelete({$gid},'{$num}');\">{$ligne}</td>\n\t\t\t<tr>"; } $USER_GLIST = $USER_GLIST . "</table>"; } $html = "\n\n\t{$tabs}\n\t<table style='margin:0px;padding:0px;border:0px;margin-top:5px'>\n\t<tr>\n\t<td valign='top' width=1%><img src='img/user-group-90.gif'></td>\n\t<td width=50% valign='top'>{$USER_GLIST}</td>\n\t<td width=50% valign='top'>{$USER_LIST}</td>\n\t</tr>\n\t</table>\n\t"; $tpl = new templates(); echo DIV_SHADOW($tpl->_parse_body($html), 'windows'); }
function getSommaire() { $ldap = new clladp(); $GLOBALS["OU-USERS"] = $ldap->hash_users_ou($GLOBALS["OU"]); echo __FUNCTION__ . " " . count($GLOBALS["OU-USERS"]) . " users...\n"; }