Viewing File: /usr/local/cpanel/whostmgr/docroot/cgi/softaculous/enduser/themes/default/ampps/alias_theme.php

<?php

//////////////////////////////////////////////////////////////
//===========================================================
// userindex_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 alias_theme(){

	global $user, $globals, $l, $theme, $softpanel, $iscripts, $catwise, $error;
	global $insid, $backed, $software, $soft, $done;
	
	global $alias_list;
	
	if(optGET('ajaxdel')){
			
		if(!empty($error)){
			echo '0'.current($error);
			return false;
		}
		if(!empty($done)){
			echo '1'.__('Alias deleted successfully');
			return true;			
		}
	}
	
	if(optGET('ajaxalias') ){
		
		if(!empty($error)){
			echo '0'.current($error);
			return false;
		}
		
		// Creating new table for display new DB
		if(!empty($done)){
			$alias_list = $softpanel->alias();
			echo '1 Alias Created Successfully';
			alias_table();
			return true;
		}
	}
	
	softheader(__('$0 - Alias Manager', array(APP)));
	
	error_handle($error, '100%');
		
	echo '<script language="javascript" type="text/javascript"><!-- // --><![CDATA[

	var dompath = false;
	
	// For msgbox
	var message_box = function() {
		return {
			show_message: function(title, body , image) {
				var okbutton = \'<input  style="width:75px; background:#00a0d2; border-radius:4px; color:#fff;" class="sai_submit" type="button" onclick="message_box.close_message();" value="OK" />\';
				if(image == "1"){
					var img = \'<i class="fas fa-exclamation-triangle fa-4x" style="color:orange;"></i>\';
				}else{
					var img = \'<i class="fas fa-check fa-4x" style="color:green;"></i>\';
				}
				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="40%" > \'+ img + \'</td><td width="60%" 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="40%">\'+ img +  \'</td><td widt="60%" 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 );
				}
			},
			delete_message: function(title, body ,did) {
				var yesbutton = \'<input type="button" style="width:75px; background:#00a0d2; border-radius:4px; color:#fff;" onclick="message_box.yes_close_message(\\\'\'+did+\'\\\');" value="YES" class="sai_submit"/>\';
				var nobutton = \'<input type="button" style="width:75px; background:#00a0d2; border-radius:4px; color:#fff;" onclick="message_box.no_close_message();" value="NO" class="sai_submit" />\';
				var img = \'<i class="fas fa-trash-alt fa-4x" style="color:red;"></i>\';
				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 height="60%" ><td rowspan="2" width="40%" > \'+ img + \'</td><td width="60%" class ="msg_tr1" height="10%">\' +  title + \'</td></tr><tr ><td style="text-align:left" height="60%" cellpading="2" class ="msg_tr2">\' + body + \'</td></tr><tr ><td colspan="2">\' + yesbutton + \'&nbsp; &nbsp; \' + nobutton + \'</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" cellpadding="8" width="100%" height="100%"><tr height="60%" ><td rowspan="2" width="40%">\'+ img +  \'</td><td widt="60%" class ="msg_tr1" height="10%">\' + title + \'</td></tr><tr><td style="text-align:left" height="60%" cellpading="2" class ="msg_tr2">\' + body + \'</td></tr><tr ><td colspan="2">\' + yesbutton + \'&nbsp; &nbsp; \' + nobutton + \'</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\');
			},
			yes_close_message: function(did) {
				$(\'#did\'+did).attr("src","'.$theme['images'].'progress.gif");
				jQuery(\'.sai_message_box\').hide(\'fast\');
				$.ajax({
					type: "POST",
					url: window.location+"&ajaxdel=1&delete_alias_id="+did,
					// checking for error
					success: function(data){
						var result = data.substring(0,1);
						var msg = data.substring(1);
						if(result == "1"){
							message_box.show_message( "Delete ",msg,2);
							
							$("#tr"+did).fadeOut(2000);
						}
						if(result == "0"){
							message_box.show_message( "Error ",msg,1);
						}
					},
					error: function(request,error) {
						message_box.show_message("Error",\''.__js('Oops there was an error while connecting to <strong>Server</strong>').'\',1);
					}
				});
			},
			no_close_message: function() {
				jQuery(\'.sai_message_box\').hide(\'fast\');			
			}
		}
	}();
	
	function suggestdompath(domval){
		if(dompath){
			return true;	
		}
		$_("aliaspath").value = "'.cleanpath($softpanel->user['homedir']).'/www/"+$_("aliasname").value;
	}
	
			
$(document).ready(function(){

	jQuery(\'#butHide\').hide("fast");	
	$(".sai_altrowstable tr").mouseover(function(){
		var old_class = $(this).attr("class");		
		$(this).attr("class", "sai_tr_bgcolor");		
		$(this).mouseout(function(){
			$(this).attr("class", old_class);
		});
	});
	// For showing ADD NEW
	$("#butShow").click(function() {	
		jQuery(\'#showtemp\').slideDown(\'slide\',\'\',1000);
		jQuery(\'#butShow\').fadeOut(0);
		jQuery(\'#butHide\').fadeIn(0);
	});	
	// For hiding ADD NEW
	$("#butHide").click(function() {	
		jQuery(\'#showtemp\').slideUp(\'slide\',\'\',1000);	
		jQuery(\'#butHide\').fadeOut(0);
		jQuery(\'#butShow\').fadeIn(0);			
	});
	// For deleting record
	$(".delete").click(function() {	
		var did = $(this).attr(\'id\');
		did = did.substr(3);
		message_box.delete_message (\'Warning\',\''.__js('Are you sure want to delete this Alias?').'\',did);			
	});	
	// for adding alias	
	$(".submitalias").click(function() {
		$("#createalias").css("display", "");	
		var aliasname = ($("#aliasname").val());
		var aliaspath = ($("#aliaspath").val());					
		$.ajax({
			type: "POST",
			url: window.location+"&submitalias=1&ajaxalias=1",					
			data: "aliasname="+aliasname+"&aliaspath="+aliaspath,
			// checking for error
			success: function(data){
				$("#createalias").css("display", "none");						
				var result = data.substring(0,1);														
				if(result == "1"){
					$_("aliasname").value="";				
					var msg = data.substring(2,data.indexOf("<table"));
					var output = data.substring(data.indexOf("<table"));
					message_box.show_message( "Done ",msg,2);							
					$("#showtab").html(output);
					$(".sai_altrowstable tr").mouseover(function(){
						var old_class = $(this).attr("class");		
						$(this).attr("class", "sai_tr_bgcolor");		
						$(this).mouseout(function(){
							$(this).attr("class", old_class);
						});
					});
					// For deleting record
					$(".delete").click(function() {	
						var did = $(this).attr(\'id\');
						did = did.substr(3);
						message_box.delete_message (\'Warning\',\''.__js('Are you sure want to delete this Alias?').'\',did);			
					});																								
				}
				if(result == "0"){
					$("#createalias").css("display", "none");
					var msg = data.substring(1);
					message_box.show_message( "Error",msg,1);
				}
			},
			error: function() {
				message_box.show_message("Error",\''.__js('Oops there was an error while connecting to <strong>Server</strong>').'\',1);						
			}															
		});													
	});	
});					
// ]]></script>';  

echo '
<div class="bg">
	<div class="row sai_main_head">
		<div class="col-12 my-3 text-center">
			<span class="form-title"><img height="48" width="48" src="'.$theme['a_images'].'alias.png" />&nbsp;'.__('Alias Manager').'</span>
		</div>
	</div><hr />
	<div id="butShow" align="right">
		<a href="javascript:void(0)" style="text-decoration:none;" color="#fff";><p class="btn sai-button">'.__('Add New').'</p></a>
	</div>	
	<div id="butHide" align="right>
		<a href="javascript:void(0)" style="text-decoration:none;" class="btn sai-button" color:#fff;>'.__('Go Back').'</a>
	</div><br />

	<div id="showtemp" style="display:none">
	<br />
	<script language="javascript" type="text/javascript"><!-- // --><![CDATA[

	// ]]></script>
	<div class="row mt-4">
			<div class="col-sm-5 col-xs-12 px-4">
			<label for="aliasname"  class="sai_head">'.__('Alias Name').'</label>&nbsp;&nbsp;&nbsp;&nbsp;</br><span class="sai_exp2">'.__('e.g your_site').'</span>
			<span class="sai_exp">'.__('<b>Note:</b> After adding this, you should be able to access http://localhost/your_site.').'</span>
		</div>
		
		<div class="col-sm-7 col-xs-12 px-4">
			<input type="text" name="aliasname" id="aliasname" onkeyup="suggestdompath(this);" size="30" value="'.POSTval('aliasname', '').'" onfocus="" class="form-control"/>
		</div>	
	</div><br />
		
	<div class="row mt-4">
			<div class="col-sm-5 col-xs-12 px-4">
			<label for="aliaspath" class="sai_head">'.__('Path').'</label>&nbsp;&nbsp;&nbsp;&nbsp;</br><span class="sai_exp2">'.__('e.g C:/www/your_site').'</span>
			<span class="sai_exp">'.__('<b>Note:</b> Make sure the path is correct. New directory will be created in case of new path.').'</span>
		</div>
			
		<div class="col-sm-7 col-xs-12 px-4">
			<input type="text" name="aliaspath" id="aliaspath" size="30" value="'.cleanpath($softpanel->path).'/www/'.'" onfocus="" class="form-control"/>
			<script language="javascript" type="text/javascript"><!-- // --><![CDATA[
			//Add an event handler
			$_("aliaspath").onkeydown = function(){
				dompath = true;
			}
		// ]]></script>
		</div>
	</div><br />

	<div class="row">
		<div class="col-10 px-4 text-center">
			<input type="button" class="submitalias btn sai-button" style="cursor:pointer" name="submitalias" value="'.__('Create Alias').'" /> &nbsp;<img id="createalias" src="'.$theme['images'].'progress.gif" style="display:none"></p>
		</div>
	</div>
	</form>
	<br />
	</div>
	<div id="showtab">';

	alias_table();
				
	echo '
	</div><form accept-charset="'.$globals['charset'].'" name="importsoftware" method="post" action="" onsubmit="return checkform();">
	<script language="javascript" type="text/javascript"><!-- // --><![CDATA[

	function checkform(){
		try{
			if(!formcheck() || !checkdbname(\'softdb\', true)){
				return false;
			}
		}catch(e){
			//Do nothing
		}
		return true;
	};';
	echo '// ]]></script>';

softfooter();
	echo '</div>';
}		
/*function died(){
print_r(error_get_last());
}
register_shutdown_function('died');*/
function alias_table(){
	
	global $user, $globals, $l, $theme, $softpanel, $iscripts, $catwise, $error;
	global $insid, $backed, $software, $soft, $done;
	
	global $alias_list;
	
	echo '<table border="0" cellpadding="5" cellspacing="0" width="100%" class="table table-hover mb-2 borderless">
	<tr>
		<thead class="sai_head2">
			<th align="center"  width="60">'.__('Alias').'</th>
			<th align="center"  width="30">'.__('Path').'</th>
			<th align="center"  width="10">'.__('Options').'</th>
		</thead>
	</tr>';
	
	if(empty($alias_list)){
		echo '<tr class="sai_evenrowcolor" id="tr0">
			<td colspan="3" style="text-align:center;">'.__('No Alias found').'</td>
			</tr>';
	}else{
		
		$i =1;
		
		foreach ($alias_list as $key => $value)
		{
			echo '<tr class="'.($i % 2 == 0 ? "sai_evenrowcolor" : "sai_oddrowcolor").'" id="tr'.$i.'">
				<td><a target="_blank" href="http://'.$_SERVER["SERVER_NAME"].'/' . $key . '"> '.$key.'</a></td>
				<td>'.$value.'</td>
				<td>
					<i class="delete fas fa-trash-alt px-2 sai_icons" title="Delete" style="cursor:pointer;color:red;" id="did'.$i.'"></i>
				</td>
				</tr>';
			$i++;
		}
	}
	
	echo '</table>';
}
Back to Directory