Current File : //etc/zpanel/panel/modules/phpexecution/code/controller.ext.php
<?php

/**
 * @copyright 2014-2015 Sentora Project (http://www.sentora.org/) 
 * Sentora is a GPL fork of the ZPanel Project whose original header follows:
 *
 * ZPanel - A Cross-Platform Open-Source Web Hosting Control panel.
 *
 * @package ZPanel
 * @version $Id$
 * @author Bobby Allen - ballen@bobbyallen.me
 * @copyright (c) 2008-2014 ZPanel Group - http://www.zpanelcp.com/
 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License v3
 *
 * This program (ZPanel) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
class module_controller extends ctrl_module
{

    static function getBlockedFiles()
    {
		global $zdbh;
		global $controller;
        $currentuser = ctrl_users::GetUserDetail();
		$cmd='';
		if ($currentuser['usergroup'] == "Administrators" || $currentuser['usergroup'] == "Resellers") 
		{
			$cmd='cat /var/sentora/temp/spamavoid/php_execution_block.log | sort | uniq -c '." | sed -e 's/^[ \t]*//' ";
        } 
		else 
		{
    		$cmd='cat /var/sentora/temp/spamavoid/php_execution_block.log ';
			$cmd.=' | grep '.ctrl_options::GetSystemOption('hosted_dir').$currentuser['username'].'/';
			$cmd.=' | sort | uniq -c ';
			$cmd.=" | sed -e 's/^[ \t]*//' ";	
		}	
        $line=shell_exec($cmd);
        $line = trim($line);
        if($line)
        {
            $line_data = explode("\n", $line);
            if(count($line_data) > 0)
            {
                $line="";
                foreach($line_data as $data)
                {
                    $data_arr = explode(" ", $data);
                    $file_path = $data_arr[1];
                    $line .= "<div class='each-file-block'>".$data."<button class='btn btn-primary allowFile' type='submit' name='AllowFile' id='AllowFile' value='$file_path'>Allow</button></div>";
                }
            }
            else
		    {
    			$line="No data available";
	    	}
        }
        else
        {
            $line="No data available";
        }
		return $line;
	}	 

  static function gethelpicon()
    {
        global $zdbh;
        global $controller;
        $temp=$controller->GetControllerRequest('URL','module') ;
        $val = '/assets/one.txt';
        $val1 = '/modules/';
        $name=file_get_contents("modules/$temp/assets/helpicon.txt");
        return $name;
    }

    static function getAllowedFiles()
    {
		global $zdbh;
		global $controller;
        $currentuser = ctrl_users::GetUserDetail();
		$cmd='';
		if ($currentuser['usergroup'] == "Administrators" || $currentuser['usergroup'] == "Resellers") 
		{
			$cmd='cat /var/sentora/temp/spamavoid/php_execution_block.log | sort | uniq -c '." | sed -e 's/^[ \t]*//' ";
        } 
		else 
		{
    		$cmd='cat /var/sentora/temp/spamavoid/php_execution_allow.txt ';
			$cmd.=' | grep '.ctrl_options::GetSystemOption('hosted_dir').$currentuser['username'].'/';
		}
        	
        $line=shell_exec($cmd);
        $line = trim($line);
        if($line)
        {
            $line_data = explode("\n", $line);
            if(count($line_data) > 0)
            {
                $line="";
                foreach($line_data as $file_path)
                {
                    $line .= "<div class='each-file-block'>".$file_path."<button class='btn btn-primary disallowFile' type='submit' name='DisAllowFile' id='DisAllowFile' value='$file_path'>Disallow</button></div>";
                }
            }
            else
		    {
    			$line="No data available";
	    	}
        }
        else
        {
            $line="No data available";
        }
		return $line;
	}
    
    static function doAllowFiles()
    {
        global $controller;
        $FilePath = $controller->GetControllerRequest('FORM', 'FilePath');
        $FilePath = trim($FilePath);
        $allow_file_path = "/var/sentora/temp/spamavoid/php_execution_allow.txt";
        $RepalcedFilePath = str_replace("/","\/", $FilePath);
        file_put_contents($allow_file_path, $FilePath."\n", FILE_APPEND | LOCK_EX);
        $blocked_file_path = "/var/sentora/temp/spamavoid/php_execution_block.log";
        $cmd="sed -i '/$RepalcedFilePath/d' $blocked_file_path";
        shell_exec($cmd);
        shell_exec("awk 'NF' $blocked_file_path");
        $out = self::getAllowedFiles();
        echo $out;exit;
    }

    static function doDisAllowFile()
    {
        global $controller;
        $FilePath = $controller->GetControllerRequest('FORM', 'FilePath');
        $FilePath = trim($FilePath);
        $blocked_file_path = "/var/sentora/temp/spamavoid/php_execution_block.log";
        $RepalcedFilePath = str_replace("/","\/", $FilePath);
        file_put_contents($blocked_file_path, $FilePath."\n", FILE_APPEND | LOCK_EX);
        $allow_file_path = "/var/sentora/temp/spamavoid/php_execution_allow.txt";
        $cmd="sed -i '/$RepalcedFilePath/d' $allow_file_path";
        shell_exec($cmd);
        shell_exec("awl 'NF' $allow_file_path");
        $out = self::getBlockedFiles();
        echo $out;exit;
    }

}