You are here

private function FirewallUpdater::unpackData in Anti Spam by CleanTalk 8.4

Same name and namespace in other branches
  1. 9.1.x src/lib/Cleantalk/Common/Firewall/FirewallUpdater.php \Cleantalk\Common\Firewall\FirewallUpdater::unpackData()
1 call to FirewallUpdater::unpackData()
FirewallUpdater::update in src/lib/Cleantalk/Common/Firewall/FirewallUpdater.php

File

src/lib/Cleantalk/Common/Firewall/FirewallUpdater.php, line 285

Class

FirewallUpdater

Namespace

Cleantalk\Common\Firewall

Code

private function unpackData($file_url) {
  $helper = $this->helper;
  $file_url = trim($file_url);
  $response_code = $helper::http__request__get_response_code($file_url);
  if (empty($response_code['error'])) {
    if ($response_code == 200 || $response_code == 501) {
      $gz_data = $helper::http__request__get_content($file_url);
      if (empty($gz_data['error'])) {
        if (Helper::get_mime_type($gz_data, 'application/x-gzip')) {
          if (function_exists('gzdecode')) {
            $data = gzdecode($gz_data);
            if ($data !== false) {
              return Helper::buffer__parse__csv($data);
            }
            else {
              return array(
                'error' => 'COULD_DECODE_FILE',
              );
            }
          }
          else {
            return array(
              'error' => 'FUNCTION_GZ_DECODE_DOES_NOT_EXIST',
            );
          }
        }
        else {
          return array(
            'error' => 'WRONG_FILE_MIME_TYPE',
          );
        }
      }
      else {
        return array(
          'error' => 'COULD_NOT_GET_IFILE: ' . $gz_data['error'],
        );
      }
    }
    else {
      return array(
        'error' => 'FILE_BAD_RESPONSE_CODE: ' . (int) $response_code,
      );
    }
  }
  else {
    return array(
      'error' => 'FILE_COULD_NOT_GET_RESPONSE_CODE: ' . $response_code['error'],
    );
  }
}