function ApplyConfigMbx() { $artica = new artica_general(); $tpl = new templates(); if ($artica->RelayType == "single") { echo $tpl->_parse_body(Infos('mailbox_main_settings', 'feature_disabled')); exit; } $ldap = new clladp(); $hash = $ldap->Hash_all_mailboxesActives(); if (!is_array($hash)) { echo $tpl->_parse_body(Infos('mailbox_main_settings', 'no_mailboxes')); exit; } $cyrus = new cyrus(); $cyrconf = new cyrus_conf(); $cyrconf->SaveToLdap(); while (list($uid, $password) = each($hash)) { writelogs("Creating Mailbox {$uid}", __FUNCTION__, __FILE__); if (!$cyrus->CreateMailbox($uid, 1)) { writelogs("Creating Mailbox {$uid} failed aborting", __FUNCTION__, __FILE__); echo $tpl->_parse_body(InfosError('mailbox_main_settings', "{error_creating_mailbox} <strong>{$uid}</strong>")); exit; } } echo $tpl->_ENGINE_parse_body(Success('mailbox_main_settings')); }
function ExportUsers($ou, $server, $port, $admin, $password) { $sql = "DELETE FROM exports WHERE `function`='" . __FUNCTION__ . '"'; $q = new mysql(); $q->QUERY_SQL($sql, 'artica_events'); $AuThMeth = "?AuThMeth=" . base64_encode(serialize(array("admin" => $admin, "pass" => $password))); $ldap = new clladp(); $users = $ldap->Hash_all_mailboxesActives($ou); $CountDeUsers = count($users); events("[{$admin}@{$server}:{$port}]: Exporting {$CountDeUsers} active member(s) inside {$ou}", null, __FUNCTION__, __LINE__); while (list($uid, $password) = each($users)) { $user = new user($uid); foreach ($user as $key => $value) { if ($key == "uidNumber") { continue; } if ($key == "local_sid") { continue; } if ($key == "accountGroup") { continue; } if ($key == "group_id") { continue; } $array[$uid][$key] = $value; } } events("[{$admin}@{$server}:{$port}]: Exporting array of " . count($array) . " items", null, __FUNCTION__, __LINE__); $curl = new ccurl("https://{$server}:{$port}/import.users.listener.php{$AuThMeth}", true); $curl->parms["MEMBERS"] = base64_encode(serialize($array)); $curl->parms["OU"] = $ou; if (!$curl->get()) { events("[{$admin}@{$server}:{$port}]: Exporting {$CountDeUsers} active member(s) inside {$ou}", $curl->error, __FUNCTION__, __LINE__); return false; } if (preg_match("#<ERROR>(.+?)</ERROR>#is", $curl->data, $re)) { events("[{$admin}@{$server}:{$port}]: Exporting {$CountDeou} organizations failed", $re[1], __FUNCTION__, __LINE__); return false; } if (preg_match("#<SUCCESS>(.+?)</SUCCESS>#is", $curl->data, $re)) { events("[{$admin}@{$server}:{$port}]: Success Exporting {$CountDeou} organizations", $re[1], __FUNCTION__, __LINE__); return false; } }