CHips L MINI SHELL

CHips L pro

Current Path : /opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/lib/RVSGL/CpHandle/
Upload File :
Current File : //opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/lib/RVSGL/CpHandle/DaRoot.php

<?php

require_once dirname(__FILE__) . '/InterfaceForAdmin.php';
require_once dirname(__FILE__) . '/DaLibs.php';

/*
 * Admin is use function in InterfaceAmin and InterfaceUser
 * Admin จำเป็นต้องใช้ทุก function ของ User จึง implements ทั้ง Interface
 * CpHandle_InterfaceForAdmin
 * CpHandle_InterfaceForUser
 * */
class CpHandle_DaRoot extends CpHandle_DaLibs implements CpHandle_InterfaceForAdmin
{
    public function CpHandle_DaRoot() { }
    
    public function init()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        
        return true;
    }
    
    public function FrameTarget()
    {
        return 'mainFrame';
    }
    
    public function actionAJExternal($url)
    {
        return false;
    }
    
    public function isSkipAllowUserPerms()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return false;
    }
    
    /**
    * no process in cpanel
    * ฝากตรวจสอบ function นี้ด้วยนะครับว่าควรที่จะมีใน root/reseller หรือไม่
    * เหมือนว่าตอนนี้มีอยู่ครับ
    */
    public function getPathPHPsuexec()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return false;
    }
    
    public function getHomeDir($username=RVS_USER_NAME)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
            $aHomeDir = posix_getpwnam($username);
            if (empty($aHomeDir['dir']) === true) {
                $aHomeDir['dir'] = '/home/' . $username;
            }
            return $aHomeDir['dir'];
    }
    
    public function listAllAcctsData()
    {
    	$aAllData = $this->getDataAllUser();
    	$aListAcc = array();
    	$i = 0;
    	foreach ($aAllData as $k => $v) {
    		$aListAcc[$i] = $v;
    		$aListAcc[$i]['domain'] = $v['default'];
    		$aListAcc[$i]['user'] = $v['username'];
    		$i++;
    	}
    	return $aListAcc;
    }
    
    
    public function listAccts($owner='')
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	if ($owner == '') {
    		//case: all user = user 
    		$aUserAll = $this->socketAPI('CMD_API_SHOW_ALL_USERS');
    		$aReseller = $this->socketAPI('CMD_API_SHOW_RESELLERS');
    		
    		if (isset($aReseller['list']) && isset($aUserAll['list'])) {
    			$aUserList['list'] = array_unique(array_merge((array)$aReseller['list'], (array)$aUserAll['list']));
    		} else {
    			$aUserList['list'] = $aUserAll['list'];
    		}
    	} else {
    		//case: list user by owner
    		$aUserList = $this->socketAPI('CMD_API_SHOW_USERS');
    	}
    	return (isset($aUserList['list']) && $aUserList['list']) ? $aUserList['list'] : array();
    }
    
    public function getControlPanelUrl()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return INDEX_URL . '/CMD_SHOW_USER?user=';
    }
    
    //TODO รอ path update install ที่ ถูกต้อง
     /**
     * Validate update RVSitebuilder
     * 
     * @author Puttipong <puttipong@rvglobalsoft.com>
     * @return mix Array or Boolean
     */
    public function getUpgradeRVSitebuilder()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $dirInstall = RvsLibs_File::buildPath(array('/usr', 'local', 'rvglobalsoft', 'rvsitebuilderinstaller', 'RVSInstaller'));
        $fileAutoInstall = RvsLibs_File::buildPath(array('/usr', 'local', 'rvglobalsoft', 'rvsitebuilderinstaller', 'autoinstaller.cgi'));
        return (is_dir($dirInstall) === true && is_file($fileAutoInstall) === true)
                        ? $fileAutoInstall : false;    
    }
    
    //TODO รอใส่คำพูดให้ถูกต้องที่ไฟล์ rvs_sitebuilder.html
    public function detectPathPHP()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
          if (!function_exists('get_cfg_var')) {
            return false;
        }
        $pathPHPini = get_cfg_var('cfg_file_path');
        $pathPHPini = trim($pathPHPini);
        return ($pathPHPini != '/usr/local/directadmin/plugins/rvsitebuilder/user/php.ini') ? true : false;
    }
    
    public function getLogoutUrl()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return '/CMD_LOGOUT';
    }
    
    public function getCPDATA($username=RVS_USER_NAME)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $aCpdata = array();
        $aAllData = $this->getDataAllUser();
        $dns = RvsLibs_String::dbeExplode('<br>', $aAllData[$username]['list']);
        $aCpdata['USER'] = $aAllData[$username]['username'];
        $aCpdata['OWNER'] = $aAllData[$username]['creator'];
        $aCpdata['IP'] = $aAllData[$username]['ip'];
        $aCpdata['DNS'] = $aAllData[$username]['default'];

        foreach ($dns as $k => $v) {
            if (trim($v) != '' && $v != $aCpdata['DNS']) {
            	$aCpdata['DNS' . $k] = $v;
            }
        }
     
        return $aCpdata;
    }
    
    /**
     * Process in cp mode
     * @param $cycleNow = 0, $errorNotExit = 0, $skipMsg = 0
     * @author pharadol@rvglobalsoft.com
     * */
    public function checkFileConfigLicenseCycle($cycleNow = 0, $errorNotExit = 0, $skipMsg = 0)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        require_once dirname(dirname(__FILE__)) . '/LicenseCycle.php';
        $oCycle = new LicenseCycle();
        $oCycle->FileConfigLicenseCycle($cycleNow, $errorNotExit, $skipMsg);
        return true;
    }
    
    /**
     * getHashUrl()
     * @return ''
     * @author pharadol@rvglobalsoft.com
     * */
    public function getHashUrl()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return '';
    }
    
    public function getResellers()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $result = $this->socketAPI('CMD_API_SHOW_RESELLERS');
        $aResellerList = (isset($result['list'])) ? $result['list'] : array();
        if (is_array($aResellerList) === false) {
            $aResellerList = array($aResellerList);
        }
        return $aResellerList;
    }
    
    public function replateAtOnUserName($userName)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return $userName;
    }

    public function getWhmRemoteFrame()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return 0;
    }
    
    public function checkRVSkinWHMAddon(&$input)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return false;
    }
    
    public function whmRequest($request,$host,$user,$accesshash,$usessl)
    {
       SGL::logMessage(null, PEAR_LOG_DEBUG);  
    }
    
    //admin ต้องมี .rvsitebuilder อ้างอิงจาก rvswrapper.c
    public function getTmpPath()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
         return RvsLibs_File::buildPath(array(RVS_USER_HOME, 'tmp'));
    }
    
   public function getUserDNS($all=0)
    {
        $result = $this->socketAPI('CMD_API_ADDITIONAL_DOMAINS');
        if ($all == 1) {
            $aDNS = array();
            $aDNS = array_keys($result);
        } else {
            $aDNS = key(preg_grep( "/defaultdomain=yes/", $result));
            $aDNS = (isset($aDNS) && $aDNS !='')? $aDNS : '';
        }
        return  preg_replace('/_/', '.', $aDNS);
    }
    
    public function isAllowExportProject()
    {
        return (isset($this->conf['Admin']['Owner']['AllowExportProject'])) 
            ? $this->conf['Admin']['Owner']['AllowExportProject'] 
            : '0';
    }
    
    public function isAllowImportProject()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return (isset($this->conf['Admin']['Owner']['AllowImportProject'])) 
            ? $this->conf['Admin']['Owner']['AllowImportProject'] 
            : '0';
    }
    
    /**
     * Is mode tryout
     * 
     * @author Puttipong <puttipong@rvglobalsoft.com>
     * @return Boolean False
     */
    public function isTryout()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return false;
    }
    
    /**
     * Is mode nocp
     * 
     * @author Puttipong <puttipong@rvglobalsoft.com>
     * @return Boolean True
     */
    public function isNocp()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return false;
    }
    
    public function getRvBinPath()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return '/usr/local/rvglobalsoft/rvsitebuilder/rvbin/rvswrapper';
    }
    
    public function isCpanel()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return false;
    }
    
    public function isDirectAdmin()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return true;
    }
    
    public function isNotTryout()
    {
        //log loop SGL::logMessage(null, PEAR_LOG_DEBUG);
        return true;
    }
    
    public function runDetectPhpSuexec($dePhpSuexec)
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	$phpSuExec = RvsLibs_System::runDetectPhpSuexec();
    	if($phpSuExec != $dePhpSuexec) {
    		RvsLibs_Config::autoUpdatePhpSuExecToMainIpConf($phpSuExec, $this->conf);
    	}
    	return $phpSuExec;
    }
    
    public function isValidClearCacheAndRVSiteFIX()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return true;
    }
    
    public function isValidIncludeFileLang($aConfTemplateList)
    {
        return  false;
    }
    

    public function getTypeFileEncode($fileName)
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	$TypeFileEncode = '';
    	if (RvsLibs_System::function_exists('finfo_open') && RvsLibs_System::function_exists('finfo_file')) {
    		$finfo = @finfo_open(FILEINFO_MIME_ENCODING);
    		$TypeFileEncode = @finfo_file($finfo, $fileName);
    	}
    	return $TypeFileEncode;
    }
    
    public function isVaildTemplatePrivate()
    {
    	//SGL::logMessage(null, PEAR_LOG_DEBUG);
    	return false;
    }
    
    public function skipValidTemplate()
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	return false;
    }
    
    public function isValidUpdateRollbackVersion()
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	return true;
    }


    public function isAdmin($username = RVS_USER_NAME) 
    {
       SGL::logMessage(null, PEAR_LOG_DEBUG);
       return ($username == RVS_ROOT_USER_NAME)? true : false;
    }
    

    public function ownerIsAdmin($ownername = RVS_OWNER_USER_NAME)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        return ($ownername == RVS_ROOT_USER_NAME || $ownername == 'root')? true : false;
    }
    
    public function UserUploadSymLinksecureCommand($realPathUserUpload)
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    }

    public function makeUploadFolder($userUploadPath, $pathRootUpload, $rootPath)
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	
    	if (is_link($userUploadPath) && (is_dir($rootPath)) ) {
    		unlink($userUploadPath);
    	}
    	
       if (!is_dir($userUploadPath)) {
            RvsLibs_System::mkDir(array('-p', $userUploadPath));
        }
    	return false;
    }
    
    public function createUserSymlinkUserFolder($pathUserUpload, $pathUploadLink)
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	RvsLibs_User::createUserSymlinkUserFolderDa($pathUserUpload, $pathUploadLink);
    }

    public function moveUploadedFile($tempFile, $destination)
    {
    	SGL::logMessage('tempFile :: ' . $tempFile, PEAR_LOG_DEBUG);
    	SGL::logMessage('destination::' . $destination, PEAR_LOG_DEBUG);
    	return RvsLibs_System::copy(array($tempFile, $destination));
    }

    public function isUploadedFile($tempFile)
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	return is_file($tempFile);
    }
    
    public function makeLink($source, $des)
    {
    	SGL::logMessage('tempFile :: ' . $source, PEAR_LOG_DEBUG);
    	SGL::logMessage('destination::' . $des, PEAR_LOG_DEBUG);
    	RvsLibs_System::copy(array($source, $des));
    }
    
    function secureCommandMakeLinkProjectId($projectId)
    {
        return true;
    }
    
    public function isTryoutOpenbaseDir($user)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $aDns =  $this->getAllDomainsByUser($user);
        $pattern1 = '/\/usr\/local\/rvglobalsoft\/rvsitebuilder/';
        $pattern2 = '/\/usr\/local\/directadmin\/plugins\/rvsitebuilder/';
      
        foreach ($aDns as $domain) {
        	$pathDNS = RvsLibs_File::buildPath(array('/usr', 'local', 'directadmin', 'data' , 'users' , $user, 'domains' , $domain . '.cust_httpd'));
        	if(is_file($pathDNS)) {
        		$aData = file($pathDNS);
        		foreach ($aData as $line) {
        			if (RvsLibs_String::preg_match($pattern1, trim($line)) && RvsLibs_String::preg_match($pattern2, trim($line))) {
        				return true;
        			}
        		}
        	} 
        }
         return false;
    }
    
    public function buildProjectUrlForDa()
    {
    	SGL::logMessage(null, PEAR_LOG_DEBUG);
    	$defaultDomain = $this->getDefaultDomain();
    	$socketDomain = $this->validateDomain($defaultDomain);
    	if ($socketDomain === false) {
    		return false;
    	}
    	$dirPath = RvsLibs_File::buildPath(array(RVS_USER_HOME, 'domains', $defaultDomain, 'public_html', '.rvsitebuilderHome'));
    	$dirRVS = RvsLibs_File::buildPath(array(RVS_USER_HOME, 'domains', $defaultDomain, 'public_html', '.rvsitebuilder'));
    	$realProjectPath = RvsLibs_File::buildPath(array(RVS_USER_HOME, '.rvsitebuilder', 'projects'));
    	if (is_dir($dirPath) == false) {
    		RvsLibs_System::mkDir(array('-p','-m', 0755, $dirPath));
    	}
    	//.rvsitebuilder ไม่ควรมีใน public_html
    	if (is_dir($dirRVS) == true) {
    		RvsLibs_System::rm(array('-rf', $dirRVS));
    	}
    	// ถ้า phpsu มีปัญหาให้ validate ก่อน
        // symlink /home/{user}/public_html/.rvsitebuilderHome/projects -----> /home/{user}/.rvsitebuilder/projects
    	// phpsu make folder /home/{user}/public_html/.rvsitebuilderHome/projects
        // if (RvsLibs_System::runDetectPhpSuexec()) {
    	// $this->createProjectLink($realProjectPath, $dirPath . '/projects');
    	
    	SGL::logMessage("To:" . $realProjectPath . ' From: ' . $dirPath . '/projects' , PEAR_LOG_DEBUG);
    	if (is_dir($dirPath .'/projects') == true) {
    		RvsLibs_System::rm(array('-rf', $dirPath .'/projects'));
    	}
    	if(is_link($dirPath .'/projects') == false) {
    		RvsLibs_System::ln(array('-s', $realProjectPath, $dirPath . '/projects'));
    	}

    	$pathImg = SGL_WEB_ROOT . '/images/error.gif';
    	$pathPublicImg = RvsLibs_File::buildPath(array(RVS_USER_HOME, 'domains', $defaultDomain, 'public_html', 'error.gif'));
    	if (is_file($pathPublicImg) == false) {
    		RvsLibs_System::copy(array($pathImg, $pathPublicImg));
    	}

    	//move .htaccess : nipaporn
    	RvsLibs_File::appendImagesDa($dirPath);

    }
    public function isRealConfigUpLoadMaxFileSize()
    {
        $data = $this->socketAPI('HTM_FILE_UPLOAD',array('path'=>'/'));
        $reINIMaxSize = ini_get('upload_max_filesize');
        $iniMaxSize = intval($reINIMaxSize);
        $data = is_array($data)
               ? join('',array_keys($data))
               : false;
        if (preg_match('/Max_Filesize_:_(.*?)_MB/simx' ,$data, $regs)) {
            $sevMaxSize = intval($regs[1]);
            return ($sevMaxSize < $iniMaxSize) ? $sevMaxSize . 'M' : $reINIMaxSize;
        } else {
            return false;
        }
    }
    
    /**
     * Make userdata path
     * @return unknown_type
     */
    function makeuserdatapath($userdataPath)
    {
        return RvsLibs_System::secureCommand('makeuserdatapath');
    }
    
    /**
     * 
     * Make Restore Online Counter
     * 
     * @author Puttipong <puttipong at rvglobalsoft.com>
     * 
     * @param $projectId <STRING>
     * @return TRUE
     */
    public function makeRestoreOnlineCounter($projectId=null) {
        return true;
    }
    
}
?>

Copyright 2K16 - 2K18 Indonesian Hacker Rulez