You are here

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

Same name and namespace in other branches
  1. 7 cleantalk.module \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 src/Cleantalk.php
Create msg for cleantalk server

File

src/Cleantalk.php, line 198

Class

Cleantalk
Cleantalk Base class

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;
}