<?php
/************************************************************************
	UebiMiau is a GPL'ed software developed by 
	 - Aldoir Ventura - aldoir@users.sourceforge.net
	 - http://uebimiau.sourceforge.net São Paulo - Brasil
   		
	***********************************************************************
	Version 3.2.0 Upgrades and templates developed by
	 - Todd Henderson - Lead Developer - http://tdah.us 
	 - Dave Rodgers - Developer - http://www.manvel.net 
	 - Laurent (AdNovea) - Developer - http://adnovea.free.fr
	 
	***********************************************************************
	 - Special thanks to the developers at 
	codeworxtech.com, tinymce.moxiecode.com
	telaen.org, phptoys.com, winged.info, ngcoders.com
	without help this project wouldn't be possible 
	
	***********************************************************************
	- File:			install4.php
	- Developer: 	Todd Henderson / Mods by Laurent (AdNovea)
	- Date:			November 4, 2008
	- version:		(3.2.0) 1.0
	- Description:  Second stage in the installation

*************************************************************************/

	// Load config files
	echo "<span id=\"error_msg\"><small><font color=\"#FF0000\">"._STG3__LOAD_ERROR." <a href=\"./index.php\">"._STG5_FRONT1."</a><br></font></small></span>";
	if ($reinstall && ($_SESSION['installMode'] != "reset")) {
		require_once (RPATH_ROOT.CFG_CONFIG);
		require_once(RPATH_ROOT.CFG_MAIL);
	}
	
	// Load POP-IMAP Servers for ONE-FORE-EACH
	echo "\n<script type=\"text/javascript\" language=\"javascript\">\n";
	echo "	var js_reinstall = ".($reinstall ? "true" : "false" ).";\n";
	echo "	var js_reset_params = ".(($_SESSION['installMode'] == "reset") ? "true" : "false" ).";\n";
	echo "	var tmp_servers = new Array();\n";

	if (($_SESSION['installMode'] != "reset")) {
		$content = "";
		if (isset($mail_servers)) foreach ($mail_servers as $key => $value) $content .= implode(",",$value).",";
		$content = substr($content,0,-1); // remove last separator
		if (isset($_POST['cmail_servers'])) echo "	var js_servers = '".$_POST['cmail_servers']."';";
		else echo "	var js_servers = '$content';\n";
		echo "	tmp_servers = splitArray(js_servers);\n";
	}
	echo "\nfunction init_form() {
			document.getElementById('error_msg').style.display = 'none';
			listServers();
			if (tmp_servers.length > 0) {
				changeServers(0);
			}
		}
		</script>\n";

	if ($_SESSION['installMode'] == "reset") {
		$url = $_SERVER['SERVER_NAME'];
		$root = $url.$_SERVER['PHP_SELF'];
		$root = str_replace("install/","",$root);
		$root = str_replace("maillist","",$root);
		$root = str_replace("/admin.php","/",$root);
		$root = str_replace("/index.php","/",$root);
		$root = str_replace("/admin/","/",$root);
		$URL_site = "http://$root";
	} else 
		$URL_site = $cwebsite;
 
?>

	<form name="form1" method="post" action="index.php?stage=5&lid=<?php echo $lid; ?>">
	<input name="cdb" type="hidden" class="textboxgray"  id="cdb" value="text" size="4">
	
	
	<input type="hidden" name="ctitle" value="<?php echo $_POST['ctitle']; ?>">

	<input type="hidden" name="cdefault_mail_server" value="<?php echo $_POST['cdefault_mail_server']; ?>">
	<input type="hidden" name="csmtp_server" value="<?php echo $_POST['csmtp_server']; ?>">
	<input type="hidden" name="cuse_password_for_smtp" value="<?php echo $_POST['cuse_password_for_smtp']; ?>">
	<input type="hidden" name="csmtp_static_auth" value="<?php echo $_POST['csmtp_static_auth']; ?>">
	<input type="hidden" name="csmtp_static_user" value="<?php echo $_POST['csmtp_static_user']; ?>">
	<input type="hidden" name="cmailer_type" value="<?php echo $_POST['cmailer_type']; ?>">
	<input type="hidden" name="cmail_server_type" value="<?php echo $_POST['cmail_server_type']; ?>">
	<input type="hidden" name="csmtp_static_password" value="<?php echo $_POST['csmtp_static_password']; ?>">
	<input type="hidden" name="csmtp_server" value="<?php echo $_POST['csmtp_server']; ?>">
	
	<input type="hidden" name="callow_user_change_language" value="<?php echo $_POST['callow_user_change_language']; ?>">
	<input type="hidden" name="cdefault_language" value="<?php echo $_POST['cdefault_language']; ?>">
	<input type="hidden" name="ctimezone" value="<?php echo $_POST['ctimezone']; ?>">
	<input type="hidden" name="callow_user_change_theme" value="<?php echo $_POST['callow_user_change_theme']; ?>">
	<input type="hidden" name="cdefault_theme" value="<?php echo $_POST['cdefault_theme']; ?>">
	<input type="hidden" name="cdefault_protocol" value="<?php echo $_POST['cdefault_protocol']; ?>">
	<input type="hidden" name="cdefault_port" value="<?php echo $_POST['cdefault_port']; ?>">
	<input type="hidden" name="ccheck_first_login" value="<?php echo $_POST['ccheck_first_login']; ?>">
  <input type="hidden" name="cquota" value="<?php echo $_POST['cquota']; ?>">
	<input type="hidden" name="cmail_use_top" value="<?php echo $_POST['cmail_use_top']; ?>">
	<input type="hidden" name="cadd_signature" value="<?php echo $_POST['cadd_signature']; ?>">
	<input type="hidden" name="cdefault_sortby" value="<?php echo $_POST['cdefault_sortby']; ?>">
	<input type="hidden" name="cdefault_sortorder" value="<?php echo $_POST['cdefault_sortorder']; ?>">
	<input type="hidden" name="cenable_debug" value="<?php echo $_POST['cenable_debug']; ?>">
	<input type="hidden" name="callow_html" value="<?php echo $_POST['callow_html']; ?>">
	<input type="hidden" name="callow_modified_from" value="<?php echo $_POST['callow_modified_from']; ?>">
	<input type="hidden" name="callow_scripts" value="<?php echo $_POST['callow_scripts']; ?>">
	<input type="hidden" name="callow_filters" value="<?php echo $_POST['callow_filters']; ?>">
	<input type="hidden" name="cblock_external_images" value="<?php echo $_POST['cblock_external_images']; ?>">
	<input type="hidden" name="crequire_same_ip" value="<?php echo $_POST['crequire_same_ip']; ?>">
	<input type="hidden" name="cdefault_char_set" value="<?php echo $_POST['cdefault_char_set']; ?>">
	<input type="hidden" name="cidle_timeout" value="<?php echo $_POST['cidle_timeout']; ?>">
	<input type="hidden" name="cmail_detect_port" value="<?php echo $_POST['cmail_detect_port']; ?>">
	<input type="hidden" name="cmail_detect_prefix" value="<?php echo $_POST['cmail_detect_prefix']; ?>">
	
	<input type="hidden" name="csmtp_port" value="<?php echo $_POST['csmtp_port']; ?>">
	<input type="hidden" name="csmtp_secure" value="<?php echo $_POST['csmtp_secure']; ?>">
	<input type="hidden" name="cusername" value="<?php echo $_POST['cusername']; ?>">
	<input type="hidden" name="cpassword" value="<?php echo $_POST['cpassword']; ?>">
	<input type="hidden" id="cmail_servers" name="cmail_servers" value="<?php echo $_POST['cmail_servers']; ?>">


<!-- Tabs -->
	<table width='100%' cellpadding='0' cellspacing='0'>
	<tr>
		<td height="30" valign="bottom">
			<table width='100%' cellpadding='0' cellspacing='0'>
			<tr>
			<!-- tab 1 -->
				<td id="tab_main" class="tab_info_visible">
					<table cellpadding="0" cellspacing="0">
					<tr>
						<td><img src="images/tab_left.gif" width="2" height="21" alt=""></td>
						<td style="background-image: url('themes/default/images/tab_middle.gif');" onclick="SwitchSetupTab('main')"><nobr>
							&nbsp;<?php echo _STG3_MAIN;?>&nbsp;</nobr></td>
						<td><img src="images/tab_right.gif" width="2" height="21" alt=""></td>
					</tr>
					</table>
				</td>
			<!-- tab 2 -->
				<td id="tab_pop" class="tab_info_hidden">
					<table cellpadding="0" cellspacing="0">
					<tr>
						<td><img src="images/tab_left.gif" width="2" height="21" alt=""></td>
						<td style="background-image: url('themes/default/images/tab_middle.gif');" onclick="SwitchSetupTab('pop')"><nobr>
							&nbsp;<?php echo _STG3_POP;?>&nbsp;</nobr></td>
						<td><img src="images/tab_right.gif" width="2" height="21" alt=""></td>
					</tr>
					</table>
				</td>
			
				
			<!-- tab 4 -->
				<td id="tab_smtp" class="tab_info_hidden">
					<table cellpadding="0" cellspacing="0">
					<tr>
						<td><img src="images/tab_left.gif" width="2" height="21" alt=""></td>
						<td style="background-image: url('themes/default/images/tab_middle.gif');" onclick="SwitchSetupTab('smtp')"><nobr>
							&nbsp;<?php echo _STG3_SMTP;?>&nbsp;</nobr></td>
						<td><img src="images/tab_right.gif" width="2" height="21" alt=""></td>
					</tr>
					</table>
				</td>
			<!-- tab 5 -->
				<td id="tab_defaults" class="tab_info_hidden">
					<table cellpadding="0" cellspacing="0">
					<tr>
						<td><img src="images/tab_left.gif" width="2" height="21" alt=""></td>
						<td style="background-image: url('themes/default/images/tab_middle.gif');" onclick="SwitchSetupTab('defaults')"><nobr>
							&nbsp;<?php echo _STG3_DEFAULTS;?>&nbsp;</nobr></td>
						<td><img src="images/tab_right.gif" width="2" height="21" alt=""></td>
					</tr>
					</table>
			<!-- tab 6 -->
				<td id="tab_security" class="tab_info_hidden">
					<table cellpadding="0" cellspacing="0">
					<tr>
						<td><img src="images/tab_left.gif" width="2" height="21" alt=""></td>
						<td style="background-image: url('themes/default/images/tab_middle.gif');" onclick="SwitchSetupTab('security')"><nobr>
							&nbsp;<?php echo _STG3_EXTRAS;?>&nbsp;</nobr></td>
						<td><img src="images/tab_right.gif" width="2" height="21" alt=""></td>
					</tr>
					</table>
				</td>
			<!-- push all tabs to the left -->
				<td width='100%'>&nbsp; </td>
			</tr>
			</table>
		
		</td>				
	</tr>
	</table>



<!-- Tab divisions -->	
	<table width='100%' cellpadding='0' cellspacing='0' class="tab"  height="250">
	<tr>
		<td>
	<!-- first tab - main -->
		<div id="main" class="tab_visible">
			<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
								
			<tr bgcolor="f7f7f7" >
				<td colspan="2" style="height: 26px; background-image: url('images/bar.gif');"class="menuheader"><?php echo _STG3_MAIN; ?></td>
			</tr>
			
				<tr>
				<td style="height: 10px;" ></td>
			</tr>
				<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_MAIN3_EXP; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_TITLE; ?></td>
				<td><input name="ccompany" type="text" class="textboxgray" id="ccompany" value="<?php if ($_SESSION['installMode'] == "reset") echo 'Uebimiau Webmail'; else echo $company; ?>" size="90"></td>
			</tr>
				
				<td height="20" colspan="2"></td>
				
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_CLIENT_CONFIG; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_POP_TYPE;?></td>
				<td>
				
				<select name="cmail_server_type" id="cmail_server_type" onchange="javascript:if (this.value == 'ONE-FOR-EACH') document.getElementById('tab_popm').style.display='block'; else document.getElementById('tab_popm').style.display='none';">
				
				<option value="ONE-FOR-ALL" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($mail_server_type == 'ONE-FOR-ALL') echo '>'; else echo '>';} echo _STG3_TYPE_ONE_FOR_ALL; ?></option>
				
				<option value="ONE-FOR-EACH" <?php if (($_SESSION['installMode'] != "reset") && ($mail_server_type == 'ONE-FOR-EACH')) { echo 'selected>'; } else { echo 'selected>'; } echo _STG3_TYPE_ONE_FOR_EACH; ?></option>
				
				
				</select>
				
				
				</td>
			</tr>
			 			</table>
		</div>

	<!-- second tab - pop -->
		<div id="pop" class="tab_hidden">
			<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
			<tr bgcolor="f7f7f7">
				<td width="58%" style="height: 26px; background-image: url('images/bar.gif');"class="menuheader"><?php echo _STG3_POP;?></td>
				<td width="42%" style="background-image: url('images/bar.gif');">&nbsp;</td>
			</tr>
		
			<tr>
				<tr bgcolor="f7f7f7">
				<td width="58%" style="height: 26px;" class="menuheader"><?php echo _STG3_TITLE_ONE_FOR_ALL; ?> </td>
				<td width="42%">&nbsp;</td>
			</tr>
						<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_ONE_FOR_ALL; ?></font></div></td>
			</tr>
					
			<tr>
				<td><?php echo _STG3_POPSERVER;?></td>
				<td>
				<input name="cdefault_mail_server" type="text" class="textboxgray" id="cdefault_mail_server"  value="<?php if ($_SESSION['installMode'] == "reset") echo 'localhost'; else echo $default_mail_server; ?>" size="30"></td>
			</tr>
			<tr>
				<td><?php echo _STG3_POPPORT2;?></td>
				<td>
					<select name="cdefault_protocol" id="cdefault_protocol">
					<option value="pop3" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($default_protocol == 'pop3') echo 'selected>'; else echo '>';} echo 'pop3';?></option>
					<option value="imap" <?php if (($_SESSION['installMode'] != "reset") && ($default_protocol == 'imap')) echo 'selected>'; else echo '>'; echo 'imap';?></option>
				</select> /&nbsp;
				<input name="cdefault_port" type="text" class="textboxgray" id="cdefault_port"  value="<?php if ($_SESSION['installMode'] == "reset") echo '110'; else echo $default_port; ?>" size="5"></td>
			</tr>
			<tr>
				<td height="20" colspan="2"></td>
			</tr>

<tr bgcolor="f7f7f7">
					<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_ONE_FOR_EACH; ?></font></div></td>
			</tr>
				
				
				<td width="58%" style="height: 26px;" class="menuheader"><?php echo _STG3_TITLE_ONE_FOR_EACH; ?> </td>
		
				
				
				<td width="42%"><?php echo _STG3_POP_MSERVER;?> <input class="button" type="button" value="<?php echo _STG3_POP_ADD;?>" onclick="javascript:addServer();">&nbsp;
					<select id="select_server" onchange="javascript: changeServers(this.value);"><option></option></select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_DOMAIN_EXP3; ?></font></div></td>
			</tr>
				<tr>
					<td><?php echo _STG3_DOMAIN;?></td>
					<td><input name="ctmp_domain" type="text" class="textboxgray" id="ctmp_domain"  value="" size="30"></td>
				</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_POPSERVER_EXP3; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_POPSERVER;?></td>
				<td><input name="ctmp_server" type="text" class="textboxgray" id="ctmp_server"  value="" size="30"></td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_POPLOGINTYPE_EXP3; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_POPLOGINTYPE;?></td>
				<td><input name="ctmp_type" type="text" class="textboxgray" id="ctmp_type"  value="" size="30"></td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_POPPROTOCOL_EXP3; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_POPPROTOCOL;?></td>
				<td><input name="ctmp_protocol" type="text" class="textboxgray" id="ctmp_protocol"  value="" size="5"></td>
				
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_POPPORT_EXP3; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_POPPORT;?></td>
				<td><input name="ctmp_port" type="text" class="textboxgray" id="ctmp_port"  value="" size="5"></td>
			</tr>
			<tr>
				<td></td><td><br>
					&nbsp; 
					
					
					<input class="button" id="bt_update" type="button" value="<?php echo _STG3_POP_SAVE;?>" onclick="javascript:updateServers(document.getElementById('select_server').value,'<?php echo _STG3_POP_SAVE_OK; ?>');">
					<input class="button" id="bt_default" type="button" value="<?php echo _STG3_POP_DEFAULT;?>" onclick="javascript:setDefault();">
					<input class="button" id="bt_remove" type="button" value="<?php echo _STG3_POP_REMOVE;?>" onclick="javascript:removeServer(document.getElementById('select_server').value,'<?php echo _STG3_POP_REMOVE_OK;?>');">&nbsp; 
					&nbsp;<br><br><b><?php echo _STG3_POP_SAVE_REMIND;?></b>
				</td>
			</table>

		</div>
		
	

		
	<!-- fourth tab - smtp -->
		<div id="smtp" class="tab_hidden">
			<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
			<tr bgcolor="f7f7f7">
				<td width="58%" style="height: 26px; background-image: url('images/bar.gif')"class="menuheader"><?php echo _STG3_SMTP;?></td>
				<td width="42%" style="height: 26px; background-image: url('images/bar.gif')">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="2"><font color="#999999"><?php echo _STG3_SMTP_TYPEc; ?></font></td>
			</tr> 
			<tr>
				<td><?php echo _STG3_SMTP_TYPE;?></td>
				<td>
					<select name="cmailer_type" id="cmailer_type">
					<option value="smtp" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($mailer_type == 'smtp') echo 'selected>'; else echo '>';} echo _STG3_TYPE_SMTP;?></option>
					<option value="sendmail" <?php if (($_SESSION['installMode'] != "reset") && ($mailer_type == 'sendmail')) echo 'selected>'; else echo '>'; echo _STG3_TYPE_SENDMAIL;?></option>
					<option value="mail"<?php if (($_SESSION['installMode'] != "reset") && ($mailer_type == 'mail')) echo 'selected>'; else echo '>';echo _STG3_TYPE_PHPMAIL;?></option>
				</select>
				</td>
			</tr>
			<tr>
				<td><?php echo _STG3_SMTPSERVER;?></td>
				<td><input name="csmtp_server" type="text" class="textboxgray" id="csmtp_server"  value="<?php if ($_SESSION['installMode'] == "reset") echo 'localhost'; else echo $smtp_server?>" size="30"></td>
			</tr>
			<tr>
				<td><?php echo _STG3__SMTPPORT;?></td>
				<td><input name="csmtp_port" type="text" class="textboxgray" id="csmtp_port"  value="<?php if ($_SESSION['installMode'] == "reset") echo '25'; else echo $smtp_port?>" size="5"></td>
			</tr> 
			<tr>
				<td height="20" colspan="2"></td>
			</tr>
			<tr bgcolor="f7f7f7">
				<td width="58%" style="height: 26px; background-image: url('images/bar.gif');"class="menuheader"><?php echo _STG3_SMTPAUTH;?></td>
				<td width="42%" style="background-image: url('images/bar.gif');">&nbsp;</td>
			</tr>    
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_ADMIN_EXP2; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_AUTHENTICATION;?></td>
				<td>
					<select name="cuse_password_for_smtp" id="cuse_password_for_smtp">
					<option value="no" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($use_password_for_smtp == 0) echo 'selected>'; else echo '>';} echo _DROPDOWN_NO;?></option>
					<option value="yes"<?php if (($_SESSION['installMode'] != "reset") && ($use_password_for_smtp == 1)) echo 'selected>'; else echo '>'; echo _DROPDOWN_YES;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td><?php echo _STG3__SMTPSECURE;?></td>
				<td>
					<select name="csmtp_secure" id="csmtp_secure">
					<option value="no" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($smtp_secure == 0) echo 'selected>'; else echo '>';} echo _DROPDOWN_NO;?></option>          
					<option value="ssl "<?php if (($_SESSION['installMode'] != "reset") && ($smtp_secure == 'ssl')) echo 'selected>'; else echo '>'; echo _STG3__SMTPSECURE_SSL;?></option>
					<option value="tlc" <?php if (($_SESSION['installMode'] != "reset") && ($smtp_secure == 'tlc')) echo 'selected>'; else echo '>'; echo _STG3__SMTPSECURE_TLC;?></option>
					</select>
				</td>
			</tr> 
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_ADMIN_EXP3; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_STATICAUTHENTICATION;?></td>
				<td>
					<select name="csmtp_static_auth" id="csmtp_static_auth">
					<option value="no" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($smtp_static_auth == 0) echo 'selected>'; else echo '>';} echo _DROPDOWN_NO;?></option>
					<option value="yes" <?php if (($_SESSION['installMode'] != "reset") && ($smtp_static_auth == 1)) echo 'selected>'; else echo '>'; echo _DROPDOWN_YES;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td><?php echo _STG3_AUTH_NAME;?></td>
				<td><input name="csmtp_static_user" type="text" class="textboxgray"  id="csmtp_static_user" value="<?php if ($_SESSION['installMode'] == "reset") echo 'Smtp User Name'; else echo $smtp_static_user; ?>" size="30"></td>
			</tr>
			<tr>
				<td><?php echo _STG3_AUTH_PASSWORD;?></td>
				<td><input name="csmtp_static_password" type="text" class="textboxgray"  id="csmtp_static_password" value="<?php if ($_SESSION['installMode'] == "reset") echo 'Smtp Password'; else echo $smtp_static_user; ?>" size="30"></td>
			</tr>
			</table>
		</div>
		
	<!-- fifth tab - defaults -->
		<div id="defaults" class="tab_hidden">
			<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
			<tr bgcolor="f7f7f7">
				<td width="58%" style="height: 26px; background-image: url('images/bar.gif');"class="menuheader"><?php echo _STG3_DEFAULTS;?></td>
				<td width="42%" style="background-image: url('images/bar.gif');">&nbsp;</td>
			</tr>
			
			
				<tr>
				<td><?php echo _STG3_DEFAULT_CHARSET;?></td>
				<td><input name="cdefault_char_set" type="text" class="textboxgray"  id="cdefault_char_set" value="<?php if ($_SESSION['installMode'] == "reset") echo 'EUC-JP'; else echo $default_char_set; ?>" size="30"></td>
			</tr>
			
			
			
			
			
			
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_allow_user_change_languagec; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_allow_user_change_language;?></td>
				<td>
					<select name="callow_user_change_language" id="callow_user_change_language">
					<option value="no" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($allow_user_change_language == 0) echo 'selected>'; else echo '>';} echo _DROPDOWN_NO;?></option>
					<option value="yes" <?php if (($_SESSION['installMode'] != "reset") && ($allow_user_change_language == 1)) echo 'selected>'; else echo '>'; echo _DROPDOWN_YES;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_DEFAULT_LANGUAGEc; ?></font></div></td>
			</tr>
			
	<tr>
				<td><?php echo _STG3_add_signaturec;?></td>
				<td>
					<select name="cadd_signature" id="cadd_signature">
					<option value="no" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($add_signature == 0) echo 'selected>'; else echo '>';} echo _DROPDOWN_NO;?></option>
					<option value="yes"<?php if (($_SESSION['installMode'] != "reset") && ($add_signature == 1)) echo 'selected>'; else echo '>'; echo _DROPDOWN_YES;?></option>
					</select>
				</td>
			</tr>

<tr>
				<td><?php echo _STG3_DEFAULT_LANGUAGE; ?></td>
				<td>			
					<select name="cdefault_language" id="cdefault_language">
					<?php
						foreach($languages as $key => $lang) {
							if ($_SESSION['installMode'] == "reset") { 
								$selected = ($lid == $key)?" selected":"";
							} else {
								$selected = ($default_language == $key)?" selected":"";
							}
							echo "<option value=\"$key\"$selected>".$lang["name"]."</option>\r";
						}
					?>
					</select>
					<select name="ctimezone" id="ctimezone">
					<?php
						$gmttime = time()-date("Z");
						for($i=-12; $i<=12; $i = $i+0.5) {
							$nowgmt = $gmttime + $i*3600;
							$operator = ($i < 0)?"-":"+";
							$z = abs($i);
							$diff = $operator . sprintf("%02d",intval($z)) . sprintf("%02d",($z-intval($z))*60);
							if ($_SESSION['installMode'] == "reset") { 
								$selected = (date("Z")/3600 == $i? " selected" : "");
							} else {
								$selected = ($default_preferences['timezone_default'] == $diff ) ? " selected" : "";
							}
							echo "<option value=\"$diff\"$selected>GMT " .$diff. " (" .date("h:i A",$nowgmt). ")</option>\r";
						}
					?>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_allow_user_change_themec; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_allow_user_change_theme;?></td>
				<td>
					<select name="callow_user_change_theme" id="callow_user_change_theme">
					<option value="no" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($allow_user_change_theme == 0) echo 'selected>'; else echo '>';} echo _DROPDOWN_NO;?></option>
					<option value="yes" <?php if (($_SESSION['installMode'] != "reset") && ($allow_user_change_theme == 1)) echo 'selected>'; else echo '>'; echo _DROPDOWN_YES;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_default_themec." / ". _STG3_default_theme; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_default_theme;?></td>
				<td>
					<select name="cdefault_theme" id="cdefault_theme">
					<?php
						foreach($themes as $key => $theme) {
							if ($_SESSION['installMode'] == "reset") { 
								$selected = ($tid == $key)?" selected":"";
							} else {
								$selected = ($default_theme == $key)?" selected":"";
							}
							echo "<option value=\"$key\"$selected>".$theme["name"]."\r";
						}
					?>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_check_first_loginc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_check_first_login;?></td>
				<td>
					<select name="ccheck_first_login" id="ccheck_first_login">
					<option value="yes" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($check_first_login == 1) echo 'selected>'; else echo '>';} echo _DROPDOWN_YES;?></option>
					<option value="no" <?php if (($_SESSION['installMode'] != "reset") && ($check_first_login == 0)) echo 'selected>'; else echo '>'; echo _DROPDOWN_NO;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_use_topc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_use_top;?></td>
				<td>
					<select name="cmail_use_top" id="cmail_use_top">
					<option value="yes" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($mail_use_top == 1) echo 'selected>'; else echo '>';} echo _DROPDOWN_YES;?></option>
					<option value="no" <?php if (($_SESSION['installMode'] != "reset") && ($mail_use_top == 0)) echo 'selected>'; else echo '>'; echo _DROPDOWN_NO;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_default_sortbyc." "._STG3_default_sortorderc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_default_sortby;?></td>
				<td>
					<select name="cdefault_sortby" class="textboxgray" id="cdefault_sortby">
					<option value="date" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($default_sortby == 'date') echo 'selected>'; else echo '>';} echo _DROPDOWN_DATE; ?></option>
					<option value="subject" <?php if (($_SESSION['installMode'] != "reset") && ($default_sortby == 'subject')) echo 'selected>'; else echo '>'; echo _DROPDOWN_SUBJECT; ?></option>
					<option value="from" <?php if (($_SESSION['installMode'] != "reset") && ($default_sortby == 'from')) echo 'selected>'; else echo '>'; echo _DROPDOWN_FROM; ?></option>
					<option value="size" <?php if (($_SESSION['installMode'] != "reset") && ($default_sortby == 'size')) echo 'selected>'; else echo '>'; echo _DROPDOWN_SIZE; ?></option>
					<option value="name" <?php if (($_SESSION['installMode'] != "reset") && ($default_sortby == 'name')) echo 'selected>'; else echo '>'; echo _DROPDOWN_NAME; ?></option>
					</select>
					&nbsp;
					<select name="cdefault_sortorder" class="textboxgray" id="cdefault_sortorder">
					<option value="DESC" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($default_sortby == 'DESC') echo 'selected>'; else echo '>';} echo _DROPDOWN_DESC; ?></option>
					<option value="ASC" <?php if (($_SESSION['installMode'] != "reset") && ($default_sortby == 'ASC')) echo 'selected>'; else echo '>'; echo _DROPDOWN_ASC; ?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_enable_debugc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_enable_debug;?></td>
				<td>
					<select name="cenable_debug" id="cenable_debug">
					<option value="0" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>0'; } else { if ($enable_debug == 0) echo 'selected>0'; else echo '>0';} ?></option>
					<option value="1" <?php if (($_SESSION['installMode'] != "reset") && ($enable_debug == 1)) echo 'selected>1'; else echo '>1'; ?></option>
					<option value="2" <?php if (($_SESSION['installMode'] != "reset") && ($enable_debug == 2)) echo 'selected>2'; else echo '>2'; ?></option>
					</select>
				</td>
			</tr>
			</table>
		</div>
		
	<!-- sixth tab - security -->
		<div id="security" class="tab_hidden">
			<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
			<tr bgcolor="f7f7f7">
				<td width="58%" style="height: 26px; background-image: url('images/bar.gif');"class="menuheader"><?php echo _STG3_EXTRAS;?></td>
				<td width="42%" style="background-image: url('images/bar.gif');">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_QUOTA_EXP; ?></font></div></td>
			</tr>
	<tr>
				<td><?php echo _STG3_QUOTA; ?></td>
				<td><input name="cquota" type="text" class="textboxgray" id="cquota" value="<?php if ($_SESSION['installMode'] == "reset") echo '0'; else echo $quota_limit; ?>" size="10"> <?php echo _STG3_QUOTA_UNIT; ?></td>
			</tr>
<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_allow_htmlc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_allow_html;?></td>
				<td>
					<select name="callow_html" id="callow_html">
					<option value="yes" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($allow_html == 1) echo 'selected>'; else echo '>';} echo _DROPDOWN_YES; ?></option>
					<option value="no" <?php if (($_SESSION['installMode'] != "reset") && ($allow_html == 0)) echo 'selected>'; else echo '>'; echo _DROPDOWN_NO;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_allow_modified_fromc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_allow_modified_from;?></td>
				<td>
					<select name="callow_modified_from" id="callow_modified_from">
					<option value="yes" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($allow_modified_from == 1) echo 'selected>'; else echo '>';} echo _DROPDOWN_YES;?></option>
					<option value="no" <?php if (($_SESSION['installMode'] != "reset") && ($allow_modified_from == 0)) echo 'selected>'; else echo '>'; echo _DROPDOWN_NO;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_allow_scriptsc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_allow_scripts;?></td>
				<td>
					<select name="callow_scripts" id="callow_scripts">
					<option value="no" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($allow_scripts == 0) echo 'selected>'; else echo '>';} echo _DROPDOWN_NO;?></option>
					<option value="yes" <?php if (($_SESSION['installMode'] != "reset") && ($allow_scripts == 1)) echo 'selected>'; else echo '>'; echo _DROPDOWN_YES;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_allow_filtersc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_allow_filters;?></td>
				<td>
					<select name="callow_filters" id="callow_filters">
					<option value="yes" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($allow_filters == 1) echo 'selected>'; else echo '>';} echo _DROPDOWN_YES;?></option>
					<option value="no" <?php if (($_SESSION['installMode'] != "reset") && ($allow_filters == 0)) echo 'selected>'; else echo '>'; echo _DROPDOWN_NO;?></option>
					</select>
			</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_block_external_imagesc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_block_external_images;?></td>
				<td>
					<select name="cblock_external_images" id="cblock_external_images">
					<option value="no" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($block_external_images == 0) echo 'selected>'; else echo '>';} echo _DROPDOWN_NO;?></option>
					<option value="yes" <?php if (($_SESSION['installMode'] != "reset") && ($block_external_images == 1)) echo 'selected>'; else echo '>'; echo _DROPDOWN_YES;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_require_same_ipc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_require_same_ip;?></td>
				<td>
					<select name="crequire_same_ip" id="crequire_same_ip">
					<option value="no" <?php if ($_SESSION['installMode'] == "reset") { echo 'selected>'; } else { if ($require_same_ip == 0) echo 'selected>'; else echo '>';} echo _DROPDOWN_NO;?></option>
					<option value="yes" <?php if (($_SESSION['installMode'] != "reset") && ($require_same_ip == 1)) echo 'selected>'; else echo '>'; echo _DROPDOWN_YES;?></option>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2"><div align="left" class="f8"><font color="#999999"><?php echo _STG3_idle_timeoutc; ?></font></div></td>
			</tr>
			<tr>
				<td><?php echo _STG3_idle_timeout;?></td>
				<td><input name="cidle_timeout" type="text" class="textboxgray"  id="cidle_timeout" value="<?php if ($_SESSION['installMode'] == "reset") echo '30'; else echo $idle_timeout; ?>" size="4">&nbsp; <?php echo _STG3_MINUTES;?></td>
			</tr>
		
			
				<!-- Validation -->
			<tr>
			<?php if (!$reinstall) { ?>
				<td colspan="2">
					<div align="left" class="f8"><font color="#999999"><?php echo _STG3_admin_account; ?></font></div>
				</td>
			</tr>
			<tr>
				<td><?php echo _STG_USERNAME; ?></td><td><input class="textboxgray" id="xusername" name="cusername" type="text" size="15" value="admin"></td>
			</tr>
			<tr>
				<td><?php echo _STG_PASSWORD." / "._STG3_CONFIRM; ?></td><td>
					<input class="textboxgray" id="xpassword" name="cpassword" type="password" size="15">&nbsp;/&nbsp;
					<input class="textboxgray" id="xconfirm" name="cconfirm" type="password" size="15">
				</td>
			</tr>
			<tr>
				<td colspan="2" align="right">
			<?php } else { ?>
				<td colspan="2" align="right">
			<?php } 
					echo "<a href=\"javascript:sendData('"._STG3_PWD_NOTVALID."');\" class=\"menulink\">"._STG_CONTINUE."</a>"; ?>
				</td>
			</tr>
			
			</table>
		</div>

		<td>
	</table>
	</form>
	<script type="text/javascript" language="javascript">init_form();</script>
