Skip to content

Instantly share code, notes, and snippets.

@iarp
Last active June 10, 2017 12:10
Show Gist options
  • Save iarp/f2e01b124f36940f8841 to your computer and use it in GitHub Desktop.
Save iarp/f2e01b124f36940f8841 to your computer and use it in GitHub Desktop.
PHP function that decodes GoldMine's log timestamp values
function Decode($strValueIn) {
$intX = 0;
$intY = 0;
$Temp = "";
$Mod = "";
$intMod =0;
$intTemp = 0;
$ValueOut = "";
$intY = 1;
$strValueOut="";
for ($intX = 1; $intX <= ((strlen($strValueIn)/2)/2); $intX++) {
$strTemp="";
$strMod="";
if (($intX % 2) == 0) {
$strMod = substr(substr($strValueIn, $intY-1, 4),0,2);
$strTemp = substr(substr($strValueIn, $intY-1, 4),strlen(substr($strValueIn, $intY-1, 4))-(2));
} else {
$strMod = substr(substr($strValueIn, $intY-1,4), strlen(substr($strValueIn, $intY-1, 4))-(2));
$strTemp = substr(substr($strValueIn, $intY-1,4), 0, 2);
}
$intMod = hexdec($strMod);
$intTemp = hexdec($strTemp);
$intTemp = $intTemp-$intMod;
$strValueOut = $strValueOut . chr($intTemp);
$intY += 4;
}
return $strValueOut;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment