Current File : /home/inlingua/www/decay_sym/root/var/softaculous/apps/php-common/themes/admin/php_ext_theme.php
<?php

//////////////////////////////////////////////////////////////
//===========================================================
// WEBUZO CONTROL PANEL
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit
// Date:       10th Jan 2009
// Time:       21:00 hrs
// Site:       https://webuzo.com/ (WEBUZO)
// ----------------------------------------------------------
// Please Read the Terms of Use at https://webuzo.com/terms
// ----------------------------------------------------------
//===========================================================
// (c) Softaculous Ltd.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('SOFTACULOUS')){
	die('Hacking Attempt');
}

function phpc_php_ext_theme(){

	global $theme, $globals, $user, $langs, $skins, $error, $saved, $list, $done, $apps, $ext_list, $iapps,$installed_php;

	echo '
<div class="soft-smbox col-12 col-md-10 mx-auto p-3">
	<div class="sai_main_head">
		<img src="'.$theme['images'].'php_ext.png" class="me-1"/>'.__('PHP Extensions').'
	</div>
</div>
<div class="soft-smbox col-12 col-md-10 mx-auto mt-4 p-3">';
		
	//Check if any PHP is installed or not?
	$is_php_installed = group_iapp_ids('php');
	
	if(empty($is_php_installed)){
	
		echo '
	<div class="sai_head text-center">
		<h4>'.__('PHP is not installed on your server.').'</h4>
	</div>';
	
	}else{
		echo '
	<div id="dispconf">';
	
		$default_php = $globals['WU_DEFAULT_PHP'];
		
		if(!empty($default_php)){
			$php = get_app_record($default_php);
		}
		
		echo '
		<form accept-charset="'.$globals['charset'].'" name="php_extensions" method="post" action="" id="editphpext" onsubmit="return submitExtForm(this)">
			<div class="row my-2">
				<div class="col-12 col-lg-3">
					<label class="sai_head">'.__('Select PHP Verison').'</label>
				</div>
				<div class="col-12 col-lg-7">
					<select name="php_version" id="php_version" class="form-select">
					';
					$selected_php = !empty(optREQ('php')) ? optREQ('php') : $php.'_1';
					foreach ($installed_php as $k => $v) {
						echo '<option value="'.$k.'" '.(($selected_php == $k) ? 'selected' : '').'>'.$v.'</option>';
					}
				echo '
					</select>
				</div>
			</div>		
			<div class="sai_sub_head text-center my-3">'.__('This page allows you to Enable / Disable Extensions for ').'<span id="d_phpversion">'.$apps[$iapps[$selected_php]['aid']]['name'].'</span></div>
			<div class="alert alert-warning mb-3">
				<span>'.__('You can refer to the {$0}Custom Extension Docs{$1} to add custom Extensions in PHP.', ['<a href="https://webuzo.com/docs/how-tos/custom-php-extensions/" target="_blank">', '</a>']).'</span>
			</div>
			<div class="table-responsive">
			<table border="0" cellpadding="8" cellspacing="0" class="table webuzo-table td_font">
			<thead>
				<tr>
					<th colspan="4" class="text-start">'.__('Extensions  Enabled:').'&nbsp;
						<span id="enabled">'.$ext_list['enabled_count'].'</span>&nbsp;&nbsp;
						'.__('Disabled:').'&nbsp;<span id="disabled">'.$ext_list['disabled_count'].'</span>
					</th>
					<th colspan="4" class="text-end">'.__('Select All').'&nbsp;
						<input type="checkbox" id="check_all_ext"/>
					</th>
				</tr>
			</thead>
			<tbody id="ext_list">';
				
			echo '
			</tbody>
			</table>
			</div>
			<div class="text-center mt-2">			
				<input type="submit" value="'.__('Save').'" name="save_ext" class="btn btn-primary" id="savephpext" />
			</div>
		</form>
	</div>';
	}
	
	echo '
</div>

<script language="javascript" type="text/javascript">

$(document).ready(function(){
	var data = {ext_list:'.json_encode($ext_list['php_ext']).'}
	// console.log(data);
	create_ext_table(data);
	$("#check_all_ext").on("click", function(event){
		if(this.checked == true){
			$(".check_ext").prop("checked", true);
		}else{
		$(".check_ext").prop("checked", false);
		}
	});
	
	$(".ext_box").on("click", function(e) {
		if(e.target==this){
				var checkbox = $(this).find("input");
				checkbox.prop("checked", !checkbox.prop("checked"));	
				$(this).toggleClass("selected");
		}else{
			$(this).toggleClass("selected");
		}
	});
});

$("#php_version").change(function(){
	var jEle = $(this);
	var option = $(this).val();
	if(!empty(option)){
		window.location = "'.$globals['admin_url'].'act='.$GLOBALS['act'].'&php="+option;
	}
	d = {php:option, ext_list:1};
	submitit(d,{
		handle:function(data, p){
			$("#d_phpversion").html($("#php_version option:selected").text());
			$("#enabled").text(data.enabled_count);
			$("#disabled").text(data.disabled_count);
			create_ext_table(data);
		}
	});
});

function submitExtForm(ele){
	// console.log(ele);return false;
	var d = {};
	var extensions = [];		
	$(".check_ext").each(function () {
		if ($(this).is(":checked")) {
			var ext = $(this).data("ext");
			extensions.push(ext);
		}
	});

	if(extensions.length === 0 ){
		extensions = ["disableall"];
	}
	
	var php = $("#php_version option:selected").val();
	d.extensions = extensions.join(",");
	d.php = php;
	d.save_ext = 1;
	submitit(d, {done_reload : window.location.href});
	return false;
}
	
function create_ext_table(data){
	// console.log(data.ext_list);
	var tmphtml = "", counter = 0;
	tmphtml += \'<tr>\';
	
	$.each(data.ext_list, function(key, value){
		counter++;
		tmphtml += \'<td width="3%" class="ext_box" style="padding-top: 15px; position:relative">\';
		tmphtml += \'<input type="checkbox" name="extlist[\'+key+\']" id="extlist[\'+key+\']" value="1" \'+(value != 1 ? "" : "checked")+\' data-ext="\'+key+\'" class="check_ext"/></td>\';
		tmphtml += \'<td width="22%"><label for="extlist[\'+key+\']"><span class="sai_head">\'+key+\'</span></label></td>\';
		
		if(counter % 4 === 0){
			tmphtml += \'</tr><tr>\';
		}
		
	});
	
	$("#ext_list").html(tmphtml);
}
</script>';

}