You are here

private function Cleantalk::compressData in Anti Spam by CleanTalk 7

Same name and namespace in other branches
  1. 7.5 src/Cleantalk.php \Cleantalk::compressData()
  2. 7.2 cleantalk.module \Cleantalk::compressData()
  3. 7.4 src/Cleantalk.php \Cleantalk::compressData()

Compress data and encode to base64

Parameters

type string:

Return value

string

1 call to Cleantalk::compressData()
Cleantalk::createMsg in ./cleantalk.module
Create msg for cleantalk server

File

./cleantalk.module, line 517
Main CleanTalk integration module functions.

Class

Cleantalk
Cleantalk class create request

Code

private function compressData($data = null) {
  if (strlen($data) > $this->dataMaxSise && function_exists('gzencode') && function_exists('base64_encode')) {
    $localData = gzencode($data, $this->compressRate, FORCE_GZIP);
    if ($localData === false) {
      return $data;
    }
    $localData = base64_encode($localData);
    if ($localData === false) {
      return $data;
    }
    return $localData;
  }
  return $data;
}