function servers_list() { $search = $_GET["search"]; $MyPage = CurrentPageName(); $page = 1; $users = new usersMenus(); $tpl = new templates(); $sock = new sockets(); $q = new mysql(); $table = "ejabberd"; $database = "artica_backup"; $t = $_GET["t"]; if ($q->COUNT_ROWS($table, $database) == 0) { $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); echo json_encode($data); return; } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if ($_POST["query"] != null) { $_POST["query"] = str_replace("*", "%", $_POST["query"]); $search = $_POST["query"]; $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')"; $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}`"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; if ($OnlyEnabled) { $limitSql = null; } $sql = "SELECT * FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($sql, "", "", "")); } $ldap = new clladp(); while ($ligne = mysql_fetch_assoc($results)) { $color = black; $groupware = $tpl->_ENGINE_parse_body($groupware); $forward_text = $tpl->_ENGINE_parse_body($forward_text); $servername_text = $tpl->_ENGINE_parse_body($servername_text); $ServerAlias = $tpl->_ENGINE_parse_body($ServerAlias); $uptime = $tpl->_ENGINE_parse_body($uptime); $memory = $tpl->_ENGINE_parse_body($memory); $requests_second = $tpl->_ENGINE_parse_body("{$requests_second}"); $traffic_second = $tpl->_ENGINE_parse_body($traffic_second); $checkResolv = $tpl->_ENGINE_parse_body($checkResolv); $checkDNS = $tpl->_ENGINE_parse_body($checkDNS); $checkMember = $tpl->_ENGINE_parse_body($checkMember); $delete = $tpl->_ENGINE_parse_body($delete); $md5S = md5($ligne["hostname"]); $icon = "jabberd-24.png"; $servername_text = $ligne["hostname"]; $enabled = Field_checkbox("enabled_{$md5S}", 1, $ligne["enabled"], "eJabberdEnableHost('enabled_{$md5S}','{$ligne["hostname"]}')"); $href = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('ejabberd.edit.php?hostname={$ligne["hostname"]}&t={$t}')\" style='text-decoration:underline'>"; $spanStyle1 = "<span style='font-size:13px;font-weight:bold;color:#5F5656;'>"; $ou = $ldap->ou_by_smtp_domain($ligne["hostname"]); $delete = "<a href=\"javascript:blur();\" OnClick=\"javascript:JabberdDelete('{$ligne["hostname"]}','{$md5S}');\"><img src='img/delete-24.png'></a>"; $data['rows'][] = array('id' => $md5S, 'cell' => array("<img src='img/{$icon}'>", "<strong style='font-size:14px;style='color:{$color}'>{$href}{$servername_text}</a>{$groupware}{$forward_text}</strong>", "{$spanStyle1}{$enabled}</span>", "{$spanStyle1}{$ou}/{$ligne["uid"]}</span>", $delete)); } echo json_encode($data); }
function export_all_domains() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $oldpid = @file_get_contents($pidfile); if ($unix->process_exists($oldpid)) { die; } @file_put_contents($pidfile, getmypid()); $ldap = new clladp(); $array_final = array(); $array = $ldap->hash_get_all_domains(); if (!is_array($array)) { return; } while (list($index, $none) = each($array)) { $ou = $ldap->ou_by_smtp_domain($index); $array_final[trim(strtolower($index))]["ou"] = $ou; $array_final[trim(strtolower($index))]["TYPE"] = "LOCAL"; $ous[] = $ou; } if (!is_array($ous)) { return null; } while (list($index, $ou) = each($ous)) { $hash = $ldap->Hash_relay_domains($ou); if (is_array($hash)) { while (list($domain, $transport) = each($hash)) { $array_final[trim(strtolower($domain))]["TYPE"] = $transport; } } } if (!is_array($array_final)) { return null; } echo "exporting " . count($array_final) . " domains in \"/etc/artica-postfix/metadomains.cache\"\n"; $datas = base64_encode(serialize($array_final)); @file_put_contents("/etc/artica-postfix/metadomains.cache", $datas); $http = new httpget(); $sock = new sockets(); $meta = new artica_meta(); $http->uploads["ALL_DOMAINS"] = "/etc/artica-postfix/metadomains.cache"; $body = $http->send("{$meta->ArticaMetaHostname}/lic.users.import.php", "post", array("DATAS" => base64_encode(serialize($meta->GLOBAL_ARRAY)))); events(count($array_final) . " domains exported to global Management console", __FUNCTION__, __FILE__, __LINE__); send_email_events(count($array_final) . " domains exported to global Management console", $body, "CLOUD"); echo $body; }
function main_fetchmail_build(){ include_once('ressources/class.user.inc'); include_once('ressources/class.main_cf.inc'); include_once('ressources/class.fetchmail.inc'); $failed=false; $isp_address_mail=$_GET["isp_address_mail"]; $isp_pop3_server=$_GET["isp_pop3_server"]; $isp_smtp_server=$_GET["isp_smtp_server"]; $isp_account=$_GET["isp_account"]; $isp_password=$_GET["isp_password"]; $local_email=$_GET["local_email"]; $local_password=$_GET["local_password"]; $isp_smtp_account=$_GET["isp_smtp_account"]; $isp_smtp_password=$_GET["isp_smtp_password"]; $relay_server=$_GET["relay_server"]; if($local_email==null){ echo main_fetchmail_build_results(true,'local mail (False)'); exit; } $ldap=new clladp(); writelogs("i try to found if user exists",__FUNCTION__,__FILE__); $uid=$ldap->uid_from_email($local_email); if($uid<>null){ $user=new user($local_email); $ou=$user->ou; }else{ writelogs("no user found, create it",__FUNCTION__,__FILE__); $tb=explode("@",$local_email); $local_domain=$tb[1]; $user=new user($tb[0]); $ou=$ldap->ou_by_smtp_domain($local_domain); if($ou==null){ $ou=$local_domain; writelogs("Adding new organization $ou",__FUNCTION__,__FILE__); $ldap->AddOrganization($ou); } } writelogs("Creating user",__FUNCTION__,__FILE__); $user=new user($local_email); $user->mail=$local_email; $user->password=$local_password; $user->ou=$ou; $user->SenderCanonical=$isp_address_mail; if(!$user->add_user()){ echo main_fetchmail_build_results(true,$user->ldap_error); exit; } if($isp_smtp_account<>null){ writelogs("Creating SMTP authentification for $isp_smtp_server width $isp_smtp_account",__FUNCTION__,__FILE__); $sasl=new smtp_sasl_password_maps(); $sasl->add($isp_address_mail,$isp_smtp_account,$isp_password); $main=new main_cf(); writelogs("Enable sasl engine in postfix",__FUNCTION__,__FILE__); $main->smtp_sasl_password_maps_enable_2(); } writelogs("Creating sender_dependent_relayhost_maps -> $isp_smtp_server",__FUNCTION__,__FILE__); $sender=new sender_dependent_relayhost_maps(); if(!$sender->Add($isp_address_mail,$isp_smtp_server)){ echo main_fetchmail_build_results(true,"sender_dependent_relayhost_maps:$sender->ldap_error"); exit; } $fetchmail=new Fetchmail_settings(); $array["poll"]=$isp_pop3_server; $array["proto"]="auto"; $array["keep"]="yes"; $array["user"]=$isp_account; $array["pass"]=$isp_password; $array["is"]=$local_email; $array["fetchall"]="yes"; $line=$fetchmail->compile($array); if(!$user->fetchmail_add_rule($line)){ echo main_fetchmail_build_results(true,"fetchmail rule:$user->ldap_error"); exit; } $relay=new Routing($ou); if($relay_server<>null){ if(!$relay->create_relay_server($local_domain,$relay_server,$ou)){ echo main_fetchmail_build_results(true,"relay:$relay->ldap_error"); } }else{ if(!$relay->create_localdomain($ou,$local_domain)){ echo main_fetchmail_build_results(true,"local domain:$relay->ldap_error"); } } $fetchmail=new fetchmail(); $fetchmail->Save(); $main=new main_cf(); $main->save_conf(); $main->save_conf_to_server(); $info="<table style='width:100%'> <tr> <td width=1%><img src='img/fw_bold.gif'></td> <td nowrap align='right'><strong>{organization}</strong>:</td> <td nowrap><strong>$ou</strong></td> </tr> <tr> <td width=1%><img src='img/fw_bold.gif'></td> <td nowrap align='right'><strong>{local_mail}</strong>:</td> <td nowrap><strong>$local_email</strong></td> </tr> <tr> <td width=1%><img src='img/fw_bold.gif'></td> <td nowrap align='right'><strong>{isp_address_mail}</strong>:</td> <td nowrap><strong>$isp_address_mail</strong></td> </tr> </table> "; echo main_fetchmail_build_results(false,$info); }
function autoaccount_submit() { if (!CheckAutousers()) { exit; } $login = $_GET["login"]; $email = "{$login}@{$_GET["domain"]}"; $tpl = new templates(); $ldap = new clladp(); $uid = $ldap->uid_from_email($email); if ($uid != null) { echo $tpl->_ENGINE_parse_body('{account_already_exists}'); exit; } $ou = $ldap->ou_by_smtp_domain($_GET["domain"]); $user = new user(); $user->DisplayName = $_GET["first_name"] . " " . $_GET["last_name"]; $user->sn = $_GET["first_name"]; $user->cn = $_GET["last_name"]; $user->mail = $email; $user->domainname = $_GET["domain"]; $user->password = $_GET["password"]; $user->ou = $ou; $user->uid = $login; if ($user->add_user()) { echo $tpl->_ENGINE_parse_body("{success}:{$email}\n"); } else { echo $user->ldap_error; } }
function blacklistdom($domain = null) { $ldap = new clladp(); if ($domain != null) { $domain = "*"; } $hash = $ldap->BlackListFromDomain($domain); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if ($_POST["query"] != null) { $search = $_POST["query"]; $search = str_replace(".", "\\.", $search); $search = str_replace("*", ".*?", $search); } $c = 0; if (is_array($hash)) { while (list($from, $line) = each($hash)) { $recipient_domain = $from; if (preg_match("#(.+?)@(.+)#", $recipient_domain, $re)) { $recipient_domain = $re[2]; } $ou = $ldap->ou_by_smtp_domain($recipient_domain); while (list($num, $wl) = each($line)) { if ($search != null) { if (!preg_match("#{$search}#", $wl)) { continue; } } $c++; $id = md5("{$from}{$wl}"); $delete = imgsimple("delete-24.png", "{delete}", "DeleteBlackList('{$from}','{$wl}','{$id}');"); $data['rows'][] = array('id' => $id, 'cell' => array("<span style='font-size:14px;color:{$color}'>{$ou}</span>", "<span style='font-size:14px;color:{$color}'>{$wl}</span>", "<span style='font-size:14px;color:{$color}'>{$from}</span>", $delete)); } } } $data['total'] = $c; echo json_encode($data); }
function remotedomain_remove() { $ldap = new clladp(); $domain_name = $_POST["remotedomain-remove"]; $ou = $_POST["ou"]; if ($ou == null) { $ou = $ldap->ou_by_smtp_domain($domain_name); } $ldap = new clladp(); $ldap->DeleteRemoteDomain($domain_name, $ou); ChockServices(); }
function blacklistdom($domain=null){ if($domain==null){$domain="*";} $ldap=new clladp(); $hash=$ldap->BlackListFromDomain($domain); $html=" <table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'> <thead class='thead'> <tr> <th colspan=2>{search}:$domain</th> <th>{from}</th> <th>{recipients}</th> <th> </th> </tr> </thead> <tbody class='tbody'>"; if(is_array($hash)){ while (list ($from, $line) = each ($hash)){ $recipient_domain=$from; if(preg_match("#(.+?)@(.+)#",$from,$re)){$recipient_domain=$re[2];} $ou=$ldap->ou_by_smtp_domain($recipient_domain); while (list ($num, $wl) = each ($line)){ if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";} $html=$html . "<tr class=$classtr> <td width=1%><img src='img/fw_bold.gif'></td> <td><strong style='font-size:13px'>$ou</strong></td> <td><strong style='font-size:13px'>$wl</strong> <td><strong style='font-size:13px'>$from</strong></td> <td width=1%>" . imgtootltip('delete-32.png','{delete}',"DeleteBlackList('$from','$wl');")."</td> </tr>";} }} $html=$html . "</table>"; $form=$html; return $form; }
function CreateThisUser($email) { if (!preg_match("#(.+?)@(.+)#", $email, $re)) { return null; } $domain = $re[2]; $uid = $re[1]; $ldap = new clladp(); $ou = $ldap->ou_by_smtp_domain($domain); if ($ou == null) { write_syslog("CreateThisUser():: Unable to detect organization by domain \"{$domain}\"", __FILE__); return null; } $ct = new user($uid); $ct->ou = $ou; $ct->mail = $email; $ct->uid = $uid; if (!$ct->add_user()) { write_syslog("CreateThisUser():: Unable to Create user {$uid} \"{$email}\"", __FILE__); return null; } $uid2 = $ldap->uid_from_email($email); write_syslog("CreateThisUser():: new user \"{$uid2}\"", __FILE__); return $uid2; }
function blacklistdom($domain = null) { if ($domain == null) { $domain = "*"; } $ldap = new clladp(); $hash = $ldap->BlackListFromDomain($domain); $html = "<H5>{$domain}</H5>\n\t<table style='width:99%' class=table_form>\n\t<tr style='background-color:#CCCCCC'>\n\t\t<td> </td>\n\t\t<td> </td>\n\t\t<td><strong>{recipients}</strong></td>\n\t\t<td><strong>{from}</strong></td>\n\t\t<td> </td>\n\t</tr>"; if (is_array($hash)) { while (list($from, $line) = each($hash)) { $recipient_domain = $from; if (preg_match("#(.+?)@(.+)#", $from, $re)) { $recipient_domain = $re[2]; } $ou = $ldap->ou_by_smtp_domain($recipient_domain); while (list($num, $wl) = each($line)) { $html = $html . "<tr " . CellRollOver() . ">\n\t\t\t\t<td width=1%><img src='img/fw_bold.gif'></td>\n\t\t\t\t<td><strong>{$ou}</strong></td>\n\t\t\t\t<td><strong>{$from}</strong></td>\n\t\t\t\t<td><strong>{$wl}</strong>\n\t\t\t\t<td width=1%>" . imgtootltip('x.gif', '{delete}', "DeleteBlackList('{$from}','{$wl}');") . "</td>\n\t\t\t</tr>"; } } } $html = $html . "</table>"; $form = $html; return $form; }
function hostname_config() { $t = $_GET["t"]; $tpl = new templates(); $users = new usersMenus(); $page = CurrentPageName(); $sock = new sockets(); $hostname = $_GET["hostname"]; $buttonname = "{apply}"; $jaberd = new ejabberd($hostname); $status = "{activew}"; if ($jaberd->enabled == 0) { $status = "{inactive}"; } $ldap = new clladp(); $ou = $ldap->ou_by_smtp_domain($hostname); $html = "<table style='width:99%' class=form>\n\t<tr>\n\t\t<td class=legend style='font-size:18px'>{status}:</td>\n\t\t<td style='font-size:18px'>{$status}</td>\n\t\t<td> </td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:18px'>{administrator}:</td>\n\t\t<td>" . Field_text("uid-{$t}", $jaberd->uid, "font-size:18px;width:220px") . "</td>\n\t\t<td>" . button("{browse}...", "Loadjs('MembersBrowse.php?OnlyUsers=1&NOComputers=1&field-user=uid-{$t}&Zarafa=1&organization={$ou}')", 12) . "</td>\n\t</tr>\n\n\t</table>\n<hr>\n<div style='text-align:right'>" . button($buttonname, "SaveeJabberdCHost()", 22) . "</div>\t\n\t<script>\n\t\n\tvar x_SaveeJabberdCHost= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tvar currenthost='{$hostname}';\n\t\tif (res.length>3){alert(res);}\n\t\t\$('#jabberd-table-{$t}').flexReload();\n\t\tRefreshTab('main_ejabberd_{$t}');\n\t}\t\t\t\n\t\t\n\t\tfunction SaveeJabberdCHost(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('uid',document.getElementById('uid-{$t}').value);\n\t\t\tXHR.appendData('hostname','{$hostname}');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveeJabberdCHost);\t\n\t\t}\t\n\t\n\t</script>\n\t\n\t"; echo $tpl->_ENGINE_parse_body($html); }