Current File : //root/panel/modules/webserver/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 $error;
    static $alreadyexists;
    static $badname;
    static $blank;
    static $ok;
	static $vok;
	static $nok;
    static $edit;
    static $samepackage;
	static $okupdate;
    /**
     * The 'worker' methods.
     */
    static function SetCallDaemon()
    {

        $service_port = 4445 ;
    $address = gethostbyname('localhost');
        $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
                if ($socket === false)
                {
                /* 
                echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
                self::$tryagain=true;
                return false;
                */
                }
       //  echo "Attempting to connect to '$address' on port '$service_port'...";
        $result = socket_connect($socket, $address, $service_port);
        if ($result === false)
                {
        /* 
                echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n";
                self::$tryagain=true;
                return false;
                */
                }
                socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec" => 2000, "usec" =>0));
                $in="command DaemonCall ";
                socket_write($socket, $in, strlen($in));
                socket_close($socket);

    }
  static function dooperation()
    {
		global $zdbh;
		global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		if(isset($_POST['postoperation']))
		{
				
				
				//if($_POST['postoperation']=="varnishrestart" || $_POST['postoperation']=="apacherestart")					
			 if($_POST['postoperation']=="varnishrestart" || $_POST['postoperation']=="apacherestart" || $_POST['postoperation']=="nginxrestart" )	
			{
				
				
				$sql = "INSERT INTO x_web_server(x_service) VALUES (:x_service)";
				$numrows = $zdbh->prepare($sql);
				$numrows->bindParam(':x_service',$_POST['postoperation']);
				$numrows->execute();
					if($_POST['postoperation']=="apacherestart")
					{
					self::$ok = TRUE;
					return;
					}else if($_POST['postoperation']=="varnishrestart")
					{
					self::$vok = TRUE;
					return;	
					}else
					{
					self::$nok = TRUE;
					return;		
					}
				}else if($_POST['postoperation']=="apachedefault")
				{
					//set off into x_varnish table
					
									$sql = "SELECT  COUNT(*) FROM x_varnish WHERE x_user_id=:userid";
									//$numrows = $zdbh->query($sql);
									$numrows = $zdbh->prepare($sql);
									$numrows->bindParam(':userid', $currentuser['userid']);
									$numrows->execute();

									if ($numrows->fetchColumn() <> 0) {
										
									// update the column 
									$sql = "Update x_varnish SET x_varnish=:x_varnish,
									x_isactive=:x_isactive,x_nginx=:x_nginx									 
									WHERE	x_user_id=:userid";
									$time = time();
									$x_isactive=0;
									$varnish_val="Off";
									$x_nginx="Off";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':userid', $currentuser['userid']);
									$sql->bindParam(':x_varnish',$varnish_val);
									$sql->bindParam(':x_nginx',$x_nginx);
									$sql->bindParam(':x_isactive', $x_isactive);
									$sql->execute();
									
									$customport=80;
							
									$sql = $zdbh->prepare("Update x_vhosts SET vh_custom_port_in='".$customport."' WHERE vh_acc_fk='".$currentuser['userid']."'");
									$sql->execute();


									$gsql=$zdbh->prepare("select vh_id_pk from x_vhosts where  vh_acc_fk=:userid AND vh_deleted_ts is NULL");	
									$gsql->bindParam(':userid', $userid);
									$gsql->execute();
									$records_list="";
									$iter=0;
									while($res=$gsql->fetch())
									{
									if($iter==0)
									{
									$records_list=$res['vh_id_pk'];
									$iter=1;
									}	
									else
									{

									$records_list=$res['vh_id_pk'];
									}	
									}
									$sql = "UPDATE x_settings SET so_value_tx=:newlist WHERE so_name_vc='dns_hasupdates'";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':newlist', $records_list);
									$sql->execute();

									$sql = $zdbh->prepare("UPDATE x_settings
									SET so_value_tx='true'
									WHERE so_name_vc='apache_changed'");
									$sql->execute();
								    $sql = $zdbh->prepare("UPDATE x_ssl SET ssl_status='0' WHERE ssl_status='1' and ssl_delete is NULL;");
			                        $sql->execute(); // nandhini
									//shell_exec('sh /etc/sentora/panel/cronshell.sh');					
									self::$ok = true;
									return true;

									}else
									{
										
									// insert the column 
									$sql = "INSERT INTO x_varnish ( x_user_id, 
									x_varnish,
									x_interval,
									x_timeout,
									x_window,
									x_threshold,
									x_lastupdate,x_isactive,x_nginx) VALUES (
									:userid,
									:x_varnish,
									:x_interval,
									:x_timeout,
									:x_window,
									:x_threshold,
									:time,
									:x_isactive,
									:x_nginx)";
									$time = time();
									$x_isactive=0;
									$x_interval=5;
									$x_timeout=1;
									$x_window=5;
									$x_threshold=3;
									$varnish_val="Off";
									$x_nginx="Off";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':userid', $currentuser['userid']);
									$sql->bindParam(':x_varnish',$varnish_val);
									$sql->bindParam(':x_nginx',$x_nginx);
									$sql->bindParam(':x_interval',$x_interval);
									$sql->bindParam(':x_timeout',$x_timeout);
									$sql->bindParam(':x_window',$x_window);
									$sql->bindParam(':x_isactive',$x_isactive);
									$sql->bindParam(':x_threshold',$x_threshold);
									$sql->bindParam(':time', $time);
									$sql->execute();
									$customport=80;
									
									$sql = $zdbh->prepare("Update x_vhosts SET vh_custom_port_in='".$customport."' WHERE vh_acc_fk='".$currentuser['userid']."'");
									$sql->execute();

									$gsql=$zdbh->prepare("select vh_id_pk from x_vhosts where  vh_acc_fk=:userid AND vh_deleted_ts is NULL");	
									$gsql->bindParam(':userid', $userid);
									$gsql->execute();
									$records_list="";
									$iter=0;
									while($res=$gsql->fetch())
									{
									if($iter==0)
									{
									$records_list=$res['vh_id_pk'];
									$iter=1;
									}	
									else
									{

									$records_list=$res['vh_id_pk'];
									}	
									}
									$sql = "UPDATE x_settings SET so_value_tx=:newlist WHERE so_name_vc='dns_hasupdates'";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':newlist', $records_list);
									$sql->execute();

									$sql = $zdbh->prepare("UPDATE x_settings
									SET so_value_tx='true'
									WHERE so_name_vc='apache_changed'");
									$sql->execute();
								    $sql = $zdbh->prepare("UPDATE x_ssl SET ssl_status='0' WHERE ssl_status='1' and ssl_delete is NULL;");
			                        $sql->execute(); // nandhini
									//shell_exec('sh /etc/sentora/panel/cronshell.sh');	
									self::$ok = true;
									return true;

									}
					
				}
				else if($_POST['postoperation']=="varnishdefault")
				{
					
									
					//set off into x_varnish table
									$sql = "SELECT  COUNT(*) FROM x_varnish WHERE x_user_id=:userid";
									$numrows = $zdbh->prepare($sql); 
									$numrows->bindParam(':userid', $currentuser['userid']);
									$numrows->execute();

									if ($numrows->fetchColumn() <> 0) {
									// update the column 
									$sql = "Update x_varnish SET x_varnish=:x_varnish,
									x_isactive=:x_isactive,x_nginx=:x_nginx									 
									WHERE	x_user_id=:userid";
									$time = time();
									$x_isactive=0;
									$varnish_val="On";
									$x_nginx="Off";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':userid', $currentuser['userid']);
									$sql->bindParam(':x_varnish',$varnish_val);
									$sql->bindParam(':x_nginx',$x_nginx);
									$sql->bindParam(':x_isactive', $x_isactive);
									$sql->execute();
									
									$customport=8080;
							
									$sql = $zdbh->prepare("Update x_vhosts SET vh_custom_port_in='".$customport."' WHERE vh_acc_fk='".$currentuser['userid']."'");
									$sql->execute();


									$gsql=$zdbh->prepare("select vh_id_pk from x_vhosts where  vh_acc_fk=:userid AND vh_deleted_ts is NULL");	
									$gsql->bindParam(':userid', $userid);
									$gsql->execute();
									$records_list="";
									$iter=0;
									while($res=$gsql->fetch())
									{
									if($iter==0)
									{
									$records_list=$res['vh_id_pk'];
									$iter=1;
									}	
									else
									{

									$records_list=$res['vh_id_pk'];
									}	
									}
									$sql = "UPDATE x_settings SET so_value_tx=:newlist WHERE so_name_vc='dns_hasupdates'";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':newlist', $records_list);
									$sql->execute();

									$sql = $zdbh->prepare("UPDATE x_settings
									SET so_value_tx='true'
									WHERE so_name_vc='apache_changed'");
									$sql->execute();
									$sql = $zdbh->prepare("UPDATE x_ssl SET ssl_status='0' WHERE ssl_status='1' and ssl_delete is NULL;");
			                        $sql->execute();
										$sql = $zdbh->prepare("UPDATE x_ssl SET ssl_status='0' WHERE ssl_status='1' and ssl_delete is NULL;");
			                        $sql->execute(); // nandhini
									//shell_exec('sh /etc/sentora/panel/cronshell.sh');					
									self::$vok = true;
									return true;

									}else
									{

									// insert the column 
									$sql = "INSERT INTO x_varnish ( x_user_id, 
									x_varnish,
									x_interval,
									x_timeout,
									x_window,
									x_threshold,
									x_lastupdate,x_isactive,x_nginx) VALUES (
									:userid,
									:x_varnish,
									:x_interval,
									:x_timeout,
									:x_window,
									:x_threshold,
									:time,
									:x_isactive,:x_nginx)";
									$time = time();
									$x_isactive=0;
									$x_interval=5;
									$x_timeout=1;
									$x_window=5;
									$x_threshold=3;
									$varnish_val="On";
									$x_nginx="Off";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':userid', $currentuser['userid']);
									$sql->bindParam(':x_varnish',$varnish_val);
									$sql->bindParam(':x_interval',$x_interval);
									$sql->bindParam(':x_timeout',$x_timeout);
									$sql->bindParam(':x_window',$x_window);
									$sql->bindParam(':x_isactive',$x_isactive);
									$sql->bindParam(':x_threshold',$x_threshold);
									$sql->bindParam(':x_nginx',$x_nginx);
									$sql->bindParam(':time', $time);
									$sql->execute();
									$customport=8080;
									
									$sql = $zdbh->prepare("Update x_vhosts SET vh_custom_port_in='".$customport."' WHERE vh_acc_fk='".$currentuser['userid']."'");
									$sql->execute();

									$gsql=$zdbh->prepare("select vh_id_pk from x_vhosts where  vh_acc_fk=:userid AND vh_deleted_ts is NULL");	
									$gsql->bindParam(':userid', $userid);
									$gsql->execute();
									$records_list="";
									$iter=0;
									while($res=$gsql->fetch())
									{
									if($iter==0)
									{
									$records_list=$res['vh_id_pk'];
									$iter=1;
									}	
									else
									{

									$records_list=$res['vh_id_pk'];
									}	
									}
									$sql = "UPDATE x_settings SET so_value_tx=:newlist WHERE so_name_vc='dns_hasupdates'";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':newlist', $records_list);
									$sql->execute();

									$sql = $zdbh->prepare("UPDATE x_settings
									SET so_value_tx='true'
									WHERE so_name_vc='apache_changed'");
									$sql->execute();
									$sql = $zdbh->prepare("UPDATE x_ssl SET ssl_status='0' WHERE ssl_status='1' and ssl_delete is NULL;");
			                        $sql->execute(); // nandhini
									//shell_exec('sh /etc/sentora/panel/cronshell.sh');	
									self::$vok = true;
									return true;

									}
					
					
				}
				else if($_POST['postoperation']=="nginxdefault")
				{
					
									
					//set off into x_varnish table
									$sql = "SELECT  COUNT(*) FROM x_varnish WHERE x_user_id=:userid";
									$numrows = $zdbh->prepare($sql);
									$numrows->bindParam(':userid', $currentuser['userid']);
									$numrows->execute();
			
									if ($numrows->fetchColumn() <> 0) {
										
										   $sql = "Update x_varnish SET x_varnish=:x_varnish,
									x_isactive=:x_isactive,x_nginx=:x_nginx									 
									WHERE	x_user_id=:userid";
									$time = time();
									$x_isactive=0;
									$varnish_val="Off";
									$x_nginx="On";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':userid', $currentuser['userid']);
									$sql->bindParam(':x_varnish',$varnish_val);
									$sql->bindParam(':x_nginx',$x_nginx);
									$sql->bindParam(':x_isactive', $x_isactive);
									$sql->execute();
									
									/* $customport=80;
							
									$sql = $zdbh->prepare("Update x_vhosts SET vh_custom_port_in='".$customport."' WHERE vh_acc_fk='".$currentuser['userid']."'");
									$sql->execute();


									$gsql=$zdbh->prepare("select vh_id_pk from x_vhosts where  vh_acc_fk=:userid AND vh_deleted_ts is NULL");	
									$gsql->bindParam(':userid', $userid);
									$gsql->execute();
									$records_list="";
									$iter=0;
									while($res=$gsql->fetch())
									{
									if($iter==0)
									{
									$records_list=$res['vh_id_pk'];
									$iter=1;
									}	
									else
									{

									$records_list=$res['vh_id_pk'];
									}	
									}
									$sql = "UPDATE x_settings SET so_value_tx=:newlist WHERE so_name_vc='dns_hasupdates'";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':newlist', $records_list);
									$sql->execute();

									$sql = $zdbh->prepare("UPDATE x_settings
									SET so_value_tx='true'
									WHERE so_name_vc='apache_changed'");
									$sql->execute(); */				
									self::$nok = true;
									return true;
									}else
									{
									$sql = "INSERT INTO x_varnish ( x_user_id, 
									x_varnish,
									x_interval,
									x_timeout,
									x_window,
									x_threshold,
									x_lastupdate,x_isactive,x_nginx) VALUES (
									:userid,
									:x_varnish,
									:x_interval,
									:x_timeout,
									:x_window,
									:x_threshold,
									:time,
									:x_isactive,:x_nginx)";
									$time = time();
									$x_isactive=0;
									$x_interval=5;
									$x_timeout=1;
									$x_window=5;
									$x_threshold=3;
									$varnish_val="Off";
									$x_nginx="On";
									$sql = $zdbh->prepare($sql);
									$sql->bindParam(':userid', $currentuser['userid']);
									$sql->bindParam(':x_varnish',$varnish_val);
									$sql->bindParam(':x_interval',$x_interval);
									$sql->bindParam(':x_timeout',$x_timeout);
									$sql->bindParam(':x_window',$x_window);
									$sql->bindParam(':x_isactive',$x_isactive);
									$sql->bindParam(':x_threshold',$x_threshold);
									$sql->bindParam(':x_nginx',$x_nginx);
									$sql->bindParam(':time', $time);
									self::$nok = true;
									return true;
								}
				}
		}
		self::SetCallDaemon();
		self::$error = TRUE;
        return;
	
	}
	
    static function getResult()
    {
      
		if (!fs_director::CheckForEmptyValue(self::$error)) {
		return ui_sysmessage::shout(ui_language::translate("<strong>Error:</strong> There was an error for restart the server."), "Error");
		}
        if (!fs_director::CheckForEmptyValue(self::$ok)) {
            return ui_sysmessage::shout(ui_language::translate("<strong>Success:</strong> Apache restarted successfully."), "Ok");
        }
		 if (!fs_director::CheckForEmptyValue(self::$vok)) {
            return ui_sysmessage::shout(ui_language::translate("<strong>Success:</strong> Varnish & Apache restarted successfully."), "Ok");
        }
		if (!fs_director::CheckForEmptyValue(self::$nok)) {
            return ui_sysmessage::shout(ui_language::translate("<strong>Success:</strong> Nginx restarted successfully."), "Ok");
        }
        return;
    }

	static function getShowServerName()
	{
		global $zdbh;
        global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		$sql = "SELECT  * FROM x_varnish WHERE x_user_id=:userid";
        //$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_nginx']=="On")
			{
			return 'Notice: Your server currently running under the nginx server' ;
			}else
			{
			if($res['x_varnish']=="On")
			return 'Notice: Your server currently running under the apache server with varnish cache server' ;
			else 
			return 'Notice: Your server currently running under the apache server' ;
			}	
	}else
		{
		return "Notice: Your server currently running under the apache server";	
		}
	}
    /**
     * Webinterface sudo methods.
     */
	 /* //////////////////////// apache starting enable /////////////////  */
	 static function getcheckedapache()
	{
		global $zdbh;
        global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		$sql = "SELECT  * FROM x_varnish WHERE x_user_id=:userid";
        //$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_varnish']=="Off" && $res['x_nginx']=="Off" )
			return 'checked' ;
			else
			return '';
		}else
		{
		return "";	
		}
	}
	 static function getenabledapachedefault()
	{
		global $zdbh;
        global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		$sql = "SELECT  * FROM x_varnish WHERE x_user_id=:userid";
        //$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_varnish']=="Off" && $res['x_nginx']=="Off" )
			return 'disabled' ;
			else 
			return '';
		}else
		{
		return '';	
		}
	}
		 static function getenabledapacherestart()
	{
		global $zdbh;
        global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		$sql = "SELECT  * FROM x_varnish WHERE x_user_id=:userid";
        //$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_varnish']=="Off" && $res['x_nginx']=="Off" )
			return '' ;
			else 
			return 'disabled';
		}else
		{
		return "";	
		}
	}
	/* //////////////////////// apache Ending enable /////////////////  */
	 /* //////////////////////// varnish Starting enable /////////////////  */
	 static function getcheckedvarnish()
	{
		global $zdbh;
        global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		$sql = "SELECT  * FROM x_varnish WHERE x_user_id=:userid";
        //$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_varnish']=="On" && $res['x_nginx']=="Off" )
			return 'checked' ;
			else
			return '';
		}else
		{
		return "";	
		}
	}
	 static function getenabledvarnishdefault()
	{
		global $zdbh;
        global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		$sql = "SELECT  * FROM x_varnish WHERE x_user_id=:userid";
        //$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_varnish']=="On" && $res['x_nginx']=="Off" )
			return 'disabled' ;
			else 
			return '';
		}else
		{
		return "";	
		}
	}
		 static function getenabledvarnishrestart()
	{
		global $zdbh;
        global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		$sql = "SELECT  * FROM x_varnish WHERE x_user_id=:userid";
        //$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_varnish']=="On" && $res['x_nginx']=="Off" )
			return '' ;
			else 
			return 'disabled';
		}else
		{
		return "";	
		}
	}
	
	 /* //////////////////////// varnish Ending enable /////////////////  */
	 
	 /* //////////////////////// NGINX starting enable /////////////////  */
	 
	 static function getcheckednginx()
	{
		global $zdbh;
        global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		$sql = "SELECT  * FROM x_varnish WHERE x_user_id=:userid";
        //$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_varnish']=="Off" && $res['x_nginx']=="On" )
			return 'checked' ;
			else
			return '';
		}else
		{
		return "";	
		}
	}
	static function getenablednginxdefault()
	{
		global $zdbh;
		global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		$sql = "SELECT  * FROM x_varnish WHERE x_user_id=:userid";
		//$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_varnish']=="Off" && $res['x_nginx']=="On" )
		return 'disabled' ;
		else 
		return '';
		}else
		{
		return 'disabled';	
		}

		
	}
	static function getenablednginxrestart()
	{
		global $zdbh;
        global $controller;
		$currentuser = ctrl_users::GetUserDetail();
		$sql = "SELECT  * FROM x_varnish WHERE x_user_id=:userid";
        //$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_varnish']=="Off" && $res['x_nginx']=="On" )
			return '' ;
			else 
			return 'disabled';
		}else
		{
		return "";	
		}

	}
	
	 /* //////////////////////// NGINX Ending enable /////////////////  */
}