Version 2.0.0
This commit is contained in:
1 parent
5699abfc0e
commit
0eecc172d9
696 files changed
+120723
-77160
No files matched your search
+80
-61
@@ -2,16 +2,15 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
@@ -90,9 +89,9 @@ class tar {
|
||||
var $tarfile_path_name = "";
|
||||
var $workfiles = array();
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// CONSTRUCTOR: Attempt to guess the current working dir.
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function tar() {
|
||||
global $HTTP_SERVER_VARS;
|
||||
@@ -119,12 +118,12 @@ class tar {
|
||||
);
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Set the tarname. If we are extracting a tarball, then it must be the
|
||||
// path to the tarball, and it's name (eg: $tar->new_tar("/foo/bar" ,'myTar.tar')
|
||||
// or if we are creating a tar, then it must be the path and name of the tar file
|
||||
// to create.
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function new_tar($tarpath, $tarname) {
|
||||
|
||||
@@ -140,9 +139,9 @@ class tar {
|
||||
}
|
||||
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Easy way to overwrite defaults
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function over_write_existing() {
|
||||
$this->attributes['over_write_existing'] = 1;
|
||||
@@ -159,9 +158,9 @@ class tar {
|
||||
|
||||
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// User assigns the root directory for the tar ball creation/extraction
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function current_dir($dir = "") {
|
||||
|
||||
@@ -169,9 +168,9 @@ class tar {
|
||||
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// list files: returns an array with all the filenames in the tar file
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function list_files($advanced="") {
|
||||
|
||||
@@ -201,13 +200,13 @@ class tar {
|
||||
return $final;
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Add a directory to the tar files.
|
||||
// $tar->add_directory( str(TO DIRECTORY) )
|
||||
// Can be used in the following methods.
|
||||
// $tar->add_directory( "/foo/bar" );
|
||||
// $tar->write_tar( "/foo/bar" );
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function add_directory( $dir ) {
|
||||
|
||||
@@ -233,7 +232,7 @@ class tar {
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function get_dir_contents( $dir )
|
||||
{
|
||||
@@ -276,7 +275,7 @@ class tar {
|
||||
}
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Extract the tarball
|
||||
// $tar->extract_files( str(TO DIRECTORY), [ array( FILENAMES ) ] )
|
||||
// Can be used in the following methods.
|
||||
@@ -284,7 +283,7 @@ class tar {
|
||||
// This will seek out the files in the user array and extract them
|
||||
// $tar->extract( "/foo/bar" );
|
||||
// Will extract the complete tar file into the user specified directory
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function extract_files( $to_dir, $files="" ) {
|
||||
|
||||
@@ -299,18 +298,18 @@ class tar {
|
||||
return;
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
// change into the directory chosen by the user.
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
chdir($to_dir);
|
||||
$cur_dir = getcwd();
|
||||
|
||||
$to_dir_slash = $to_dir . "/";
|
||||
|
||||
//+------------------------------
|
||||
//-----------------------------------------
|
||||
// Get the file info from the tar
|
||||
//+------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
$in_files = $this->read_tar();
|
||||
|
||||
@@ -320,9 +319,9 @@ class tar {
|
||||
|
||||
foreach ($in_files as $k => $file) {
|
||||
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Are we choosing which files to extract?
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if (is_array($files))
|
||||
{
|
||||
@@ -334,10 +333,10 @@ class tar {
|
||||
|
||||
chdir($cur_dir);
|
||||
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
// GNU TAR format dictates that all paths *must* be in the *nix
|
||||
// format - if this is not the case, blame the tar vendor, not me!
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if ( preg_match("#/#", $file['name']) )
|
||||
{
|
||||
@@ -349,9 +348,9 @@ class tar {
|
||||
$file_name = $file['name'];
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
// If we have a path, then we must build the directory tree
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if (count($path_info) > 0)
|
||||
@@ -380,9 +379,9 @@ class tar {
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
// check the typeflags, and work accordingly
|
||||
//---------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
if (($file['typeflag'] == 0) or (!$file['typeflag']) or ($file['typeflag'] == ""))
|
||||
{
|
||||
@@ -445,7 +444,7 @@ class tar {
|
||||
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// add files:
|
||||
// Takes an array of files, and adds them to the tar file
|
||||
// Optionally takes a path to use as root for the tar file - if omitted, it
|
||||
@@ -461,20 +460,21 @@ class tar {
|
||||
// in an error. Either that, or use:
|
||||
// chdir("/usr/home/somedir/forums");
|
||||
// $tar->add_files( $files );
|
||||
//+--------------------------------------------------------------------------
|
||||
|
||||
function add_files( $files, $root_path="" ) {
|
||||
//-----------------------------------------
|
||||
|
||||
function add_files( $files, $root_path="" )
|
||||
{
|
||||
// Do we a root path to change into?
|
||||
|
||||
if ($root_path != "") {
|
||||
if ($root_path != "")
|
||||
{
|
||||
chdir($root_path);
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
// is it a Mac OS X work file?
|
||||
|
||||
if ( preg_match("/\.ds_store/i", $file ) )
|
||||
@@ -490,7 +490,8 @@ class tar {
|
||||
|
||||
// Did stat fail?
|
||||
|
||||
if (! is_array($stat) ) {
|
||||
if (! is_array($stat) )
|
||||
{
|
||||
$this->warnings[] = "Error: Stat failed on $file";
|
||||
continue;
|
||||
}
|
||||
@@ -502,25 +503,34 @@ class tar {
|
||||
$size = filesize($file);
|
||||
$mtime = filemtime($file);
|
||||
|
||||
if (is_file($file)) {
|
||||
if (is_file($file))
|
||||
{
|
||||
// It's a plain file, so lets suck it up
|
||||
|
||||
$typeflag = 0;
|
||||
if ( $FH = fopen($file, 'rb') ) {
|
||||
|
||||
if ( $FH = fopen($file, 'rb') )
|
||||
{
|
||||
$data = fread( $FH, filesize($file) );
|
||||
fclose($FH);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->warnings[] = "ERROR: Failed to open $file";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (is_link($file)) {
|
||||
else if (is_link($file))
|
||||
{
|
||||
$typeflag = 1;
|
||||
$linkname = @readlink($file);
|
||||
}
|
||||
else if (is_dir($file)) {
|
||||
else if (is_dir($file))
|
||||
{
|
||||
$typeflag = 5;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// Sockets, Pipes and char/block specials are not
|
||||
// supported, so - lets use a silly value to keep the
|
||||
// tar ball legitimate.
|
||||
@@ -563,11 +573,11 @@ class tar {
|
||||
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// write_tar:
|
||||
// Writes the tarball into the directory specified in new_tar with a filename
|
||||
// specified in new_tar
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function write_tar() {
|
||||
|
||||
@@ -591,16 +601,22 @@ class tar {
|
||||
|
||||
// make sure the filename isn't longer than 99 characters.
|
||||
|
||||
if (strlen($file['name']) > 99) {
|
||||
if (strlen($file['name']) > 99)
|
||||
{
|
||||
$pos = strrpos( $file['name'], "/" );
|
||||
if (is_string($pos) && !$pos) {
|
||||
|
||||
if (is_string($pos) && !$pos)
|
||||
{
|
||||
// filename alone is longer than 99 characters!
|
||||
$this->error[] = "Filename {$file['name']} exceeds the length allowed by GNU Tape ARchives";
|
||||
continue;
|
||||
}
|
||||
|
||||
$prefix = substr( $file['name'], 0 , $pos ); // Move the path to the prefix
|
||||
$file['name'] = substr( $file['name'], ($pos+1));
|
||||
if (strlen($prefix) > 154) {
|
||||
|
||||
if (strlen($prefix) > 154)
|
||||
{
|
||||
$this->error[] = "File path exceeds the length allowed by GNU Tape ARchives";
|
||||
continue;
|
||||
}
|
||||
@@ -635,15 +651,18 @@ class tar {
|
||||
|
||||
$checksum = 0;
|
||||
|
||||
for ($i = 0 ; $i < 148 ; $i++ ) {
|
||||
for ($i = 0 ; $i < 148 ; $i++ )
|
||||
{
|
||||
$checksum += ord( substr($tmp, $i, 1) );
|
||||
}
|
||||
|
||||
for ($i = 148 ; $i < 156 ; $i++) {
|
||||
for ($i = 148 ; $i < 156 ; $i++)
|
||||
{
|
||||
$checksum += ord(' ');
|
||||
}
|
||||
|
||||
for ($i = 156, $j = 0 ; $i < 512 ; $i++, $j++) {
|
||||
for ($i = 156, $j = 0 ; $i < 512 ; $i++, $j++)
|
||||
{
|
||||
$checksum += ord( substr($last, $j, 1) );
|
||||
}
|
||||
|
||||
@@ -684,9 +703,9 @@ class tar {
|
||||
// Done..
|
||||
}
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// Read the tarball - builds an associative array
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function read_tar() {
|
||||
|
||||
@@ -832,13 +851,13 @@ class tar {
|
||||
|
||||
|
||||
|
||||
//+------------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// INTERNAL FUNCTIONS - These should NOT be called outside this module
|
||||
//+------------------------------------------------------------------------------
|
||||
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
// build_string: Builds a repititive string
|
||||
//+--------------------------------------------------------------------------
|
||||
//-----------------------------------------
|
||||
|
||||
function internal_build_string($string="", $times=0) {
|
||||
|
||||
|
||||
Reference in new issue
Block a user