HEX
Server: Apache
System: Linux sg241.singhost.net 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP Wed Jan 17 13:19:23 EST 2018 x86_64
User: honghock (909)
PHP: 8.0.30
Disabled: passthru,system,shell_exec,show_source,exec,popen,proc_open
Upload Files
File: //opt/cloudlinux/alt-php54/root/usr/share/pear/RVSeagullMod/modules/main/classes/WebFormMgr.php
<?php
##copyright##

require_once 'DB/DataObject.php';

/**
 * WebFormMgr
 *
 * @package seagull
 * @author  RV Global Soft Team <bus@webexperts.co.th>
 */
class WebFormMgr extends SGL_Manager
{
    function WebFormMgr()
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        parent::SGL_Manager();

        $this->_aActionsMapping =  array(
            'view'          => array('view'),
            'send'          => array('send')
        );
    }

    function validate($req, &$input)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $this->validated    = true;
        $input->error       = array();
        $input->masterTemplate = $this->masterTemplate;
        $input->action      = ($req->get('action')) ? $req->get('action') : 'view';
        $input->pageTitle   = $this->pageTitle . ' :: ' . $input->action;
        $input->formError = $req->get('error');
        
        $input->name      = $req->get('name');
        $input->email      = $req->get('email');
        $input->Email      = $req->get('Email');
        $input->subject      = $req->get('subject');
        $input->message      = $req->get('message');
        $input->required      = $req->get('required');
        
        $input->redirect      = $req->get('redirect');
        $input->charset      = $req->get('charset');
        
        if ($req->get('submit')) {
            $input->action = 'send';
        }
        
        $input->page      = $req->get('page');
        
        include_once('WebFormMail.php');
        $this->oWebFormMail = new WebFormMail();

        $input->sendSuccess = $req->get('success');

        
        
        if ($this->_loadTemplate($input) === true) { 
            $input->pageTitle = $this->pageTitle . ' :: ' . $input->page;
            $input->template = $input->fullPage;
        } else {
            SGL::raiseError('Cannot find page file! ' . $input->page);
            $input->pageTitle = 'Error :: ' . $input->page;
            $input->template = 'formMail.html';
        }   
      
    ################ Start validate ###############
        $aErrors = array();
        
        switch ($input->action) {
            case "send":
                $this->_validateSend($input, &$aErrors);
                break;                
        }

        //  if errors have occured
         if (count($aErrors) > 0) {
            $input->error = $this->_customBuildFormError($aErrors);
            $aErrors = $this->_customBuildRaiseError($aErrors);
            SGL::raiseMsg(SGL_Output::translate('Validation Failed.') . '<br /><br />' . join('<br/>', $aErrors),false);
            $this->validated = false;
        }        
    }
    
    function _customBuildRaiseError($aErrors = array())
    {
        if (isset($aErrors['require'])) {
            unset($aErrors['require']);
        }
        if (isset($aErrors['email'])) {
            unset($aErrors['email']);
        } 
        return $aErrors;
    }
    function _customBuildFormError($aErrors = array())
    {
        if (isset($aErrors['require'])) {
            preg_match_all("/<b>(.*)<\/b>/", $aErrors['require'],$match);
            if (isset($match) && count($match[1])) {
                foreach($match[1] as $val) {
                    if ($val == '') {
                        continue;
                    }
                    $val = preg_replace("/: /",'',$val);
                    $val = trim($val);
                    $aErrors["$val"] = $val;
                }
            }
        }
        return $aErrors;            
    }
    
    function display(&$output)
    {
        if (!class_exists('formSpamBotBlocker')) {
            require_once dirname(__FILE__)  . '/fsbb/fsbb.php';
        }
        $rvSpamBot = new formSpamBotBlocker();
        //$rvSpamBot->setTimeWindow(2,14400);
        $rvSpamBot->setTrap(true, "spambot");
        
        $output->spamBotTags = $rvSpamBot->makeTags();        
        $c = SGL_Config::singleton();
        $conf = $c->getAll();    
        $output->redirectURL = $conf['site']['baseUrl'] . '/' . $conf['site']['frontScriptName'] . '/main/webform/action/view/success/send/';
        $output->currentCharset = SGL::getCurrentCharset();
    }

    function _cmd_view(&$input, &$output)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);        
    }
    
    function _validateSend($input, &$aErrors)
    {
        
        $aMailVars['require'] = '';
        $aMailVars['name'] = isset($input->name) ? $input->name : '';
        $aMailVars['email'] = isset($input->email) ? $input->email : '';
        $aMailVars['email'] = isset($input->Email) ? $input->Email : $aMailVars['email'];
        $aMailVars['subject'] = isset($input->subject) ? $input->subject : '';
        $aMailVars['required'] = isset($input->required) ? $input->required : '';
        
        $aMailVars['charset'] = isset($input->charset) ? $input->charset : '';
                
        $aMailVars['zip_code'] = '';
        $aMailVars['ZIP_CODE'] = '';
        $aMailVars['phone_no'] = '';
        $aMailVars['PHONE_NO'] = '';
        $aMailVars['fax_no'] = '';
        $aMailVars['FAX_NO'] = '';
        $aMailVars['sort'] = '';
        $aMailVars['attachment'] = '';
        $aMailVars['attachment']['name'] = '';
        $aMailVars['attachment']['size'] = '';
        $aMailVars['attachment']['type'] = '';
        $aMailVars['file'] = '';
        $aMailVars['file']['name'] = '';
        $aMailVars['file_size'] = '';
        $aMailVars['path_to_file'] = '';
        $aMailVars['file2'] = '';
        $aMailVars['file2']['name'] = '';
        $aMailVars['file2_size'] = '';
        $aMailVars['env_report'] = '';
        $aMailVars['ar_file'] = '';
        $aMailVars['redirect'] = '';
        
        $aMailVars['title'] = '';
        $aMailVars['bgcolor'] = '';
        $aMailVars['text_color'] = '';
        $aMailVars['link_color'] = '';
        $aMailVars['vlink_color'] = '';
        $aMailVars['alink_color'] = '';
        $aMailVars['style_sheet'] = '';
        $aMailVars['background'] = '';
        $aMailVars['missing_fields_redirect'] = '';
        
        
        $CONF = array();
        
        if (isset($this->conf['cookie']['name'])) {
    
            $CONF['recipient'] = Array();
            $CONF['recipient']['1'] = $this->conf['email']['support'];
        
            if (isset($CONF['referers']) === false) {
                $CONF['referers'] = Array();
                $CONF['referers']['1'] = 'localhost';
                $CONF['referers']['2'] = '127.0.0.1';
                $CONF['referers']['2'] = $this->oWebFormMail->hostnameToFilename();
                $CONF['referers']['3'] = 'www.' . $CONF['referers']['2'];
            }
        
            if (isset($CONF['banlist']) === false) {
                $CONF['banlist'] = Array();
            }
        }
        $aLangs = $GLOBALS['_SGL']['TRANSLATION'];
        $this->oWebFormMail->prepare($aMailVars, $aLangs);
        $aErrors = array();
        
        /*
         * SGL not have $_GET or $_POST
         */
        $this->request = $input->aProps['request']->aProps;

        $this->oWebFormMail->validate($aMailVars, $CONF, $this->request, &$aErrors);
        return true;
    }
    
    function _cmd_send(&$input, &$output)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
        $result = $this->oWebFormMail->sendmail();
        if ($result != 1){
            SGL::raiseMsg($result, false);    
        } else {
            $this->oWebFormMail->redirectToPage($input->redirect);
        }
        
    }
    
    function _loadTemplate(&$input)
    {
        SGL::logMessage(null, PEAR_LOG_DEBUG);
//        $input->page = trim(strtolower($input->page));
        $input->fullPage = $input->page . '.html';

        $defaultTheme = 'rvtheme';

        if (isset($_SESSION['aPrefs']['theme'])) {
            $defaultTheme = $_SESSION['aPrefs']['theme'];
        }
        
        if (file_exists(SGL_THEME_DIR . '/' . $defaultTheme .'/main/' . $input->fullPage)) {
            return true;
        } else if (file_exists(SGL_MOD_DIR . '/main/templates/' . $input->fullPage)) {
            return true;
        }
        return false;
    }
    
}
?>