#copyright(c)Syslint technologies 
import os
import sys
from shellcolor import shellcolor
from datetime import datetime
import subprocess
import version
import deps
import sys
import platform

def precheck():
    version=deps.get_this_version()
    now = datetime.now()
    if os.path.exists("/usr/local/cpanel/version"):
	sys.stdout.write("Checking for cPanel .. " + shellcolor.green + "ok" + shellcolor.end+"\n") 
	os.popen('/usr/sbin/whmapi1 set_tweaksetting key=enablefileprotect value=0').read()
        ioncube = deps.check_cpphp_ioncube()
        if ioncube == 0:
	    sys.stdout.write("Checking for Ioncube Loader in CPPHP  .. " + shellcolor.green + "ok" + shellcolor.end+"\n")
        else:
            loader='/usr/sbin/whmapi1 set_tweaksetting key=phploader value=ioncube'
            subprocess.call(loader,shell=True)
	    sys.stdout.write("Installing  Ioncube Loader in CPPHP  .. " + shellcolor.fail + "yes" + shellcolor.end+"\n")
    else:
	sys.stdout.write("Checking for cPanel .. " + shellcolor.fail + "faild" + shellcolor.end+"\n") 
	sys.stdout.write("Installation Failed !!!\n")
	sys.exit()

