function RelayRecipientsTable($echo=0){
	
	
$html="
<div style='text-align:right;margin:5px;margin-top:0px'>". button("{add_routing_relay_recipient_rule}","PostfixAddRelayRecipientTable()")."</div>
<table style='width:99%;padding:5px;border:2px solid #8E8785;' align='center' class=table_form>
	<tr style='background-color:#CCCCCC'>
		<th style='font-size:12px'>&nbsp;</th>
		<th style='font-size:12px'><strong>{recipient}</strong></th>
		<th style='font-size:12px'><strong>&nbsp;</strong></th>
		<th align='center' style='font-size:12px'><strong>-</strong></th>
		<th style='font-size:12px'><strong>-</strong></td>
		<th align='center' style='font-size:12px'><strong>-</strong></th>
		<th align='center' style='font-size:12px'><strong-</strong></th>
		<th style='font-size:12px'>&nbsp;</th>
	</tr>";	
	$ldap=new clladp();
	$hash=$ldap->hash_get_relay_recipients();	
if(is_array($hash)){
while (list ($domain, $ligne) = each ($hash) ){
		$delete=imgtootltip("delete-24.png",'{delete}',"PostfixDeleteRelayRecipient('$domain')");
		if($domain=="@localhost.localdomain"){$delete=null;}
		$html=$html . "
		<tr>
		<td width=1%><img src='img/internet.png'></td>
		<td style='font-size:13px'><code>$domain</a></strong></code></td>
		<td width=1%><img src='img/fw_bold.gif'></td>
		<td align='center' style='font-size:12px'>{relay}</td>
		<td ><code></td>
		<td align='center' style='font-size:13px'><code></code></td>
		<td align='center' style='font-size:13px'><code></code></td>
		<td align='center' style='font-size:13px' width=1%>$delete</td>
		</tr>";
	}
}
$html=$html . "</table>";
$html="<div style='width:99%;height:350px;overflow:auto' id='routing-table'>$html</div>".ArticaSyncTable($echo);

$tpl=new templates();
if($echo==1){echo $tpl->_ENGINE_parse_body($html);exit;}
return $tpl->_ENGINE_parse_body($html);
}
function ArticaSyncTable_list($echo = 0)
{
    $page = CurrentPageName();
    $ldap = new clladp();
    if ($_POST["query"] != null) {
        $searchZ = str_replace("*", ".*?", $_POST["query"]);
    }
    $ttime = $_GET["t"];
    $dn = "cn=artica_smtp_sync,cn=artica,{$ldap->suffix}";
    $filter = array("cn");
    $sr = @ldap_search($ldap->ldap_connection, $dn, '(&(objectclass=ArticaSMTPSyncDB)(cn=*))', $filter);
    if ($sr) {
        $hash = ldap_get_entries($ldap->ldap_connection, $sr);
        if (!is_array($hash)) {
            return null;
        }
        for ($i = 0; $i < $hash["count"]; $i++) {
            $cn = $hash[$i]["cn"][0];
            if (preg_match("#(.+?):(.+)#", $cn, $re)) {
                $mailserver = $re[1];
            }
            $cn_dn = "cn=table,cn={$cn},cn=artica_smtp_sync,cn=artica,{$ldap->suffix}";
            $search = @ldap_search($ldap->ldap_connection, $dn, '(&(objectclass=InternalRecipients)(cn=*))', array("cn"));
            if ($search) {
                $hash2 = ldap_get_entries($ldap->ldap_connection, $search);
                for ($t = 0; $t < $hash2["count"]; $t++) {
                    $cn_email = $hash2[$t]["cn"][0];
                    $dn = base64_encode($hash2[$t]["dn"]);
                    if ($searchZ != null) {
                        if (!preg_match("#{$searchZ}#", $cn_email)) {
                            continue;
                        }
                    }
                    $m5 = md5($cn_email);
                    $data['rows'][] = array('id' => "dom{$m5}", 'cell' => array("\n\t\t\t\t\t<a href=\"javascript:blur();\" \n\t\t\t\t\t\tOnClick=\"\" \n\t\t\t\t\t\tstyle='font-size:16px;font-weight:bold;text-decoration:'>{$cn_email}</span>", "<span style='font-size:14px'>{$mailserver}:25</span>", imgtootltip('delete-32.png', '{delete}', "ArticaSyncTableDelete{$ttime}('{$dn}','{$m5}');")));
                    if ($c > $_POST["rp"]) {
                        break;
                    }
                    $c++;
                }
            }
        }
    }
    $hash = $ldap->hash_get_relay_recipients();
    if (is_array($hash)) {
        while (list($domain, $ligne) = each($hash)) {
            $m5 = md5($domain);
            if ($searchZ != null) {
                if (!preg_match("#{$searchZ}#", $domain)) {
                    continue;
                }
            }
            if ($c > $_POST["rp"]) {
                break;
            }
            $c++;
            $data['rows'][] = array('id' => "dom{$m5}", 'cell' => array("\n\t\t\t\t\t<a href=\"javascript:blur();\" \n\t\t\t\t\t\tOnClick=\"\" \n\t\t\t\t\t\tstyle='font-size:16px;font-weight:bold;text-decoration:'>{$domain}</span>", "<span style='font-size:14px'>&nbsp;</span>", imgtootltip('delete-32.png', '{delete}', "PostfixDeleteRelayRecipient{$ttime}('{$domain}','{$m5}');")));
        }
    }
    $data['page'] = 1;
    $data['total'] = $c;
    echo json_encode($data);
}