Example #1
0
<?php

if (posix_getuid() != 0) {
    die("Cannot be used in web server mode\n\n");
}
include_once dirname(__FILE__) . '/ressources/class.templates.inc';
$sock = new sockets();
echo "<port>" . $sock->RandomPort() . "</port>\n";
die;
Example #2
0
function stunnel(){
$page=CurrentPageName();
$sock=new sockets();

$stunnel=new stunnel4();
$relay_host=$stunnel->main_array["postfix_relayhost"]["connect"];
$localport=$stunnel->main_array["postfix_relayhost"]["accept"];

if(!is_numeric($localport)){
	$sock=new sockets();
	$localport=$sock->RandomPort();
	}
	



$sTunnel4enabled=$sock->GET_INFO('sTunnel4enabled');
$enable=Paragraphe_switch_img('{enable_stunnel}',"{enable_stunnel_text}",'enable_stunnel',$sTunnel4enabled);

$intro="
<div id='ssltunnelid'>
	<table style='width:100%' align=center>
	<tr>
		<td valign='top'>
			<img src='img/postfix-relayhost-ssl-bg.png' style='padding:4px;border:1px dotted #CCCCCC;margin:3px'>
		</td>
		<td valign='top' width='99%'>
			<div id='servinfos_stunnel'></div>
		</td>
	</tr>
		<tr><td colspan=2><p class=explain>{smtps_relayhost_text}</div></td></tr>
	</table>
	<br>
	
	<table style='width:100%' class=form>
	<tr>
		<td class=legend style='font-size:14px'>{enable_stunnel}</td>
		<td>". Field_checkbox("enable_stunnel",1,$sTunnel4enabled)."</td>
		<td>". help_icon("{enable_stunnel_text}")."</td>
	</tr>
	<tr>
		<td align='right' nowrap style='font-size:14px'><strong>{stunnelport}:&nbsp;</strong></td>
		<td><input type='text' id='localport' value='$localport' style='font-size:14px;width:30%'></td>
		<td>&nbsp;</td>
	</tr>	
	<tr>
		<td colspan=3 align='right'><hr>". button('{apply}',"StunnelApply()")."</td>
	</tr>
	</table>
</div>
<script>

	function x_StunnelApply(obj) {
		var tempvalue=obj.responseText;
		if(tempvalue.length>0){alert(tempvalue);}
		RefreshTab('main_config_postfix_relayssl');
	}

	function StunnelApply(){
		var XHR = new XHRConnection();
		if(document.getElementById('enable_stunnel').checked){
			XHR.appendData('enable_stunnel',1);
		}else{
			XHR.appendData('enable_stunnel',0);
		}
		
		XHR.appendData('localport',document.getElementById('localport').value);
		document.getElementById('ssltunnelid').innerHTML=\"<center style='width:400px'><img src='img/wait_verybig.gif'></center>\";
		XHR.sendAndLoad('$page', 'GET',x_StunnelApply);	
	}

	LoadAjax('servinfos_stunnel','$page?stunnel-status=yes&hostname={$_GET["hostname"]}');
</script>


";	


$html="$intro";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);

}
Example #3
0
function sub_page()
{
    $main = new main_cf();
    $stunnel = new stunnel4();
    $relay_host = $stunnel->main_array["postfix_relayhost"]["connect"];
    $localport = $stunnel->main_array["postfix_relayhost"]["accept"];
    $apply = applysettingsGeneral('apply', 'relayssl_start()', 'apply_text', true);
    $main = new main_cf();
    $sock = new sockets();
    $sTunnel4enabled = $sock->GET_INFO('sTunnel4enabled');
    preg_match('#(.+?):([0-9]+)#', $relay_host, $h);
    //$relayhost=$main->main_array["relayhost"];
    $sasl = new smtp_sasl_password_maps();
    preg_match('#(.+?):(.+)#', $sasl->smtp_sasl_password_hash[$h[1]], $ath);
    if ($localport == null) {
        $sock = new sockets();
        $localport = $sock->RandomPort();
    }
    if ($h[2] == null) {
        $h[2] = 465;
    }
    $form = "\n<table style='width:100%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align='right' nowrap style='font-size:14px'><strong>{yserver}:&nbsp;</strong></td>\n\t\t\t\t\t<td><input type='text' id='server' value='{$h[1]}' style='font-size:14px'></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align='right' nowrap style='font-size:14px'><strong>{yport}:&nbsp;</strong></td>\n\t\t\t\t\t<td><input type='text' id='port' value='{$h[2]}' style='font-size:14px;width:30%'></td>\n\t\t\t\t</tr>\t\t\t\t\n\t\t\t</table>\n\n";
    $artica = new artica_general();
    $enable = Paragraphe_switch_img('{enable_stunnel}', "{enable_stunnel_text}", 'enable_stunnel', $sTunnel4enabled);
    $form1 = "\n<table style='width:100%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align='right' nowrap style='font-size:14px'><strong>{stunnelport}:&nbsp;</strong></td>\n\t\t\t\t\t<td><input type='text' id='localport' value='{$localport}' style='font-size:14px;width:30%'></td>\n\t\t\t\t</tr>\t\t\t\n\t\t\t</table>\n\n";
    $form2 = "\n<table style='width:100%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align='right' nowrap style='font-size:14px'><strong><u>" . texttooltip("{smtp_sender_dependent_authentication}", "{smtp_sender_dependent_authentication_tooltip}", "smtp_sender_dependent_authentication()") . "</u>:&nbsp;</strong></td>\n\t\t\t\t\t<td>" . Field_yesno_checkbox('smtp_sender_dependent_authentication', $main->main_array["smtp_sender_dependent_authentication"]) . "</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t\t<div id='peruser'>\n\t\t\t<table style='width:100%'>\n\t\t\t\t<tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align='left' nowrap style='font-size:16px' colspan=2><strong>{single_auth}:</strong>\n\t\t\t\t</tr>\n\t\t\t\t\n\t\t\t\t\t<td align='right' nowrap style='font-size:14px'><strong>{username}:&nbsp;</strong></td>\n\t\t\t\t\t<td><input type='text' id='username' value='{$ath[1]}' style='font-size:14px'></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align='right' nowrap style='font-size:14px'><strong>{password}:&nbsp;</strong></td>\n\t\t\t\t\t<td><input type='text' id='password' value='{$ath[2]}' style='font-size:14px;'></td>\n\t\t\t\t</tr>\t\t\t\t\n\t\t\t</table>\n\t\t</div>\n\n";
    $form = "<br>" . RoundedLightWhite($form);
    $form1 = "<br>" . RoundedLightWhite($form1);
    $form2 = "<br>" . RoundedLightWhite($form2);
    return "\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top'>\n\t\t\t\t<table style='width:100%'>\n\t\t\t\t<tr " . CellRollOver("stunnelSwitchdiv('stunnel_relayhost')") . ">\n\t\t\t\t<td valign='top' width=1%><img src='img/chiffre1_32.png'></td>\n\t\t\t\t<td valign='top' width=99%><span style='font-size:13px;font-weight:bold'>{relayhost}</span>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2>\n\t\t\t\t\t\t<div id='stunnel_relayhost'>\t\t\t\t\n\t\t\t\t\t\t<p class=caption>{relayhost_text}</p>\n\t\t\t\t\t\t{$form}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr><td colspan=2><hr></tr>\n\t\t\t\t<tr " . CellRollOver("stunnelSwitchdiv('stunnel_relayport')") . ">\n\t\t\t\t<td valign='top' width=1%><img src='img/chiffre2_32.png'></td>\n\t\t\t\t<td valign='top' width=99%><span style='font-size:13px;font-weight:bold'>{stunnelport}</span></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t<td colspan=2>\n\t\t\t\t\t\t<div id='stunnel_relayport' style='width:0px;height:0px;visibility:hidden'>\n\t\t\t\t\t\t<p class=caption>{stunnelport_text}</p>\n\t\t\t\t\t\t{$form1}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\t\n\t\t\t\t<tr><td colspan=2><hr></tr>\n\t\t\t\t<tr " . CellRollOver("stunnelSwitchdiv('stunnel_auth')") . ">\n\t\t\t\t<td valign='top' width=1%><img src='img/chiffre3_32.png'></td>\n\t\t\t\t<td valign='top' width=99%><span style='font-size:13px;font-weight:bold'>{authentication}</span></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t<td colspan=2>\n\t\t\t\t\t\t<div id='stunnel_auth' style='width:0px;height:0px;visibility:hidden'>\n\t\t\t\t\t\t<p class=caption>{authentication_text}</p>\n\t\t\t\t\t\t{$form2}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\t\t\n\t\t\t\t</table>\n\t\t</td>\n\t\t<td valign='top'>{$enable}<br>{$apply}<br></td>\n\t\t\n\t</tr>\n\t</table>\n\t\n\t\n\t";
}