You are here

function _drd_server_validate_request in Drupal Remote Dashboard Server 6.2

Same name and namespace in other branches
  1. 7.2 drd_server.module \_drd_server_validate_request()

Parameters

array $args:

string $action_name:

Return value

array

9 calls to _drd_server_validate_request()
drd_server_config_domain_read in ./drd_server.module
drd_server_config_domain_save in ./drd_server.module
drd_server_config_server_read in ./drd_server.module
drd_server_config_server_save in ./drd_server.module
drd_server_execute in ./drd_server.module
This is called to execute one of the actions that are defined on one of the hook_drd_server_actions()

... See full list

File

./drd_server.module, line 886

Code

function _drd_server_validate_request(&$args, $action_name = '') {
  $langcode = $args[2];
  $debug = $args[3];
  global $language;
  $language->language = $langcode;
  _drd_server_debug_mode($debug);
  $aes = drd_server_aes();
  if (empty($aes)) {
    _drd_server_watchdog('Execution request unauthorized.', array(), WATCHDOG_ALERT);
    return array(
      drd_server_error(t('Referer (' . ip_address() . ') not allowed.'), DRD_SERVER_ERROR_WRONG_REFERER),
    );
  }
  array_push($args, $action_name);
  $iv = _drd_server_iv();
  foreach ($args as $i => $value) {
    if (!empty($value) && !in_array($i, array(
      2,
      3,
    ))) {
      $args[$i] = drd_server_aes_decrypt($value, TRUE, $aes['key'], $aes['cipher'], $iv, $aes['impl']);
    }
  }
  $api = array_shift($args);
  $timestamp = array_shift($args);
  $langcode = array_shift($args);
  $debug = array_shift($args);
  if (!_drd_server_validate_timestamp($timestamp)) {
    _drd_server_watchdog('Wrong encryption keys.', array(), WATCHDOG_EMERGENCY);
    return array(
      drd_server_error(t('Wrong encryption keys.'), DRD_SERVER_ERROR_WRONG_KEYS),
    );
  }
  if ($api !== DRD_SERVER_API_VERSION) {
    _drd_server_watchdog('Wrong API: %api.', array(
      '%api' => $api,
    ), WATCHDOG_ALERT);
    return array(
      drd_server_error(t('Wrong API.'), DRD_SERVER_ERROR_WRONG_API),
    );
  }
  $action_name = empty($args[0]) ? t('simple') : $args[0];
  if (sizeof($args) < 2) {
    _drd_server_watchdog('Remote execution request: !action_name', array(
      '!action_name' => $action_name,
    ));
  }
  else {
    _drd_server_watchdog('Remote execution request: !action_name <pre>!args</pre>', array(
      '!action_name' => $action_name,
      '!args' => print_r($args, TRUE),
    ));
  }
  return TRUE;
}