Skip to content

Commit

Permalink
refactor ajax.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmi3yy committed Sep 4, 2017
1 parent b0d0b17 commit b32c345
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions manager/media/style/default/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
$modx->getSettings();
}

if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') || ($_SERVER['REQUEST_METHOD'] != 'POST')) {
$modx->sendRedirect($modx->config['site_url']);
if (!isset($_SESSION['mgrValidated']) || !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') || ($_SERVER['REQUEST_METHOD'] != 'POST')) {
$modx->sendErrorPage();
}

include_once MODX_BASE_PATH . MGR_DIR . '/includes/lang/' . $modx->config['manager_language'] . '.inc.php';
Expand Down Expand Up @@ -197,7 +197,7 @@
$a = 88;
$output = '';
$items = '';
$filter = !empty($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '\%*_') : '';
$filter = !empty($_REQUEST['filter']) && is_scalar($_REQUEST['filter']) ? addcslashes(trim($_REQUEST['filter']), '\%*_') : '';
$sqlLike = $filter ? 'WHERE t1.username LIKE "' . $modx->db->escape($filter) . '%"' : '';
$sqlLimit = $sqlLike ? '' : 'LIMIT ' . $limit;

Expand Down Expand Up @@ -233,10 +233,11 @@
}

case 'modxTagHelper': {
$name = isset($_REQUEST['name']) ? $_REQUEST['name'] : false;
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : false;
$name = isset($_REQUEST['name']) && is_scalar($_REQUEST['name']) ? $modx->db->escape($_REQUEST['name']) : false;
$type = isset($_REQUEST['type']) && is_scalar($_REQUEST['type']) ? $modx->db->escape($_REQUEST['type']) : false;
$contextmenu = '';

if ($name && $type) {
if ($role && $name && $type) {
switch ($type) {
case 'Snippet':
case 'SnippetNoCache': {
Expand Down Expand Up @@ -468,6 +469,8 @@
echo json_encode($contextmenu, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE);
break;
}

break;
}

case 'movedocument' : {
Expand All @@ -476,7 +479,7 @@
if ($modx->hasPermission('new_document') && $modx->hasPermission('edit_document') && $modx->hasPermission('save_document')) {
$id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : '';
$parent = isset($_REQUEST['parent']) ? (int)$_REQUEST['parent'] : 0;
$menuindex = isset($_REQUEST['menuindex']) ? $_REQUEST['menuindex'] : 0;
$menuindex = isset($_REQUEST['menuindex']) && is_scalar($_REQUEST['menuindex']) ? $_REQUEST['menuindex'] : 0;

// set parent
if ($id && $parent >= 0) {
Expand Down

0 comments on commit b32c345

Please sign in to comment.