Current File : //root/panel/modules/apache_admin/hooks/OnDaemonRun.hook.php |
<?php
//$cmd1='echo "Hai" >> /etc/php.ini';
//shell_exec($cmd1);
/* author: saravana
module : Split log
purpose : Need to create a folder path each and every domain */
/* ***************************************************** Start split log ************************************* */
function splitlogGenerator()
{
global $zdbh;
$splitlog_flag=0;
$sql_splitlog = "SELECT * FROM x_splitlog";
$sql_splitlog = $zdbh->prepare($sql_splitlog);
$sql_splitlog->execute();
$res_splitlog = $sql_splitlog->fetch();
if($res_splitlog['x_flag']=="1")
{
$splitlog_flag=1;
echo "START split log hook" . fs_filehandler::NewLine();
$sql_vhosts = "SELECT * FROM x_vhosts WHERE vh_deleted_ts IS NULL";
$sql_vhosts = $zdbh->prepare($sql_vhosts);
$sql_vhosts->execute();
while($res_vhosts = $sql_vhosts->fetch())
{
$filename = '/var/log/httpd/access/'.$res_vhosts['vh_name_vc'];
if (file_exists($filename)) {
} else {
mkdir($filename, 0777, true);
}
}
echo "End split log hook" . fs_filehandler::NewLine();
}
}
splitlogGenerator();
/* ***************************************************** End split log ************************************* */
echo fs_filehandler::NewLine() . "START Apache Config Hook." . fs_filehandler::NewLine();
if (ui_module::CheckModuleEnabled('Apache Config')) {
echo "Apache Admin module ENABLED..." . fs_filehandler::NewLine();
TriggerApacheQuotaUsage();
if (ctrl_options::GetSystemOption('apache_changed') == strtolower("true")) {
echo "Apache Config has changed..." . fs_filehandler::NewLine();
if (ctrl_options::GetSystemOption('apache_backup') == strtolower("true")) {
echo "Backing up Apache Config to: " . ctrl_options::GetSystemOption('apache_budir') . fs_filehandler::NewLine();
BackupVhostConfigFile();
}
echo "Begin writing Apache Config to: " . ctrl_options::GetSystemOption('apache_vhost') . fs_filehandler::NewLine();
WriteVhostConfigFile();
} else {
echo "Apache Config has NOT changed...nothing to do." . fs_filehandler::NewLine();
}
} else {
echo "Apache Admin module DISABLED...nothing to do." . fs_filehandler::NewLine();
}
phpconfigGenerator();
echo "END Apache Config Hook." . fs_filehandler::NewLine();
function getPHPConfValueBasedOnKey($key, $domain_name)
{
global $zdbh;
global $controller;
shell_exec("echo Domain Name PHP- : $domain_name >> /etc/sentora/panel/modules/apache_admin/hooks/sample_fastcg_started.log");
$sql = "SELECT * FROM x_vhosts WHERE vh_name_vc = '$domain_name' AND vh_deleted_ts is NULL LIMIT 1";
$sql_data = $zdbh->prepare($sql);
$sql_data->execute();
while($res_data = $sql_data->fetch())
{
$current_user_id = $res_data['vh_acc_fk'];
}
shell_exec("echo current user php- : $current_user_id >> /etc/sentora/panel/modules/apache_admin/hooks/sample_fastcg_started.log");
$confg_query = "SELECT * FROM x_php_config WHERE x_clearname='$key' AND x_old_value='$current_user_id' LIMIT 1";
shell_exec("echo Select query : $confg_query >> /etc/sentora/panel/modules/apache_admin/hooks/sample_fastcg_started.log");
$config_data = $zdbh->prepare($confg_query);
$config_data->execute();
if($config_data->rowCount())
{
while($php_conf_data = $config_data->fetch())
{
$return = $php_conf_data['x_value'] ;
}
}
else
{
$confg_query = "SELECT * FROM x_php_config WHERE x_clearname='$key' AND x_old_value='1' LIMIT 1";
$config_data = $zdbh->prepare($confg_query);
$config_data->execute();
while($phpConfData = $config_data->fetch())
{
$return = $phpConfData['x_value'] ;
}
}
//shell_exec("echo Return for FINAL_ANS $key => $return >> /etc/sentora/panel/modules/apache_admin/hooks/sample_fastcg_started.log");
return $return;
}
function phpconfigGenerator()
{
global $zdbh;
$sql = "SELECT * FROM x_php_config WHERE x_clearname='x_update_flag'";
$sql = $zdbh->prepare($sql);
$sql->execute();
$res = $sql->fetch();
if($res['x_value']=="1")
{
$sql = "SELECT * FROM x_php_config ";
$sql = $zdbh->prepare($sql);
$sql->execute();
while( $res = $sql->fetch())
{
if($res['x_clearname']=="post_max_size")
{
$cmd1="sed -i -e 's/post_max_size = ".$res['x_old_value']."/post_max_size = ".$res['x_value']."/g' /etc/php.ini";
shell_exec($cmd1);
}
if($res['x_clearname']=="upload_max_filesize")
{
$cmd1="sed -i -e 's/upload_max_filesize = ".$res['x_old_value']."/upload_max_filesize = ".$res['x_value']."/g' /etc/php.ini";
shell_exec($cmd1);
}
if($res['x_clearname']=="memory_limit")
{
$cmd1="sed -i -e 's/memory_limit = ".$res['x_old_value']."/memory_limit = ".$res['x_value']."/g' /etc/php.ini";
shell_exec($cmd1);
}
if($res['x_clearname']=="max_input_time")
{
$cmd1="sed -i -e 's/max_input_time = ".$res['x_old_value']."/max_input_time = ".$res['x_value']."/g' /etc/php.ini";
shell_exec($cmd1);
}
if($res['x_clearname']=="file_uploads")
{
$cmd1="sed -i -e 's/file_uploads = ".$res['x_old_value']."/file_uploads = ".$res['x_value']."/g' /etc/php.ini";
shell_exec($cmd1);
}
if($res['x_clearname']=="max_execution_time")
{
$cmd1="sed -i -e 's/max_execution_time = ".$res['x_old_value']."/max_execution_time = ".$res['x_value']."/g' /etc/php.ini";
shell_exec($cmd1);
}
if($res['x_clearname']=="session_save_path")
{
$src = str_replace('/', '\/', $res['x_old_value']);
$dest= str_replace('/', '\/', $res['x_value']);
echo $cmd1="sed -i -e 's/session\.save_path = ".$src."/session\.save_path = ".$dest."/g' /etc/php.ini";
echo shell_exec($cmd1);
}
}
$sql1 = "Update x_php_config set x_value='0',x_old_value='0' WHERE x_clearname='x_update_flag'";
$sql1 = $zdbh->prepare($sql1);
$sql1->execute();
// exit;
}
}
/**
*
* @param string $vhostName
* @param numeric $customPort
* @param string $userEmail
* @return string
*
*/
function BuildVhostPortForward($vhostName, $customPort, $userEmail)
{
$line = fs_filehandler::NewLine() . fs_filehandler::NewLine();
$line .= "# DOMAIN: " . $vhostName . fs_filehandler::NewLine();
$line .= "# PORT FORWARD FROM 80 TO: " . $customPort . fs_filehandler::NewLine();
$line .= "<virtualhost *:80>" . fs_filehandler::NewLine();
$line .= "ServerName " . $vhostName . fs_filehandler::NewLine();
$line .= "ServerAlias www." . $vhostName . fs_filehandler::NewLine();
$line .= "ServerAdmin " . $userEmail . fs_filehandler::NewLine();
$line .= "RewriteEngine on" . fs_filehandler::NewLine();
$line .= "ReWriteCond %{SERVER_PORT} !^" . $customPort . "$" . fs_filehandler::NewLine();
$line .= ( $customPort === "443" ) ? "RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] " . fs_filehandler::NewLine() : "RewriteRule ^/(.*) http://%{HTTP_HOST}:" . $customPort . "/$1 [NC,R,L] " . fs_filehandler::NewLine();
$line .= "</virtualhost>" . fs_filehandler::NewLine();
$line .= "# END DOMAIN: " . $vhostName . fs_filehandler::NewLine() . fs_filehandler::NewLine();
return $line;
}
# global $zdbh;
# global $controller;
#$sql= $zdbh->prepare("SELECT flag FROM x_picdata where id='1'");
#$sql->execute();
#$contentl=$sql->fetch();
function WriteVhostConfigFile()
{
global $zdbh;
$config_folder_path="/etc/sentora/configs/apache/domains/";
////////////////////////////////////////////// Port Problem Solving Start ////////////////////////////////////
$sql= $zdbh->prepare("SELECT flag FROM x_picdata where id='1'");
$sql->execute();
$contentl=$sql->fetch();
$sql = "SELECT so_id_pk, so_value_tx FROM x_settings WHERE so_name_vc='apache_log_settings'";
$numrows = $zdbh->prepare($sql);
$numrows->execute();
$add_hash_apache_log = "#";
if ($numrows->fetchColumn() > 0)
{
$sql = $zdbh->prepare($sql);
$sql->execute();
$res = $sql->fetch();
if($res['so_value_tx'] == true)
$add_hash_apache_log = "";
}
$sql = "SELECT * FROM x_varnish";
$sql=$zdbh->query($sql);
$sql->execute();
$res = $sql->fetch();
if($res['x_isactive']==1)
{
$port_id_array=shell_exec(" cat /etc/sentora/configs/apache/httpd-vhosts.conf_dont_use | grep 'Listen '");
$port_id=explode(" ",trim($port_id_array));
$customport=$port_id[count($port_id)-1];
$sql = $zdbh->prepare("Update x_vhosts SET vh_custom_port_in='".$customport."'");
$sql->execute();
if($customport=="8080")
{
$sql = $zdbh->prepare("Update x_varnish SET x_varnish='On'");
$sql->execute();
}else
{
$sql = $zdbh->prepare("Update x_varnish SET x_varnish='Off'");
$sql->execute();
}
}
else
{
if($res['x_varnish']=="On")
{
$customport="8080";
$sql = $zdbh->prepare("Update x_vhosts SET vh_custom_port_in='".$customport."'");
$sql->execute();
}
else
{
$customport="80";
$sql = $zdbh->prepare("Update x_vhosts SET vh_custom_port_in='".$customport."'");
$sql->execute();
}
}
////////////////////////////////////////////// Port Problem Solving End ////////////////////////////////////
//Get email for server admin of Sentora
$getserveremail = $zdbh->query("SELECT ac_email_vc FROM x_accounts where ac_id_pk=1")->fetch();
$serveremail = ( $getserveremail['ac_email_vc'] != "" ) ? $getserveremail['ac_email_vc'] : "postmaster@" . ctrl_options::GetSystemOption('sentora_domain');
$VHostDefaultPort = ctrl_options::GetSystemOption('apache_port');
$customPorts = array(ctrl_options::GetSystemOption('sentora_port'));
$portQuery = $zdbh->prepare("SELECT vh_custom_port_in FROM x_vhosts WHERE vh_deleted_ts IS NULL");
$portQuery->execute();
while ($rowport = $portQuery->fetch()) {
$customPorts[] = (empty($rowport['vh_custom_port_in'])) ? $VHostDefaultPort : $rowport['vh_custom_port_in'];
}
$customPortList = array_unique($customPorts);
/*
* ##############################################################################################################
* #
* # Default Virtual Host Container
* #
* ##############################################################################################################
*/
$line = "################################################################" . fs_filehandler::NewLine();
$line .= "# Apache VHOST configuration file" . fs_filehandler::NewLine();
$line .= "# Automatically generated by Sentora " . sys_versions::ShowSentoraVersion() . fs_filehandler::NewLine();
$line .= "# Generated on: " . date(ctrl_options::GetSystemOption('sentora_df'), time()) . fs_filehandler::NewLine();
$line .= "#==== YOU MUST NOT EDIT THIS FILE : IT WILL BE OVERWRITTEN ====" . fs_filehandler::NewLine();
$line .= "# Use Sentora Menu -> Admin -> Module Admin -> Apache config" . fs_filehandler::NewLine();
$line .= "################################################################" . fs_filehandler::NewLine();
$line .= fs_filehandler::NewLine();
$pline="";
$pline .= fs_filehandler::NewLine();
$pline = "################################################################" . fs_filehandler::NewLine();
$pline .= "# Apache VHOST configuration file" . fs_filehandler::NewLine();
$pline .= "# Automatically generated by Sentora " . sys_versions::ShowSentoraVersion() . fs_filehandler::NewLine();
$pline .= "# Generated on: " . date(ctrl_options::GetSystemOption('sentora_df'), time()) . fs_filehandler::NewLine();
$pline .= "#==== YOU MUST NOT EDIT THIS FILE : IT WILL BE OVERWRITTEN ====" . fs_filehandler::NewLine();
$pline .= "# Use Sentora Menu -> Admin -> Module Admin -> Apache config" . fs_filehandler::NewLine();
$pline .= "################################################################" . fs_filehandler::NewLine();
$pline .= fs_filehandler::NewLine();
$splitlog_flag=0;
$sql_splitlog = "SELECT * FROM x_splitlog";
$sql_splitlog = $zdbh->prepare($sql_splitlog);
$sql_splitlog->execute();
$res_splitlog = $sql_splitlog->fetch();
if($res_splitlog['x_flag']=="1")
{
$splitlog_flag=1;
}
if($splitlog_flag==1)
{
$chkwrite=shell_exec("sed -i -e 's/###!!!LogFormat/LogFormat/g' /etc/sentora/configs/apache/httpd.conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!CustomLog/CustomLog/g' /etc/sentora/configs/apache/httpd.conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!LogFormat/###!!!LogFormat/g' /etc/sentora/configs/apache/httpd.conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!CustomLog/###!!!CustomLog/g' /etc/sentora/configs/apache/httpd.conf");
}else
{
$chkwrite=shell_exec("sed -i -e 's/LogFormat/###!!!LogFormat/g' /etc/sentora/configs/apache/httpd.conf");
$chkwrite=shell_exec("sed -i -e 's/CustomLog/###!!!CustomLog/g' /etc/sentora/configs/apache/httpd.conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!LogFormat/###!!!LogFormat/g' /etc/sentora/configs/apache/httpd.conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!CustomLog/###!!!CustomLog/g' /etc/sentora/configs/apache/httpd.conf");
}
# NameVirtualHost is still needed for Apache 2.2 but must be removed for apache 2.3
if ((double) sys_versions::ShowApacheVersion() < 2.3) {
/* foreach ($customPortList as $port) {
$line .= "NameVirtualHost *:" . $port . fs_filehandler::NewLine();
} */
$sql = "SELECT * FROM x_varnish";
$numrows = $zdbh->prepare($sql);
$numrows->execute();
if ($numrows->fetchColumn() <> 0) {
$sql = $zdbh->prepare($sql);
$sql->execute();
$res = $sql->fetch();
// if($res['x_isactive']==0)
// {
if($res['x_varnish']=="Off")
{
$port=80;
$line .= "NameVirtualHost *:" . $port . fs_filehandler::NewLine();
$pline .= "NameVirtualHost *:" . $port . fs_filehandler::NewLine();
}else
{
$port=8080;
$line .= "NameVirtualHost *:" . $port . fs_filehandler::NewLine();
$pline .= "NameVirtualHost *:" . $port . fs_filehandler::NewLine();
}
// }
}else
{
$port=80;
$line .= "NameVirtualHost *:" . $port . fs_filehandler::NewLine();
$pline .= "NameVirtualHost *:" . $port . fs_filehandler::NewLine();
}
}
# Listen is mandatory for each port <> 80 (80 is defined in system config)
/* foreach ($customPortList as $port) {
$line .= "Listen " . $port . fs_filehandler::NewLine();
} */
$sql = "SELECT * FROM x_varnish";
$numrows = $zdbh->prepare($sql);
$numrows->execute();
if ($numrows->fetchColumn() <> 0) {
$sql = $zdbh->prepare($sql);
$sql->execute();
$res = $sql->fetch();
// if($res['x_isactive']==0)
// {
if($res['x_varnish']=="Off")
{
$port=80;
$line .= "Listen " . $port . fs_filehandler::NewLine();
$pline .= "Listen " . $port . fs_filehandler::NewLine();
}else
{
$port=8080;
$line .= "Listen " . $port . fs_filehandler::NewLine();
$pline .= "Listen " . $port . fs_filehandler::NewLine();
}
// }
}else
{
$port=80;
$line .= "Listen " . $port . fs_filehandler::NewLine();
$pline .= "Listen " . $port . fs_filehandler::NewLine();
}
$port=8080;
$sql = "SELECT * FROM x_varnish";
$numrows = $zdbh->prepare($sql);
$numrows->execute();
if ($numrows->fetchColumn() <> 0) {
$sql = $zdbh->prepare($sql);
$sql->execute();
$res = $sql->fetch();
// if($res['x_isactive']==0)
// {
if($res['x_varnish']=="Off")
{
$port=80;
}else
{
$port=8080;
}
// }
}
if(!file_exists("/etc/sentora/configs/apache/port/port.conf"))
{
$pfile = fopen("/etc/sentora/configs/apache/port/port.conf","w");
fwrite($pfile,$pline);
fclose($pfile);
}
else
{
// need to change the Correct Port
if($port==80)
{
$chkwrite=shell_exec("sed -i -e 's/\<Listen 8080\>/Listen 80/g' /etc/sentora/configs/apache/port/port.conf");
$chkwrite=shell_exec("sed -i -e 's/\<NameVirtualHost \*\:8080\>/NameVirtualHost \*\:80/g' /etc/sentora/configs/apache/port/port.conf");
}
if($port==8080)
{
$chkwrite=shell_exec("sed -i -e 's/\<Listen 80\>/Listen 8080/g' /etc/sentora/configs/apache/port/port.conf");
$chkwrite=shell_exec("sed -i -e 's/\<NameVirtualHost \*\:80\>/NameVirtualHost \*\:8080/g' /etc/sentora/configs/apache/port/port.conf");
}
}
$line .= fs_filehandler::NewLine();
$line .= "# Configuration for Sentora control panel." . fs_filehandler::NewLine();
//$line .= "<VirtualHost *:" . ctrl_options::GetSystemOption('sentora_port') . ">" . fs_filehandler::NewLine();
$line .= "<VirtualHost *:" . $port . ">" . fs_filehandler::NewLine();
$line .= "ServerAdmin " . $serveremail . fs_filehandler::NewLine();
$line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('ipdomain_dir') . '"' . fs_filehandler::NewLine();
//$line .= "ServerName " . ctrl_options::GetSystemOption('sentora_domain') . fs_filehandler::NewLine();
$line .= "ServerName " . ctrl_options::GetSystemOption('server_ip') . fs_filehandler::NewLine();
if($splitlog_flag==0)
{
$line .= $add_hash_apache_log.'ErrorLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-error.log" ' . fs_filehandler::NewLine();
$line .= $add_hash_apache_log.'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-access.log" ' . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
$line .= $add_hash_apache_log.'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-bandwidth.log" ' . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
} else
{
$line .= '###!!!ErrorLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-error.log" ' . fs_filehandler::NewLine();
$line .= '###!!!CustomLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-access.log" ' . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
$line .= '###!!!CustomLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-bandwidth.log" ' . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
}
$line .= "AddType application/x-httpd-php .php" . fs_filehandler::NewLine();
$sline="";
$sline .= fs_filehandler::NewLine();
$sline .= "# Configuration for Sentora control panel." . fs_filehandler::NewLine();
$sline .= "<VirtualHost *:" . $port . ">" . fs_filehandler::NewLine();
$sline .= "ServerAdmin " . $serveremail . fs_filehandler::NewLine();
$sline .= 'DocumentRoot "' . ctrl_options::GetSystemOption('ipdomain_dir') . '"' . fs_filehandler::NewLine();
$sline .= "ServerName " . ctrl_options::GetSystemOption('server_ip') . fs_filehandler::NewLine();
if($splitlog_flag==0)
{
$sline .= $add_hash_apache_log.'ErrorLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-error.log" ' . fs_filehandler::NewLine();
$sline .= $add_hash_apache_log.'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-access.log" ' . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
$sline .= $add_hash_apache_log.'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-bandwidth.log" ' . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
}else
{
$sline .= '###!!!ErrorLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-error.log" ' . fs_filehandler::NewLine();
$sline .= '###!!!CustomLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-access.log" ' . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
$sline .= '###!!!CustomLog "' . ctrl_options::GetSystemOption('log_dir') . 'sentora-bandwidth.log" ' . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
}
$sline .= "AddType application/x-httpd-php .php" . fs_filehandler::NewLine();
/* if($contentl['flag']=='0')
{ */
$line .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$sline .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$sline .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$sline .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$sline .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$sline .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$sline .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
/* }
else
{
$line .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('sentora_domain').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('sentora_domain').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('sentora_domain').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('sentora_domain').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('sentora_domain').':2082/?access=cpanel'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('sentora_domain').':2082/?access=cpanel'.fs_filehandler::NewLine();
$sline .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('sentora_domain').':2095'.fs_filehandler::NewLine();
$sline .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('sentora_domain').':2095'.fs_filehandler::NewLine();
$sline .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('sentora_domain').':2086/?access=whm'.fs_filehandler::NewLine();
$sline .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('sentora_domain').':2086/?access=whm'.fs_filehandler::NewLine();
$sline .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('sentora_domain').':2082/?access=cpanel'.fs_filehandler::NewLine();
$sline .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('sentora_domain').':2082/?access=cpanel'.fs_filehandler::NewLine();
} */
/* //////////////////////////// Temporary URL Start //////////////////////// */
echo "Temprory URL rewriting start\n ";
$sql_account = "SELECT * FROM x_accounts WHERE ac_deleted_ts IS NULL AND ac_id_pk!='1'";
$numrows_account = $zdbh->prepare($sql_account);
$numrows_account->execute();
if ($numrows_account->fetchColumn() <> 0) {
$sql_account = $zdbh->prepare($sql_account);
$sql_account->execute();
while($res_user = $sql_account->fetch())
{
$user_dir="";
$sql_user="SELECT * FROM x_vhosts WHERE vh_id_pk IN ( select x_domain_id from x_main_domain where x_user_id ='".$res_user['ac_id_pk']."')";
$numrows_sql_user = $zdbh->prepare($sql_user);
$numrows_sql_user->execute();
if ($numrows_sql_user->fetchColumn() <> 0) {
$sql_user="SELECT * FROM x_vhosts WHERE vh_id_pk IN ( select x_domain_id from x_main_domain where x_user_id ='".$res_user['ac_id_pk']."')";
}else
{
$sql_user="SELECT * FROM x_vhosts WHERE vh_name_vc Like '%".$res_user['ac_user_vc'].".%' AND vh_deleted_ts IS NULL Order By vh_id_pk ASC";
}
$numrows_sql_user = $zdbh->prepare($sql_user);
$numrows_sql_user->execute();
$reshost= $numrows_sql_user->fetch();
// $DestDir = '"' . ctrl_options::GetSystemOption('hosted_dir') . $res_user['ac_user_vc'] . $reshost['vh_directory_vc'] . '"'; // by nandhini
$DestDir = '"' . ctrl_options::GetSystemOption('hosted_dir') . $res_user['ac_user_vc'] . '/"'; // by saravana
$line.='Alias "/~'.$res_user['ac_user_vc'].'/" '.$DestDir.fs_filehandler::NewLine();
$sline.='Alias "/~'.$res_user['ac_user_vc'].'/" '.$DestDir.fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() >= 2.4)
{
$line .= '<Directory ' . $DestDir . '>' . fs_filehandler::NewLine();
$line .= " AllowOverride All" . fs_filehandler::NewLine();
$line .= " Require all granted" . fs_filehandler::NewLine();
$line .= "</Directory>" . fs_filehandler::NewLine();
$sline .= '<Directory ' . $DestDir . '>' . fs_filehandler::NewLine();
$sline .= " AllowOverride All" . fs_filehandler::NewLine();
$sline .= " Require all granted" . fs_filehandler::NewLine();
$sline .= "</Directory>" . fs_filehandler::NewLine();
}
}
}
echo "Temprory URL rewriting End\n";
/* //////////////////////////// Temporary URL End //////////////////////// */
$line .= '<Directory "' . ctrl_options::GetSystemOption('ipdomain_dir') . '">' . fs_filehandler::NewLine();
$line .= "Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$line .= " AllowOverride All" . fs_filehandler::NewLine();
$sline .= '<Directory "' . ctrl_options::GetSystemOption('ipdomain_dir') . '">' . fs_filehandler::NewLine();
$sline .= "Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$sline .= " AllowOverride All" . fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() < 2.4) {
$line .= " Order allow,deny" . fs_filehandler::NewLine();
$line .= " Allow from all" . fs_filehandler::NewLine();
$sline .= " Order allow,deny" . fs_filehandler::NewLine();
$sline .= " Allow from all" . fs_filehandler::NewLine();
} else {
$line .= " Require all granted" . fs_filehandler::NewLine();
$sline .= " Require all granted" . fs_filehandler::NewLine();
}
$line .= "</Directory>" . fs_filehandler::NewLine();
$line .= fs_filehandler::NewLine();
$line .= "# Custom settings are loaded below this line (if any exist)" . fs_filehandler::NewLine();
// Global custom Sentora entry
$line .= ctrl_options::GetSystemOption('global_zpcustom') . fs_filehandler::NewLine();
$line .= "</VirtualHost>" . fs_filehandler::NewLine();
$line .= fs_filehandler::NewLine();
$line .= "################################################################" . fs_filehandler::NewLine();
$line .= "# Sentora generated VHOST configurations below....." . fs_filehandler::NewLine();
$line .= "################################################################" . fs_filehandler::NewLine();
$line .= fs_filehandler::NewLine();
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
$sline .= "</Directory>" . fs_filehandler::NewLine();
$sline .= fs_filehandler::NewLine();
$sline .= "# Custom settings are loaded below this line (if any exist)" . fs_filehandler::NewLine();
// Global custom Sentora entry
$sline .= ctrl_options::GetSystemOption('global_zpcustom') . fs_filehandler::NewLine();
$sline .= "</VirtualHost>" . fs_filehandler::NewLine();
$sline .= fs_filehandler::NewLine();
$sline .= "################################################################" . fs_filehandler::NewLine();
$sline .= "# Sentora generated VHOST configurations below....." . fs_filehandler::NewLine();
$sline .= "################################################################" . fs_filehandler::NewLine();
$sline .= fs_filehandler::NewLine();
/* if(!file_exists("/etc/sentora/configs/apache/sentora/sentora.conf"))
{ */
$sfile = fopen("/etc/sentora/configs/apache/sentora/sentora.conf","w");
fwrite($sfile,$sline);
fclose($sfile);
/* }else
{
// need to change the Correct Port
if($splitlog_flag==1)
{
$chkwrite=shell_exec("sed -i -e 's/ErrorLog /###!!!ErrorLog /g' /etc/sentora/configs/apache/sentora/sentora.conf");
$chkwrite=shell_exec("sed -i -e 's/CustomLog /###!!!CustomLog /g' /etc/sentora/configs/apache/sentora/sentora.conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!ErrorLog /###!!!ErrorLog /g' /etc/sentora/configs/apache/sentora/sentora.conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!CustomLog /###!!!CustomLog /g' /etc/sentora/configs/apache/sentora/sentora.conf");
}else
{
$chkwrite=shell_exec("sed -i -e 's/###!!!ErrorLog /ErrorLog /g' /etc/sentora/configs/apache/sentora/sentora.conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!CustomLog /CustomLog /g' /etc/sentora/configs/apache/sentora/sentora.conf");
}
if($port==80)
{
$chkwrite=shell_exec("sed -i -e 's/\<VirtualHost \*\:8080\>/VirtualHost \*\:80/g' /etc/sentora/configs/apache/sentora/sentora.conf");
}
if($port==8080)
{
$chkwrite=shell_exec("sed -i -e 's/\<VirtualHost \*\:80\>/VirtualHost \*\:8080/g' /etc/sentora/configs/apache/sentora/sentora.conf");
}
} */
/*
* ##############################################################################################################
* #
* # All Virtual Host Containers
* #
* ##############################################################################################################
*/
// Sentora virtual host container configuration
$sql = $zdbh->prepare("SELECT * FROM x_vhosts WHERE vh_deleted_ts IS NULL");
$sql->execute();
while ($rowvhost = $sql->fetch()) {
$vline="". fs_filehandler::NewLine();
// Grab some variables we will use for later...
$vhostuser = ctrl_users::GetUserDetail($rowvhost['vh_acc_fk']);
$bandwidth = ctrl_users::GetQuotaUsages('bandwidth', $vhostuser['userid']);
$diskspace = ctrl_users::GetQuotaUsages('manageclientcurrentdisk', $vhostuser['userid']);
// Set the vhosts to "LIVE"
$vsql = $zdbh->prepare("UPDATE x_vhosts SET vh_active_in=1 WHERE vh_id_pk=:id");
$vsql->bindParam(':id', $rowvhost['vh_id_pk']);
$vsql->execute();
// Add a default email if no email found for client.
$useremail = ( fs_director::CheckForEmptyValue($vhostuser['email']) ) ? "postmaster@" . $rowvhost['vh_name_vc'] : $vhostuser['email'];
// Check if domain or subdomain to see if we add an alias with 'www'
$serveralias = ( $rowvhost['vh_type_in'] == -2 ) ? '' : " www." . $rowvhost['vh_name_vc'];
$vhostPort = ( fs_director::CheckForEmptyValue($rowvhost['vh_custom_port_in']) ) ? $VHostDefaultPort : $rowvhost['vh_custom_port_in'];
$vhostIp = ( fs_director::CheckForEmptyValue($rowvhost['vh_custom_ip_vc']) ) ? "*" : $rowvhost['vh_custom_ip_vc'];
/*
* ##################################################
* #
* # Get a PHP version
* #
* ##################################################
*/
$phpVersion="";
$sql_php = "SELECT * FROM x_phpversion_upgrade WHERE x_client_id=:userid ";
$numrows_php = $zdbh->prepare($sql_php);
$numrows_php->bindParam(':userid',$rowvhost['vh_id_pk']);
$numrows_php->execute();
$core_php_version = ctrl_options::GetSystemOption('core_php_version');
if ($numrows_php->fetchColumn() <> 0)
{
$numrows_php1 = $zdbh->prepare($sql_php);
$numrows_php1->bindParam(':userid', $rowvhost['vh_id_pk']);
$numrows_php1->execute();
$res=$numrows_php1->fetch();
$phpVersion=$res['x_php_version'];
}else
{
if(!$core_php_version)
{
if(version_compare(phpversion(),"5.5")==1)
{
$phpVersion="php56";
}else
{
$phpVersion="php53";
}
}
else
{
$phpVersion=strtolower($core_php_version);
}
}
//Domain is enabled
//Line1: Domain enabled & Client also is enabled.
//Line2: Domain enabled & Client may be disabled, but 'Allow Disabled' = 'true' in apache settings.
if ($rowvhost['vh_enabled_in'] == 1 && ctrl_users::CheckUserEnabled($rowvhost['vh_acc_fk']) ||
$rowvhost['vh_enabled_in'] == 1 && ctrl_options::GetSystemOption('apache_allow_disabled') == strtolower("true")) {
/*
* ##################################################
* #
* # Disk Quotas Check
* #
* ##################################################
*/
//Domain is beyond its diskusage
if ($vhostuser['diskquota'] != 0 && $diskspace > $vhostuser['diskquota']) {
$line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "# THIS DOMAIN HAS BEEN DISABLED FOR QUOTA OVERAGE" . fs_filehandler::NewLine();
$line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
$line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
$line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('static_dir') . 'diskexceeded"' . fs_filehandler::NewLine();
$vline .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "# THIS DOMAIN HAS BEEN DISABLED FOR QUOTA OVERAGE" . fs_filehandler::NewLine();
$vline .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
$vline .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
$vline .= 'DocumentRoot "' . ctrl_options::GetSystemOption('static_dir') . 'diskexceeded"' . fs_filehandler::NewLine();
if($contentl['flag']=='0')
{
$line .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
}
else
{
$line .= 'Redirect /webmail http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel/ http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail/ http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm/ http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel/ http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
}
$vline .= 'SecRuleEngine On'.fs_filehandler::NewLine();
$vline .= 'SecRequestBodyAccess On'.fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() >= 2.4)
{
$vline .= 'SecTmpSaveUploadedFiles On'.fs_filehandler::NewLine();
}
$checkversion="";
if(!$core_php_version)
{
if(version_compare(phpversion(),"5.5")==1)
{
$checkversion="php56";
}else
{
$checkversion="php53";
}
}
else
{
$checkversion=strtolower($core_php_version);
}
if($phpVersion===$checkversion)
{
$line .= '###!!!<FilesMatch \.php$>'.fs_filehandler::NewLine();
$line .= '###!!!SetHandler fcgid-script'.fs_filehandler::NewLine();
$line .= '###!!!</FilesMatch>'.fs_filehandler::NewLine();
$vline .= '###!!!<FilesMatch \.php$>'.fs_filehandler::NewLine();
$vline .= '###!!!SetHandler fcgid-script'.fs_filehandler::NewLine();
$vline .= '###!!!</FilesMatch>'.fs_filehandler::NewLine();
}else
{
$line .= '<FilesMatch \.php$>'.fs_filehandler::NewLine();
$line .= 'SetHandler fcgid-script'.fs_filehandler::NewLine();
$line .= '</FilesMatch>'.fs_filehandler::NewLine();
$vline .= '<FilesMatch \.php$>'.fs_filehandler::NewLine();
$vline .= 'SetHandler fcgid-script'.fs_filehandler::NewLine();
$vline .= '</FilesMatch>'.fs_filehandler::NewLine();
}
$line .= '<Directory "' . ctrl_options::GetSystemOption('static_dir') . 'diskexceeded">' . fs_filehandler::NewLine();
$vline .= '<Directory "' . ctrl_options::GetSystemOption('static_dir') . 'diskexceeded">' . fs_filehandler::NewLine();
$line .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
if($phpVersion===$checkversion)
{
/* $line .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine(); */
$line .= " ###!!!AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$line .= " ###!!!FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
$vline .= " ###!!!AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$vline .= " ###!!!FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
}else
{
/* $line .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
*/
$line .= " AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$line .= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
$vline .= " AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$vline .= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
}
$line .= " AllowOverride All" . fs_filehandler::NewLine();
$vline .= " AllowOverride All" . fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() < 2.4) {
$line .= " Order allow,deny" . fs_filehandler::NewLine();
$line .= " Allow from all" . fs_filehandler::NewLine();
$line .= " Order allow,deny" . fs_filehandler::NewLine();
$line .= " Allow from all" . fs_filehandler::NewLine();
$vline .= " Order allow,deny" . fs_filehandler::NewLine();
$vline .= " Allow from all" . fs_filehandler::NewLine();
$vline .= " Order allow,deny" . fs_filehandler::NewLine();
$vline .= " Allow from all" . fs_filehandler::NewLine();
} else {
$line .= " Require all granted" . fs_filehandler::NewLine();
$vline .= " Require all granted" . fs_filehandler::NewLine();
}
$line .= "</Directory>" . fs_filehandler::NewLine();
$line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
$line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
$line .= "</virtualhost>" . fs_filehandler::NewLine();
$line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "################################################################" . fs_filehandler::NewLine();
$line .= fs_filehandler::NewLine();
$vline .= "</Directory>" . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
$vline .= "</virtualhost>" . fs_filehandler::NewLine();
$vline .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "################################################################" . fs_filehandler::NewLine();
$vline .= fs_filehandler::NewLine();
if ($rowvhost['vh_portforward_in'] <> 0) {
$line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
$Vline .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
}
$line .= fs_filehandler::NewLine();
$vline .= fs_filehandler::NewLine();
/*
* ##################################################
* #
* # Bandwidth Quotas Check
* #
* ##################################################
*/
//Domain is beyond its quota
} elseif ($vhostuser['bandwidthquota'] != 0 && $bandwidth > $vhostuser['bandwidthquota']) {
$line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "# THIS DOMAIN HAS BEEN DISABLED FOR BANDWIDTH OVERAGE" . fs_filehandler::NewLine();
$line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
$line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
$line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('static_dir') . 'bandwidthexceeded"' . fs_filehandler::NewLine();
$vline .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "# THIS DOMAIN HAS BEEN DISABLED FOR BANDWIDTH OVERAGE" . fs_filehandler::NewLine();
$vline .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
$vline .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
$vline .= 'DocumentRoot "' . ctrl_options::GetSystemOption('static_dir') . 'bandwidthexceeded"' . fs_filehandler::NewLine();
if($contentl['flag']=='0')
{
$line .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
}
else
{
$line .= 'Redirect /webmail http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel/ http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail/ http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm/ http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel/ http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
}
$vline .= 'SecRuleEngine On'.fs_filehandler::NewLine();
$vline .= 'SecRequestBodyAccess On'.fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() >= 2.4)
{
$vline .= 'SecTmpSaveUploadedFiles On'.fs_filehandler::NewLine();
}
$checkversion="";
if(!$core_php_version)
{
if(version_compare(phpversion(),"5.5")==1)
{
$checkversion="php56";
}else
{
$checkversion="php53";
}
}
else
{
$checkversion=strtolower($core_php_version);
}
if($phpVersion===$checkversion)
{
$line .= '###!!!<FilesMatch \.php$>'.fs_filehandler::NewLine();
$line .= '###!!!SetHandler fcgid-script'.fs_filehandler::NewLine();
$line .= '###!!!</FilesMatch>'.fs_filehandler::NewLine();
$vline .= '###!!!<FilesMatch \.php$>'.fs_filehandler::NewLine();
$vline .= '###!!!SetHandler fcgid-script'.fs_filehandler::NewLine();
$vline .= '###!!!</FilesMatch>'.fs_filehandler::NewLine();
}
else
{
$line .= '<FilesMatch \.php$>'.fs_filehandler::NewLine();
$line .= 'SetHandler fcgid-script'.fs_filehandler::NewLine();
$line .= '</FilesMatch>'.fs_filehandler::NewLine();
$vline .= '<FilesMatch \.php$>'.fs_filehandler::NewLine();
$vline .= 'SetHandler fcgid-script'.fs_filehandler::NewLine();
$vline .= '</FilesMatch>'.fs_filehandler::NewLine();
}
$line .= '<Directory "' . ctrl_options::GetSystemOption('static_dir') . 'bandwidthexceeded">' . fs_filehandler::NewLine();
// $line .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$vline .= '<Directory "' . ctrl_options::GetSystemOption('static_dir') . 'bandwidthexceeded">' . fs_filehandler::NewLine();
$line .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
if($phpVersion===$checkversion)
{
/* $line .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine(); */
$line .= " ###!!!AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$line .= " ###!!!FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
$vline .= " ###!!!AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$vline .= " ###!!!FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
}else
{
/* $line .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
*/
$line .= " AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$line .= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
$vline .= " AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$vline .= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
}
$line .= " AllowOverride All" . fs_filehandler::NewLine();
$vline .= " AllowOverride All" . fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() < 2.4) {
$line .= " Order allow,deny" . fs_filehandler::NewLine();
$line .= " Allow from all" . fs_filehandler::NewLine();
$vline .= " Order allow,deny" . fs_filehandler::NewLine();
$vline .= " Allow from all" . fs_filehandler::NewLine();
} else {
$line .= " Require all granted" . fs_filehandler::NewLine();
$vline .= " Require all granted" . fs_filehandler::NewLine();
}
$line .= "</Directory>" . fs_filehandler::NewLine();
$line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
$line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
$line .= "</virtualhost>" . fs_filehandler::NewLine();
$line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "################################################################" . fs_filehandler::NewLine();
$line .= fs_filehandler::NewLine();
$vline .= "</Directory>" . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
$vline .= "</virtualhost>" . fs_filehandler::NewLine();
$vline .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "################################################################" . fs_filehandler::NewLine();
$vline .= fs_filehandler::NewLine();
if ($rowvhost['vh_portforward_in'] <> 0) {
$line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
$vline .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
}
$line .= fs_filehandler::NewLine();
$vline .= fs_filehandler::NewLine();
/*
* ##################################################
* #
* # Parked Domain
* #
* ##################################################
*/
//Domain is a PARKED domain.
} elseif ($rowvhost['vh_type_in'] == 3) {
$RootDir = '"' . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . $rowvhost['vh_directory_vc'] . '"'; //by nandhini
$line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
$line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
//$line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('parking_path') . '"' . fs_filehandler::NewLine();
$line .= 'DocumentRoot ' . $RootDir . fs_filehandler::NewLine();
$vline .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
$vline .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
//$line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('parking_path') . '"' . fs_filehandler::NewLine();
$vline .= 'DocumentRoot ' . $RootDir . fs_filehandler::NewLine();
if($contentl['flag']=='0')
{
$line .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
}
else
{
$line .= 'Redirect /webmail http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel/ http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail/ http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm/ http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel/ http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
}
$vline .= 'SecRuleEngine On'.fs_filehandler::NewLine();
$vline .= 'SecRequestBodyAccess On'.fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() >= 2.4)
{
$vline .= 'SecTmpSaveUploadedFiles On'.fs_filehandler::NewLine();
}
$checkversion="";
if(!$core_php_version)
{
if(version_compare(phpversion(),"5.5")==1)
{
$checkversion="php56";
}else
{
$checkversion="php53";
}
}
else
{
$checkversion=strtolower($core_php_version);
}
if($phpVersion===$checkversion)
{
$line .= '###!!!<FilesMatch \.php$>'.fs_filehandler::NewLine();
$line .= '###!!!SetHandler fcgid-script'.fs_filehandler::NewLine();
$line .= '###!!!</FilesMatch>'.fs_filehandler::NewLine();
$vline .= '###!!!<FilesMatch \.php$>'.fs_filehandler::NewLine();
$vline .= '###!!!SetHandler fcgid-script'.fs_filehandler::NewLine();
$vline .= '###!!!</FilesMatch>'.fs_filehandler::NewLine();
}else
{
$line .= '<FilesMatch \.php$>'.fs_filehandler::NewLine();
$line .= 'SetHandler fcgid-script'.fs_filehandler::NewLine();
$line .= '</FilesMatch>'.fs_filehandler::NewLine();
$vline .= '<FilesMatch \.php$>'.fs_filehandler::NewLine();
$vline .= 'SetHandler fcgid-script'.fs_filehandler::NewLine();
$vline .= '</FilesMatch>'.fs_filehandler::NewLine();
}
$line .= '<Directory ' . $RootDir . '>' . fs_filehandler::NewLine();
$vline .= '<Directory ' . $RootDir . '>' . fs_filehandler::NewLine();
$line .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
if($phpVersion===$checkversion)
{
/* $line .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine(); */
$line .= " ###!!!AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$line .= " ###!!!FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
$vline .= " ###!!!AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$vline .= " ###!!!FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
}else
{
/* $line .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
*/
$line .= " AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$line .= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
$vline .= " AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$vline .= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
}
$line .= " AllowOverride All" . fs_filehandler::NewLine();
$vline .= " AllowOverride All" . fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() < 2.4) {
$line .= " Order allow,deny" . fs_filehandler::NewLine();
$line .= " Allow from all" . fs_filehandler::NewLine();
$vline .= " Order allow,deny" . fs_filehandler::NewLine();
$vline .= " Allow from all" . fs_filehandler::NewLine();
} else {
$line .= " Require all granted" . fs_filehandler::NewLine();
$vline .= " Require all granted" . fs_filehandler::NewLine();
}
$line .= "</Directory>" . fs_filehandler::NewLine();
$line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
$line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
$line .= "# Custom Global Settings (if any exist)" . fs_filehandler::NewLine();
$line .= ctrl_options::GetSystemOption('global_vhcustom') . fs_filehandler::NewLine();
$line .= "# Custom VH settings (if any exist)" . fs_filehandler::NewLine();
$line .= $rowvhost['vh_custom_tx'] . fs_filehandler::NewLine();
$line .= "</virtualhost>" . fs_filehandler::NewLine();
$line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "################################################################" . fs_filehandler::NewLine();
$line .= fs_filehandler::NewLine();
$vline .= "</Directory>" . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
$vline .= "# Custom Global Settings (if any exist)" . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('global_vhcustom') . fs_filehandler::NewLine();
$vline .= "# Custom VH settings (if any exist)" . fs_filehandler::NewLine();
$vline .= $rowvhost['vh_custom_tx'] . fs_filehandler::NewLine();
$vline .= "</virtualhost>" . fs_filehandler::NewLine();
$vline .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "################################################################" . fs_filehandler::NewLine();
$vline .= fs_filehandler::NewLine();
if ($rowvhost['vh_portforward_in'] <> 0) {
$line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
$vline .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
}
$line .= fs_filehandler::NewLine();
$vline .= fs_filehandler::NewLine();
/*
* ##################################################
* #
* # Regular or Sub domain
* #
* ##################################################
*/
//Domain is a regular domain or a subdomain.
} else {
$RootDir = '"' . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . $rowvhost['vh_directory_vc'] . '"'; //by nandhini
$line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
$vline .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
/*
* todo
*/
// Bandwidth Settings
//$line .= "Include C:/Sentora/bin/apache/conf/mod_bw/mod_bw/mod_bw_Administration.conf" . fs_filehandler::NewLine();
// Server name, alias, email settings
$line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
if (!empty($serveralias))
$line .= "ServerAlias " . $serveralias . fs_filehandler::NewLine();
$line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
// Document root
$line .= 'DocumentRoot ' . $RootDir . fs_filehandler::NewLine();
// Get Package openbasedir and suhosin enabled options
if (!empty($serveralias))
$vline .= "ServerAlias " . $serveralias . fs_filehandler::NewLine();
$vline .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
// Document root
$vline .= 'DocumentRoot ' . $RootDir . fs_filehandler::NewLine();
// Get Package openbasedir and suhosin enabled options
if (ctrl_options::GetSystemOption('use_openbase') == "true") {
if ($rowvhost['vh_obasedir_in'] <> 0) {
$line .= 'php_admin_value open_basedir "' . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . ctrl_options::GetSystemOption('openbase_seperator') . ctrl_options::GetSystemOption('openbase_temp') . '"' . fs_filehandler::NewLine(); // by nandhini
$vline .= 'php_admin_value open_basedir "' . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . ctrl_options::GetSystemOption('openbase_seperator') . ctrl_options::GetSystemOption('openbase_temp') . '"' . fs_filehandler::NewLine(); // by nandhini
}
}
if (ctrl_options::GetSystemOption('use_suhosin') == "true") {
if ($rowvhost['vh_suhosin_in'] <> 0) {
$line .= ctrl_options::GetSystemOption('suhosin_value') . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('suhosin_value') . fs_filehandler::NewLine();
}
}
// Logs
if (!is_dir(ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/")) {
fs_director::CreateDirectory(ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/");
}
if($splitlog_flag==0)
{
$line .= $add_hash_apache_log.'ErrorLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-error.log" ' . fs_filehandler::NewLine();
$line .= $add_hash_apache_log.'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-access.log" ' . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
$line .= $add_hash_apache_log.'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-bandwidth.log" ' . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
$vline .= $add_hash_apache_log.'ErrorLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-error.log" ' . fs_filehandler::NewLine();
$vline .= $add_hash_apache_log.'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-access.log" ' . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
$vline .= $add_hash_apache_log.'CustomLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-bandwidth.log" ' . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
}
else
{
$line .= '###!!!ErrorLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-error.log" ' . fs_filehandler::NewLine();
$line .= '###!!!CustomLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-access.log" ' . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
$line .= '###!!!CustomLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-bandwidth.log" ' . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
$vline .= '###!!!ErrorLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-error.log" ' . fs_filehandler::NewLine();
$vline .= '###!!!CustomLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-access.log" ' . ctrl_options::GetSystemOption('access_log_format') . fs_filehandler::NewLine();
$vline .= '###!!!CustomLog "' . ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" . $rowvhost['vh_name_vc'] . '-bandwidth.log" ' . ctrl_options::GetSystemOption('bandwidth_log_format') . fs_filehandler::NewLine();
}
if($contentl['flag']=='0')
{
$line .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();// Directory options
$line .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();// Directory options
$vline .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
}
else
{
$line .= 'Redirect /webmail http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();// Directory options
$line .= 'Redirect /cpanel/ http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail/ http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm/ http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();// Directory options
$vline .= 'Redirect /cpanel/ http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
}
$vline .= 'SecRuleEngine On'.fs_filehandler::NewLine();
$vline .= 'SecRequestBodyAccess On'.fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() >= 2.4)
{
$vline .= 'SecTmpSaveUploadedFiles On'.fs_filehandler::NewLine();
}
$checkversion="";
if(!$core_php_version)
{
if(version_compare(phpversion(),"5.5")==1)
{
$checkversion="php56";
}else
{
$checkversion="php53";
}
}
else
{
$checkversion=strtolower($core_php_version);
}
if($phpVersion===$checkversion)
{
$line .= '###!!!<FilesMatch \.php$>'.fs_filehandler::NewLine();
$line .= '###!!!SetHandler fcgid-script'.fs_filehandler::NewLine();
$line .= '###!!!</FilesMatch>'.fs_filehandler::NewLine();
$vline .= '###!!!<FilesMatch \.php$>'.fs_filehandler::NewLine();
$vline .= '###!!!SetHandler fcgid-script'.fs_filehandler::NewLine();
$vline .= '###!!!</FilesMatch>'.fs_filehandler::NewLine();
}else
{
$line .= '<FilesMatch \.php$>'.fs_filehandler::NewLine();
$line .= 'SetHandler fcgid-script'.fs_filehandler::NewLine();
$line .= '</FilesMatch>'.fs_filehandler::NewLine();
$vline .= '<FilesMatch \.php$>'.fs_filehandler::NewLine();
$vline .= 'SetHandler fcgid-script'.fs_filehandler::NewLine();
$vline .= '</FilesMatch>'.fs_filehandler::NewLine();
}
$line .= '<Directory ' . $RootDir . '>' . fs_filehandler::NewLine();
// $line .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$vline .= '<Directory ' . $RootDir . '>' . fs_filehandler::NewLine();
// $vline .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$line .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
if($phpVersion===$checkversion)
{
/* $line .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine(); */
$line .= " ###!!!AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$line .= " ###!!!FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
$vline .= " ###!!!AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$vline .= " ###!!!FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
}else
{
/* $line .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
*/
$line .= " AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$line .= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
$vline .= " AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$vline .= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
}
$line .= " AllowOverride All" . fs_filehandler::NewLine();
$vline .= " AllowOverride All" . fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() < 2.4) {
$line .= " Order allow,deny" . fs_filehandler::NewLine();
$line .= " Allow from all" . fs_filehandler::NewLine();
$vline .= " Order allow,deny" . fs_filehandler::NewLine();
$vline .= " Allow from all" . fs_filehandler::NewLine();
} else {
$line .= " Require all granted" . fs_filehandler::NewLine();
$vline .= " Require all granted" . fs_filehandler::NewLine();
}
$line .= "</Directory>" . fs_filehandler::NewLine();
$vline .= "</Directory>" . fs_filehandler::NewLine();
// Get Package php and cgi enabled options
$rows = $zdbh->prepare("SELECT * FROM x_packages WHERE pk_id_pk=:packageid AND pk_deleted_ts IS NULL");
$rows->bindParam(':packageid', $vhostuser['packageid']);
$rows->execute();
$packageinfo = $rows->fetch();
if ($packageinfo['pk_enablephp_in'] <> 0) {
$line .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('php_handler') . fs_filehandler::NewLine();
}
# curently disabled because un secure
# need correct cleaning in interface for full removal or in comment here until restoration
# if ( $packageinfo[ 'pk_enablecgi_in' ] <> 0 ) {
# $line .= ctrl_options::GetSystemOption( 'cgi_handler' ) . fs_filehandler::NewLine();
# if ( !is_dir( ctrl_options::GetSystemOption( 'hosted_dir' ) . $vhostuser[ 'username' ] . "/public_html" . $rowvhost[ 'vh_directory_vc' ] . "/_cgi-bin" ) ) {
# fs_director::CreateDirectory( ctrl_options::GetSystemOption( 'hosted_dir' ) . $vhostuser[ 'username' ] . "/public_html" . $rowvhost[ 'vh_directory_vc' ] . "/_cgi-bin" );
# }
# }
// Error documents:- Error pages are added automatically if they are found in the _errorpages directory
// and if they are a valid error code, and saved in the proper format, i.e. <error_number>.html
$errorpages = ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . $rowvhost['vh_directory_vc'] . "/_errorpages"; // by nandhini
if (is_dir($errorpages)) {
if ($handle = opendir($errorpages)) {
while (($file = readdir($handle)) !== false) {
if ($file != "." && $file != "..") {
$page = explode(".", $file);
if (!fs_director::CheckForEmptyValue(CheckErrorDocument($page[0]))) {
$line .= "ErrorDocument " . $page[0] . " /_errorpages/" . $page[0] . ".html" . fs_filehandler::NewLine();
$vline .= "ErrorDocument " . $page[0] . " /_errorpages/" . $page[0] . ".html" . fs_filehandler::NewLine();
}
}
}
closedir($handle);
}
}
// Directory indexes
$line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
// Global custom global vh entry
$line .= "# Custom Global Settings (if any exist)" . fs_filehandler::NewLine();
$line .= ctrl_options::GetSystemOption('global_vhcustom') . fs_filehandler::NewLine();
// Client custom vh entry
$line .= "# Custom VH settings (if any exist)" . fs_filehandler::NewLine();
$line .= $rowvhost['vh_custom_tx'] . fs_filehandler::NewLine();
// End Virtual Host Settings
$line .= "</virtualhost>" . fs_filehandler::NewLine();
$line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "################################################################" . fs_filehandler::NewLine();
$line .= fs_filehandler::NewLine();
// Directory indexes
$vline .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
// Global custom global vh entry
$vline .= "# Custom Global Settings (if any exist)" . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('global_vhcustom') . fs_filehandler::NewLine();
// Client custom vh entry
$vline .= "# Custom VH settings (if any exist)" . fs_filehandler::NewLine();
$vline .= $rowvhost['vh_custom_tx'] . fs_filehandler::NewLine();
// End Virtual Host Settings
$vline .= "</virtualhost>" . fs_filehandler::NewLine();
$vline .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "################################################################" . fs_filehandler::NewLine();
$vline .= fs_filehandler::NewLine();
if ($rowvhost['vh_portforward_in'] <> 0) {
$line .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
$vline .= BuildVhostPortForward($rowvhost['vh_name_vc'], $vhostPort, $useremail);
}
$line .= fs_filehandler::NewLine();
$vline .= fs_filehandler::NewLine();
}
/*
* ##################################################
* #
* # Disabled domain
* #
* ##################################################
*/
} else {
//Domain is NOT enabled
$line .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "# THIS DOMAIN HAS BEEN DISABLED" . fs_filehandler::NewLine();
$line .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
$line .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
$line .= 'DocumentRoot "' . ctrl_options::GetSystemOption('static_dir') . 'disabled/"' . fs_filehandler::NewLine();
//Domain is NOT enabled
$vline .= "# DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "# THIS DOMAIN HAS BEEN DISABLED" . fs_filehandler::NewLine();
$vline .= "<virtualhost " . $vhostIp . ":" . $vhostPort . ">" . fs_filehandler::NewLine();
$vline .= "ServerName " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "ServerAlias www." . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "ServerAdmin " . $useremail . fs_filehandler::NewLine();
$vline .= 'DocumentRoot "' . ctrl_options::GetSystemOption('static_dir') . 'disabled/"' . fs_filehandler::NewLine();
if($contentl['flag']=='0')
{
$line .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail/ http://'.ctrl_options::GetSystemOption('server_ip').':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm/ http://'.ctrl_options::GetSystemOption('server_ip').':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel/ http://'.ctrl_options::GetSystemOption('server_ip').':2082/?access=cpanel'.fs_filehandler::NewLine();
}
else
{
$line .= 'Redirect /webmail http://'.$rowvhost['vh_name_vc'] .':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /webmail/ http://'.$rowvhost['vh_name_vc'] .':2095'.fs_filehandler::NewLine();
$line .= 'Redirect /whm http://'.$rowvhost['vh_name_vc'] .':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /whm/ http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$line .= 'Redirect /cpanel/ http://'.$rowvhost['vh_name_vc'].':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /webmail/ http://'.$rowvhost['vh_name_vc'].':2095'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /whm/ http://'.$rowvhost['vh_name_vc'].':2086/?access=whm'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel http://'.$rowvhost['vh_name_vc'] .':2082/?access=cpanel'.fs_filehandler::NewLine();
$vline .= 'Redirect /cpanel/ http://'.$rowvhost['vh_name_vc'] .':2082/?access=cpanel'.fs_filehandler::NewLine();
}
$vline .= 'SecRuleEngine On'.fs_filehandler::NewLine();
$vline .= 'SecRequestBodyAccess On'.fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() >= 2.4)
{
$vline .= 'SecTmpSaveUploadedFiles On'.fs_filehandler::NewLine();
}
$checkversion="";
if(!$core_php_version)
{
if(version_compare(phpversion(),"5.5")==1)
{
$checkversion="php56";
}else
{
$checkversion="php53";
}
}
else
{
$checkversion=strtolower($core_php_version);
}
if($phpVersion===$checkversion)
{
$line .= '###!!!<FilesMatch \.php$>'.fs_filehandler::NewLine();
$line .= '###!!!SetHandler fcgid-script'.fs_filehandler::NewLine();
$line .= '###!!!</FilesMatch>'.fs_filehandler::NewLine();
$vline .= '###!!!<FilesMatch \.php$>'.fs_filehandler::NewLine();
$vline .= '###!!!SetHandler fcgid-script'.fs_filehandler::NewLine();
$vline .= '###!!!</FilesMatch>'.fs_filehandler::NewLine();
}else
{
$line .= '<FilesMatch \.php$>'.fs_filehandler::NewLine();
$line .= 'SetHandler fcgid-script'.fs_filehandler::NewLine();
$line .= '</FilesMatch>'.fs_filehandler::NewLine();
$vline .= '<FilesMatch \.php$>'.fs_filehandler::NewLine();
$vline .= 'SetHandler fcgid-script'.fs_filehandler::NewLine();
$vline .= '</FilesMatch>'.fs_filehandler::NewLine();
}
$line .= '<Directory "' . ctrl_options::GetSystemOption('static_dir') . 'disabled/">' . fs_filehandler::NewLine();
// $line .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$vline .= '<Directory "' . ctrl_options::GetSystemOption('static_dir') . 'disabled/">' . fs_filehandler::NewLine();
$line .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
if($phpVersion===$checkversion)
{
/* $line .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes" . fs_filehandler::NewLine(); */
$line .= " ###!!!AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$line .= " ###!!!FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
$vline .= " ###!!!AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$vline .= " ###!!!FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
}else
{
/* $line .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
$vline .= " Options -FollowSymLinks -Indexes +ExecCGI" . fs_filehandler::NewLine();
*/
$line .= " AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$line .= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
$vline .= " AddHandler fcgid-script .php" . fs_filehandler::NewLine();
$vline .= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php" . fs_filehandler::NewLine();
}
$line .= " AllowOverride All" . fs_filehandler::NewLine();
$vline .= " AllowOverride All" . fs_filehandler::NewLine();
if ((double) sys_versions::ShowApacheVersion() < 2.4) {
$line .= " Order allow,deny" . fs_filehandler::NewLine();
$line .= " Allow from all" . fs_filehandler::NewLine();
$vline .= " Order allow,deny" . fs_filehandler::NewLine();
$vline .= " Allow from all" . fs_filehandler::NewLine();
} else {
$line .= " Require all granted" . fs_filehandler::NewLine();
$vline .= " Require all granted" . fs_filehandler::NewLine();
}
$line .= "</Directory>" . fs_filehandler::NewLine();
$line .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
$line .= "</virtualhost>" . fs_filehandler::NewLine();
$line .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$line .= "################################################################" . fs_filehandler::NewLine();
$vline .= "</Directory>" . fs_filehandler::NewLine();
$vline .= ctrl_options::GetSystemOption('dir_index') . fs_filehandler::NewLine();
$vline .= "</virtualhost>" . fs_filehandler::NewLine();
$vline .= "# END DOMAIN: " . $rowvhost['vh_name_vc'] . fs_filehandler::NewLine();
$vline .= "################################################################" . fs_filehandler::NewLine();
}
if(!(file_exists("/etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf")))
{
echo $rowvhost['vh_name_vc']." - Nginx configuration writing";
//$getcurrentuser=$webhost['ac_user_vc'];
//$vh_directory_vc=$rowvhost['vh_directory_vc'];
//$DomRootDir = '"' . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . '/public_html' . $rowvhost['vh_directory_vc'] . '"';
$location_rootpath=ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . $rowvhost['vh_directory_vc'] ; // by nandhini
$rootpath=rtrim($location_rootpath,"/");
$conf_file = fopen("/etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf","w");
fwrite($conf_file,"server { \n");
fwrite($conf_file,"listen 80; \n");
fwrite($conf_file,"server_name ".$rowvhost['vh_name_vc']." www.".$rowvhost['vh_name_vc']."; \n");
fwrite($conf_file,"access_log ".ctrl_options::GetSystemOption('log_dir') . "domains/" . $vhostuser['username'] . "/" .$rowvhost['vh_name_vc']."-access.log main; \n");
fwrite($conf_file,"location / { \n");
fwrite($conf_file,"root ".$rootpath."; \n");
fwrite($conf_file,"index index.html index.htm index.php; \n");
fwrite($conf_file,"try_files $"."uri $"."uri/ /index.php?$"."args; \n");
fwrite($conf_file,"rewrite ^/whm/$"." http://".$rowvhost['vh_name_vc'].":2086/?access=whm redirect; \n");
fwrite($conf_file,"rewrite ^/whm$"." http://".$rowvhost['vh_name_vc'].":2086/?access=whm redirect; \n");
fwrite($conf_file,"rewrite ^/cpanel/$"." http://".$rowvhost['vh_name_vc'].":2082/?access=cpanel redirect; \n");
fwrite($conf_file,"rewrite ^/cpanel$"." http://".$rowvhost['vh_name_vc'].":2082/?access=cpanel redirect; \n");
fwrite($conf_file,"rewrite ^/webmail/$"." http://".$rowvhost['vh_name_vc'].":2095 redirect; \n");
fwrite($conf_file,"rewrite ^/webmail$"." http://".$rowvhost['vh_name_vc'].":2095 redirect; \n");
fwrite($conf_file,"} \n");
fwrite($conf_file,"location ~ \.php$ { \n");
fwrite($conf_file,"root ".$location_rootpath."; \n");
echo $phpVersion." - ".$checkversion."\n";
if($phpVersion===$checkversion)
{
fwrite($conf_file,"fastcgi_pass 127.0.0.1:9000; \n");
}else
{
$write_line="fastcgi_pass 127.0.0.1:9000; \n";
if($phpVersion=="php54")
$write_line="fastcgi_pass 127.0.0.1:9001; \n";
else if($phpVersion=="php55")
$write_line="fastcgi_pass 127.0.0.1:9002; \n";
else if($phpVersion=="php70")
$write_line="fastcgi_pass 127.0.0.1:9003; \n";
else if($phpVersion=="php71")
$write_line="fastcgi_pass 127.0.0.1:9004; \n";
else if($phpVersion=="php72")
$write_line="fastcgi_pass 127.0.0.1:9005; \n";
else if($phpVersion=="php56")
$write_line="fastcgi_pass 127.0.0.1:9006; \n";
fwrite($conf_file,$write_line);
}
fwrite($conf_file,"fastcgi_index index.php; \n");
fwrite($conf_file,"fastcgi_param SCRIPT_FILENAME ".$rootpath.""."$"."fastcgi_script_name; \n");
fwrite($conf_file,"include fastcgi_params; \n");
fwrite($conf_file,"} \n");
fwrite($conf_file,"error_page 500 502 503 504 /50x.html; \n");
fwrite($conf_file,"location = /50x.html { \n");
fwrite($conf_file,"root /usr/share/nginx/html; \n");
fwrite($conf_file,"} \n");
fwrite($conf_file,"} \n");
fclose($conf_file);
}else
{
////////////////////////////////////////////////////////////////////////// Nginx File Updte Start ///////////////////////////////////////////////////////////////////
$vhost_id = $rowvhost['vh_id_pk'];
$dosql = $zdbh->prepare("SELECT * FROM x_settings WHERE so_name_vc='Domain_directory_change' AND so_value_tx IS NOT NULL");
$dosql->execute();
$row = $dosql->fetch();
if($row['so_value_tx']!=NULL)
{
$domain_id = explode(",",$row['so_value_tx']);
print_r($vhost_id);
if (in_array($vhost_id, $domain_id)) {
echo "Domain Directory Change Start";
$vh_dir_path=$rowvhost['vh_directory_vc'] ;
$vh_dir_path = rtrim($vh_dir_path,'/');
$DomRootDir = '"' . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . $vh_dir_path. '"'; // by andhni
$DomRootDir = str_replace("/", "\/", $DomRootDir);
$OldRootDir = '';
$OldRootDir = shell_exec("cat /etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf | grep root | awk '{print $2}' | awk 'NR==1{print $1}'");
$OldRootDir = str_replace("/", "\/", $OldRootDir);
$OldRootDir = trim(str_replace('"','',$OldRootDir));
$OldRootDir = trim(str_replace('\n','',$OldRootDir));
$DomRootDir = trim(str_replace('"','',$DomRootDir));
$DomRootDir = trim(str_replace('\n','',$DomRootDir));
$OldRootDir = rtrim($OldRootDir,';');
$OldRootDir = rtrim($OldRootDir,'/');
//echo "sed -i 's/$OldRootDir/$DomRootDir/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf";
echo "sed -i 's/$OldRootDir/$DomRootDir/g' /etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf";
$chkwrite=shell_exec("sed -i 's/$OldRootDir/$DomRootDir/g' /etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf");
if((file_exists("/etc/nginx/availablesites/SSL_".$rowvhost['vh_name_vc'].".conf")))
{
$chkwrite=shell_exec("sed -i 's/$OldRootDir/$DomRootDir/g' /etc/nginx/availablesites/SSL_".$rowvhost['vh_name_vc'].".conf");
}
/*
$ssl_conf_query="SELECT * FROM x_ssl WHERE ssl_doamin='".$rowvhost['vh_name_vc']."' AND ssl_delete IS NULL";
$ssl_conf = $zdbh->prepare($ssl_conf_query);
$ssl_conf->execute();
$ssl_count = $ssl_conf->fetchColumn();
if ($ssl_count > 0) {
$chkwrite=shell_exec("sed -i 's/$OldRootDir/$DomRootDir/g' /etc/httpd/conf.d/ssl.conf");
}
*/
/*
echo "Domain Directory Change End";
$remove_domain=array($vhost_id);
$updatedomaindirectory_array=array_diff($domain_id,$remove_domain);
if(empty($updatedomaindirectory_array))
{
$doupdatesql = $zdbh->prepare("Update x_settings set so_value_tx=NULL WHERE so_name_vc='Domain_directory_change'");
$doupdatesql->execute();
}else
{
$updatedomainvalue=implode(",",$updatedomaindirectory_array);
$doupdatesql = $zdbh->prepare("Update x_settings set so_value_tx=NULL WHERE so_name_vc='Domain_directory_change'");
$doupdatesql->execute();
} */
}
}
$write_line="fastcgi_pass 127.0.0.1:9000;";
if($phpVersion===$checkversion)
{
$write_line="fastcgi_pass 127.0.0.1:9000;";
}else
{
$write_line="fastcgi_pass 127.0.0.1:9000;";
if($phpVersion=="php54")
$write_line="fastcgi_pass 127.0.0.1:9001;";
else if($phpVersion=="php55")
$write_line="fastcgi_pass 127.0.0.1:9002;";
else if($phpVersion=="php70")
$write_line="fastcgi_pass 127.0.0.1:9003;";
else if($phpVersion=="php71")
$write_line="fastcgi_pass 127.0.0.1:9004;";
else if($phpVersion=="php72")
$write_line="fastcgi_pass 127.0.0.1:9005; \n";
else if($phpVersion=="php56")
$write_line="fastcgi_pass 127.0.0.1:9006; \n";
}
//ECHO "sed -i \"/fastcgi_pass/c\\".$write_line."\" /etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf";
if((file_exists("/etc/nginx/availablesites/SSL_".$rowvhost['vh_name_vc'].".conf")))
{
shell_exec("sed -i \"/fastcgi_pass/c\\".$write_line."\" /etc/nginx/availablesites/SSL_".$rowvhost['vh_name_vc'].".conf");
}
if((file_exists("/etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf")))
{
shell_exec("sed -i \"/fastcgi_pass/c\\".$write_line."\" /etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf");
}
////////////////////////////////////////////////////////////////////////// Nginx File Updte End ///////////////////////////////////////////////////////////////////
}
if(!file_exists("/etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf"))
{
$vfile = fopen("/etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf","w");
fwrite($vfile,$vline);
fclose($vfile);
}else
{
///////////////////////////////////////// Code for Directory Change start //////////////////////////////////////////////
$vhost_id = $rowvhost['vh_id_pk'];
$dosql = $zdbh->prepare("SELECT * FROM x_settings WHERE so_name_vc='Domain_directory_change' AND so_value_tx IS NOT NULL");
$dosql->execute();
$row = $dosql->fetch();
if($row['so_value_tx']!=NULL)
{
$domain_id = explode(",",$row['so_value_tx']);
print_r($vhost_id);
if (in_array($vhost_id, $domain_id)) {
echo "Domain Directory Change Start";
$DomRootDir = '"' . ctrl_options::GetSystemOption('hosted_dir') . $vhostuser['username'] . $rowvhost['vh_directory_vc'] . '"'; //by anndhini
$DomRootDir = str_replace("/", "\/", $DomRootDir);
$OldRootDir = '';
$OldRootDir = shell_exec("cat /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf | grep DocumentRoot | awk '{print $2}'");
$OldRootDir = str_replace("/", "\/", $OldRootDir);
$OldRootDir = trim(str_replace('"','',$OldRootDir));
$OldRootDir = trim(str_replace('\n','',$OldRootDir));
$DomRootDir = trim(str_replace('"','',$DomRootDir));
$DomRootDir = trim(str_replace('\n','',$DomRootDir));
//echo "sed -i 's/$OldRootDir/$DomRootDir/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf"
// $cmd = "sed -i 's/$OldRootDir/$DomRootDir/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf";
$chkwrite=shell_exec("sed -i 's/$OldRootDir/$DomRootDir/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$ssl_conf_query="SELECT * FROM x_ssl WHERE ssl_doamin='".$rowvhost['vh_name_vc']."' AND ssl_delete IS NULL";
$ssl_conf = $zdbh->prepare($ssl_conf_query);
$ssl_conf->execute();
$ssl_count = $ssl_conf->fetchColumn();
if ($ssl_count > 0) {
$chkwrite=shell_exec("sed -i 's/$OldRootDir/$DomRootDir/g' /etc/httpd/conf.d/ssl.conf");
}
echo "Domain Directory Change End";
$remove_domain=array($vhost_id);
$updatedomaindirectory_array=array_diff($domain_id,$remove_domain);
if(empty($updatedomaindirectory_array))
{
$doupdatesql = $zdbh->prepare("Update x_settings set so_value_tx=NULL WHERE so_name_vc='Domain_directory_change'");
$doupdatesql->execute();
}else
{
$updatedomainvalue=implode(",",$updatedomaindirectory_array);
$doupdatesql = $zdbh->prepare("Update x_settings set so_value_tx=NULL WHERE so_name_vc='Domain_directory_change'");
$doupdatesql->execute();
}
}
}
///////////////////////////////////////// Code for Directory Change End //////////////////////////////////////////////
if($phpVersion===$checkversion)
{
$chkwrite=shell_exec("sed -i -e 's/ AddHandler / ###!!!AddHandler /g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/ FCGIWrapper / ###!!!FCGIWrapper /g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/<FilesMatch/###!!!<FilesMatch/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/SetHandler/###!!!SetHandler/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/<\/FilesMatch/###!!!<\/FilesMatch/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!<FilesMatch/###!!!<FilesMatch/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!SetHandler/###!!!SetHandler/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!<\/FilesMatch/###!!!<\/FilesMatch/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$write_line="fastcgi_pass 127.0.0.1:9000; \n";
if((file_exists("/etc/nginx/availablesites/SSL_".$rowvhost['vh_name_vc'].".conf")))
{
shell_exec("sed -i \"/fastcgi_pass/c\\".$write_line."\" /etc/nginx/availablesites/SSL_".$rowvhost['vh_name_vc'].".conf");
}
if((file_exists("/etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf")))
{
shell_exec("sed -i \"/fastcgi_pass/c\\".$write_line."\" /etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf");
}
}else
{
$domain_name = $rowvhost['vh_name_vc'];
shell_exec("echo Domain Name : $domain_name > /etc/sentora/panel/modules/apache_admin/hooks/sample_fastcg_started.log");
$php_confg_file_name = "/etc/sentora/configs/apache/fcgi-config/".$domain_name;
if(file_exists($php_confg_file_name) && !is_dir($php_confg_file_name))
unlink($php_confg_file_name);
$sample_value = file_get_contents("/etc/sentora/panel/modules/apache_admin/hooks/sample_fastcg_started.txt");
$sample_value = str_replace("phpVersion",$phpVersion,$sample_value);
$upload_max_filesize = getPHPConfValueBasedOnKey('upload_max_filesize',$domain_name)."M";
$post_max_size = getPHPConfValueBasedOnKey('post_max_size', $domain_name)."M";
$max_execution_time = getPHPConfValueBasedOnKey('max_execution_time', $domain_name);
$max_input_time = getPHPConfValueBasedOnKey('max_input_time', $domain_name);
$memory_limit = getPHPConfValueBasedOnKey('memory_limit', $domain_name)."M";
$file_uploads = getPHPConfValueBasedOnKey('file_uploads', $domain_name);
$sample_value = str_replace("UploadMaxFileSize","$upload_max_filesize",$sample_value);
$sample_value = str_replace("postMaxSize","$post_max_size",$sample_value);
$sample_value = str_replace("maxExecutionTime","$max_execution_time",$sample_value);
$sample_value = str_replace("MaxInputTime","$max_input_time",$sample_value);
$sample_value = str_replace("MemoryLimit","$memory_limit",$sample_value);
$sample_value = str_replace("FileUpload","$file_uploads",$sample_value);
shell_exec("echo $upload_max_filesize >> /etc/sentora/panel/modules/apache_admin/hooks/sample_fastcg_started.log");
file_put_contents($php_confg_file_name, $sample_value);
$chmod_service=trim(shell_exec("whereis chmod | awk '{print $2}'"));
$chmod_ret=shell_exec("$chmod_service 755 $php_confg_file_name");
$chown_service=trim(shell_exec("whereis chown | awk '{print $2}'"));
$chmod_ret=shell_exec("$chown_service apache:apache $php_confg_file_name");
$chkwrite=shell_exec("sed -i -e 's/###!!!<FilesMatch/<FilesMatch/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!SetHandler/SetHandler/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!<\/FilesMatch/<\/FilesMatch/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/ ###!!!AddHandler / AddHandler /g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$FCGIWrapper= " FCGIWrapper /etc/sentora/configs/apache/fcgi-config/".$rowvhost['vh_name_vc']." .php";
$FCGIWrapper=str_replace("/","\/",$FCGIWrapper);
$chkwrite=shell_exec("sed -i -e 's/ ###!!!FCGIWrapper.*/".$FCGIWrapper."/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/ FCGIWrapper.*/".$FCGIWrapper."/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$write_line="fastcgi_pass 127.0.0.1:9000; \n";
if($phpVersion=="php54")
$write_line="fastcgi_pass 127.0.0.1:9001; \n";
else if($phpVersion=="php55")
$write_line="fastcgi_pass 127.0.0.1:9002; \n";
else if($phpVersion=="php70")
$write_line="fastcgi_pass 127.0.0.1:9003; \n";
else if($phpVersion=="php71")
$write_line="fastcgi_pass 127.0.0.1:9004; \n";
else if($phpVersion=="php72")
$write_line="fastcgi_pass 127.0.0.1:9005; \n";
else if($phpVersion=="php56")
$write_line="fastcgi_pass 127.0.0.1:9006; \n";
if((file_exists("/etc/nginx/availablesites/SSL_".$rowvhost['vh_name_vc'].".conf")))
{
shell_exec("sed -i \"/fastcgi_pass/c\\".$write_line."\" /etc/nginx/availablesites/SSL_".$rowvhost['vh_name_vc'].".conf");
}
if((file_exists("/etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf")))
{
shell_exec("sed -i \"/fastcgi_pass/c\\".$write_line."\" /etc/nginx/availablesites/".$rowvhost['vh_name_vc'].".conf");
}
}
if($splitlog_flag==1)
{
$chkwrite=shell_exec("sed -i -e 's/ErrorLog /###!!!ErrorLog /g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/CustomLog /###!!!CustomLog /g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!ErrorLog /###!!!ErrorLog /g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!###!!!CustomLog /###!!!CustomLog /g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
}else
{
$chkwrite=shell_exec("sed -i -e 's/###!!!ErrorLog /ErrorLog /g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$chkwrite=shell_exec("sed -i -e 's/###!!!CustomLog /CustomLog /g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
}
// need to change the Correct Port
if($port==80)
{
$chkwrite=shell_exec("sed -i -e 's/\<virtualhost \*\:8080\>/virtualhost \*\:80/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
}
if($port==8080)
{
$chkwrite=shell_exec("sed -i -e 's/\<virtualhost \*\:80\>/virtualhost \*\:8080/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
}
/* //////////////////////////////////////////// Disabled the client domain Start /////////////////////////////////////// */
if($rowvhost['vh_active_in']==0)
{
$DomRootDir = ctrl_options::GetSystemOption('static_dir') . 'disabled/"';
$DomRootDir = str_replace("/", "\/", $DomRootDir);
$OldRootDir = '';
$OldRootDir = shell_exec("cat /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf | grep DocumentRoot | awk '{print $2}'");
$OldRootDir = str_replace("/", "\/", $OldRootDir);
$OldRootDir = trim(str_replace('"','',$OldRootDir));
$OldRootDir = trim(str_replace('\n','',$OldRootDir));
$DomRootDir = trim(str_replace('"','',$DomRootDir));
$DomRootDir = trim(str_replace('\n','',$DomRootDir));
$chkwrite=shell_exec("sed -i 's/$OldRootDir/$DomRootDir/g' /etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf");
$ssl_conf_query="SELECT * FROM x_ssl WHERE ssl_doamin='".$rowvhost['vh_name_vc']."' AND ssl_delete IS NULL";
$ssl_conf = $zdbh->prepare($ssl_conf_query);
$ssl_conf->execute();
$ssl_count = $ssl_conf->fetchColumn();
if ($ssl_count > 0)
{
$chkwrite=shell_exec("sed -i 's/$OldRootDir/$DomRootDir/g' /etc/httpd/conf.d/ssl.conf");
}
}
/* //////////////////////////////////////////// Disabled the client domain End /////////////////////////////////////// */
}
$vline="";
}
//Function : Need to remove the file continuesly
//////////////////////////////////////////////////////////////////////////////// Content Start ////////////////////////////////////////////////////////////////////////////////
$sql = $zdbh->prepare("select * from x_vhosts where vh_deleted_ts is NOT NULL AND vh_name_vc NOT IN ( select vh_name_vc from x_vhosts where vh_deleted_ts is NULL )");
$sql->execute();
while ($rowvhost = $sql->fetch())
{
$file_path="/etc/sentora/configs/apache/domains/".$rowvhost['vh_name_vc'].".conf";
if(file_exists($file_path))
{
unlink($file_path);
}
}
//////////////////////////////////////////////////////////////////////////////// Content End ////////////////////////////////////////////////////////////////////////////////
/*
* ##############################################################################################################
* #
* # Write vhost file to disk
* #
* ##############################################################################################################
*/
// write the vhost config file
$vhconfigfile = ctrl_options::GetSystemOption('apache_vhost');
if (fs_filehandler::UpdateFile($vhconfigfile, 0777, $line)) {
// Reset Apache settings to reflect that config file has been written, until the next change.
$time = time();
$vsql = $zdbh->prepare("UPDATE x_settings
SET so_value_tx=:time
WHERE so_name_vc='apache_changed'");
$vsql->bindParam(':time', $time);
$vsql->execute();
echo "Finished writting Apache Config... Now reloading Apache..." . fs_filehandler::NewLine();
$returnValue = 0;
if (sys_versions::ShowOSPlatformVersion() == "Windows") {
system("" . ctrl_options::GetSystemOption('httpd_exe') . " " . ctrl_options::GetSystemOption('apache_restart') . "", $returnValue);
} else {
$command = ctrl_options::GetSystemOption('zsudo');
$args = array(
"service",
ctrl_options::GetSystemOption('apache_sn'),
ctrl_options::GetSystemOption('apache_restart')
);
$returnValue = ctrl_system::systemCommand($command, $args);
}
echo "Apache reload " . ((0 === $returnValue ) ? "suceeded" : "failed") . "." . fs_filehandler::NewLine();
} else {
return false;
}
}
function CheckErrorDocument($error)
{
$errordocs = array(100, 101, 102, 200, 201, 202, 203, 204, 205, 206, 207,
300, 301, 302, 303, 304, 305, 306, 307, 400, 401, 402,
403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413,
414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424,
425, 426, 500, 501, 502, 503, 504, 505, 506, 507, 508,
509, 510);
if (in_array($error, $errordocs)) {
return true;
} else {
return false;
}
}
function BackupVhostConfigFile()
{
echo "Apache VHost backups are enabled... Backing up current vhost.conf to: " . ctrl_options::GetSystemOption('apache_budir') . fs_filehandler::NewLine();
if (!is_dir(ctrl_options::GetSystemOption('apache_budir'))) {
fs_director::CreateDirectory(ctrl_options::GetSystemOption('apache_budir'));
}
copy(ctrl_options::GetSystemOption('apache_vhost'), ctrl_options::GetSystemOption('apache_budir') . "VHOST_BACKUP_" . time());
fs_director::SetFileSystemPermissions(ctrl_options::GetSystemOption('apache_budir') . ctrl_options::GetSystemOption('apache_vhost') . ".BU", 0777);
if (ctrl_options::GetSystemOption('apache_purgebu') == strtolower("true")) {
echo "Apache VHost purges are enabled... Purging backups older than: " . ctrl_options::GetSystemOption('apache_purge_date') . " days..." . fs_filehandler::NewLine();
echo "[FILE][PURGE_DATE][FILE_DATE][ACTION]" . fs_filehandler::NewLine();
$purge_date = ctrl_options::GetSystemOption('apache_purge_date');
if ($handle = @opendir(ctrl_options::GetSystemOption('apache_budir'))) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$filetime = @filemtime(ctrl_options::GetSystemOption('apache_budir') . $file);
if ($filetime == NULL) {
$filetime = @filemtime(utf8_decode(ctrl_options::GetSystemOption('apache_budir') . $file));
}
$filetime = floor((time() - $filetime) / 86400);
echo $file . " - " . $purge_date . " - " . $filetime . "";
if ($purge_date < $filetime) {
//delete the file
echo " - Deleting file..." . fs_filehandler::NewLine();
unlink(ctrl_options::GetSystemOption('apache_budir') . $file);
} else {
echo " - Skipping file..." . fs_filehandler::NewLine();
}
}
}
}
echo "Purging old backups complete..." . fs_filehandler::NewLine();
}
echo "Apache backups complete..." . fs_filehandler::NewLine();
}
function TriggerApacheQuotaUsage()
{
global $zdbh;
global $controller;
$sql = $zdbh->prepare("SELECT * FROM x_vhosts WHERE vh_deleted_ts IS NULL");
$sql->execute();
while ($rowvhost = $sql->fetch()) {
if ($rowvhost['vh_enabled_in'] == 1 && ctrl_users::CheckUserEnabled($rowvhost['vh_acc_fk']) ||
$rowvhost['vh_enabled_in'] == 1 && ctrl_options::GetSystemOption('apache_allow_disabled') == strtolower("true")) {
//$checksize = $zdbh->query("SELECT * FROM x_bandwidth WHERE bd_month_in = " . date("Ym") . " AND bd_acc_fk = " . $rowvhost['vh_acc_fk'] . "")->fetch();
$date = date("Ym");
$findsize = $zdbh->prepare("SELECT * FROM x_bandwidth WHERE bd_month_in = :date AND bd_acc_fk = :acc");
$findsize->bindParam(':date', $date);
$findsize->bindParam(':acc', $rowvhost['vh_acc_fk']);
$findsize->execute();
$checksize = $findsize->fetch();
$currentuser = ctrl_users::GetUserDetail($rowvhost['vh_acc_fk']);
if ($checksize['bd_diskover_in'] != $checksize['bd_diskcheck_in'] && $checksize['bd_diskover_in'] == 1) {
echo "Disk usage over quota, triggering Apache..." . fs_filehandler::NewLine();
$updateapache = $zdbh->prepare("UPDATE x_settings SET so_value_tx = 'true' WHERE so_name_vc ='apache_changed'");
$updateapache->execute();
//$updateapache = $zdbh->query("UPDATE x_bandwidth SET bd_diskcheck_in = 1 WHERE bd_acc_fk =" . $rowvhost['vh_acc_fk'] . "");
$updateapache2 = $zdbh->prepare("UPDATE x_bandwidth SET bd_diskcheck_in = 1 WHERE bd_acc_fk = :acc");
$updateapache2->bindParam(':acc', $rowvhost['vh_acc_fk']);
$updateapache2->execute();
}
if ($checksize['bd_diskover_in'] != $checksize['bd_diskcheck_in'] && $checksize['bd_diskover_in'] == 0) {
echo "Disk usage under quota, triggering Apache..." . fs_filehandler::NewLine();
$updateapache = $zdbh->prepare("UPDATE x_settings SET so_value_tx = 'true' WHERE so_name_vc ='apache_changed'");
$updateapache->execute();
//$updateapache = $zdbh->query("UPDATE x_bandwidth SET bd_diskcheck_in = 0 WHERE bd_acc_fk =" . $rowvhost['vh_acc_fk'] . "");
$updateapache2 = $zdbh->prepare("UPDATE x_bandwidth SET bd_diskcheck_in = 0 WHERE bd_acc_fk = :acc");
$updateapache2->bindParam(':acc', $rowvhost['vh_acc_fk']);
$updateapache2->execute();
}
if ($checksize['bd_transover_in'] != $checksize['bd_transcheck_in'] && $checksize['bd_transover_in'] == 1) {
echo "Bandwidth usage over quota, triggering Apache..." . fs_filehandler::NewLine();
$updateapache = $zdbh->prepare("UPDATE x_settings SET so_value_tx = 'true' WHERE so_name_vc ='apache_changed'");
$updateapache->execute();
//$updateapache = $zdbh->query("UPDATE x_bandwidth SET bd_transcheck_in = 1 WHERE bd_acc_fk =" . $rowvhost['vh_acc_fk'] . "");
$updateapache2 = $zdbh->prepare("UPDATE x_bandwidth SET bd_transcheck_in = 1 WHERE bd_acc_fk = :acc");
$updateapache2->bindParam(':acc', $rowvhost['vh_acc_fk']);
$updateapache2->execute();
}
if ($checksize['bd_transover_in'] != $checksize['bd_transcheck_in'] && $checksize['bd_transover_in'] == 0) {
echo "Bandwidth usage under quota, triggering Apache..." . fs_filehandler::NewLine();
$updateapache = $zdbh->prepare("UPDATE x_settings SET so_value_tx = 'true' WHERE so_name_vc ='apache_changed'");
$updateapache->execute();
//$updateapache = $zdbh->query("UPDATE x_bandwidth SET bd_transcheck_in = 0 WHERE bd_acc_fk =" . $rowvhost['vh_acc_fk'] . "");
$updateapache2 = $zdbh->prepare("UPDATE x_bandwidth SET bd_transcheck_in = 0 WHERE bd_acc_fk = :acc");
$updateapache2->bindParam(':acc', $rowvhost['vh_acc_fk']);
$updateapache2->execute();
}
}
}
}
global $zdbh;
global $controller;
/* /////////////////////////////// start the code for varnish cache settings ///////////////////////////////////// */
//$currentuser = ctrl_users::GetUserDetail();
// $sql = "SELECT * FROM x_varnish WHERE x_user_id=:userid";
$sql = "SELECT * FROM x_varnish";
//$numrows = $zdbh->query($sql);
$numrows = $zdbh->prepare($sql);
//$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->execute();
if ($numrows->fetchColumn() <> 0) {
$sql = $zdbh->prepare($sql);
//$sql->bindParam(':userid', $currentuser['userid']);
$sql->execute();
$res = $sql->fetch();
if($res['x_isactive']==0)
{
if($res['x_varnish']=="Off" && $res['x_nginx']=="Off")
{
// Enable Apache Server
//$sql = "Update x_varnish set x_isactive=1 WHERE x_user_id=:userid";
$sql = "Update x_varnish set x_isactive=1";
$numrows = $zdbh->prepare($sql);
//$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->execute();
exec("/usr/sbin/service php-fpm stop");
exec("/usr/sbin/service nginx stop");
exec("kill -9 $(lsof -t -i:80)");
exec("kill -9 $(lsof -t -i:443)");
exec("/usr/sbin/service varnish stop");
exec("setso --set apache_port 80");
exec("setso --set sentora_port 80");
exec("/usr/sbin/service varnish stop");
exec("/usr/sbin/service httpd restart");
if ((double) sys_versions::ShowApacheVersion() < 2.3)
{
exec("/usr/sbin/service varnish stop");
exec("/usr/sbin/service httpd restart");
exec("/usr/sbin/service named restart");
}else
{
exec("/bin/systemctl stop varnish.service");
exec("/bin/systemctl restart httpd.service");
exec("/bin/systemctl restart named.service");
}
exec("/usr/sbin/service php-fpm stop");
if(file_exists("/etc/init.d/php-fpm-54")) exec("/etc/init.d/php-fpm-54 stop");
if(file_exists("/etc/init.d/php-fpm-55")) exec("/etc/init.d/php-fpm-55 stop");
if(file_exists("/etc/init.d/php-fpm-56")) exec("/etc/init.d/php-fpm-56 stop");
if(file_exists("/etc/init.d/php-fpm-70")) exec("/etc/init.d/php-fpm-70 stop");
if(file_exists("/etc/init.d/php-fpm-71")) exec("/etc/init.d/php-fpm-71 stop");
if(file_exists("/etc/init.d/php-fpm-72")) exec("/etc/init.d/php-fpm-72 stop");
$chkconfig_path=str_replace("\n","",shell_exec("whereis chkconfig | awk '{print $2}';"));
shell_exec("$chkconfig_path nginx off");
shell_exec("$chkconfig_path httpd on");
shell_exec("$chkconfig_path varnish off");
shell_exec("$chkconfig_path php-fpm off");
}
else if($res['x_varnish']=="On" && $res['x_nginx']=="Off")
{
// Enable Varnish Cache Server
//$sql = "Update x_varnish set x_isactive=1 WHERE x_user_id=:userid";
$interval=$res['x_interval'];
$timeout=$res['x_timeout'];
$window=$res['x_window'];
$threshold=$res['x_threshold'];
/* ///////////////////////// Need to update varnish settings only //////////////////// */
echo "\n Varnish settings changing started";
$change_cmd='sed -i "/interval/c \ \ \ \ \ \ \ \ \ .interval = '.$interval.'s;" /etc/varnish/default.vcl';
$run_cmd=shell_exec($change_cmd);
$change_cmd='sed -i "/timeout/c \ \ \ \ \ \ \ \ \ .timeout = '.$timeout.' s;" /etc/varnish/default.vcl';
$run_cmd=shell_exec($change_cmd);
$change_cmd='sed -i "/window/c \ \ \ \ \ \ \ \ \ .window = '.$window.';" /etc/varnish/default.vcl';
$run_cmd=shell_exec($change_cmd);
$change_cmd='sed -i "/threshold/c \ \ \ \ \ \ \ \ \ .threshold = '.$threshold.';" /etc/varnish/default.vcl';
$run_cmd=shell_exec($change_cmd);
echo "\n Varnish settings changed Successfully";
/* ///////////////////////// Need to update varnish settings only //////////////////// */
$sql = "Update x_varnish set x_isactive=1";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->execute();
exec("kill -9 $(lsof -t -i:80)");
exec("kill -9 $(lsof -t -i:443)");
exec("/usr/sbin/service php-fpm stop");
exec("/usr/sbin/service nginx stop");
exec("killall -9 httpd");
exec("/usr/sbin/service varnish stop");
exec("setso --set apache_port 8080");
exec("setso --set sentora_port 8080");
if ((double) sys_versions::ShowApacheVersion() < 2.3) {
exec("/usr/sbin/service varnish start");
exec("/usr/sbin/service httpd restart");
exec("/usr/sbin/service named restart");
}else
{
exec("/bin/systemctl restart httpd.service");
exec(" /bin/systemctl restart varnish.service");
exec("/bin/systemctl restart named.service");
}
exec("/usr/sbin/service php-fpm stop");
if(file_exists("/etc/init.d/php-fpm-54")) exec("/etc/init.d/php-fpm-54 stop");
if(file_exists("/etc/init.d/php-fpm-55")) exec("/etc/init.d/php-fpm-55 stop");
if(file_exists("/etc/init.d/php-fpm-56")) exec("/etc/init.d/php-fpm-56 stop");
if(file_exists("/etc/init.d/php-fpm-70")) exec("/etc/init.d/php-fpm-70 stop");
if(file_exists("/etc/init.d/php-fpm-71")) exec("/etc/init.d/php-fpm-71 stop");
if(file_exists("/etc/init.d/php-fpm-72")) exec("/etc/init.d/php-fpm-72 stop");
$chkconfig_path=str_replace("\n","",shell_exec("whereis chkconfig | awk '{print $2}';"));
shell_exec("$chkconfig_path nginx off");
shell_exec("$chkconfig_path php-fpm off");
shell_exec("$chkconfig_path httpd on");
shell_exec("$chkconfig_path varnish on");
}else if($res['x_varnish']=="Off" && $res['x_nginx']=="On")
{
exec("/usr/sbin/service varnish stop");
exec("/usr/sbin/service httpd stop");
exec("/usr/sbin/service php-fpm restart");
if(file_exists("/etc/init.d/php-fpm-54")) exec("/etc/init.d/php-fpm-54 restart");
if(file_exists("/etc/init.d/php-fpm-55")) exec("/etc/init.d/php-fpm-55 restart");
if(file_exists("/etc/init.d/php-fpm-56")) exec("/etc/init.d/php-fpm-56 restart");
if(file_exists("/etc/init.d/php-fpm-70")) exec("/etc/init.d/php-fpm-70 restart");
if(file_exists("/etc/init.d/php-fpm-71")) exec("/etc/init.d/php-fpm-71 restart");
if(file_exists("/etc/init.d/php-fpm-72")) exec("/etc/init.d/php-fpm-72 restart");
exec("kill -9 $(lsof -t -i:443)");
exec("/usr/sbin/service nginx restart");
$sql_update = "Update x_varnish set x_isactive=1";
$numrows_result = $zdbh->prepare($sql_update);
$numrows_result->execute();
$chkconfig_path=str_replace("\n","",shell_exec("whereis chkconfig | awk '{print $2}';"));
shell_exec("$chkconfig_path nginx on");
shell_exec("$chkconfig_path php-fpm on");
shell_exec("$chkconfig_path httpd off");
shell_exec("$chkconfig_path varnish off");
////////////////////////////////////////////// nginx Coding End ///////////////////////////////////////////////
}
}
}
/* /////////////////////////////// End the code for varnish cache settings ///////////////////////////////////// */
$sql = $zdbh->prepare("SELECT * FROM x_web_server");
$sql->execute();
while ($webserver = $sql->fetch()) {
$stat=$webserver['x_service'];
if($stat=="apachestop")
{
$sql = $zdbh->prepare("Delete FROM x_web_server where x_id='".$webserver['x_id']."'");
$sql->execute();
$r2=exec("/usr/sbin/service httpd stop");
}
if($stat=="varnishdefault")
{
$sql = $zdbh->prepare("Delete FROM x_web_server where x_id='".$webserver['x_id']."'");
$sql->execute();
exec("/usr/sbin/service php-fpm stop");
exec("/usr/sbin/service nginx stop");
exec("/usr/sbin/service varnish stop");
exec("setso --set apache_port 8080");
exec("setso --set sentora_port 8080");
//exec("sed -i -e 's/:80/:8080/g' /etc/sentora/configs/apache/httpd-vhosts.conf");
//exec("sed -i -e 's/Listen 80/Listen 8080/g' /etc/sentora/configs/apache/httpd-vhosts.conf");
if ((double) sys_versions::ShowApacheVersion() < 2.3) {
exec("/usr/sbin/service varnish start");
exec("/usr/sbin/service httpd restart");
exec("/usr/sbin/service varnish restart");
exec("/usr/sbin/service httpd restart");
exec("/usr/sbin/service named restart");
}else{
exec("/bin/systemctl start varnish.service");
exec(" /bin/systemctl restart httpd.service");
exec("/bin/systemctl restart varnish.service");
exec(" /bin/systemctl restart httpd.service");
exec("/bin/systemctl restart named.service");
}
exec("/sbin/chkconfig varnish on");
exec("/sbin/chkconfig nginx off");
}
if($stat=="apachedefault")
{
$sql = $zdbh->prepare("Delete FROM x_web_server where x_id='".$webserver['x_id']."'");
$sql->execute();
exec("/usr/sbin/service php-fpm stop");
exec("/usr/sbin/service nginx stop");
exec("/usr/sbin/service varnish stop");
exec("setso --set apache_port 80");
exec("setso --set sentora_port 80");
//exec("sed -i -e 's/:8080/:80/g' /etc/sentora/configs/apache/httpd-vhosts.conf");
//exec("sed -i -e 's/Listen 8080/Listen 80/g' /etc/sentora/configs/apache/httpd-vhosts.conf");
if ((double) sys_versions::ShowApacheVersion() < 2.3) {
exec("/usr/sbin/service varnish stop");
exec("/usr/sbin/service httpd restart");
exec("/usr/sbin/service httpd restart");
exec("/usr/sbin/service httpd restart");
exec("/usr/sbin/service named restart");
}else{
exec("/bin/systemctl stop varnish.service");
exec(" /bin/systemctl restart httpd.service");
exec("/bin/systemctl restart httpd.service");
exec(" /bin/systemctl restart httpd.service");
exec("/bin/systemctl restart named.service");
}
exec("/sbin/chkconfig varnish off");
exec("/sbin/chkconfig nginx off");
}
if($stat=="apacherestart")
{
$sql = $zdbh->prepare("Delete FROM x_web_server where x_id='".$webserver['x_id']."'");
$sql->execute();
exec("/usr/sbin/service httpd restart");
}
if($stat=="varnishrestart")
{
$sql = $zdbh->prepare("Delete FROM x_web_server where x_id='".$webserver['x_id']."'");
$sql->execute();
exec("/usr/sbin/service varnish restart");
}
if($stat=="nginxrestart")
{
$sql = $zdbh->prepare("Delete FROM x_web_server where x_id='".$webserver['x_id']."'");
$sql->execute();
exec("/usr/sbin/service php-fpm restart");
exec("kill -9 $(lsof -t -i:443)");
exec("/usr/sbin/service php-fpm restart");
if(file_exists("/etc/init.d/php-fpm-54")) exec("/etc/init.d/php-fpm-54 restart");
if(file_exists("/etc/init.d/php-fpm-55")) exec("/etc/init.d/php-fpm-55 restart");
if(file_exists("/etc/init.d/php-fpm-56")) exec("/etc/init.d/php-fpm-56 restart");
if(file_exists("/etc/init.d/php-fpm-70")) exec("/etc/init.d/php-fpm-70 restart");
if(file_exists("/etc/init.d/php-fpm-71")) exec("/etc/init.d/php-fpm-71 restart");
if(file_exists("/etc/init.d/php-fpm-72")) exec("/etc/init.d/php-fpm-72 restart");
exec("/usr/sbin/service nginx restart");
}
}
############################################## Spam assassians Start ##############################################
$sql = "select * from x_apachespam_settings ";
$sql = $zdbh->prepare($sql);
$sql->execute();
$res = $sql->fetch();
if($res['x_status']=='Yes')
{
$sender_access=0;
$cmd="cd /etc/mail/spamassassin/";
shell_exec($cmd);
$line="required_hits ".$res['x_score'];
$cmd="echo ".$line." > /etc/mail/spamassassin/local.cf";
shell_exec($cmd);
$line="";
$cmd="echo ".$line." > /etc/postfix/sender_access";
shell_exec($cmd);
$line="report_safe 0";
$cmd="echo ".$line." >> /etc/mail/spamassassin/local.cf";
shell_exec($cmd);
$line="rewrite_header Subject [SPAM]";
$cmd="echo ".$line." >> /etc/mail/spamassassin/local.cf";
shell_exec($cmd);
$line="required_score ".$res['x_score'];
$cmd="echo ".$line." >> /etc/mail/spamassassin/local.cf";
shell_exec($cmd);
/*====================================================*/
if($res['x_spam_enable'] == "1") {
$line='';
$cmd="echo ".$line." > /etc/postfix/header_checks";
shell_exec($cmd);
}
else {
$line='/^X-Spam-Flag:.YES/ DISCARD spam';
$cmd="echo ".$line." > /etc/postfix/header_checks";
shell_exec($cmd);
$line='/^X-Spam-Flag:.YES/ DISCARD spam flag yes';
$cmd="echo ".$line." >> /etc/postfix/header_checks";
shell_exec($cmd);
$line='/^X-Spam-Level: \\\*\{'.$res['x_score'].',\}\/ DISCARD Spam score to high, rejecting.';
$cmd="echo ".$line." >> /etc/postfix/header_checks";
shell_exec($cmd);
}
/*====================================================*/
$sql = "SELECT * FROM x_apachesapm_filters WHERE x_flag='1'";
$numrows = $zdbh->prepare($sql);
// $numrows->bindParam(':userid', $currentuser['userid']);
$numrows->execute();
if ($numrows->fetchColumn() <> 0) {
$sql = $zdbh->prepare($sql);
$sql->execute();
$res=$sql->fetch();
$whitelist_from_array=explode("|",$res['x_domain_list']);
for($i=0;$i<count($whitelist_from_array);$i++)
{
$whitelist=trim($whitelist_from_array[$i]);
if($whitelist!="")
{
$line="whitelist_from ".$whitelist;
$cmd="echo ".$line." >> /etc/mail/spamassassin/local.cf";
shell_exec($cmd);
if($sender_access==0)
{
$sender_access=1;
$line=$whitelist." OK";
$cmd="echo ".$line." > /etc/postfix/sender_access";
shell_exec($cmd);
}else
{
$line=$whitelist." OK";
$cmd="echo ".$line." >> /etc/postfix/sender_access";
shell_exec($cmd);
}
}
}
}
$sql = "SELECT * FROM x_apachesapm_filters WHERE x_flag='0'";
$numrows = $zdbh->prepare($sql);
// $numrows->bindParam(':userid', $currentuser['userid']);
$numrows->execute();
if ($numrows->fetchColumn() <> 0) {
$sql = $zdbh->prepare($sql);
$sql->execute();
$res=$sql->fetch();
$blacklist_from_array=explode("|",$res['x_domain_list']);
for($i=0;$i<count($blacklist_from_array);$i++)
{
$blacklist=trim($blacklist_from_array[$i]);
if($blacklist!="")
{
$line="blacklist_from ".$blacklist;
$cmd="echo ".$line." >> /etc/mail/spamassassin/local.cf";
shell_exec($cmd);
if($sender_access==0)
{
$sender_access=1;
$line=$blacklist." REJECT";
$cmd="echo ".$line." > /etc/postfix/sender_access";
shell_exec($cmd);
}else
{
$line=$blacklist." REJECT";
$cmd="echo ".$line." >> /etc/postfix/sender_access";
shell_exec($cmd);
}
}
}
}
$cmd="postmap /etc/postfix/sender_access";
shell_exec($cmd);
$cmd="service spamassassin restart";
shell_exec($cmd);
$cmd="service postfix restart";
shell_exec($cmd);
$sql_update = "Update x_apachespam_settings set x_status='No'";
$sql_update = $zdbh->prepare($sql_update);
$sql_update->execute();
}
############################################## Spam assassians End ##############################################
?>