<?php

//////////////////////////////////////////////////////////////
//===========================================================
// editdetail_theme.php
//===========================================================
// SOFTACULOUS 
// Version : 1.1
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       10th Jan 2009
// Time:       21:00 hrs
// Site:       http://www.softaculous.com/ (SOFTACULOUS)
// ----------------------------------------------------------
// Please Read the Terms of use at http://www.softaculous.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Inc.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('SOFTACULOUS')){

	die('Hacking Attempt');

}


function editdetail_theme(){

global $user, $globals, $l, $theme, $softpanel, $iscripts, $catwise, $error, $edit, $settings;
global $insid, $edited, $software, $soft, $scripts, $version_updated, $account_details_editable, $no_autoupgrade, $add_to_fileindex, $__settings, $default_fileindex, $pfx_error, $owned_themes, $full_tables, $default_tables, $no_autoupgrade_acl, $notes, $act;

// For update theme and plugins ajax call
if(optGET('upgradenow')){
	
	// It was not successful
	if(!empty($error)){
		echo '0'.current($error);
		return false;
	}
	
	// It was successful
	if(!empty($edited)){
		
		if(!empty($_REQUEST['upgradeplugins'])){
			$successmsg = __('Plugin(s) Upgraded Successfully!!');
		}
		
		if(!empty($_REQUEST['upgradetheme'])){
			$successmsg = __('Theme Upgraded Successfully!!');
		}
		
		echo '1'.$successmsg;
		return true;
	}
}

softheader(__('$0 - Edit Detail', array($globals['sn'])));

echo '<script language="javascript" type="text/javascript"><!-- // --><![CDATA[

var message_box = function(){			
	return {
		show_message: function(title, body , image) {			
			var okbutton = \'<input  style="width:75px; margin-top:5px; background:#00A0D2; color:#FFF;" class="sai_submit" type="button" onclick="message_box.close_message();" value="OK" />\';
			if(image == "1"){
				var img = \'<img src="'.$theme['images'].'error.gif" />\';
			}else{
				var img = \'<img src="'.$theme['images'].'confirm.gif" />\';			
			}
								
			if(jQuery(\'.sai_message_box\').html() === null || jQuery(\'.sai_message_box\').html() === undefined ) {
				var message = \'<div class="sai_message_box"><table border="0" cellpadding="8" width="100%" height="100%"><tr ><td rowspan="2" width="30%" > \'+ img + \'</td><td width="70%" class ="msg_tr1">\' +  title + \'</td></tr><tr class ="msg_tr2"><td style="text-align:left">\' + body + \'</td></tr><tr ><td colspan="2">\' + okbutton + \'</td></tr></table></div>\';
				jQuery(document.body).append( message );								
				jQuery(\'.sai_message_box\').css(\'top\', jQuery(\'html, body\').scrollTop() + 150);
				jQuery(\'.sai_message_box\').show(\'slow\');
			}else{
				var message =\' <table border="0" width="100%" cellpadding="8" height="100%"><tr ><td rowspan="2" width="30%">\'+ img +  \'</td><td widt="70%" class ="msg_tr1">\' + title + \'</td></tr><tr class ="msg_tr2"><td style="text-align:left">\' + body + \'</td></tr><tr ><td colspan="2">\' + okbutton + \'</td></tr></table>\';				
				jQuery(\'.sai_message_box\').css(\'top\', jQuery(\'html, body\').scrollTop() + 150);
				jQuery(\'.sai_message_box\').show(\'slow\');
				jQuery(\'.sai_message_box\').html( message );
			}
		},
		close_message: function() {
			jQuery(\'.sai_message_box\').hide(\'fast\');
		}
	}
}();

$(document).ready(function(){
		
	// For Plugins Upgrade
	$("#plugins_upgrade").click(function(){
		
		$("#upgradeplugins").val(1);
		$("#plugins_upgrade_gif").css("display", "");
		
		return upgradenow("plugins");
													
	});

	// For Theme Upgrade
	$("#theme_upgrade").click(function(){
		
		$("#upgradetheme").val(1);
		$("#theme_upgrade_gif").css("display", "");
		
		return upgradenow("theme");
													
	});
	
	$("#issue_softwp_license").click(function(){
		
		insid = $("#issue_softwp_license").attr("insid");
		
		document.querySelector(".issue_softwp_license").innerHTML = \'<a><img src="' . $theme['images'] . 'load.gif" alt="' . __js('Installing') . '" width="25" ></a>\';
		document.querySelector("#issue_softwp_license").disabled = true;

		var csrf_token = $("#csrf_token").val();

		$.ajax({
			type: "GET",
			data: {
				"insid":insid,
				"csrf_token":csrf_token,
				"issue_prod_license":"1",
				},
			url: "' . $globals['index'] . 'act=editdetail&api=json",
			success: function(data){
				var resp = JSON.parse(data.trim());
				if(!resp.done){
					if(resp.error){
						alert(Object.values(resp.error).join("\n"));
					}else{
						alert("' . __js('Some error occurred') . '");
					}
					resp = false;
					//console.log(resp.error);
				}
				else{
					if(resp.userins.softaculous_pro_license){
						document.querySelector(".issue_softwp_license").innerHTML = resp.userins.softaculous_pro_license + "&nbsp;&nbsp;&nbsp;";
					}
					resp = resp.done;
					document.querySelector("#issue_softwp_license").disabled = false;
					document.querySelector("#issue_softwp_license").value = "'.__js('Regenerate SoftWP License').'";
				}
			}
		});
	});
});

function upgradenow(action){
	$.ajax({
		type: "POST",
		url: window.location+"&upgradenow=1",					
		data: $("#editsettings").serialize(),
		
		// Checking for error
		success: function(data){
			
			$("#" + action + "_upgrade_gif").css("display", "none");
			
			// Reset the button so it is not submitted next time
			$("#upgrade" + action).val(0);
			
			var result = data.trim().substring(0,1);
			if(result == "1"){
				var msg = data.trim().substring(1);
				message_box.show_message( "'.__js('Done').'", msg, 2);
			}
			if(result == "0"){
				var msg = data.trim().substring(1);
				message_box.show_message( "'.__js('Error').'", msg, 1);
			}
		},
		error: function() {
			message_box.show_message("Error", "Oops ... the connection was lost", 1);
		}													
	});
	
	return false;
}
// ]]></script>';

echo '
<script language="javascript" type="text/javascript"><!-- // --><![CDATA[

// show/hide backup options
function show_backup(){
	try{
		var auto_backup = $("#auto_backup").val();
		if(auto_backup == 0){
			$("#auto_backup_rotation").prop("disabled", true);
			$("#custom_autobackup_cron").css("display", "none");
		}else{
			if(auto_backup == "custom"){
				$("#custom_autobackup_cron").css("display", "block");
			}else{
				$("#custom_autobackup_cron").css("display", "none");
			}				
			$("#auto_backup_rotation").prop("disabled", false);
		}
		
	}catch(e){
		//
	}
	return true;
};

function toggle_advoptions(ele){
	//alert("#"+ele);
	if ($("#"+ele).is(":hidden")){
		$("#"+ele).slideDown("slow");
		$("#advoptions_toggle_plus").attr("class", "fas fa-minus-square");
	}
	else{
		$("#"+ele).slideUp("slow");
		$("#advoptions_toggle_plus").attr("class", "fas fa-plus-square");
	}

}

function plus_onmouseover(ele){
	$("#"+ele.id+"_plus").attr("src", "'.$theme['images'].'plus_hover.gif");
}

function plus_onmouseout(ele){
	$("#"+ele.id+"_plus").attr("src", "'.$theme['images'].'plus.gif");
}

$(document).ready(function() {
	$("#editfiles tr").click(function(event) {
		if (event.target.type !== "checkbox") {
		  $(":checkbox", this).trigger("click");
		}
	});
});

'.(!empty($_POST) ? '' : 'addonload(\'show_backup();\');').'

// ]]></script>';

$width_size = 65;

if(!empty($softpanel->leftpanel_resize)){
	$width_size = 40;
}

if(!empty($edited)){

	$return = '';
	$role = '';

	if(can_wordpress_manager($soft)){
		$return .= '<a role="button" href="'.$globals['ind'].'act=wordpress&insid='.$insid.'"><span class="btn btn-outline-primary">'.__('Return to WordPress Management').'</span></a>&nbsp';
		
		$role = 'role="button"';
	}

	$return .= '<a '.$role.' href="'.script_link($soft).'&highlight='.$insid.'&postact=edit"><span class="btn btn-outline-primary">'.__('Return to Overview').'</span></a>';
	
	//Filter to customize the return to link
	$return = apply_filters('return_link', $return, $act);
	
	echo '
	<div class="bg"><br />
		<div class="alert alert-success"><center>'.__('The installation details were edited successfully').'</center></div><br />';
		
		if(!empty($notes)){
			echo __('The following are some important notes. It is highly recommended that you read them ').' : <br />
			<div class="sai_notes">'.softparse($notes, $soft).'</div><br />';
		}
		
		if(!empty($pfx_error)){
			error_handle($pfx_error, "100%");
		}
			
	echo '<br /><center>'.$return.'</center><br />
	</div><!--end of bg-->';
}else{

	$return = '';
	$role = '';

	if(can_wordpress_manager($soft)){
		$return .= '<a role="button" href="'.$globals['ind'].'act=wordpress&insid='.$insid.'"><span class="btn btn-outline-primary">'.__('Return to WordPress Management').'</span></a>&nbsp';
		
		$role = 'role="button"';
	}

	$return .= '<a '.$role.' href="'.script_link($soft).'"><span class="btn btn-outline-primary">'.__('Return to Overview').'</span></a>';
	
	//Filter to customize the return to link
	$return = apply_filters('return_link', $return, $act);
	
	echo '
	<form accept-charset="'.$globals['charset'].'" name="editsettings" id="editsettings" method="post" action="" class="form-horizontal">
		<div class="bg"><br />
			<div class="row sai_main_head mt-8 mb-4">
			
				<div class="col-12 text-center">
					<i class="fas fa-pencil-alt fa-1x mr-2" style="color:#00A0D2;"></i>
					<span class="form-title">'.__('Edit Installation Details').'</span>
				</div>
			</div>';
			
			error_handle($error, '100%');
			
			if(!empty($version_updated)){
				echo '<div class="alert alert-warning m-3" align="center">
					<a href="#close" class="close" data-dismiss="alert" aria-label="close">&times;</a>'.__('The version has been updated in our records.').'</div>';
			}

			echo (!empty($GLOBALS['alreadyupdated']) ? '
				<form accept-charset="'.$globals['charset'].'" method="post" name="uprec" id="uprec" action="">
					<center class="alert alert-warning m-3">
						<a href="#close" class="close" data-dismiss="alert" aria-label="close">&times;</a>
						<a href="'.$globals['index'].'act=editdetail&insid='.$insid.'&updateversion=1" style="text-decoration:none;"><img src="'.$theme['images'].'notice.gif" /> &nbsp; '.__('Hmm ... it looks like the actual version of the installation is <b>$0</b> and not <b>$1</b>. <br />Click here to update $2 records.', array($GLOBALS['alreadyupdated'], $user['ins'][$insid]['ver'], APP)).'</a>
					</center>
					'.csrf_display().'
				</form>' : '');

			echo '
			<div class="card m-3 p-3 admin-settings">
				<div class="sai_sub_head">'.__('Installation Details').'</div>
				<hr class="sai_main_head_hr">
				<div class="row">';
		
				if(empty($globals['hide_directory_url'])){
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="edit_dir" class="sai_head mb-2">'.__('Directory').'</label><br />
						<input type="text" name="edit_dir" id="edit_dir" class="form-control" value="'.POSTval('edit_dir', $user['ins'][$insid]['softpath']).'" size="'.$width_size.'" />
					</div>	
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="edit_url" class="sai_head mb-2">'.__('URL').'</label>
						<input type="text" name="edit_url" id="edit_url" class="form-control" value="'.POSTval('edit_url', $user['ins'][$insid]['softurl']).'" size="'.$width_size.'" />
					</div>';
				}
				
				// Web directory @since 3.5
				if(!empty($user['ins'][$insid]['wwwdir'])){
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="edit_wwwdir" class="sai_head mb-2">'.__('Web Directory').'</label><br />
						<input type="text" name="edit_wwwdir" id="edit_wwwdir" class="form-control" value="'.POSTval('edit_wwwdir', $user['ins'][$insid]['wwwdir']).'" size="'.$width_size.'" />
					</div>';
				}
				
				// Web directory URL @since 3.5
				if(!empty($user['ins'][$insid]['wwwurl'])){
				
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="edit_wwwurl" class="sai_head mb-2">'.__('Web Directory URL').'</label><br />
						<input type="text" name="edit_wwwurl" id="edit_wwwurl" class="form-control" value="'.POSTval('edit_wwwurl', $user['ins'][$insid]['wwwurl']).'" size="'.$width_size.'" />
					</div>';
				}
				
				// Data directory ?
				if(!empty($user['ins'][$insid]['softdatadir'])){
				
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="edit_datadir" class="sai_head mb-2">'.__('Data Directory').'</label><br />
						<input type="text" name="edit_datadir" id="edit_datadir" class="form-control" value="'.POSTval('edit_datadir', $user['ins'][$insid]['softdatadir']).'" size="'.$width_size.'" />
					</div>';
				}
			
				if(!empty($user['ins'][$insid]['softdb'])){
					
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="edit_db" class="sai_head mb-2">'.__('Database Name').'</label>
						<input type="text" name="edit_dbname" id="edit_db" class="form-control" value="'.POSTval('edit_dbname', $user['ins'][$insid]['softdb']).'" size="'.$width_size.'" />
					</div>';
				}
				
				if(!empty($user['ins'][$insid]['softdbuser'])){
				
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="edit_dbuser" class="sai_head mb-2">'.__('Database User').'</label><br />
						<input type="text" name="edit_dbuser" id="edit_dbuser" class="form-control" value="'.POSTval('edit_dbuser', $user['ins'][$insid]['softdbuser']).'" size="'.$width_size.'" />
					</div>';
				}
			
				if(!empty($user['ins'][$insid]['display_softdbpass'])){
				
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="edit_dbpass" class="sai_head mb-2">'.__('Database Password').'</label>
						'.((!empty($globals['no_prefill_pass'])) ? '<span class="sai_exp">'.__('New Database Password. <br/>Leave blank if you do not want to update the password').'</span>' : '').'
						<div class="row">
							<div class="col-sm-11">
								<input type="password" name="edit_dbpass" id="edit_dbpass" class="form-control" value="'.aPOSTval('edit_dbpass', (empty($globals['no_prefill_pass']) ? htmlizer($user['ins'][$insid]['softdbpass']) : '')).'" size="'.$width_size.'" autocomplete="new-password" />
							</div>
							<div class="col-sm-1" style="margin-left:-20px;">
								<input id="toggle_pass_dbpass" type="checkbox" style="display:none;" onclick="toggle_pass(\'show_hide_dbpass\', \'edit_dbpass\');"/><label for="toggle_pass_dbpass" style="margin-top:6px;"><span id="show_hide_dbpass">'.__('Show').'</span></label>
							</div>
						</div>
					</div>';
				}
				
				if(!empty($user['ins'][$insid]['softdbhost'])){
				
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="edit_dbhost" class="sai_head mb-2">'.__('Database Host').'</label><br />
						<input type="text" name="edit_dbhost" class="form-control" id="edit_dbhost" value="'.aPOSTval('edit_dbhost', $user['ins'][$insid]['softdbhost']).'" size="'.$width_size.'" />
					</div>';
				}
				
				echo '
				<div class="col-sm-6 col-xs-12 mb-2">';
				
				//Do not show 'disable update notifications' option if both 'Turn off all Emails sent to endusers' and 'Disable End User Update E-Mails' or either is enabled in Admin Panel
				if(empty($globals['off_email_link']) && empty($globals['eu_email_off'])){
					echo '
					<div>
						<input type="checkbox" class="mr-1 mb-0" name="disable_notify_update" id="disable_notify_update" '.POSTchecked('disable_notify_update', $user['ins'][$insid]['disable_notify_update']).' />
						<label for="disable_notify_update" class="sai_head mb-2">'.__('Disable Update Notifications Emails').'</label>
						<span class="sai_exp">'.__('If checked you will not receive an email notification for updates available for this installation.').'</span>
					</div>';
				}
				
				if(empty($globals['off_upgrade_plugins']) && !empty($software['update_plugins'])){
					echo '
					<div>
						<input type="checkbox" name="auto_upgrade_plugins" class="mr-1 mb-0" id="auto_upgrade_plugins" id="auto_upgrade_plugins" '.POSTchecked('auto_upgrade_plugins', (!empty($globals['force_upgrade_plugins']) ? $globals['force_upgrade_plugins'] : $user['ins'][$insid]['auto_upgrade_plugins'])).(!empty($globals['force_upgrade_plugins']) ? 'disabled' : '').' />
						
						<label for="auto_upgrade_plugins" class="sai_head mb-2">'.__('Auto Upgrade $0 Plugins', array($software['name'])).'</label>
						<span class="sai_exp">'.__('If checked, all $0 plugins installed for this installation will be automatically upgraded to the latest version (every 24 hours).', array($software['name'])).'</span>
					</div>';
				}
			
				if(empty($globals['off_upgrade_themes']) && !empty($software['update_themes'])){
					echo '
					<div>
						<input type="checkbox" class="mr-1 mb-0" name="auto_upgrade_themes" id="auto_upgrade_themes" '.POSTchecked('auto_upgrade_themes', (!empty($globals['force_upgrade_themes']) ? $globals['force_upgrade_themes'] : $user['ins'][$insid]['auto_upgrade_themes'])).(!empty($globals['force_upgrade_themes']) ? 'disabled' : '').' />
						
						<label for="auto_upgrade_themes" class="sai_head mb-2">'.__('Auto Upgrade $0 Themes', array($software['name'])).'</label>
						<span class="sai_exp">'.__('If checked, all $0 themes for this installation will be automatically upgraded to the latest version (every 24 hours).', array($software['name'])).'</span>
					</div>';
				}
				
				echo '
				</div>
				<div class="col-sm-6 col-xs-12 mb-2">
				<div class="row">';
					
				if(empty($globals['off_upgrade_plugins']) && !empty($software['update_plugins'])){
					echo '
					<div class="col-sm-6 col-xs-12 mb-2" style="text-align:center;">
						<input type="hidden" name="upgradeplugins" id="upgradeplugins" />
						<input id="plugins_upgrade" class="btn sai-button" name="plugins_upgrade" value="'.__('Upgrade Plugin(s) Now').'" type="button">
						<img id="plugins_upgrade_gif" src="'.$theme['images'].'progress.gif" style="display:none">
					</div>';
				}
				
				if(empty($globals['off_upgrade_themes']) && !empty($software['update_themes'])){
					echo '
					<div class="col-sm-6 col-xs-12" style="text-align:center;">
						<input type="hidden" name="upgradetheme" id="upgradetheme" />
						<input id="theme_upgrade" class="btn sai-button" name="theme_upgrade" value="'.__('Upgrade Theme Now').'" type="button">
						<img id="theme_upgrade_gif" src="'.$theme['images'].'progress.gif" style="display:none">
					</div>';
				}
				
				echo '
				</div>
				</div>';
				
				if(!empty($scripts[$soft]['auto_upgrade']) && empty($no_autoupgrade) && empty($no_autoupgrade_acl)){
					
					$user['ins'][$insid]['eu_auto_upgrade'] = (int) $user['ins'][$insid]['eu_auto_upgrade'];
					
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="eu_auto_upgrade" class="sai_head mb-2">'.__('Auto Upgrade').'</label>
						<span class="sai_exp">'.__('Select the automatic upgrade preference for this installation when a new version is available').'</span>
						<br />
						<input type="radio" class="mr-1" name="eu_auto_upgrade" id="eu_auto_upgrade_0" value="0" '.POSTradio('eu_auto_upgrade', 0, $user['ins'][$insid]['eu_auto_upgrade']).(!empty($globals['force_auto_upgrade']) ? 'disabled' : '').' /> 
						<label for="eu_auto_upgrade_0" class="radio-title">'.__('Do not Auto Upgrade').'</label> <br />
						
						'.(!empty($software['has_minor']) ? '<input type="radio" class="mr-1" name="eu_auto_upgrade" id="eu_auto_upgrade_2" value="2" '.POSTradio('eu_auto_upgrade', 2, $user['ins'][$insid]['eu_auto_upgrade']).(!empty($globals['force_auto_upgrade']) ? 'disabled' : '').' /> <label for="eu_auto_upgrade_2" class="radio-title">'.__('Upgrade to <b>Minor</b> versions only').'</label><br />' : '').'
						
						<input type="radio" class="mr-1" name="eu_auto_upgrade" id="eu_auto_upgrade_1" value="1" '.POSTradio('eu_auto_upgrade', 1, (!empty($globals['force_auto_upgrade']) ? $globals['force_auto_upgrade'] : $user['ins'][$insid]['eu_auto_upgrade'])).(!empty($globals['force_auto_upgrade']) ? 'disabled' : '').' /> <label for="eu_auto_upgrade_1" class="radio-title">'.__('Upgrade to any latest version available (<b>Major</b> as well as <b>Minor</b>)').'</label>
					</div>';
				}
				
				if(empty($globals['off_rbackup']) && empty($globals['disable_backup_restore'])){
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="backup_location" class="sai_head mb-2">'.__('Backup Location').'</label>
						<span class="sai_exp">'.__('Choose the backup location to be used while backing up this installation').'</span>	
					
						<select name="backup_location" class="form-control" id="backup_location">
									<option value="0" '.POSTselect('backup_location', 0, (empty($user['ins'][$insid]['backup_location']) ? '1' : '0')).'>'.__('Default').'</option>';
									if(empty($globals['disable_local_backup'])){
										echo '<option value="-1" '.POSTselect('backup_location', -1, ($user['ins'][$insid]['backup_location'] == -1 ? '1' : '0')).'>'.__('Local Folder').'</option>';
									}
							foreach($user['remote_backup_locs'] as $k => $v){
								echo '<option value="'.$k.'" '.POSTselect('backup_location', $k, ($user['ins'][$insid]['backup_location'] == $k ? '1' : '0')).'>'.$v['name'].'</option>';
							}
						echo '</select>
					</div>';
				}
		
				if(empty($globals['disable_backup_restore']) && empty($globals['disable_auto_backup'])){
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="auto_backup" class="sai_head mb-2">'.__('Automated backups').'</label>
						<span class="sai_exp">'.__('$0 will take automated backups via CRON as per the frequency you select', array(APP)).'</span>	
						<select name="auto_backup" class="form-control" id="auto_backup" onchange="show_backup();">
						<option value="0" '.POSTselect('auto_backup', '0', (empty($user['ins'][$insid]['auto_backup']) ? '1' : '0')).'>'.__("Don't backup").'</option>'.
						(empty($globals['disable_auto_backup_daily']) ? '<option value="daily" '.POSTselect('auto_backup', 'daily', ($user['ins'][$insid]['auto_backup'] == 'daily' ? '1' : '0')).'>'.__('Once a day').'</option>' : '').
						(empty($globals['disable_auto_backup_weekly']) ? '<option value="weekly" '.POSTselect('auto_backup', 'weekly', ($user['ins'][$insid]['auto_backup'] == 'weekly' ? '1' : '0')).'>'.__('Once a week').'</option>' : '').
						(empty($globals['disable_auto_backup_monthly']) ? '<option value="monthly" '.POSTselect('auto_backup', 'monthly', ($user['ins'][$insid]['auto_backup'] == 'monthly' ? '1' : '0')).'>'.__('Once a month').'</option>' : '').
						(empty($globals['disable_auto_backup_custom']) ? '<option value="custom" '.POSTselect('auto_backup', 'custom', ($user['ins'][$insid]['auto_backup'] == 'custom' ? '1' : '0')).'>'.__('Custom').'</option>' : '').'
						</select>					
					</div>';
					
					$autobackup_cron = explode(",", $user['ins'][$insid]['auto_backup_crontime']);
					
					echo '
					<div id="custom_autobackup_cron" class="col-sm-6 col-xs-12" style="display:none;">
						<div class="row">
						<div class="col-sm-12 col-xs-12">
							<label for="autobackup_cron_min" class="sai_head mb-2">'.__('Automated Backups Cron time').'</label>
							<span class="sai_exp">'.__('Please specify the CRON timings for automated backups').'</span>
						</div>
						<div class="col-sm-12 col-xs-12 mb-2">
							<div class="row">
								<div class="col-sm-2">
									<label for="autobackup_cron_min" class="sai_head mb-2">'.__('Min').'</label>	
									<input type="text" class="form-control" name="autobackup_cron_min" id="autobackup_cron_min" size="2" value="'.POSTval('autobackup_cron_min', $autobackup_cron[0]).'" />
								</div>
								<div class="col-sm-2">
									<label for="autobackup_cron_hour" class="sai_head mb-2">'.__('Hour').'</label>
									<input type="text" class="form-control" name="autobackup_cron_hour" id="autobackup_cron_hour" size="2" value="'.POSTval('autobackup_cron_hour', $autobackup_cron[1]).'" />
								</div>
								<div class="col-sm-2">
									<label for="autobackup_cron_day" class="sai_head mb-2">'.__('Day').'</label>
									<input type="text" class="form-control" name="autobackup_cron_day" id="autobackup_cron_day" size="2" value="'.POSTval('autobackup_cron_day', $autobackup_cron[2]).'" />
								</div>
								<div class="col-sm-2">
									<label for="autobackup_cron_month" class="sai_head mb-2">'.__('Month').'</label>
									<input type="text" class="form-control" name="autobackup_cron_month" id="autobackup_cron_month" size="2" value="'.POSTval('autobackup_cron_month', $autobackup_cron[3]).'" />
								</div>
								<div class="col-sm-2">
									<label for="autobackup_cron_weekday" class="sai_head mb-2">'.__('Weekday').'</label>
									<input type="text" class="form-control" name="autobackup_cron_weekday" id="autobackup_cron_weekday" size="2" value="'.POSTval('autobackup_cron_weekday', $autobackup_cron[4]).'" />
								</div>
							</div>
						</div>
						</div>	
					</div>';
					
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="auto_backup_rotation" class="sai_head mb-2">'.__('Backup Rotation').'</label>
						<span class="sai_exp">'.__('If the backup rotation limit is reached $0 will delete the oldest backup for this installation and create a new backup. The backups will utilize your space so choose the backup rotation as per the space available on your server', array(APP)).'</span>
						<select name="auto_backup_rotation" class="form-control" id="auto_backup_rotation">';
						
						if(isset($user['ins'][$insid]['auto_backup_rotation'])){
							$current_rotation = $user['ins'][$insid]['auto_backup_rotation'];
							
							// Is the current limit set greater than the admin max limit ?
							if(!empty($globals['auto_backup_limit']) && $user['ins'][$insid]['auto_backup_rotation'] > $globals['auto_backup_limit']){
								$current_rotation = $globals['auto_backup_limit'];
							}
						}
						
						for($i=0; $i<=10; $i++){
							// Do we have a limit from admin ?
							if(!empty($globals['auto_backup_limit']) && ($i > $globals['auto_backup_limit'] || $i == 0) || !empty($globals['max_backups']) && ($i > $globals['max_backups'] || $i == 0)) continue;
							echo '<option value="'.$i.'" '.POSTselect('auto_backup_rotation', $i, (!empty($current_rotation) && $current_rotation == $i ? '1' : ((!isset($current_rotation) && $i == 4) ? '1' : '0'))).'>'.(empty($i) ? __('Unlimited') : $i).'</option>';
						}
						echo '</select>		
					</div>';
				}
				
				if(!empty($add_to_fileindex)){
				
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="advoptions_toggle" class="sai_head mb-2">'.__('Additional Files/Folders associated with your installation').'</label>
						<span class="sai_exp">'.__('Please select the additonal files/folders associated with this installation. <br />This list will be used for operations like Clone, Backup and Removal of this installation').'</span><br />
						
						<div id="advoptions_toggle" onclick="toggle_advoptions(\'selectfile\');" class="sai_head" style="background: none; cursor:pointer;"><i id="advoptions_toggle_plus" class="fas fa-plus-square" class="mr-2"></i> &nbsp; '.__('Select additional files/folders').'</div>
						<div id="selectfile" style="display:none">
							<table class="table table-hover">
								<thead class="sai_head2">
									<tr>
										<th width="5%"><input type="checkbox" id="check_all_edit" name="check_all_edit"></th>
										<th colspan="2">'.__('Check All').'</th>
									</tr>
								</thead>';
								foreach($add_to_fileindex as $ck => $cv){
									
									if(in_array($cv['name'], $default_fileindex) && in_array($cv['name'], $__settings['fileindex'])) continue;
									
									echo '<tr>
											<td><input type="checkbox" name="add_to_fileindex[]" class="soft_filelist" value="'.$cv['name'].'" '.POSTmulticheck('add_to_fileindex', $cv['name'], $__settings['fileindex']).' id="add_to_fileindex_'.$cv['name'].'" /></td>
											<td width="5%"><img src="'.$theme['images'].''.(!empty($cv['dir']) ? 'dir.png' : 'file.png').'"></td>
											<td><label for="add_to_fileindex_'.$cv['name'].'" style="cursor:pointer;">'.$cv['name'].'</label></td>
										</tr>';
									$i++;
								}
							echo '
							</table>
						</div>	
					</div>';	
					
					if(empty($globals['disable_backup_restore'])){
						
						echo '
						<div class="col-sm-6 col-xs-12 mb-2">
							<label for="select_files_backup" class="sai_head">'.__('Use the selected additional files/folders for Backup').'</label>
							<span class="sai_exp">'.__('If selected only the files/folders related to this installation will be backed up. <br />By default backup will include all the files/folders under this path').'</span>
							
							<select name="select_files_backup" class="form-control" id="select_files_backup">
								<option value="0" '.POSTselect('select_files_backup', '0', (empty($user['ins'][$insid]['select_files_backup']) ? '1' : '0')).'>'.__('No (Backup all files and folders inside installation directory excluding subdomains)').'</option>
								<option value="1" '.POSTselect('select_files_backup', '1', (!empty($user['ins'][$insid]['select_files_backup']) ? '1' : '0')).'>'.__('Yes (Backup standard application files/folders along with above selected files/folders)').'</option>
							</select>				
						</div>';
					}
				}
				
				if(!empty($__settings['softdb']) && aefer() && empty($data['dbcreated'])){
					echo '
					<div class="col-sm-6 col-xs-12 mb-2">
						<label for="tables_toggle" class="sai_head mb-2">'.__('Additional database tables associated with your installation').'</label>
						<span class="sai_exp">'.__('Selected tables will be included in the database backup').'</span><br />
						<div id="tables_toggle" onclick="toggle_advoptions(\'select_tables\');" class="sai_head" style="background: none; cursor:pointer;"><i id="advoptions_toggle_plus" class="fas fa-plus-square" class="mr-2"></i> &nbsp; Select tables</div>
						<div id="select_tables" style="display:none">
							<table class="table table-hover">
								<thead class="sai_head2">
									<tr>
										<th width="5%"><input type="checkbox" id="check_all_tables" name="check_all_tables"></th>
										<th colspan="2">'.__('Check All').'</th>
									</tr>
								</thead>';
								foreach($full_tables as $k => $v){											
									echo '<tr>
											<td><input type="checkbox" name="add_to_softdbtables[]" class="soft_tablelist" value="'.$v.'" '.POSTmulticheck('add_to_softdbtables', $v, $__settings['softdbtables']).' '. (in_array($v, $default_tables) ? 'disabled' : '').' id="add_to_softdbtables_'.$v.'" /></td>
											<td><label for="add_to_softdbtables_'.$v.'" style="cursor:pointer;">'.trim($v, '`').'</label></td>
										</tr>';
									$i++;
								}
							echo '
							</table>
						</div>	
					</div>';
				}
			echo '</div>
			</div>';
		
			if(!empty($settings)){
			
				echo '
				<div class="card m-3 p-3 admin-settings">';
			
					foreach($settings as $group => $sets){
						
						if($group == 'hidden' || empty($sets)) continue;
					
						echo '
					<div class="sai_sub_head">'.$group.'</div>
					<hr class="sai_main_head_hr">
					<div class="row">';
					
						foreach($sets as $sk => $sv){
							
							if($sk == 'admin_pass' || $sk == 'signon_username' || $sk == 'admin_username'){
								$exp_class = 'sai_exp';
							}else{
								$exp_class = 'sai_exp';					
							}
							
							echo '
								<div class="col-sm-6 col-xs-12 mb-2">
									<label for='.$sk.' class="sai_head mb-2">'.$sv['head'].'</label>
									'.(empty($sv['exp']) ? '' : '
									<p class="mb-1 '.$exp_class.'">'.$sv['exp'].'</p>');
								
								//Adding class to input
								if(preg_match('/type="text"/is', $sv['tag'])){
									$sv['tag'] = preg_replace('/>/is', 'class="form-control">',$sv['tag']);
								}
								
								if($sk == 'admin_pass'){
									$sv['tag'] = preg_replace('/type="text"/is', 'type="password"',$sv['tag']);
									echo '
									<div class="row">
										<div class="col-sm-11">'.$sv['tag'].'</div>
										<div class="col-sm-1" style="margin-left:-20px;">
											<input id="toggle_pass_admin" type="checkbox" style="display:none;" onclick="toggle_pass(\'show_hide_admin\', \'admin_pass\');"/>
											<label for="toggle_pass_admin" style="margin-top:6px;">
												<span id="show_hide_admin">'.__('Show').'</span>
											</label>
										</div>
									</div>
								</div>';
								}else{
									echo $sv['tag'].'</div>';
								}					
						}
						echo '</div>';
					}
				
		
					//The Hidden groups 
					if(!empty($settings['hidden'])){
					
						foreach($settings['hidden'] as $sk => $sv){
							echo $sv['tag'];
						}					
					}		
				echo '</div><!--end of bg clss-->';
			}//End of if($settings)

		
// Do we have to display the theme 
if((!empty($globals['eu_enable_themes'])) && !empty($software['has_theme'])){
		
	if(function_exists('__'.$software['softname'].'_theme_show_options')){
		echo call_user_func('__'.$software['softname'].'_theme_show_options');
	}	
}		
		echo '
			<div class="bg m-3 info_block">			
				<div class="sai_sub_head">'.__('Info').'</div>
				<hr class="sai_main_head_hr">			
				<div class="row mb-3">
					<div class="col-sm-5 col-xs-12">
						<span class="sai_head">'.__('Software').'</span>
					</div>
					<div class="col-sm-6 col-xs-12">
						<span class="sai_info">'.$software['name'].'</span>
					</div>
				</div>
				
				<div class="row mb-3">
					<div class="col-sm-5 col-xs-12">
						<span class="sai_head">'.__('Installation Number').'</span>
					</div>
					<div class="col-sm-6 col-xs-12">
						<span class="sai_info">'.$user['ins'][$insid]['insid'].'</span>
					</div>
				</div>
				
				<div class="row mb-3">
					<div class="col-sm-5 col-xs-12">
						<span class="sai_head">'.__('Version').'</span>
					</div>
					<div class="col-sm-6 col-xs-12">
						<span class="sai_info">'.$user['ins'][$insid]['ver'].'</span>
					</div>
				</div>
				
				<div class="row mb-3">
					<div class="col-sm-5 col-xs-12">
						<span class="sai_head">'.__('Installation Time').'</span>
					</div>
					<div class="col-sm-6 col-xs-12">
						<span class="sai_info">'.datify($user['ins'][$insid]['itime']).'</span>
					</div>
				</div>
		
				<div class="row mb-3">
					<div class="col-sm-5 col-xs-12">
						<span class="sai_head">'.__('Path').'</span>
					</div>
					<div class="col-sm-6 col-xs-12">
						<span class="sai_info">'.$user['ins'][$insid]['softpath'].'</span>
					</div>
				</div>
				
				<div class="row mb-3">
					<div class="col-sm-5 col-xs-12">
						<span class="sai_head">'.__('URL').'</span>
					</div>
					<div class="col-sm-6 col-xs-12">
						<span class="sai_info"><a href="'.$user['ins'][$insid]['softurl'].'" target="_blank">'.$user['ins'][$insid]['softurl'].'</a></span>
					</div>
				</div>';
		
				if(!empty($user['ins'][$insid]['admin_folder']) || !empty($scripts[$soft]['admin_url'])){
					$adminurl = $user['ins'][$insid]['softurl'].'/'.(!empty($user['ins'][$insid]['admin_folder']) ? $user['ins'][$insid]['admin_folder'] : $scripts[$soft]['admin_url']);
					echo '
					<div class="row mb-3">
						<div class="col-sm-5 col-xs-12">
							<span class="sai_head">'.__('Admin URL').'</span>
						</div>
						<div class="col-sm-6 col-xs-12">
							<span class="sai_info"><a href="'.$adminurl.'" target="_blank">'.$adminurl.'</a></span>
						</div>
					</div>';
				}
		
				echo '
				
				'.(empty($user['ins'][$insid]['wwwdir']) ? '' :'
					<div class="row mb-3">
						<div class="col-sm-5 col-xs-12">
							<span class="sai_head">'.__('Web Directory').'</span>
						</div>
						<div class="col-sm-6 col-xs-12">
							<span class="sai_info">'.$user['ins'][$insid]['wwwdir'].'</span>
						</div>			
					</div>
				').'
				
				'.(empty($user['ins'][$insid]['wwwurl']) ? '' : '
					<div class="row mb-3">
						<div class="col-sm-5 col-xs-12">
							<span class="sai_head">'.__('Web Directory URL').'</span>
						</div>
						<div class="col-sm-6 col-xs-12">
							<span class="sai_info">'.$user['ins'][$insid]['wwwurl'].'</span>
						</div>		
					</div>
				').'
				
				'.(empty($user['ins'][$insid]['softdatadir']) ? '' : '
					<div class="row mb-3">
						<div class="col-sm-5 col-xs-12">
							<span class="sai_head">'.__('Data Directory').'</span>
						</div>
						<div class="col-sm-6 col-xs-12">
							<span class="sai_info">'.$user['ins'][$insid]['softdatadir'].'</span>
						</div>
					</div>
				').'	
				
				'.(empty($user['ins'][$insid]['softdb']) ? '' : '
					<div class="row mb-3">
						<div class="col-sm-5 col-xs-12">
							<span class="sai_head">'.__('Database Name').'</span>
						</div>
						<div class="col-sm-6 col-xs-12">
							<span class="sai_info">'.$user['ins'][$insid]['softdb'].'</span>
						</div>
					</div>
				').'	
				
				'.(empty($user['ins'][$insid]['softdbuser']) ? '' : '
					<div class="row mb-3">
						<div class="col-sm-5 col-xs-12">
							<span class="sai_head">'.__('Database User').'</span>
						</div>
						<div class="col-sm-6 col-xs-12">
							<span class="sai_info">'.$user['ins'][$insid]['softdbuser'].'</span>
						</div>
					</div>
				').'	
				
				'.(empty($user['ins'][$insid]['softdbhost']) ? '' : '
					<div class="row mb-3">
						<div class="col-sm-5 col-xs-12">
							<span class="sai_head">'.__('Database Host').'</span>
						</div>
						<div class="col-sm-6 col-xs-12">
							<span class="sai_info">'.$user['ins'][$insid]['softdbhost'].'</span>
						</div>
					</div>
				').'	
				
				'.(empty($user['ins'][$insid]['cron_command']) ? '' : '
					<div class="row mb-3">
						<div class="col-sm-5 col-xs-12">
							<span class="sai_head">'.__('Cron Command').'</span>
						</div>
						<div class="col-sm-6 col-xs-12">
							<span class="sai_info">'.base64_decode($user['ins'][$insid]['cron_command']).'</span>
						</div>
					</div>
				
				')
				
				.((is_wordpress($soft) && softaculous_is_pro() && (empty($globals['wp_fp_pref']) || $globals['wp_fp_pref'] != 2)) ? '
					<div class="row mb-3">
						<div class="col-sm-5 col-xs-12">
							<span class="sai_head">'.__('SoftWP License').'</span>
						</div>
						<div class="col-sm-6 col-xs-12">
							<span class="sai_info issue_softwp_license">
								'.(!empty($user['ins'][$insid]['softaculous_pro_license']) ? $user['ins'][$insid]['softaculous_pro_license'] . '&nbsp;&nbsp;&nbsp;' : '').'
							</span>
							<input type="button" class="flat-butt btn sai-button" id="issue_softwp_license" name="issue_softwp_license" insid="'.$insid.'" style="padding: 5px 10px;" value="'.(!empty($user['ins'][$insid]['softaculous_pro_license']) ? __('Regenerate SoftWP License') : __('Generate SoftWP License')).'">
						</div>
					</div>' : '').'
			</div><!--end of bg class-->
			
			<div class="text-center my-4">
				<input type="hidden" name="editins" id="editins" value="'.__('Save Installation Details').'" />
				<input type="submit" name="softsubmitbut" class="flat-butt btn sai-button" id="softsubmitbut" value="'.__('Save Installation Details').'"  />
				<center>
					<p class="mt-3">'.$return.'</p>
				</center>
			</div>
								
		</div><!--end of bg class-->
		'.csrf_display().'
	</form>
	
	<script language="javascript" type="text/javascript"><!-- // --><![CDATA[
		$(document).ready(function(){
		
			$("#check_all_edit").on("click", function(event){
				if(this.checked == true){
					$(".soft_filelist").prop("checked", true);
				}else{
					$(".soft_filelist").prop("checked", false);
				}
			});
			
			$("#check_all_tables").on("click", function(event){
				if(this.checked == true){
					$(".soft_tablelist").prop("checked", true);
				}else{
					$(".soft_tablelist").prop("checked", false);
				}
			});
		
			$(".sai_altrowstable tr").mouseover(function(){
				var old_class = $(this).attr("class");
				//alert(old_class);
				$(this).attr("class", "sai_tr_bgcolor");
				
				$(this).mouseout(function(){
					$(this).attr("class", old_class);
				});
			});
			
		});
	// ]]></script>';

}

// Is there a UI Controller ?
if(function_exists('__'.$software['softname'].'_theme_html')){
	call_user_func('__'.$software['softname'].'_theme_html');
}

softfooter();

}

?>