1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-11 00:54:08 +02:00

Customizable export

This commit is contained in:
Jakub Vrana
2010-10-29 17:03:02 +02:00
parent a2443670f8
commit 095d472366
8 changed files with 229 additions and 208 deletions

View File

@@ -333,3 +333,18 @@ function drop_create($drop, $create, $location, $message_drop, $message_alter, $
}
return $dropped;
}
/** Get string to add a file in TAR
* @param string
* @param string
* @return string
*/
function tar_file($filename, $contents) {
$return = pack("a100a8a8a8a12a12", $filename, 644, 0, 0, decoct(strlen($contents)), decoct(time()));
$checksum = 8*32; // space for checksum itself
for ($i=0; $i < strlen($return); $i++) {
$checksum += ord($return{$i});
}
$return .= sprintf("%06o", $checksum) . "\0 ";
return $return . str_repeat("\0", 512 - strlen($return)) . $contents . str_repeat("\0", 511 - (strlen($contents) + 511) % 512);
}