CHips L MINI SHELL

CHips L pro

Current Path : /opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/lib/SGL/
Upload File :
Current File : //opt/cpanel/ea-php54/root/usr/share/pear/RVSeagullMod/lib/SGL/RVSGLWrapper.php

<?php
class RVSGLWrapper extends SGL_FrontController
{
	var $aFiles = array();
    public static function singleton()
    {
        static $instance;
        if (!isset($instance)) {
            $class = __CLASS__;
            $instance = new $class();
        }
        return $instance;
    }

	public static function getSGLBaseURL($getType=1)
	{
		if ($getType ==1) {
			echo  (defined('RVS_PUBLISH_URL')) ? RVS_PUBLISH_URL : SGL_BASE_URL;
		} else {
			return (defined('RVS_PUBLISH_URL')) ? RVS_PUBLISH_URL : SGL_BASE_URL;
		}
	}

    public static function getCurrentUrl($getType=1)
    {
    	if ($getType ==1) {
    		echo  SGL_Session::get('current_page');
    	} else {
    		return SGL_Session::get('current_page');
    	}
    }


    public static function getWebRoot($getType=1)
    {
    	if ($getType == 1) {
    		echo (defined('RVS_PUBLISH_PATH')) ? RVS_PUBLISH_PATH : SGL_Config::get('path.webRoot');
    	} else {
    		return (defined('RVS_PUBLISH_PATH')) ? RVS_PUBLISH_PATH : SGL_Config::get('path.webRoot');
    	}
    }

    public static function getBaseUrl()
    {

    	return SGL_Config::get('site.baseUrl');

    }

    public static function getFrontscriptname($getType=1)
    {
        if ($getType ==1) {
            echo SGL_Config::get('site.frontScriptName');
        } else {
            return SGL_Config::get('site.frontScriptName');
        }
    }

    public static function getUID($getType=1)
    {
        if ($getType ==1) {
            echo SGL_Session::getUid();
        } else {
            return SGL_Session::getUid();
        }
    }

    public static function getIsmemberAllPage()
    {
    	$fileAutoConf = SGL_VAR_DIR . '/listcomponentmemberpage.ini.php';
    	if (is_file($fileAutoConf) == true) {
    		$aAutoConf = RvsLibs_Config::parse_ini_file($fileAutoConf, true);
    	}
    	return (isset($aAutoConf['isMemberAllPage'])) ? $aAutoConf['isMemberAllPage'] : '0';
    }


    public static function getIsmemberByPageCompo($page)
    {
    	//case ที่เป็น blog และ faq by page
    	$fileAutoConf = SGL_VAR_DIR . '/listcomponentmemberpage.ini.php';
    	if (is_file($fileAutoConf) == true) {
    		$aAutoConf = RvsLibs_Config::parse_ini_file($fileAutoConf, true);
    	}
    	return (isset($aAutoConf['isMember_' . $page])) ? $aAutoConf['isMember_' . $page] : '0';
    }

    public static function detectMemberPage()
    {
    	$page = str_replace(RVSGLWrapper::getWebRoot(0) . '/', '', $_SERVER['SCRIPT_FILENAME']);
    	//case ที่เป็น blog และ faq by page
    	if (RvsLibs_String::preg_match('/blogweb\/index.php/',$page)) {
    		$page = 'Blog';
    	} elseif(RvsLibs_String::preg_match('/faqweb\/index.php/',$page)) {
    		$page = 'Faq';
    	}

    	/*if (RVSGLWrapper::getIsmemberAllPage() == '1') {
    		//2. check uid
    		if (!RVSGLWrapper::getUID(0)) {
    			$aUrl = array(
            'managerName' => 'memberpage',
            'moduleName'  => 'default',
            'page'     => urlencode($page)
    			);
    			SGL_HTTP::redirect($aUrl);
    		}
    		//case component blog faq by page
    	} else*/
    	if (RVSGLWrapper::getIsmemberByPageCompo($page) == '1') {
    		if (!RVSGLWrapper::getUID(0)) {
    			$aUrl = array(
            'managerName' => 'memberpage',
            'moduleName'  => 'default',
            'page'     => urlencode($page)
    			);
    			SGL_HTTP::redirect($aUrl);
    		}
    	}

    }

    public static function getRoleId($getType=1)
    {
        if ($getType ==1) {
            echo SGL_Session::getRoleId();
        } else {
            return SGL_Session::getRoleId();
        }
    }

    public static function getUsername($getType=1)
    {
        if ($getType ==1) {
            echo SGL_Session::getUsername();
        } else {
            return SGL_Session::getUsername();
        }
    }

    public static function rvs_flexyInclude($pageData)
    {
        if (preg_match_all('#<flexy\:include.*?src.*?=.*?["|\'](.*?)["|\'].*?>#i', $pageData, $aMatch)){
            foreach ($aMatch[0] as $index => $lineData) {
                foreach ($smarty->template_dir as $template_dir) {
                    if (is_file($template_dir . '/' . $aMatch[1][$index])) {
                        ob_start();
                        include($template_dir . '/' . $aMatch[1][$index]);
                        $_results = ob_get_contents();
                        ob_end_clean();
                        $pageData = str_replace($aMatch[0][$index],$_results,$pageData);
                    }
                }
            }
        }
        return $pageData;
    }


    /**
    * Get component use language
    * input : lang
    * inputpatten : en or th or ..
    * return array lang key
    */
    public static function getCompoUseLang($lang = false)
    {
        if (!defined("RVS_COMPONENT_NAME")) {
            return array('en','utf-8');
        }

        if ($lang == false && $lang == '') {
            //$aSeagullLang = SGL_Session::get('aPrefs');//SGL_Config::get('translation.fallbackLang');
            //$seagullLang = $aSeagullLang['language'];

            $seagullLang = RVSGLWrapper::rvsGetLangId();
            if (isset($seagullLang) && $seagullLang == '') {
                $seagullLang = SGL_Config::get('translation.fallbackLang');
                list($lang,$encodeing) = preg_split('/_/',$seagullLang,2);
            } else {
                list($lang,$encodeing) = preg_split('/-/',$seagullLang,2);
            }
        }

        $fileAllLang = SGL_ETC_DIR . '/allComponentLangConfig.ini';
        $aAllData = array();
        $aSetlang = array();

        if (is_file($fileAllLang)) {
            $aAllData = @parse_ini_file($fileAllLang,true);

            foreach ($aAllData as $key => $value) {
                foreach ($value as $k => $v) {
                    $aSetlang[$key][$k] = preg_split('/,/',$v);
                }
            }
        }

        if ($aSetlang[RVS_COMPONENT_NAME][$lang]) {
            return $aSetlang[RVS_COMPONENT_NAME][$lang];

        } elseif ($aSetlang[RVS_COMPONENT_NAME]['en']) {
            return $aSetlang[RVS_COMPONENT_NAME]['en'];

        } else {

            return array('en','utf-8');
        }
    }

    public static function rvsGetLangId()
    {
        /*$currLang = (defined('RVS_AUTO_SETUP')) ? RVSCOMPODB::getCurrentLang() : SGL::getCurrentLang();
        $charset  = (defined('RVS_AUTO_SETUP')) ? RVSCOMPODB::getCurrentCharset() : $GLOBALS['_SGL']['CHARSET'];
        $langId = ($currLang != "" && $charset) ? $currLang . '-' . $charset : 'en-utf-8';
        */
        $langId = SGL_Config::get('translation.fallbackLang');
        $langId = SGL_Translation::transformLangID($langId, SGL_LANG_ID_SGL);
        return $langId;
    }

    public static function rvsGetLangElement($aDefaultLang)
    {
        $langId = RVSGLWrapper::rvsGetLangId();
        $aGetLang = $aDefaultLang[$langId];
        //$aLang = array($langId => $aGetLang, "en-utf-8" => isset($aDefaultLang['en-utf-8']) ? $aDefaultLang['en-utf-8'] : 'en-utf-8');
        $aLang = array($langId => $aGetLang, "en-utf-8" => $aDefaultLang['en-utf-8']);
        return (defined('RVS_AUTO_SETUP')) ? $aLang : $aDefaultLang;
    }

    public static function rvsTranslate($key, $filter = false, $aParams = array(), $output = null)
    {
    	$langId = RVSGLWrapper::rvsGetLangId();
    	$req = SGL_Request::singleton();
        $module = $req->get('moduleName');
    	$lang = SGL_Output::translate($key, $filter, $aParams, $output);
    	require_once SGL_LIB_DIR . '/SGL/Translation.php';
    	require_once SGL_MOD_DIR . '/translation/classes/Translation2.php';
    	$langId = SGL_Translation::transformLangID($langId, SGL_LANG_ID_SGL);
    	//Owner
        $fileNameOwner = SGL_Translation2::rvsGetFileName($module, $langId, $fileName, $level = 'owner');
    	if ($fileNameOwner && is_file($fileNameOwner)) {
    	    //echo "<br>" . $fileNameOwner;
    	    include $fileNameOwner;
    	    $aWordsOwner = ($module == 'default') ? $defaultWords : $aWords;
    	}
    	//User
        $fileName = SGL_Translation2::rvsGetFileName($module, $langId, $fileName, $level = 'user');

        if ($fileName && is_file($fileName)) {
            //echo "<br>". $fileName;
            include $fileName;
            $aWords = ($module == 'default') ? $defaultWords : $aWords;
        }
    	//$aWords = $aWordsOwner + $aWords;
    	/*echo "<pre><font color=black>";
    	print_r($aWordsOwner);
    	print_r($aWords);
    	echo "</font>";*/
    	$aWordsM = array_merge((array)$aWordsOwner, (array)$aWords);
    	return (isset($aWordsM[$key])) ? $aWordsM[$key]: $lang;
    }

    public static function getListsNewsletter()
    {
    	$aLists = array();
    	/*if(defined('RVS_COMPONENT_NAME') && RVS_COMPONENT_NAME == 'faqweb') {
    		// faqweb have problem cannot use $dbh to connect database
    		return $aLists;
    	}*/
    	require_once SGL_MOD_DIR . '/newsletter/classes/NewsletterMgr.php';
    	$news =  new NewsletterMgr();
    	 ///fix PHP 5.3
    	 $news = &$news;
    	$aLists = $news->_getList();
    	return $aLists;
    }

    public static function loadBlocks($moduleName = '', $blockName = '', $aParams=array())
    {
        $blockPath = SGL_MOD_DIR . '/' . $moduleName . '/blocks/' . $blockName . '.php';
        $output->loggedOnUserID = SGL_Session::getUid();
        if (is_file($blockPath)){
            require_once SGL_MOD_DIR . '/' . $moduleName . '/blocks/' . $blockName . '.php';
            $className = ucfirst($moduleName) . '_Block_' . ucfirst($blockName);
            eval("\$oBlock = new $className();");

            $blockContent =  $oBlock->init($output, '', $aParams);
           //eval('$blockContent =' . $className.'::getBlockContent();');
            echo $blockContent;
        }
    }
    public static function listModuleAll(){
    	$path = SGL_LIB_DIR .'/SGL/Install/Common.php';
    	include $path;
    	$sglincom = new SGL_Install_Common();
        $a = $sglincom->getModuleList();
         return $a;

    }
    public static function loadBlockAll(){
    	//1.call->listModule() output arrayMD

    $aModuleList = RVSGLWrapper::listModuleAll();

        foreach ( $aModuleList  as  $k  =>  $v ) {
        	RVSGLWrapper::loadBlocks($v , 'BlockLogin');
        }
    }

    public static function isAdmin()
    {
        $rid = SGL_Session::getRoleId();
        return ($rid && $rid == SGL_ADMIN) ? true : false;
    }

    public static function isAdminXfer()
    {
        $adminXfer = ($_COOKIE['AdminXfer'])? true : false;
        if(RVSGLWrapper::isAdmin()|| $adminXfer) {
            return true;
        }else {
            return false;
        }
    }

    public static function getSessionTimeout()
    {
    	require_once SGL_MOD_DIR . '/user/classes/UserDAO.php';
    	$sglUserId = SGL_Session::getUid();
        $daUser    = UserDAO::singleton();
        $aPref=$daUser->getPrefsByUserId($sglUserId);
        return $aPref['sessionTimeout'];
    }

    public static function buildUrlConfig()
    {
        require_once SGL_MOD_DIR  . '/main/classes/Main.php';
        $oMain = new Main;
        $showBuyAccount = '';
        $showBuyAc = '';
        if ($oMain->verifyModules('tryout') === true) {
            if (defined('RVS_USER_HOME') && defined('RVS_PROJECT_ID')) {
                 $path = RVS_USER_HOME . '/.rvsitebuilder/projects/' . RVS_PROJECT_ID . '/scripts/Tryout/setting.ini.php';
                $aSetTryout = (is_file($path)) ? parse_ini_file($path) : array();
                $showBuyAccount = (is_file($path))? $aSetTryout['showBuyAccount'] : true;
            }

        }

        if(isset($showBuyAccount) && $showBuyAccount) {
            $showBuyAc = RVSGLWrapper::billingUrl();
        }

        echo $showBuyAc;
    }

    public static function checkConfig()
    {
        require_once SGL_MOD_DIR  . '/main/classes/Main.php';
        $oMain = new Main;
        $showBuyAccount = '';
        $showBuyAc = '';

        if ($oMain->verifyModules('tryout') === true && trim($_SESSION['uid']) != '999999999' ) {
            if (defined('RVS_USER_HOME') && defined('RVS_PROJECT_ID')) {
                $path = RVS_USER_HOME . '/.rvsitebuilder/projects/' . RVS_PROJECT_ID . '/scripts/Tryout/setting.ini.php';
                $aSetTryout = (is_file($path)) ? parse_ini_file($path) : array();
                $showBuyAccount = (is_file($path))? $aSetTryout['showBuyAccount'] : true;
            }

        }
        $showBuyAccount = (isset($showBuyAccount) && $showBuyAccount)?true:false;
        return $showBuyAccount;

    }


     public static function billingUrl()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $billingUrl = '';
        require_once SGL_MOD_DIR . '/tryout/classes/TryoutAdminMgr.php';
        $tryout = new TryoutAdminMgr();
         ///fix PHP 5.3
         $tryout = &$tryout;
        $aUserInfo = $tryout->getUserByUserId();

       $aMapField = array('billing_username' => 'username' ,
                                        'billing_firstname' => 'first_name' ,
                                        'billing_lastname' => 'last_name' ,
                                        'billing_address1' => 'addr_1' ,
                                        'billing_address2' => 'addr_2' ,
                                        'billing_address3' => 'addr_3' ,
                                        'billing_city' => 'city' ,
                                        'billing_country_state_province' => 'region' ,
                                        'billing_zipcode' => 'post_code' ,
                                        'billing_country' => 'country' ,
                                        'billing_contact' => 'email' ,
                                        'billing_telephone' => 'telephone' ,
                                        'billing_mobile' => 'mobile' ,
                            );
        $aCountries = SGL::loadRegionList('countries');

        $aStates = SGL::loadRegionList('states');
        $aUserInfo[0]->country = $aCountries[$aUserInfo[0]->country];
        $aUserInfo[0]->region = $aStates[$aUserInfo[0]->region];
        SGL_Config::get('path.webRoot') . '/tryout/tryout_config.ini.php';
        $aTryoutConfig = parse_ini_file(SGL_Config::get('path.webRoot') . '/tryout/tryout_config.ini.php', true);
        // Generate Billing Url
           if (!empty($aTryoutConfig['billing_url'])) {

            $billingUrl = $aTryoutConfig['billing_url'];
            $getData = '';

            // generate $getData
            foreach ($aTryoutConfig as $key=>$value) {
                preg_match('/billing_/', $key, $matches, PREG_OFFSET_CAPTURE);
                $infoKey = (isset($aMapField[$key])) ? $aMapField[$key] : false;

                if ($infoKey) {
                    // invalid, because $aUserInfo[0]->$infoKey becomes $aUserInfo[0]->""
                    $info = (isset($aUserInfo[0]->$infoKey)) ? $aUserInfo[0]->$infoKey : false;
                }
                if (isset($aTryoutConfig['field_' . $key]) && $aTryoutConfig['field_' . $key] == true && $aTryoutConfig[$key] != '' && $info != '') {
                    if ($getData != '') {
                        $getData .= '&';
                    }
                     $getData .= $aTryoutConfig[$key] . '=' . $info;
                }
            }
            // fixed usr_id demo = 999999999
            if ( trim($_SESSION['uid']) == 999999999 ) {
                return  SGL_Config::get('site.baseUrl') . '?demoClickBuyAccount=1';
            }
            // return $billingUrl + $getData
            if ($getData != '') {
                $billingUrl = $billingUrl . '?' . $getData;
            } else {
                // remove end '/' (slash)
                if (preg_match("/\/$/", $billingUrl, $match)) {
                    $billingUrl = substr($billingUrl , 0 , (strlen($billingUrl) - 1));
                }
            }

            return $billingUrl;
      }
    }

    public static function isDiyTemplate()
    {
        if (class_exists('RVSCOMPODB')) {
            return (RVSCOMPODB::isDiyTemplate()) ? true : false;
        }
        return false;
    }

	public static function isResTemplate()
    {
        if (class_exists('RVSCOMPODB')) {
            return (RVSCOMPODB::isResTemplate() || RVSCOMPODB::isUikitTemplate()) ? true : false;
        }
        return false;
    }

	public static function isUikitTemplate()
    {
        if (class_exists('RVSCOMPODB')) {
            return (RVSCOMPODB::isUikitTemplate()) ? true : false;
        }
        return false;
    }

    public static function translate($key, $filter = false, $aParams = array(), $output = null)
    {
         echo SGL_Output::translate($key, $filter, $aParams, $output);

    }

    public static function isNotDemoAccount()
    {
        require_once SGL_MOD_DIR  . '/main/classes/Main.php';
        $oMain = new Main;
        return ($oMain->verifyModules('tryout') === true && trim($_SESSION['uid']) == '999999999') ? false : true;
    }

    public static function includeCssGallery()
    {
    	$req = SGL_Request::singleton();
        $module = $req->get('moduleName');
        $galleryId   = $req->get('galleryId');
        $pageId = str_replace('gallery_','',$galleryId);
        $pathCustom = RVSGLWrapper::getWebRoot($echo = false) . '/js/photogallery/themes/rvsdefault/galleria.' . $pageId . '.css';
        if ($module == 'photogallery') {
        	$galleriaRvsDefaultCSS = '<link id ="linkcssglobal22" rel="stylesheet" type="text/css" media="screen" href="' . SGL_Config::get('site.baseUrl') . '/js/photogallery/themes/rvsdefault/galleria.rvsdefault.css" />';
        	if (is_file($pathCustom)) {
        		$galleriaRvsDefaultCSS .= "\n". '<link id ="linkcssglobal33" rel="stylesheet" type="text/css" media="screen" href="' . SGL_Config::get('site.baseUrl') . '/js/photogallery/themes/rvsdefault/galleria.' . $pageId . '.css" />'. "\n";
        	}
   		 }
   		 echo $galleriaRvsDefaultCSS;
    }

    public function addCssFile($file)
    {
        if (is_array($file)) {
            foreach ($file as $cssFile) {
                if (!in_array($cssFile, $this->aFiles)) {
                    $this->aFiles[] = $cssFile;
                }
            }
        } else {
            if (!in_array($file, $this->aFiles)) {
                $this->aFiles[] = $file;
            }
        }
    }

    /**
     * do not make static method
     */
    public function makeCssOptimizerLink()
    {
    	$rev = SGL_Output::_getFilesModifiedTime($this->aFiles);
    	//write tmp css
    	$isCache = SGL_Output::_writeTmpFileOtimizer($this->aFiles, 'css');
    	if ($isCache) {
    		$link   = SGL_Config::get('site.baseUrl') . "/optimizer.php?type=css&amp;rev=$rev&amp;optimize=1&amp;md5=" .  md5(implode(',', $this->aFiles));
    	} else {
    		$aFilesCss = (isset($this->aFiles) && count($this->aFiles)>0)
    		                  ? '&amp;aFiles[]=' . implode('&amp;aFiles[]=', $this->aFiles)
    		                  : array();
    		$link = SGL_Config::get('site.baseUrl') . "/optimizer.php?type=css&amp;rev=$rev&amp;optimize=1" . $aFilesCss;
    	}

        $ret = '<!-- START Optimizer Css from  rvStaticHeadTag.html $oRVSGLWrapper->makeCssOptimizerLink() -->' . "\n";
        $ret .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"$link\" />\n";
        $ret .= '<!-- END Optimizer Css -->' . "\n";

        echo $ret;
    }

    public static function getBlocklogin($moduleName='')
    {
    	if ($moduleName == '') {
    		$req = SGL_Request::singleton();
    	    $moduleName = $req->get('moduleName');
    	}
    	return (strtolower($moduleName) === 'photogallery')? false : true;
    }

  /*
	function makeSGLUrl($action = '', $mgr = '', $mod = '', $aList = array(),
        $params = '', $idx = 0)
    {
    	error_reporting(E_ALL);
    	$input = SGL_Registry::singleton();
        $req = $input->getRequest();
        // Horde routes work only for browser request types
        if ($req->type == SGL_REQUEST_BROWSER
                && SGL_Config::get('site.inputUrlHandlers') == 'Horde_Routes') {
            $aArgs = func_get_args();
            // new style call
            if (count($aArgs) == 1) {
                if (strpos($aArgs[0], '|') !== false) {
                    $aVars = explode('||', $aArgs[0]);
                    $aArgs = array();
                    foreach ($aVars as $varString) {
                        list($k, $v) = explode('|', $varString);
                        $aArgs[$k] = isset($this->{$v})
                            ? $this->{$v} : $v;
                    }
                    if (isset($aArgs['module'])) {
                        $aArgs['moduleName'] = $aArgs['module'];
                        unset($aArgs['module']);
                    }
                    if (isset($aArgs['manager'])) {
                        $aArgs['managerName'] = $aArgs['manager'];
                        unset($aArgs['manager']);
                    }
                // named route
                } else {
                    $aArgs = $aArgs[0];
                }
            // old style: params string specified as not part of array
            } elseif (count($aArgs) == 5 && empty($aList)) {
                $aVars = explode('||', $aArgs[4]);
                foreach ($aVars as $varKey => $varString) {
                    $aVar = explode('|', $varString);
                    if (isset($aVar[1]) && isset($this->{$aVar[1]})) {
                        $aVar[1] = $this->{$aVar[1]};
                    }
                    $aVars[$varKey] = implode('|', $aVar);
                }
                $aArgs[4] = implode('||', $aVars);
            }
            $url = $input->getCurrentUrl();
            $ret = $url->makeLink($aArgs);
        } else {
             $ret = SGL_Url::makeLink($action, $mgr, $mod, $aList,
                $params, $idx, $this);
        }
        return $ret;
    }
    */

    public static function isEnableRegistration($getType=1)
    {
        if ($getType ==1) {
            echo SGL_Config::get('RegisterMgr.enabled');
        } else {
            return SGL_Config::get('RegisterMgr.enabled');
        }
    }
}
?>

Copyright 2K16 - 2K18 Indonesian Hacker Rulez