You are here

public static function CleantalkFuncs::_cleantalk_sfw_update in Anti Spam by CleanTalk 8.3

3 calls to CleantalkFuncs::_cleantalk_sfw_update()
BootSubscriber::handle in src/EventSubscriber/BootSubscriber.php
Handles a Request to convert it to a Response.
CleantalkFuncs::_cleantalk_apbct_remote_call__perform in src/CleantalkFuncs.php
Cleantalk inner function - perform remote call
CleantalkSettingsForm::validateForm in src/Form/CleantalkSettingsForm.php
Form validation handler.

File

src/CleantalkFuncs.php, line 617

Class

CleantalkFuncs
Cleantalk class create request

Namespace

Drupal\cleantalk

Code

public static function _cleantalk_sfw_update($access_key) {
  $sfw = new CleantalkSFW($access_key);
  $file_url_hash = isset($_GET['file_url_hash']) ? urldecode($_GET['file_url_hash']) : null;
  $file_url_nums = isset($_GET['file_url_nums']) ? urldecode($_GET['file_url_nums']) : null;
  $file_url_nums = isset($file_url_nums) ? explode(',', $file_url_nums) : null;
  if (!isset($file_url_hash, $file_url_nums)) {
    $result = $sfw
      ->sfw_update();
  }
  elseif ($file_url_hash && is_array($file_url_nums) && count($file_url_nums)) {
    $result = $sfw
      ->sfw_update($file_url_hash, $file_url_nums[0]);
    if (empty($result['error'])) {
      array_shift($file_url_nums);
      if (count($file_url_nums)) {
        CleantalkHelper::http__request((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'], array(
          'spbc_remote_call_token' => md5($access_key),
          'spbc_remote_call_action' => 'sfw_update__write_base',
          'plugin_name' => 'apbct',
          'file_url_hash' => $file_url_hash,
          'file_url_nums' => implode(',', $file_url_nums),
        ), array(
          'get',
          'async',
        ));
      }
      else {
        \Drupal::state()
          ->set('cleantalk_sfw_last_check', time());
      }
    }
    else {
      return array(
        'error' => 'ERROR_WHILE_INSERTING_SFW_DATA',
      );
    }
  }
  return $result;
}