OSDN Git Service

Small update.
authorKazuki Przyborowski <kazuki.przyborowski@gmail.com>
Wed, 15 Dec 2010 09:10:16 +0000 (09:10 +0000)
committerKazuki Przyborowski <kazuki.przyborowski@gmail.com>
Wed, 15 Dec 2010 09:10:16 +0000 (09:10 +0000)
Updated iUnTAR to version 4.0.

git-svn-id: svn://svn.code.sf.net/p/intdb/svn/trunk@602 2b68903e-0b30-0410-9a39-a2e4f3c5be39

inc/function.php
inc/versioninfo.php

index 2aa8b3c..58b1667 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2011 iDB Support - http://idb.berlios.de/
     Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
 
-    $FileInfo: function.php - Last Update: 12/07/2010 SVN 600 - Author: cooldude2k $
+    $FileInfo: function.php - Last Update: 12/15/2010 SVN 602 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="function.php"||$File3Name=="/function.php") {
@@ -66,57 +66,114 @@ $REFERERurl = null;
 function output_error($message, $level=E_USER_ERROR) {
     $caller = next(debug_backtrace());
     trigger_error($message.' in <strong>'.$caller['function'].'</strong> called from <strong>'.$caller['file'].'</strong> on line <strong>'.$caller['line'].'</strong>'."\n<br />error handler", $level); }
-// PHP iUnTAR Version 3.0
-function untar($tarfile,$outdir="./",$chmod=null) {
+// PHP iUnTAR Version 4.0
+// license: Revised BSD license
+function untar($tarfile,$outdir="./",$chmod=null,$extract=true) {
 $TarSize = filesize($tarfile);
 $TarSizeEnd = $TarSize - 1024;
-if($outdir!=""&&!file_exists($outdir)) {
-       mkdir($outdir,0777); }
+if($extract!==true&&$extract!==false) {
+       $extract = false; }
+if($outdir!=""&&!file_exists($outdir)&&$extract===true) {
+        mkdir($outdir,0777); }
 $thandle = fopen($tarfile, "r");
+if($extract===false) {
+       $FileArray = null; $i = 0; }
 while (ftell($thandle)<$TarSizeEnd) {
-       $FileName = $outdir.trim(fread($thandle,100));
-       $FileMode = trim(fread($thandle,8));
-       if($chmod===null) {
-               $FileCHMOD = octdec("0".substr($FileMode,-3)); }
-       if($chmod!==null) {
-               $FileCHMOD = $chmod; }
-       $OwnerID = trim(fread($thandle,8));
-       $GroupID = trim(fread($thandle,8));
-       $FileSize = octdec(trim(fread($thandle,12)));
-       $LastEdit = trim(fread($thandle,12));
-       $Checksum = trim(fread($thandle,8));
-       $FileType = trim(fread($thandle,1));
-       $LinkedFile = trim(fread($thandle,100));
-       fseek($thandle,255,SEEK_CUR);
-       if($FileType=="0") {
-               $FileContent = fread($thandle,$FileSize); }
-       if($FileType=="1") {
-               $FileContent = null; }
-       if($FileType=="2") {
-               $FileContent = null; }
-       if($FileType=="5") {
-               $FileContent = null; }
-       if($FileType=="0") {
-               $subhandle = fopen($FileName, "a+");
-               fwrite($subhandle,$FileContent,$FileSize);
-               fclose($subhandle); 
-               chmod($FileName,$FileCHMOD); }
-       if($FileType=="1") {
-               link($FileName,$LinkedFile); }
-       if($FileType=="2") {
-               symlink($LinkedFile,$FileName); }
-       if($FileType=="5") {
-               mkdir($FileName,$FileCHMOD); }
-       //touch($FileName,$LastEdit);
-       if($FileType=="0") {
-               $CheckSize = 512;
-               while ($CheckSize<$FileSize) {
-                       if($CheckSize<$FileSize) {
-                       $CheckSize = $CheckSize + 512; } }
-               $SeekSize = $CheckSize - $FileSize;
-               fseek($thandle,$SeekSize,SEEK_CUR); } }
-       fclose($thandle); 
-       return true; }
+        $FileName = $outdir.trim(fread($thandle,100));
+        $FileMode = trim(fread($thandle,8));
+        if($chmod===null) {
+                $FileCHMOD = octdec("0".substr($FileMode,-3)); }
+        if($chmod!==null) {
+                $FileCHMOD = $chmod; }
+        $OwnerID = trim(fread($thandle,8));
+        $GroupID = trim(fread($thandle,8));
+        $FileSize = octdec(trim(fread($thandle,12)));
+        $LastEdit = trim(fread($thandle,12));
+        $Checksum = trim(fread($thandle,8));
+        $FileType = trim(fread($thandle,1));
+        $LinkedFile = trim(fread($thandle,100));
+        fseek($thandle,255,SEEK_CUR);
+        if($FileType=="0"||$FileType=="7") {
+                               $FileContent = fread($thandle,$FileSize); }
+        if($FileType=="1") {
+                $FileContent = null; }
+        if($FileType=="2") {
+                $FileContent = null; }
+        if($FileType=="5") {
+                $FileContent = null; }
+        if($FileType=="0"||$FileType=="7") {
+                       if($extract===true) {
+                $subhandle = fopen($FileName, "a+");
+                fwrite($subhandle,$FileContent,$FileSize);
+                fclose($subhandle);
+                chmod($FileName,$FileCHMOD); }
+                       if($extract===false) { 
+                               $FileArray[$i]['FileName'] = $FileName;
+                               $FileArray[$i]['FileMode'] = $FileMode;
+                               $FileArray[$i]['OwnerID'] = $OwnerID;
+                               $FileArray[$i]['GroupID'] = $GroupID;
+                               $FileArray[$i]['FileSize'] = $FileSize;
+                               $FileArray[$i]['LastEdit'] = $LastEdit;
+                               $FileArray[$i]['Checksum'] = $Checksum;
+                               $FileArray[$i]['FileType'] = $FileType;
+                               $FileArray[$i]['LinkedFile'] = $LinkedFile;
+                               $FileArray[$i]['FileContent'] = $FileContent; } }
+        if($FileType=="1") {
+                       if($extract===true) {
+                link($FileName,$LinkedFile); }
+                       if($extract===false) { 
+                               $FileArray[$i]['FileName'] = $FileName;
+                               $FileArray[$i]['FileMode'] = $FileMode;
+                               $FileArray[$i]['OwnerID'] = $OwnerID;
+                               $FileArray[$i]['GroupID'] = $GroupID;
+                               $FileArray[$i]['FileSize'] = $FileSize;
+                               $FileArray[$i]['LastEdit'] = $LastEdit;
+                               $FileArray[$i]['Checksum'] = $Checksum;
+                               $FileArray[$i]['FileType'] = $FileType;
+                               $FileArray[$i]['LinkedFile'] = $LinkedFile;
+                               $FileArray[$i]['FileContent'] = $FileContent; } }
+        if($FileType=="2") {
+                       if($extract===true) {
+                symlink($LinkedFile,$FileName); }
+                       if($extract===false) { 
+                               $FileArray[$i]['FileName'] = $FileName;
+                               $FileArray[$i]['FileMode'] = $FileMode;
+                               $FileArray[$i]['OwnerID'] = $OwnerID;
+                               $FileArray[$i]['GroupID'] = $GroupID;
+                               $FileArray[$i]['FileSize'] = $FileSize;
+                               $FileArray[$i]['LastEdit'] = $LastEdit;
+                               $FileArray[$i]['Checksum'] = $Checksum;
+                               $FileArray[$i]['FileType'] = $FileType;
+                               $FileArray[$i]['LinkedFile'] = $LinkedFile;
+                               $FileArray[$i]['FileContent'] = $FileContent; } }
+        if($FileType=="5") {
+                       if($extract===true) {
+                mkdir($FileName,$FileCHMOD); } 
+                       if($extract===false) { 
+                               $FileArray[$i]['FileName'] = $FileName;
+                               $FileArray[$i]['FileMode'] = $FileMode;
+                               $FileArray[$i]['OwnerID'] = $OwnerID;
+                               $FileArray[$i]['GroupID'] = $GroupID;
+                               $FileArray[$i]['FileSize'] = $FileSize;
+                               $FileArray[$i]['LastEdit'] = $LastEdit;
+                               $FileArray[$i]['Checksum'] = $Checksum;
+                               $FileArray[$i]['FileType'] = $FileType;
+                               $FileArray[$i]['LinkedFile'] = $LinkedFile;
+                               $FileArray[$i]['FileContent'] = $FileContent; } }
+        //touch($FileName,$LastEdit);
+               if($extract===false) { ++$i; }
+        if($FileType=="0"||$FileType=="7") {
+                $CheckSize = 512;
+                while ($CheckSize<$FileSize) {
+                        if($CheckSize<$FileSize) {
+                        $CheckSize = $CheckSize + 512; } }
+                $SeekSize = $CheckSize - $FileSize;
+                fseek($thandle,$SeekSize,SEEK_CUR); } }
+        fclose($thandle);
+               if($extract===true) {
+                       return true; }
+               if($extract===false) {
+                       return $FileArray; } }
 // http://us.php.net/manual/en/function.uniqid.php#94959
 /**
   * Generates an UUID
index 2841dd2..54365f5 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2011 iDB Support - http://idb.berlios.de/
     Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
 
-    $FileInfo: versioninfo.php - Last Update: 12/08/2010 SVN 601 - Author: cooldude2k $
+    $FileInfo: versioninfo.php - Last Update: 12/15/2010 SVN 602 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="versioninfo.php"||$File3Name=="/versioninfo.php") {
@@ -27,8 +27,8 @@ function version_info($proname,$subver,$ver,$supver,$reltype,$svnver,$showsvn) {
        return $return_var; }
 // Version number and date stuff. :P
 $VER1[0] = 0; $VER1[1] = 4; $VER1[2] = 2; $VERFull[1] = $VER1[0].".".$VER1[1].".".$VER1[2];
-$VER2[0] = "Alpha"; $VER2[1] = "Al"; $VER2[2] = "SVN"; $SubVerN = 601; $RName = "iDB"; $SFName = "IntDB";
-$SVNDay[0] = 12; $SVNDay[1] = 08; $SVNDay[2] = 2010; $SVNDay[3] = $SVNDay[0]."/".$SVNDay[1]."/".$SVNDay[2];
+$VER2[0] = "Alpha"; $VER2[1] = "Al"; $VER2[2] = "SVN"; $SubVerN = 602; $RName = "iDB"; $SFName = "IntDB";
+$SVNDay[0] = 12; $SVNDay[1] = 15; $SVNDay[2] = 2010; $SVNDay[3] = $SVNDay[0]."/".$SVNDay[1]."/".$SVNDay[2];
 $VerInfo['iDB_Ver'] = version_info($RName,$VER1[0],$VER1[1],$VER1[2],$VER2[1],$SubVerN,false);
 $VerInfo['iDB_Ver_SVN'] = version_info($RName,$VER1[0],$VER1[1],$VER1[2],$VER2[1],$SubVerN,true);
 $VerInfo['iDB_Full_Ver'] = version_info($RName,$VER1[0],$VER1[1],$VER1[2],$VER2[0],$SubVerN,false);