Skip to content

Instantly share code, notes, and snippets.

@0test
Last active November 27, 2019 20:16
Show Gist options
  • Save 0test/75d496bce4d357bc6562c48983e39ad1 to your computer and use it in GitHub Desktop.
Save 0test/75d496bce4d357bc6562c48983e39ad1 to your computer and use it in GitHub Desktop.
AJAX file Evolution CMS
<?php
define('MODX_API_MODE', true);
include_once("index.php");
$modx->db->connect();
if (empty ($modx->config)){
$modx->getSettings();
}
$modx->invokeEvent("OnWebPageInit");
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')){
$modx->sendRedirect($modx->config['site_url']);
}
//если надо вытащить почту из системных настроек
$email = $modx->db->getValue($modx->db->select('setting_value', $modx->getFullTableName('system_settings'), "setting_name = 'client_shop_email'"));
switch($_REQUEST['q']){
case 'callme':
$result = $modx->runSnippet('FormLister', array(
'formid' => 're_callForm',
'removeEmptyPlaceholders' => '1',
));
echo $modx->parseDocumentSource($result);
exit();
break;
case 'oclick':
$result = $modx->runSnippet('FormLister', array(
'formid' => 'oclick_frm',
'prepareProcess' => array(function($modx, $data, $FormLister, $name){
return $data;
}),
'removeEmptyPlaceholders' => 1
));
echo $modx->parseDocumentSource($result);
exit();
break;
default:
$modx->sendForward($modx->config['error_page']);
break;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment