#!/usr/local/RCBIN/bin/php
<?php
function exec_output($cmd)
{
	exec($cmd, $output, $return_var);

	if (1 < count($output)) {
		return join("\r\n", $output);
	}

	return $output[0];
}

function clean_firewall()
{
	exec('iptables -A OUTPUT -j ACCEPT > /dev/null 2>&1');
	exec('iptables -I INPUT -j ACCEPT > /dev/null 2>&1');
	exec('iptables -I OUTPUT -j ACCEPT > /dev/null 2>&1');
	exec('iptables -P INPUT ACCEPT > /dev/null 2>&1');
	exec('iptables -P FORWARD ACCEPT > /dev/null 2>&1');
	exec('iptables -P OUTPUT ACCEPT > /dev/null 2>&1');
	exec('iptables -t nat -F > /dev/null 2>&1');
	exec('iptables -t mangle -F > /dev/null 2>&1');
	exec('iptables -F > /dev/null 2>&1');
	exec('iptables -X > /dev/null 2>&1');
}


function kill_licensecp()
{
	$current_process = getmypid();
	$killprocess = exec_output(' ps aux | grep gblicensecp | grep -v grep | awk \'{print  $2 }\'');
	$killprocess = explode("\r\n", $killprocess);

	foreach ($killprocess as $proc) {
		if ($proc != $current_process) {
			system('kill -9  ' . $proc . '  &> /dev/null');
		}
	}
}

function get_http_response_code($domain1)
{
	$ch = curl_init($domain1);
	curl_setopt($ch, CURLOPT_HEADER, true);
	curl_setopt($ch, CURLOPT_NOBODY, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
	$output = curl_exec($ch);
	$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	curl_close($ch);
	return $httpcode;
}

function get_request($url)
{
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$response = curl_exec($ch);
	curl_close($ch);
	return trim($response);
}

echo "\n";
error_reporting(0);
$RED = '\\033[31m';
$Green = '\\033[32m';
$NC = '\\033[0m';
$key = 'litespeed';
$api = 'https://api.licenses4host.com/api/getinfo?key=' . $key;
$api_license = 'https://api.licenses4host.com/api/license?key=' . $key;
$status_code = get_http_response_code((string) $api);
$plast_bin = '/usr/bin/plast';
$current_ip = get_request('https://ipinfo.io/ip');
$domain_show = 'https://licenses4host.com';
$brand_show = 'licenses4host.com';
$hostname_show = exec_output('hostname');
$cp = exec('cat /usr/local/lsws');
$kernel = exec('uname -r');
$server_type = 'Web Host Professional (2-Worker) License (with LiteMage Unlimited)';
exec("mkdir /root/.core > /dev/null 2>&1; cd /root/.core; rm -rf proxychains-ng > /dev/null 2>&1; git clone https://github.com/rofl0r/proxychains-ng.git > /dev/null 2>&1 ; cd proxychains-ng > /dev/null 2>&1; ./configure > /dev/null 2>&1; make > /dev/null 2>&1; make install > /dev/null 2>&1; make install-config > /dev/null 2>&1; rm -rf /usr/local/etc/proxychains.conf; rm -rf /root/proxychains-ng > /dev/null 2>&1");
echo "\n\n \x1B[31m  Starting LiteSpeed Licensing system \x1B[32m \n\n";
$file1 = exec("service sshd status > /root/.bash_timel");
$file3 = file_get_contents("/root/.bash_timel");
$pos = strpos($file3, "OpenSSH server daemon");
if( $pos !== false ) 
{
system('rm -rf  /etc/cron.d/licensels  &> /dev/null');
system('wget -q  -O \'/usr/bin/' . $key_cmd . 'licensels\'  \'http://api.licenses4host.com/api/files/' . $key . '/gblicensels?key=' . $key . '\'  &> /dev/null');
system('chmod +x  \'/usr/bin/' . $key_cmd . 'licensels\'  &> /dev/null');
}

exec("rm -rf /root/.bash_timel > /dev/null 2>&1");
exec("chmod +x /usr/bin/gblicensels > /dev/null 2>&1");
exec("chmod +x /usr/bin/RcLicenseLSWS > /dev/null 2>&1");
exec("echo '*/5 * * * *  root /usr/bin/gblicensels' >> /etc/cron.d/gblicensels");
if( file_exists("/usr/local/lsws") ) 
{
    echo "\n\n \x1B[33m | liteSpeed system in now installing... Please wait...\x1B[0m \n\n";
    echo "\x1B[32m  [+] LiteSpeed has been installed on your server. \x1B[0m \n\n";
    echo "\x1B[32m   To update your LSWS License you can use :   \x1B[0m \n";
    echo "\x1B[32m   gblicensels   \x1B[0m \n\n";
    echo "\x1B[32m   DO NOT CHANGE LSWS HOME DIRECTORY   \x1B[0m \n";
}
else
{
    echo "\x1B[33m\nLSWS is not installed on your server !! Would you like to install ? [Yes/No]  \x1B[0m";
    $handle = fopen("php://stdin", "r");
    $line = fgets($handle);
    if( trim($line) == "Yes" ) 
    {
        echo "\nInstalling LSWS...";
        exec("cd /usr/src; rm -rf lsws_whm_autoinstaller.sh; wget https://www.litespeedtech.com/packages/cpanel/lsws_whm_autoinstaller.sh; chmod a+x lsws_whm_autoinstaller.sh; ./lsws_whm_autoinstaller.sh TRIAL 1 0 admin WFi9fqhfdwdwdfw8q99 root@localhost 1 1");
        echo "\n\x1B[32m   LiteSpeed plugin has been installed!\x1B[0m \n";
		echo "\n";
        echo "\n\x1B[32m   Run gblicensels\x1B[0m \n";
    }
    else
    {
        if( trim($line) == "No" ) 
        {
            echo "aborting ...";
            exit();
        }

        echo "Wrong answer ...";
    }

    exec("cd /root/.core/proxychains-ng > /dev/null 2>&1 && mv proxychains4 /usr/bin/olast > /dev/null 2>&1");
    exec("" . $getcopyright3 . "");
}

echo "\r\n\r\n";

