Current File : //etc/sentora/panel/modules/mod_security/hooks/OnDaemonRun.hook.php
<?php
global $zdbh;
$mod_conf_count = $zdbh->prepare("SELECT * FROM x_modsecurity WHERE x_mod_hook=0");
$mod_conf_count->execute();
$mod_count = $mod_conf_count->fetchColumn();
echo $mod_count."----------------------MOD SECURITY START--------------------------- \n";
if($mod_count > 0)
{
	$mod_conf = $zdbh->prepare("SELECT * FROM x_modsecurity WHERE x_mod_hook=0");
	$mod_conf->execute();
	while($modrows = $mod_conf->fetch())
	{
		$mod_conf = $zdbh->prepare("SELECT * FROM x_vhosts  WHERE vh_id_pk=:uid and  vh_deleted_ts IS NULL");
		$mod_conf->bindParam(':uid', $modrows['x_domain_id']);
		$mod_conf->execute();
		$row = $mod_conf->fetch();
		$domain = $row['vh_name_vc'];
		$file_path = "/etc/sentora/configs/apache/domains/".$domain.".conf";
		echo $domain."\n";
		echo $modrows['x_mod_status']."\n";
		if($modrows['x_mod_status'] == "ModOff")
		{
			$ch_sec = "SecRuleEngine Off";
			$ch_sec1 = "SecRequestBodyAccess Off";
			$ch_sec2 = "SecTmpSaveUploadedFiles Off";
		}
		else
		{
			$ch_sec = "SecRuleEngine On";
			$ch_sec1 = "SecRequestBodyAccess On";
			$ch_sec2 = "SecTmpSaveUploadedFiles On";
		}
		
		$line_num = shell_exec("grep -ni 'SecRuleEngine' $file_path | head -1");
		$line_nm = explode(":",$line_num);
		$sec_line = $line_nm[0];
		$sec_data = trim($line_nm[1]);
		shell_exec("sed -i ''$sec_line's/$sec_data/$ch_sec/g' $file_path");
		
		$line_num1 = shell_exec("grep -ni 'SecRequestBodyAccess' $file_path | head -1");
		$line_nm1 = explode(":",$line_num1);
		$sec_line1= $line_nm1[0];
		$sec_data1 = trim($line_nm1[1]);
		shell_exec("sed -i ''$sec_line1's/$sec_data1/$ch_sec1/g' $file_path");
		
		$line_num2 = shell_exec("grep -ni 'SecTmpSaveUploadedFiles' $file_path | head -1");
		$line_nm2 = explode(":",$line_num2);
		$sec_line2= $line_nm2[0];
		$sec_data2 = trim($line_nm2[1]);
		shell_exec("sed -i ''$sec_line2's/$sec_data2/$ch_sec2/g' $file_path");
		
		$mod_conf = $zdbh->prepare("UPDATE x_modsecurity SET x_mod_hook=1 WHERE x_domain_id=:uid");
		$mod_conf->bindParam(':uid', $modrows['x_domain_id']);
		$mod_conf->execute();
		
	}
	echo "----------------------MOD SECURITY End--------------------------- \n";
	
}
?>