|
Source for file ami_server.php
Documentation is available at ami_server.php
* AJAX Responder plugin. Processes AJAX request and returning JSON response.
* There are no allowed modules by default.<br />
* Use plugin admin interface to modify aloowed modules list.<br />
* This plugin allows to access the CMS modules data escaping common CMS access validation.<br />
* Be careful allowing modules access.<br />
* Obligatory GET parameters:<br />
* - <b>module</b> -- module id, 'articles'|'blog'|'eshop_item'|'files'|'kb_item'|'news'|'photoalbum'|'portfolio_item'|'stickers'
* Possible GET parameters:<br />
* - <b>order</b> -- db order column, 'id' by default<br />
* - <b>dir</b> -- 'asc'|'desc', 'asc' by default<br />
* - <b>limit</b> -- records count, positive integer, 3 by default<br />
* - <b>offset</b> -- offset, integer >= 0, 0 by default<br />
* - <b>locale</b> -- locale code, 'en' by default<br />
* - <b>id_page</b> -- page id, used for multipage modules, no default value<br />
* - <b>id_site</b> -- site id, used for multisite, no default value<br />
* AJAX request example URLs:<br />
* - news: {@link http://localhost/ami_resp.php?module=news}<br />
* - blog: {@link http://localhost/ami_resp.php?module=blog}<br />
* - articles: {@link http://localhost/ami_resp.php?module=articles}<br />
* - files: {@link http://localhost/ami_resp.php?module=files}<br />
* - eshop_item: {@link http://localhost/ami_resp.php?module=eshop_item}<br />
* - kb_item: {@link http://localhost/ami_resp.php?module=kb_item}<br />
* - portfolio_item: {@link http://localhost/ami_resp.php?module=portfolio_item}<br />
* - photoalbum: {@link http://localhost/ami_resp.php?module=photoalbum}<br />
* - stickers: {@link http://localhost/ami_resp.php?module=stickers}
* @copyright Amiro.CMS. All rights reserved.
* @package Plugin_AJAXResponder
* @version $Id: ami_server.php 61273 2013-08-07 10:47:54Z Leontiev Anton $
// To avoid server overload and flood
$oResponse->sleep(100000);
// Loading allowed modules list from ini-file {
$pluginId = $oRequest->get('id_plugin', 'ami_ajax_responder');
trigger_error('Cannot load config file "' . $path . "'", E_USER_ERROR);
if(!isset ($aConfig['allowed_modules'])){
trigger_error('Missing parameter "allowed_modules" in config file "' . $path . "'", E_USER_ERROR);
$aAllowedModules = empty($aConfig['allowed_modules']) ? array() : explode(',', $aConfig['allowed_modules']);
// } Loading allowed modules list from ini-file
if(!sizeof($aAllowedModules) || !in_array($oRequest->get('module'), $aAllowedModules)){
// Forbidden module, exitpoint
$oResponse->setMessage($oRequest->get('module'), - 1);
$aModulesSettings = array(
'PlgAJAXResp_Articles_State' => 'PlgAJAXResp_Articles',
'PlgAJAXResp_Articles_ListView' => 'PlgAJAXResp_Articles'
// Plugin Articles module model
'plg_ajax_resp/articles/state/model' => 'PlgAJAXResp_Articles_State',
// Plugin Articles module view
'plg_ajax_resp/articles/list/view' => 'PlgAJAXResp_Articles_ListView',
'plg_ajax_resp/module/controller' => 'PlgAJAXResp'
'PlgAJAXResp_Blog_State' => 'PlgAJAXResp_Blog',
'PlgAJAXResp_Blog_ListView' => 'PlgAJAXResp_Blog'
// Plugin Blog module model
'plg_ajax_resp/blog/state/model' => 'PlgAJAXResp_Blog_State',
// Plugin Blog module view
'plg_ajax_resp/blog/list/view' => 'PlgAJAXResp_Blog_ListView',
'plg_ajax_resp/module/controller' => 'PlgAJAXResp'
'PlgAJAXResp_EshopItem_State' => 'PlgAJAXResp_EshopItem',
'PlgAJAXResp_EshopItem_ListView' => 'PlgAJAXResp_EshopItem'
// Plugin E-shop Product module model
'plg_ajax_resp/eshop_item/state/model' => 'PlgAJAXResp_EshopItem_State',
// Plugin E-shop Product module view
'plg_ajax_resp/eshop_item/list/view' => 'PlgAJAXResp_EshopItem_ListView',
'plg_ajax_resp/module/controller' => 'PlgAJAXResp'
'PlgAJAXResp_Files_State' => 'PlgAJAXResp_Files',
'PlgAJAXResp_Files_ListView' => 'PlgAJAXResp_Files'
// Plugin Files module model
'plg_ajax_resp/files/state/model' => 'PlgAJAXResp_Files_State',
// Plugin Files module view
'plg_ajax_resp/files/list/view' => 'PlgAJAXResp_Files_ListView',
'plg_ajax_resp/module/controller' => 'PlgAJAXResp'
'PlgAJAXResp_KbItem_State' => 'PlgAJAXResp_KbItem',
'PlgAJAXResp_KbItem_ListView' => 'PlgAJAXResp_KbItem'
// Plugin Knowledge Base Item module model
'plg_ajax_resp/kb_item/state/model' => 'PlgAJAXResp_KbItem_State',
// Plugin Knowledge Base Item module view
'plg_ajax_resp/kb_item/list/view' => 'PlgAJAXResp_KbItem_ListView',
'plg_ajax_resp/module/controller' => 'PlgAJAXResp'
'PlgAJAXResp_News_State' => 'PlgAJAXResp_News',
'PlgAJAXResp_News_ListView' => 'PlgAJAXResp_News'
// Plugin News module model
'plg_ajax_resp/news/state/model' => 'PlgAJAXResp_News_State',
// Plugin News module view
'plg_ajax_resp/news/list/view' => 'PlgAJAXResp_News_ListView',
'plg_ajax_resp/module/controller' => 'PlgAJAXResp'
'PlgAJAXResp_Photoalbum_State' => 'PlgAJAXResp_Photoalbum',
'PlgAJAXResp_Photoalbum_ListView' => 'PlgAJAXResp_Photoalbum'
// Plugin Photo Gallery module model
'plg_ajax_resp/photoalbum/state/model' => 'PlgAJAXResp_Photoalbum_State',
// Plugin Photo Gallery module view
'plg_ajax_resp/photoalbum/list/view' => 'PlgAJAXResp_Photoalbum_ListView',
'plg_ajax_resp/module/controller' => 'PlgAJAXResp'
'portfolio_item' => array(
'PlgAJAXResp_PortfolioItem_State' => 'PlgAJAXResp_PortfolioItem',
'PlgAJAXResp_PortfolioItem_ListView' => 'PlgAJAXResp_PortfolioItem'
// Plugin PortfolioItem module model
'plg_ajax_resp/portfolio_item/state/model' => 'PlgAJAXResp_PortfolioItem_State',
// Plugin PortfolioItem module view
'plg_ajax_resp/portfolio_item/list/view' => 'PlgAJAXResp_PortfolioItem_ListView',
'plg_ajax_resp/module/controller' => 'PlgAJAXResp'
'PlgAJAXResp_Stickers_State' => 'PlgAJAXResp_Stickers',
'PlgAJAXResp_Stickers_ListView' => 'PlgAJAXResp_Stickers'
// Plugin Stickers module model
'plg_ajax_resp/stickers/state/model' => 'PlgAJAXResp_Stickers_State',
// Plugin Stickers module view
'plg_ajax_resp/stickers/list/view' => 'PlgAJAXResp_Stickers_ListView',
'plg_ajax_resp/module/controller' => 'PlgAJAXResp'
'search_history' => array(
'PlgAJAXResp_SearchHistory' => 'PlgAJAXResp_SearchHistory',
'PlgAJAXResp_SearchHistory_State' => 'PlgAJAXResp_SearchHistory',
'PlgAJAXResp_SearchHistory_ListView' => 'PlgAJAXResp_SearchHistory',
'PlgAJAXResp_Search_State' => 'PlgAJAXResp_Search',
'PlgAJAXResp_Search_ListView' => 'PlgAJAXResp_Search'
// Plugin SearchHistory module model
'plg_ajax_resp/search_history/state/model' => 'PlgAJAXResp_SearchHistory_State',
// Plugin SearchHistory module view
'plg_ajax_resp/search_history/list/view' => 'PlgAJAXResp_SearchHistory_ListView',
// Plugin Search module model
'plg_ajax_resp/search/state/model' => 'PlgAJAXResp_Search_State',
// Plugin Search module view
'plg_ajax_resp/search/list/view' => 'PlgAJAXResp_Search_ListView',
// Plugin SearchHistory controller
'plg_ajax_resp/module/controller' => 'PlgAJAXResp_SearchHistory'
$moduleName = $oRequest->get('module');
if($oDeclarator->isRegistered($moduleName)){
list ($hyper, $config) = $oDeclarator->getHyperData($moduleName);
if(isset ($aModulesSettings[$moduleName])){
* @see AMI_Service::addClassMapping()
* Plugin modules resource mapping.
* Uncomment appropriate module resource mapping.
* @see PlgAJAXResp::__construct()
* @see AMI::getResource()
'PlgAJAXResp_ListViewLinks' => 'PlgAJAXResp_ListView'
$oPluginController = AMI::getResource('plg_ajax_resp/module/controller', array($oRequest, $aAllowedModules));
$response = $oPluginController->getResponse();
trigger_error('Unknown module name for AJAX Responder plugin', E_USER_WARNING);
$oResponse->write($response);
|