aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_compress.php
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2006-11-03 23:09:16 +0000
committerDavid M <davidmj@users.sourceforge.net>2006-11-03 23:09:16 +0000
commit8b0ec6e02d5a53ea3d1b87abd122d39cc3e8366f (patch)
tree22bae5ecbab9dbf8390ab3763f53c15c822c9198 /phpBB/includes/functions_compress.php
parent7ab232a45504ef357a19d9ab58dd27c454e12784 (diff)
downloadforums-8b0ec6e02d5a53ea3d1b87abd122d39cc3e8366f.tar
forums-8b0ec6e02d5a53ea3d1b87abd122d39cc3e8366f.tar.gz
forums-8b0ec6e02d5a53ea3d1b87abd122d39cc3e8366f.tar.bz2
forums-8b0ec6e02d5a53ea3d1b87abd122d39cc3e8366f.tar.xz
forums-8b0ec6e02d5a53ea3d1b87abd122d39cc3e8366f.zip
- compress is nicer (fixed a bug :P)
- UTF-8 code is nicer (fixed a bug :P) - new CAPTCHA. Replaced the old one for size and usability issues. The old CAPTCHA will most likely be released as a separate package git-svn-id: file:///svn/phpbb/trunk@6549 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_compress.php')
-rw-r--r--phpBB/includes/functions_compress.php54
1 files changed, 27 insertions, 27 deletions
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index cbada8a76d..93a3547e21 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -478,17 +478,17 @@ class compress_tar extends compress
// Run through the file and grab directory entries
while ($buffer = $fzread($this->fp, 512))
{
- $tmp = unpack("A6magic", substr($buffer, 257, 6));
+ $tmp = unpack('A6magic', substr($buffer, 257, 6));
if (trim($tmp['magic']) == 'ustar')
{
- $tmp = unpack("A100name", $buffer);
+ $tmp = unpack('A100name', $buffer);
$filename = trim($tmp['name']);
- $tmp = unpack("Atype", substr($buffer, 156, 1));
+ $tmp = unpack('Atype', substr($buffer, 156, 1));
$filetype = (int) trim($tmp['type']);
- $tmp = unpack("A12size", substr($buffer, 124, 12));
+ $tmp = unpack('A12size', substr($buffer, 124, 12));
$filesize = octdec((int) trim($tmp['size']));
if ($filetype == 5)
@@ -508,12 +508,12 @@ class compress_tar extends compress
{
trigger_error("Could not create directory $folder");
}
- @chmod("$str", 0777);
+ @chmod($str, 0777);
}
}
}
}
- else if($filesize != 0 && ($filetype == 0 || $filetype == "\0"))
+ else if ($filesize != 0 && ($filetype == 0 || $filetype == "\0"))
{
// Write out the files
if (!($fp = fopen("$dst$filename", 'wb')))
@@ -523,7 +523,7 @@ class compress_tar extends compress
@chmod("$dst$filename", 0777);
// Grab the file contents
- fwrite($fp, $fzread($this->fp, $filesize + 512 - $filesize % 512), $filesize);
+ fwrite($fp, $fzread($this->fp, ($filesize + 511) &~ 511), $filesize);
fclose($fp);
}
}
@@ -542,7 +542,7 @@ class compress_tar extends compress
$fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite');
// Symbolizes that there are no more files
- $fzwrite($this->fp, pack("a512", ""));
+ $fzwrite($this->fp, str_repeat("\0", 512));
}
$fzclose($this->fp);
@@ -560,37 +560,37 @@ class compress_tar extends compress
// This is the header data, it contains all the info we know about the file or folder that we are about to archive
$header = '';
- $header .= pack("a100", $name); // file name
- $header .= pack("a8", sprintf("%07o", $stat[2])); // file mode
- $header .= pack("a8", sprintf("%07o", $stat[4])); // owner id
- $header .= pack("a8", sprintf("%07o", $stat[5])); // group id
- $header .= pack("a12", sprintf("%011o", $stat[7])); // file size
- $header .= pack("a12", sprintf("%011o", $stat[9])); // last mod time
+ $header .= pack('a100', $name); // file name
+ $header .= pack('a8', sprintf("%07o", $stat[2])); // file mode
+ $header .= pack('a8', sprintf("%07o", $stat[4])); // owner id
+ $header .= pack('a8', sprintf("%07o", $stat[5])); // group id
+ $header .= pack('a12', sprintf("%011o", $stat[7])); // file size
+ $header .= pack('a12', sprintf("%011o", $stat[9])); // last mod time
// Checksum
$checksum = 0;
for ($i = 0; $i < 148; $i++)
{
- $checksum += ord(substr($header, $i, 1));
+ $checksum += ord($header[$i]);
}
// We precompute the rest of the hash, this saves us time in the loop and allows us to insert our hash without resorting to string functions
$checksum += 2415 + (($is_dir) ? 53 : 0);
- $header .= pack("a8", sprintf("%07o", $checksum)); // checksum
- $header .= pack("a1", $typeflag); // link indicator
- $header .= pack("a100", ''); // name of linked file
- $header .= pack("a6", 'ustar'); // ustar indicator
- $header .= pack("a2", '00'); // ustar version
- $header .= pack("a32", 'Unknown'); // owner name
- $header .= pack("a32", 'Unknown'); // group name
- $header .= pack("a8", ''); // device major number
- $header .= pack("a8", ''); // device minor number
- $header .= pack("a155", ''); // filename prefix
- $header .= pack("a12", ''); // end
+ $header .= pack('a8', sprintf("%07o", $checksum)); // checksum
+ $header .= pack('a1', $typeflag); // link indicator
+ $header .= pack('a100', ''); // name of linked file
+ $header .= pack('a6', 'ustar'); // ustar indicator
+ $header .= pack('a2', '00'); // ustar version
+ $header .= pack('a32', 'Unknown'); // owner name
+ $header .= pack('a32', 'Unknown'); // group name
+ $header .= pack('a8', ''); // device major number
+ $header .= pack('a8', ''); // device minor number
+ $header .= pack('a155', ''); // filename prefix
+ $header .= pack('a12', ''); // end
// This writes the entire file in one shot. Header, followed by data and then null padded to a multiple of 512
- $fzwrite($this->fp, $header . (($stat[7] !== 0 && !$is_dir) ? $data . (($stat[7] % 512 > 0) ? str_repeat("\0", 512 - $stat[7] % 512) : '') : ''));
+ $fzwrite($this->fp, $header . (($stat[7] !== 0 && !$is_dir) ? $data . str_repeat("\0", (($stat[7] + 511) &~ 511) - $stat[7]) : ''));
unset($data);
}