Skip to content

Instantly share code, notes, and snippets.

@Mopster
Last active February 5, 2018 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mopster/7074a3dda8b1c08528244a40fc003b9b to your computer and use it in GitHub Desktop.
Save Mopster/7074a3dda8b1c08528244a40fc003b9b to your computer and use it in GitHub Desktop.
Bullhorn : Uncompress email message body
/**
* PHP code to get readable email message bodies from Bullhorn backup, UserMessage table, commentsCompressed field
*
* Bullhorn Support thread : http://supportforums.bullhorn.com/viewtopic.php?f=34&t=1672
*
* Thanks to // https://www.experts-exchange.com/questions/28711056/Uncompressing-a-GZIP-string-in-PHP-that-was-compressed-in-Java.html
*/
/** $commentsCompressed contains the value of the commentsCompressed column of the UserMessage table */
// Remove the '0x' from the start of the string
$hex = substr($commentsCompressed, 2);
// Convert from HEX to binary
$bin = hex2bin($hex);
// Decode using zlib
$text = zlib_decode($bin); // Contains the readable body of the email message
// Encode to UTF-8 (Had issues with saving this to MySQL)
$result = utf8_encode($text); // Contains the UTF-8 encoded body of the email message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment