File: //var/softaculous/apps/php-common/themes/admin/phpfpm_settings_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_phpfpm_settings_theme(){
global $theme, $globals, $user, $langs, $error, $saved, $list, $done, $load_phpfpm, $installed_php, $iapps, $apps, $U;
error_handle($error);
echo '
<div class="soft-smbox col-12 p-3 col-12 col-md-10 mx-auto">
<div class="sai_main_head">
<img src="'.$theme['images'].'php_conf.png" class="me-1"/>'.__('PHP FPM Settings').'
</div>
</div>';
echo '
<div id="php_fpm_settings" class="soft-smbox p-4 col-12 col-md-10 mt-4 mx-auto">
<div class="sai_main_head text-center">
<h5 id="addRecordLabel">'.(!empty(optREQ('user')) ? __('PHP FPM Settings for user $0 $1 $2', ['<b>', optREQ('user'), '</b>']) : __('Global PHP FPM Settings')).'</h5>
<h5 id="php_text" class="mb-2"><b>'.(!empty(optREQ('php')) ? $installed_php[trim(optREQ('php'))]['name'].' ('.optREQ('php').')' : $installed_php[$globals['WU_DEFAULT_PHP']]['name'].' ('.$globals['WU_DEFAULT_PHP'].')').'</b></h5>';
if(empty(optREQ('user'))){
echo '
<div class="alert alert-warning">
'.__('$0 NOTE : $1 Global settings will be applied to users, if users do not have custom settings saved. ', ['<strong>', '</strong>']).'
</div>';
}
echo '
</div>
<form accept-charset="'.$globals['charset'].'" action="" method="post" name="fpm_settings" id="fpm_settings" class="form-horizontal row " onsubmit="return submitit(this)" data-donereload="1">
<div class="mb-4 row">
<div class="col-md-6">
<label class="sai_head text-center">'.__('Username :-').'</label><br/>
<select class="form-select make-select2" s2-placeholder="'.__('Select User').'" s2-ajaxurl="'.$globals['index'].'act=users&api=json" s2-query="search" s2-data-key="users" s2-data-subkey="user" s2-result-add="'.htmlentities(json_encode([['text' => 'Default value', 'id' => '0', 'value' => '0']])).'"style="width: 100%" id="user" name="user">
<option value="'.optREQ('user').'" selected="selected">'.optREQ('user').'</option>
</select>
</div>
<div class="col-md-6">
<label class="sai_head text-center">'.__('PHP Version :-').'</label><br/>
<select class="form-select make-select2" id="php" name="php">
<option value="default" '.(empty(optREQ('php')) ? 'selected' : '').'>'.__('Default').' '.$installed_php[$globals['WU_DEFAULT_PHP']]['name'].' ('.$globals['WU_DEFAULT_PHP'].')</option>';
foreach($installed_php as $k => $v){
echo '<option value="'.$k.'" '.(trim(optREQ('php')) == $k ? 'selected' : '').'>'.$v['name'].' ('.$k.')</option>';
}
echo '
</select>
</div>
</div>
<label for="pm" class="sai_head col-md-6">'.__('PHP-FPM process manager').'</label>
<select class="form-control mb-3 col-md-6" name="pm" id="pm" style="width: 50%;">
<option '.POSTselect('pm', 'ondemand', ($load_phpfpm['pm'] == 'ondemand')).' value="ondemand ">'.__('Ondemand ').'</option>
<option '.POSTselect('pm', 'static', ($load_phpfpm['pm'] == 'static')).' value="static">'.__('Static').'</option>
<option '.POSTselect('pm', 'dynamic', ($load_phpfpm['pm'] == 'dynamic')).' value="dynamic">'.__('Dynamic ').'</option>
</select>
<label for="pm_max_children" class="sai_head col-md-6">'.__('PHP-FPM Max Children ').'<span class="sai_exp">'.__('This option sets the limit on the number of simultaneous requests that will be served. ').'</span></label>
<input type="number" id="pm_max_children" name="pm_max_children" class="form-control mb-3 col-md-6" min="1" max="10000" value="'.POSTval('pm_max_children', (!empty($load_phpfpm) ? $load_phpfpm['pm.max_children'] : 5)).'" style="width: 50%;"/>
<label for="pm_start_servers" class="sai_head col-md-6">'.__('PHP-FPM Start Servers ').'<span class="sai_exp">'.__('The number of child processes created on startup.').'</span></label>
<input type="number" id="pm_start_servers" name="pm_start_servers" class="form-control mb-3 col-md-6" value="'.POSTval('pm_start_servers', (!empty($load_phpfpm) ? $load_phpfpm['pm.start_servers'] : 0)).'" style="width: 50%;"/>
<label for="pm_min_spare_servers" class="sai_head col-md-6">'.__('PHP-FPM Min Spare Servers ').'<span class="sai_exp">'.__('The desired minimum number of idle server processes.').'</span></label>
<input type="number" id="pm_min_spare_servers" name="pm_min_spare_servers" class="form-control mb-3 col-md-6" value="'.POSTval('pm_min_spare_servers', (!empty($load_phpfpm) ? $load_phpfpm['pm.min_spare_servers'] : 1)).'" style="width: 50%;"/>
<label for="pm_max_spare_servers" class="sai_head col-md-6">'.__('PHP-FPM Max Spare Servers ').'<span class="sai_exp">'.__('The desired maximum number of idle server processes.').'</span></label>
<input type="number" id="pm_max_spare_servers" name="pm_max_spare_servers" class="form-control mb-3 col-md-6" value="'.POSTval('pm_max_spare_servers', (!empty($load_phpfpm) ? $load_phpfpm['pm.max_spare_servers'] : 5)).'" style="width: 50%;"/>
<label for="pm_max_requests" class="sai_head col-md-6">'.__('PHP-FPM Max Request ').'<span class="sai_exp">'.__('The number of requests each child process should execute before respawning.').'</span></label>
<input type="number" id="pm_max_requests" name="pm_max_requests" class="form-control mb-3 col-md-6" min="1" max="10000000" value="'.POSTval('pm_max_requests', (!empty($load_phpfpm) ? $load_phpfpm['pm.max_requests'] : 20)).'" style="width: 50%;"/>
<label for="pm_process_idle_timeout" class="sai_head col-md-6">'.__('PHP-FPM Process Idle Timeout ').'<span class="sai_exp">'.__('The number of seconds after which an idle process will be killed.').'</span></label>
<input type="number" id="pm_process_idle_timeout" name="pm_process_idle_timeout" class="form-control mb-3 col-md-6" min="1" max="10000000" value="'.POSTval('pm_process_idle_timeout', (!empty($load_phpfpm) ? $load_phpfpm['pm.process_idle_timeout'] : 10)).'" style="width: 50%;"/>
<label for="request_terminate_timeout" class="sai_head col-md-6">'.__('PHP-FPM Request Terminate Timeout (seconds) ').'<span class="sai_exp">'.__('The timeout for serving a single request after which the worker process will be killed.').'</span></label>
<input type="number" id="request_terminate_timeout" name="request_terminate_timeout" class="form-control mb-3 col-md-6" value="'.POSTval('request_terminate_timeout', (!empty($load_phpfpm) ? $load_phpfpm['request_terminate_timeout'] : 120)).'" style="width: 50%;"/>
<label for="rlimit_files" class="sai_head col-md-6">'.__('PHP-FPM File Limit ').'<span class="sai_exp">'.__('The number of file descriptors that a process in PHP can open.').'</span></label>
<input type="number" id="rlimit_files" name="rlimit_files" class="form-control mb-3 col-md-6" value="'.POSTval('rlimit_files', $load_phpfpm['rlimit_files']).'" style="width: 50%;"/>
<label for="ulimit" class="sai_head col-md-6">'.__('PHP-FPM Ulimit ').'<span class="sai_exp">'.__('PHP service will start using the specified ulimit.').'</span></label>
<input type="number" id="ulimit" name="ulimit" class="form-control mb-3 col-md-6" value="'.POSTval('ulimit', $load_phpfpm['ulimit']).'" style="width: 50%;"/>
<label class="sai_main_head col-md-12 mb-2">'.__('PHP-FPM INI settings ').'</label>
<div class="row mb-2">
<label class="col-md-7 sai_head">
<input type="checkbox" id="allow_url_fopen" name="allow_url_fopen" value="on" class="me-2" '.POSTchecked('allow_url_fopen', (!empty($load_phpfpm) ? ($load_phpfpm['allow_url_fopen'] == 'on' ? 1 : 0) : 1)).' >'.__('Treat URLs as files (allow_url_fopen)').'<span class="sai_exp">'.__('Whether to allow the treatment of URLs (like http:// or ftp://) as files').'</span>
</label>
<label class="col-md-5">
<input type="checkbox" id="b_allow_url_fopen" name="b_allow_url_fopen" value="on" class="me-2" '.POSTchecked('b_allow_url_fopen', (!empty($load_phpfpm) ? ($load_phpfpm['b_allow_url_fopen'] == 'on' ? 1 : 0) : 0)).' >'.__('Block domain from changing the setting').'
</label>
</div>
<div class="row mb-2">
<label class="col-md-7 sai_head">
<input type="checkbox" id="log_errors" name="log_errors" value="on" class="me-2" '.POSTchecked('log_errors', (!empty($load_phpfpm) ? ($load_phpfpm['log_errors'] == 'on' ? 1 : 0) : 1)).'>'.__('Log errors (log_errors)').'<span class="sai_exp">'.__('Log errors into a log file').'</span>
</label>
<label class="col-md-5">
<input type="checkbox" id="b_log_errors" name="b_log_errors" value="on" class="me-2" '.POSTchecked('b_log_errors', (!empty($load_phpfpm) ? ($load_phpfpm['b_log_errors'] == 'on' ? 1 : 0) : 0)).'>'.__('Block domain from changing the setting').'
</label>
</div>
<div class="row mb-2">
<label class="col-md-7 sai_head">
<input type="checkbox" id="short_open_tag" name="short_open_tag" value="on" class="me-2" '.POSTchecked('short_open_tag', (!empty($load_phpfpm) ? ($load_phpfpm['short_open_tag'] == 'on' ? 1 : 0) : 1)).'>'.__('Recognize code between tags as PHP source (short_open_tag)').'<span class="sai_exp">'.htmlspecialchars(__('Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.')).'</span>
</label>
<label class="col-md-5">
<input type="checkbox" id="b_short_open_tag" name="b_short_open_tag" value="on" class="me-2" '.POSTchecked('b_short_open_tag', (!empty($load_phpfpm) ? ($load_phpfpm['b_short_open_tag'] == 'on' ? 1 : 0) : 0)).'>'.__('Block domain from changing the setting').'
</label>
</div>';
if(!empty(optREQ('user'))){
echo '
<div class="row mb-2">
<div class="col-md-7">
<label for="error_log" class="sai_head col-md-6">'.__('Error Log :- ').'<span class="sai_exp">'.__('Log errors to specified file.').'</span></label><br>
<div class="input-group mb-2">
<span class="input-group-text mb-2">'.$U['homedir'].'/'.'</span>
<input type="text" id="error_log" name="error_log" class="form-control mb-2" value="'.(!empty($load_phpfpm) ? explode($U['homedir'].'/', POSTval('error_log', $load_phpfpm['error_log']), 2)[1] : optREQ('user').'_'.(!empty(optREQ('php')) ? optREQ('php') : $globals['WU_DEFAULT_PHP']).'.error.log').'"/>
</div>
</div>
<label class="col-md-5">
<input type="checkbox" id="b_error_log" name="b_error_log" value="on" class="me-2" '.POSTchecked('b_error_log', (!empty($load_phpfpm) ? ($load_phpfpm['b_error_log'] == 'on' ? 1 : 0) : 0)).'>'.__('Block domain from changing the setting').'
</label>
</div>';
}
echo '
<div class="row mb-2">
<div class="col-md-7">
<label for="disable_functions" class="sai_head col-md-6">'.__('Disable Functions :- ').'<span class="sai_exp">'.__('This directive allows you to disable certain functions for security reasons.').'</span></label><br>
<select id="disable_functions" name="disable_functions[]" class="form-select form-select-sm" placeholder="Disable function" multiple="multiple" style="width: 100%;">';
if(!empty($load_phpfpm['disable_functions'])){
$disable_functions = explode(',', $load_phpfpm['disable_functions']);
foreach($disable_functions as $val){
echo '<option selected>'.$val.'</option>';
}
}
echo '
</select>
</div>
<label class="col-md-5">
<input type="checkbox" id="b_disable_functions" name="b_disable_functions" value="on" class="me-2" '.POSTchecked('b_disable_functions', (!empty($load_phpfpm) ? ($load_phpfpm['b_disable_functions'] == 'on' ? 1 : 0) : 0)).'>'.__('Block domain from changing the setting').'
</label>
</div>
<div class="row mb-2">
<div class="col-md-7">
<label for="error_reporting" class="sai_head col-md-6">'.__('Error Reporting :- ').'<span class="sai_exp">'.__('Error reporting can either be an integer representing a bit field, or named constants.').'</span></label><br>
<input type="text" id="error_reporting" name="error_reporting" class="form-control mb-3" value="'.POSTval('error_reporting', (!empty($load_phpfpm) ? $load_phpfpm['error_reporting'] : 'E_ALL & ~E_NOTICE')).'"/>
</div>
<label class="col-md-5">
<input type="checkbox" id="b_error_reporting" name="b_error_reporting" value="on" class="me-2" '.POSTchecked('b_error_reporting', (!empty($load_phpfpm) ? ($load_phpfpm['b_error_reporting'] == 'on' ? 1 : 0) : 0)).'>'.__('Block domain from changing the setting').'
</label>
</div>
<div class="text-center my-3">
<input type="button" class="btn btn-danger" value="'.__('Reset').'" name="reset_settings" id="reset_settings" data-reset_settings="1"/>
<input type="submit" class="btn btn-primary" value="'.__('Submit').'" name="fpm_settings" id="fpm_settings" />
</div>
</form>
</div>
<script>
$("#disable_functions").select2({
tags: true
});
$("#user,#php").on("select2:select", function(e, u = {}){
var user = $("#user option:selected").val();
if(user == 0){
user = "";
}
var php = $("#php option:selected").val();
if(php == "default"){
window.location = "'.$globals['index'].'act=phpfpm_settings&user="+user;
return true;
}
window.location = "'.$globals['index'].'act=phpfpm_settings&user="+user+"&php="+php;
});
$("#reset_settings").on("click", function(){
var jEle = $(this);
var d = jEle.data();
submitit(d, {done_reload : window.location.href});
});
$(document).ready(function(){
var urlParams = new URLSearchParams(window.location.search);
var userParam = urlParams.get("user");
if(userParam){
$("#rlimit_files, #ulimit, label[for=\"rlimit_files\"], label[for=\"ulimit\"]").hide();
}else{
$("#rlimit_files, #ulimit, label[for=\"rlimit_files\"], label[for=\"ulimit\"]").show();
}
});
</script>';
}