CHips L MINI SHELL

CHips L pro

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

<?php
//* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// WebSite:  http://www.rvglobalsoft.com
// Unauthorized copying is strictly forbidden and may result in severe legal action.
// Copyright (c) 2010 RV Global Soft Co.,Ltd. All rights reserved.
//
// =====YOU MUST KEEP THIS COPYRIGHTS NOTICE INTACT AND CAN NOT BE REMOVE =======
// Copyright (c) 2010 RV Global Soft Co.,Ltd. All rights reserved.
// This Agreement is a legal contract, which specifies the terms of the license
// and warranty limitation between you and RV Global Soft Co.,Ltd. and RV Site Builder.
// You should carefully read the following terms and conditions before
// installing or using this software.  Unless you have a different license
// agreement obtained from RV Global Soft Co.,Ltd., installation or use of this software
// indicates your acceptance of the license and warranty limitation terms
// contained in this Agreement. If you do not agree to the terms of this
// Agreement, promptly delete and destroy all copies of the Software.
//
// =====  Grant of License =======
// The Software may only be installed and used on a single host machine.
//
// =====  Disclaimer of Warranty =======
// THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND
// WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER
// WARRANTIES WHETHER EXPRESSED OR IMPLIED.   BECAUSE OF THE VARIOUS HARDWARE
// AND SOFTWARE ENVIRONMENTS INTO WHICH RV SITE BUILDER MAY BE USED, NO WARRANTY OF
// FITNESS FOR A PARTICULAR PURPOSE IS OFFERED.  THE USER MUST ASSUME THE
// ENTIRE RISK OF USING THIS PROGRAM.  ANY LIABILITY OF RV GLOBAL SOFT CO.,LTD. WILL BE
// LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.
// IN NO CASE SHALL RV GLOBAL SOFT CO.,LTD. BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR
// CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS
// OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE
// BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT,
// NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF
// RV GLOBAL SOFT CO.,LTD. IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL
// RV GLOBAL SOFT CO.,LTD.'S LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID
// BY LICENSEE TO RV GLOBAL SOFT CO.,LTD.
// +---------------------------------------------------------------------------+
// $id: AjaxProvider.php 28 December 2009 Parinya Exp $
// +---------------------------------------------------------------------------+

require_once SGL_CORE_DIR . '/Delegator.php';
require_once 'HTML/Template/Flexy.php';
require_once SGL_CORE_DIR . '/AjaxProvider.php';

if (class_exists('RvsLibs_AjaxProvider') === false) {
	class RvsLibs_AjaxProvider extends SGL_AjaxProvider
	{
		function __construct()
		{
			// execute ajax มีปัญหากับ DAO query data object charset database ไม่ใช่ utf8
			// จึงต้อง setConnecttion อีกครั้ง
            SGL_DB::setConnection();
		}

		function sitebuilderAjaxExecute()
		{
			SGL::logMessage(null, PEAR_LOG_DEBUG);
			define('RVS_RESPONSEFORMAT_JSON', 99);
			$input = SGL_Registry::singleton();
			$req   = SGL_Request::singleton();

			if (!isset($req->aProps['rvsMgr']) || $req->aProps['rvsMgr']==='') {
				SGL::logMessage('Not found rvsMgr.', PEAR_LOG_ERR);
				return SGL::raiseError('Not found rvsMgr.' . join(',', $req->aProps));
			} elseif (!isset($req->aProps['rvsAct']) || $req->aProps['rvsAct']==='') {
				return SGL::raiseError('rvsAct');
			}

			$req->set('managerName', $req->aProps['rvsMgr'] . 'Ajax');
			$req->set('action', $req->aProps['rvsAct']);
			$input->setRequest($req);

			$output = new SGL_Output();
			$process =
			new RVS_Task_ResolveAjaxManager(
			new RVS_MainProcess(
			));
			$process->process($input, $output);

			if (!empty($output->responseFormat)) {
				$this->responseFormat = $output->responseFormat;
			}
			    return (isset($output->data) && $output->data)? $output->data : false;
		}
	}
}

if (class_exists('RVS_MainProcess') === false) {
	class RVS_MainProcess extends RvsLibs_AjaxProvider
	{
		function __construct()
		{

		}

		function process(&$input, &$output)
		{
			SGL::logMessage(null, PEAR_LOG_DEBUG);
			$req  = $input->getRequest();
			$mgr  = $input->get('manager');
			$mgr->validate($req, $input);

			$input->aggregate($output);

			if ($mgr->isValid()) {
				try {
					$ok = $mgr->process($input, $output);
				} catch (Exception $e) {
					var_dump($e->getTrace());
				}

				if (SGL::isError($ok)) {
					$output->responseFormat = $this->responseFormat = SGL_RESPONSEFORMAT_JSON;
					return $ok;
				}

				if (isset($mgr->responseFormat)) {
					$output->responseFormat = $this->responseFormat = $mgr->responseFormat;
				}

				if (isset($mgr->aConvertHtmlToJson)) {
					$output->aConvertHtmlToJson = $this->aConvertHtmlToJson = $mgr->aConvertHtmlToJson;
				}
				switch ($this->responseFormat) {
					case SGL_RESPONSEFORMAT_JSON:
					default:
						$output->data = isset($output->responseData) ? $output->responseData : array();
						break;
					case SGL_RESPONSEFORMAT_XML:
						$output->isXMLType = true;
					case SGL_RESPONSEFORMAT_HTML:
					case SGL_RESPONSEFORMAT_PLAIN:
					case SGL_RESPONSEFORMAT_JAVASCRIPT:
						SGL_Task_BuildOutputData::addOutputData($output);
						if (!isset($output->masterTemplate) || $output->masterTemplate === '') {
							return SGL::raiseError('HTML_Template_Flexy fatal error: master template does not exist.');
						} else if (!isset($output->template) || $output->template === '') {
							return SGL::raiseError('HTML_Template_Flexy fatal error: template does not exist.');
						}
						$templateEngine = isset($output->templateEngine) ? $output->templateEngine : null;
						$view = new SGL_HtmlSimpleView($output, $templateEngine);
						$output->data = $view->render();
						break;
				}
				if(isset($output->aConvertHtmlToJson) && is_array($output->aConvertHtmlToJson) && count($output->aConvertHtmlToJson) > 0) {
					$output->responseFormat = $this->responseFormat = SGL_RESPONSEFORMAT_JSON;
					$aHtmlToJson = array();
					$aHtmlToJson['convertJs'] = '';
					foreach ($output->aConvertHtmlToJson as $id => $aJQScript) {
						if (is_array($aJQScript)) {
							foreach ($aJQScript as $setEvent => $scriptVal) {
								$aHtmlToJson['convertJs'] .= $scriptVal;
							}
						} else {
							$aHtmlToJson['convertJs'] .= $aJQScript;
						}
					}
					$aHtmlToJson['data'] = $output->data;
					$output->data = $aHtmlToJson;
					/*
					echo '<pre>';
					print_r($output->aConvertHtmlToJson);
					exit;
                    */
				}
			} else {
				$aRaiseMsg = $this->msgGet();
				if ( count($aRaiseMsg) > 0) {
					$output->data = $aRaiseMsg;
				}
				/// Validate false
				$output->responseFormat = $this->responseFormat = SGL_RESPONSEFORMAT_JSON;
				define('RVS_AJAXMGR_IS_ERROR', true);
				if ( count($input->error) > 0) {
					$output->data['errorType'] = 'MGR';
					$output->data['error'] = $input->error;
				}
				return $output;
			}
		}

		function msgGet()
		{
			$message     = SGL_Session::get('message');
			$messageType = SGL_Session::get('messageType');
			$aErrorMsg = array();
			if (!empty($message)) {
				SGL_Session::remove('message');
				SGL_Session::remove('messageType');

				switch ($messageType) {
					case SGL_MESSAGE_INFO:    $messageType = SGL_MESSAGE_INFO;    break;
					case SGL_MESSAGE_WARNING: $messageType = SGL_MESSAGE_WARNING; break;
					default: $messageType = SGL_MESSAGE_ERROR;   break;
				}
				$aErrorMsg['message'] = $message;
				$aErrorMsg['debugInfo'] = null;
				$aErrorMsg['level'] = null;
				$aErrorMsg['errorType'] = $messageType;
			}
			return $aErrorMsg;
		}
	}
}
if (class_exists('RVS_Task_ResolveAjaxManager') === false) {
	class RVS_Task_ResolveAjaxManager extends SGL_Task_ResolveManager
	{
		function process(&$input, &$output)
		{
			SGL::logMessage(null, PEAR_LOG_DEBUG);
			$req = $input->getRequest();
			$moduleName = $req->get('moduleName');
			$managerName = $req->get('managerName');
			$getDefaultMgr = false;

			if (empty($moduleName) || empty($managerName)) {
				return SGL::raiseError('Module and manager names could not be determined from request');
			} else {
				if (!SGL::moduleIsEnabled($moduleName)) {
					return SGL::raiseError('module "'.$moduleName.'" does not appear to be registered',
					SGL_ERROR_RESOURCENOTFOUND);
				} else {
					$conf = $input->getConfig();
					//  get manager name, if $managerName not correct attempt to load default
					//  manager w/$moduleName
					$mgrPath = RvsLibs_File::buildPath(array(SGL_MOD_DIR, $moduleName, 'classes', 'AjaxClass/'));
					$retMgrName = self::getManagerName($managerName, $mgrPath, $conf);
					if ($retMgrName === false) {
						return SGL::raiseError("Specified manager '$managerName' could not be found, ".
                        "defaults loaded, pls ensure full manager name is present in module's conf.ini",
						SGL_ERROR_RESOURCENOTFOUND);
					}
					$managerName = ($retMgrName)
					                ? $retMgrName
					                : self::getManagerName($moduleName, $mgrPath, $conf);
					if (!empty($managerName)) {
						//  build path to manager class
						$classPath = $mgrPath . $managerName . '.php';
						if (@is_file($classPath)) {
							require_once $classPath;
							//  if class exists, instantiate it
							if (@class_exists($managerName)) {
								$input->moduleName = $moduleName;
								$input->set('manager', new $managerName);
							} else {
								return SGL::raiseError("Class $managerName does not exist");
							}
						} else {
							return SGL::raiseError("Could not find file $classPath");
						}
					} else {
						return SGL::raiseError('Manager name could not be determined from '.
                                    'SGL_Process_ResolveManager::getManagerName');
					}
				}
			}
			if ($getDefaultMgr) {
				return SGL::raiseError("The default manager could not be found",
				SGL_ERROR_RESOURCENOTFOUND);
			}
			    $this->processRequest->process($input, $output);
		}

		/**
		 * Over write SGL_Task_ResolveManager::getManagerName
		 */

		public static function getManagerName($managerName, $path, $conf)
		{
			SGL::logMessage(null, PEAR_LOG_DEBUG);
			$match = SGL_Inflector::getManagerNameFromSimplifiedName($managerName);
			if (@is_file($path . $match . '.php')) {
				return $match;
			}
			    return false;
		}
	}
}
if (class_exists('RVS_MainAjaxProvider') === false) {
	class RVS_MainAjaxProvider extends SGL_Manager
	{
		function RVS_MainAjaxProvider()
		{
			parent::SGL_Manager();
		}

		public function process(&$input, &$output)
		{
			SGL::logMessage(null, PEAR_LOG_DEBUG);
			if (isset($output->masterTemplate)) {
				SGL::logMessage ('rvdebug: master: ' . $output->masterTemplate, PEAR_LOG_DEBUG );
			}
			if (isset($output->template)) {
				SGL::logMessage('rvdebug: template: ' . $output->template, PEAR_LOG_DEBUG);
			}
			SGL::logMessage('rvdebug: ', PEAR_LOG_DEBUG);

			$mgrName = SGL_Inflector::caseFix(get_class($this));
			if (!(array_key_exists($input->action, $this->_aActionsMapping))) {
				return SGL::raiseError('The specified method, ' . $input->action .
                ' does not exist', SGL_ERROR_NOMETHOD);
			} else {
				foreach ($this->_aActionsMapping[$input->action] as $methodName) {
					$methodName = '_ajax_'. $methodName;
					try {
						$ok = $this->{$methodName}($input, $output);
					} catch (Exception $e) {
						var_dump($e->getTrace());
					}
					if (SGL::isError($ok)) {
						return $ok;
					} else {
						return true;
					}
				}
			}
		}
	}
}
?>

Copyright 2K16 - 2K18 Indonesian Hacker Rulez