-<?php\r
-/*\r
- This program is free software; you can redistribute it and/or modify\r
- it under the terms of the Revised BSD License.\r
- \r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- Revised BSD License for more details.\r
- \r
- Copyright 2004-2012 iDB Support - http://idb.berlios.de/\r
- Copyright 2004-2012 Game Maker 2k - http://gamemaker2k.org/\r
- iUnTar ver. 4.7 by Kazuki Przyborowski & Josep Sanz Campderros\r
-\r
- $FileInfo: iuntar.php - Last Update: 12/30/2011 SVN 781 - Author: cooldude2k $\r
-*/\r
-$File3Name = basename($_SERVER['SCRIPT_NAME']);\r
-if ($File3Name=="iuntar.php"||$File3Name=="/iuntar.php") {\r
- require('index.php');\r
- exit(); }\r
-\r
-// PHP iUnTAR Version 4.7\r
-// license: Revised BSD license\r
-// Kazuki Przyborowski (http://ja.gamemaker2k.org/)\r
-// Josep Sanz Campderros (http://saltos.net/)\r
-function untar($tarfile,$outdir="./",$chmod=null,$extract=true,$lsonly=false,$findfile=null) {\r
-$TarSize = filesize($tarfile);\r
-$TarSizeEnd = $TarSize - 1024;\r
-if($extract!==true&&$extract!==false) {\r
- $extract = false; }\r
-if($lsonly!==true&&$lsonly!==false) {\r
- $lsonly = false; }\r
-if($extract===true) { \r
- $lsonly = false; }\r
-if($extract===true) {\r
-if($outdir!=""&&!file_exists($outdir)) {\r
- mkdir($outdir,0777); } }\r
-$thandle = fopen($tarfile, "rb");\r
-$i = 0;\r
-if($extract===false) {\r
- $FileArray = null; $i = 0; }\r
-$outdir = preg_replace('{/$}', '', $outdir)."/";\r
-if(isset($findfile)) {\r
-$qfindfile = preg_quote($findfile,"/"); }\r
-if(!isset($findfile)) {\r
-$qfindfile = null; }\r
-while (ftell($thandle)<$TarSizeEnd) {\r
- $FileName = null;\r
- $FileMode = null;\r
- $OwnerID = null;\r
- $GroupID = null;\r
- $FileSize = null;\r
- $LastEdit = null;\r
- $Checksum = null;\r
- $FileType = null;\r
- $LinkedFile = null;\r
- $FileContent = null;\r
- $FileName = $outdir.trim(fread($thandle,100));\r
- fseek($thandle,56,SEEK_CUR);\r
- $FileType = trim(fread($thandle,1));\r
- fseek($thandle,-57,SEEK_CUR);\r
- if($findfile!==null&&$FileType!="L"&&!preg_match("/".$qfindfile."/",$FileName)) {\r
- fseek($thandle,8,SEEK_CUR);\r
- fseek($thandle,8,SEEK_CUR);\r
- fseek($thandle,8,SEEK_CUR);\r
- $FileSize = octdec(trim(fread($thandle,12)));\r
- fseek($thandle,12,SEEK_CUR);\r
- fseek($thandle,8,SEEK_CUR);\r
- $FileType = trim(fread($thandle,1));\r
- fseek($thandle,100,SEEK_CUR);\r
- fseek($thandle,255,SEEK_CUR); \r
- if($FileType=="0"||$FileType=="7") {\r
- fseek($thandle,$FileSize,SEEK_CUR); } }\r
- if($findfile===null||$FileType=="L"||preg_match("/".$qfindfile."/",$FileName)) {\r
- $FileMode = trim(fread($thandle,8));\r
- if($chmod===null) {\r
- $FileCHMOD = octdec("0".substr($FileMode,-3)); }\r
- if($chmod!==null) {\r
- $FileCHMOD = $chmod; }\r
- $OwnerID = trim(fread($thandle,8));\r
- $GroupID = trim(fread($thandle,8));\r
- $FileSize = octdec(trim(fread($thandle,12)));\r
- $LastEdit = octdec(trim(fread($thandle,12)));\r
- $Checksum = octdec(trim(fread($thandle,8)));\r
- $FileType = trim(fread($thandle,1));\r
- $LinkedFile = trim(fread($thandle,100));\r
- fseek($thandle,255,SEEK_CUR); \r
- // LongLink support added by Josep Sanz Campderros\r
- if($FileType=="L"&&$FileSize>0) {\r
- $FileName = $outdir.trim(fread($thandle,$FileSize));\r
- fseek($thandle,512-$FileSize,SEEK_CUR);\r
- fseek($thandle,100,SEEK_CUR);\r
- $FileMode = trim(fread($thandle,8));\r
- if($chmod===null) {\r
- $FileCHMOD = octdec("0".substr($FileMode,-3)); }\r
- if($chmod!==null) {\r
- $FileCHMOD = $chmod; }\r
- $OwnerID = trim(fread($thandle,8));\r
- $GroupID = trim(fread($thandle,8));\r
- $FileSize = octdec(trim(fread($thandle,12)));\r
- $LastEdit = trim(fread($thandle,12));\r
- $Checksum = trim(fread($thandle,8));\r
- $FileType = trim(fread($thandle,1));\r
- $LinkedFile = trim(fread($thandle,100));\r
- fseek($thandle,255,SEEK_CUR); } }\r
- if($findfile===null||preg_match("/".$qfindfile."/",$FileName)) {\r
- if($FileType=="0"||$FileType=="7") {\r
- if($lsonly===true) {\r
- fseek($thandle,$FileSize,SEEK_CUR); }\r
- if($lsonly===false) {\r
- // Empty files support added by Josep Sanz Campderros\r
- if($FileSize===0) {\r
- $FileContent = ""; }\r
- if($FileSize>0) {\r
- $FileContent = fread($thandle,$FileSize); } } }\r
- if($FileType=="1") {\r
- $FileContent = null; }\r
- if($FileType=="2") {\r
- $FileContent = null; }\r
- if($FileType=="5") {\r
- $FileContent = null; }\r
- if($FileType=="0"||$FileType=="7") {\r
- if($extract===true) {\r
- $subhandle = fopen($FileName, "wb+");\r
- fwrite($subhandle,$FileContent,$FileSize);\r
- fclose($subhandle);\r
- chmod($FileName,$FileCHMOD); } }\r
- if($FileType=="1") {\r
- if($extract===true) {\r
- link($FileName,$LinkedFile); } }\r
- if($FileType=="2") {\r
- if($extract===true) {\r
- symlink($LinkedFile,$FileName); } }\r
- if($FileType=="5") {\r
- if($extract===true) {\r
- mkdir($FileName,$FileCHMOD); } }\r
- if($FileType=="0"||$FileType=="1"||$FileType=="2"||$FileType=="5"||$FileType=="7") {\r
- if($extract===false) { \r
- $FileArray[$i]['FileName'] = $FileName;\r
- $FileArray[$i]['FileMode'] = $FileMode;\r
- $FileArray[$i]['OwnerID'] = $OwnerID;\r
- $FileArray[$i]['GroupID'] = $GroupID;\r
- $FileArray[$i]['FileSize'] = $FileSize;\r
- $FileArray[$i]['LastEdit'] = $LastEdit;\r
- $FileArray[$i]['Checksum'] = $Checksum;\r
- $FileArray[$i]['FileType'] = $FileType;\r
- $FileArray[$i]['LinkedFile'] = $LinkedFile;\r
- if($lsonly===false) {\r
- $FileArray[$i]['FileContent'] = $FileContent; } } } }\r
- //touch($FileName,$LastEdit);\r
- if($extract===false&&$findfile===null&&isset($FileArray[$i]['FileName'])) { ++$i; }\r
- if($extract===false) {\r
- if($findfile!==null&&preg_match("/".$qfindfile."/",$FileName)&&isset($FileArray[$i]['FileName'])) { ++$i; } }\r
- if($extract===true) {\r
- if($findfile!==null&&preg_match("/".$qfindfile."/",$FileName)) { ++$i; } }\r
- if(($FileType=="0"||$FileType=="7")&$FileSize>0) {\r
- $CheckSize = 512;\r
- while ($CheckSize<$FileSize) {\r
- if($CheckSize<$FileSize) {\r
- $CheckSize = $CheckSize + 512; } }\r
- $SeekSize = $CheckSize - $FileSize;\r
- fseek($thandle,$SeekSize,SEEK_CUR); } }\r
- fclose($thandle);\r
- if($extract===true) {\r
- return true; }\r
- if($extract===false) {\r
- return $FileArray; } }\r
-function iuntar($tarfile,$outdir="./",$chmod=null,$extract=true,$lsonly=false,$findfile=null) {\r
- return untar($tarfile,$outdir,$chmod,$extract,$lsonly,$findfile); }\r
+<?php
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the Revised BSD License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Revised BSD License for more details.
+
+ Copyright 2004-2012 iDB Support - http://idb.berlios.de/
+ Copyright 2004-2012 Game Maker 2k - http://gamemaker2k.org/
+ iUnTar ver. 4.7 by Kazuki Przyborowski & Josep Sanz Campderros
+
+ $FileInfo: iuntar.php - Last Update: 07/04/2012 SVN 786 - Author: cooldude2k $
+*/
+$File3Name = basename($_SERVER['SCRIPT_NAME']);
+if ($File3Name=="iuntar.php"||$File3Name=="/iuntar.php") {
+ require('index.php');
+ exit(); }
+
+// PHP iUnTAR Version 4.7
+// license: Revised BSD license
+// Kazuki Przyborowski (http://ja.gamemaker2k.org/)
+// Josep Sanz Campderros (http://saltos.net/)
+function untar($tarfile,$outdir="./",$chmod=null,$extract=true,$lsonly=false,$findfile=null) {
+$TarSize = filesize($tarfile);
+$TarSizeEnd = $TarSize - 1024;
+if($extract!==true&&$extract!==false) {
+ $extract = false; }
+if($lsonly!==true&&$lsonly!==false) {
+ $lsonly = false; }
+if($extract===true) {
+ $lsonly = false; }
+if($extract===true) {
+if($outdir!=""&&!file_exists($outdir)) {
+ mkdir($outdir,0777); } }
+$thandle = fopen($tarfile, "rb");
+$i = 0;
+if($extract===false) {
+ $FileArray = null; $i = 0; }
+$outdir = preg_replace('{/$}', '', $outdir)."/";
+if(isset($findfile)) {
+$qfindfile = preg_quote($findfile,"/"); }
+if(!isset($findfile)) {
+$qfindfile = null; }
+while (ftell($thandle)<$TarSizeEnd) {
+ $FileName = null;
+ $FileMode = null;
+ $OwnerID = null;
+ $GroupID = null;
+ $FileSize = null;
+ $LastEdit = null;
+ $Checksum = null;
+ $FileType = null;
+ $LinkedFile = null;
+ $FileContent = null;
+ $FileName = $outdir.trim(fread($thandle,100));
+ fseek($thandle,56,SEEK_CUR);
+ $FileType = trim(fread($thandle,1));
+ fseek($thandle,-57,SEEK_CUR);
+ if($findfile!==null&&$FileType!="L"&&!preg_match("/".$qfindfile."/",$FileName)) {
+ fseek($thandle,8,SEEK_CUR);
+ fseek($thandle,8,SEEK_CUR);
+ fseek($thandle,8,SEEK_CUR);
+ $FileSize = octdec(trim(fread($thandle,12)));
+ fseek($thandle,12,SEEK_CUR);
+ fseek($thandle,8,SEEK_CUR);
+ $FileType = trim(fread($thandle,1));
+ fseek($thandle,100,SEEK_CUR);
+ fseek($thandle,255,SEEK_CUR);
+ if($FileType=="0"||$FileType=="7") {
+ fseek($thandle,$FileSize,SEEK_CUR); } }
+ if($findfile===null||$FileType=="L"||preg_match("/".$qfindfile."/",$FileName)) {
+ $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 = octdec(trim(fread($thandle,12)));
+ $Checksum = octdec(trim(fread($thandle,8)));
+ $FileType = trim(fread($thandle,1));
+ $LinkedFile = trim(fread($thandle,100));
+ fseek($thandle,255,SEEK_CUR);
+ // LongLink support added by Josep Sanz Campderros
+ if($FileType=="L"&&$FileSize>0) {
+ $FileName = $outdir.trim(fread($thandle,$FileSize));
+ fseek($thandle,512-$FileSize,SEEK_CUR);
+ fseek($thandle,100,SEEK_CUR);
+ $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($findfile===null||preg_match("/".$qfindfile."/",$FileName)) {
+ if($FileType=="0"||$FileType=="7") {
+ if($lsonly===true) {
+ fseek($thandle,$FileSize,SEEK_CUR); }
+ if($lsonly===false) {
+ // Empty files support added by Josep Sanz Campderros
+ if($FileSize===0) {
+ $FileContent = ""; }
+ if($FileSize>0) {
+ $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, "wb+");
+ fwrite($subhandle,$FileContent,$FileSize);
+ fclose($subhandle);
+ chmod($FileName,$FileCHMOD); } }
+ if($FileType=="1") {
+ if($extract===true) {
+ link($FileName,$LinkedFile); } }
+ if($FileType=="2") {
+ if($extract===true) {
+ symlink($LinkedFile,$FileName); } }
+ if($FileType=="5") {
+ if($extract===true) {
+ mkdir($FileName,$FileCHMOD); } }
+ if($FileType=="0"||$FileType=="1"||$FileType=="2"||$FileType=="5"||$FileType=="7") {
+ 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;
+ if($lsonly===false) {
+ $FileArray[$i]['FileContent'] = $FileContent; } } } }
+ //touch($FileName,$LastEdit);
+ if($extract===false&&$findfile===null&&isset($FileArray[$i]['FileName'])) { ++$i; }
+ if($extract===false) {
+ if($findfile!==null&&preg_match("/".$qfindfile."/",$FileName)&&isset($FileArray[$i]['FileName'])) { ++$i; } }
+ if($extract===true) {
+ if($findfile!==null&&preg_match("/".$qfindfile."/",$FileName)) { ++$i; } }
+ if(($FileType=="0"||$FileType=="7")&$FileSize>0) {
+ $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; } }
+function iuntar($tarfile,$outdir="./",$chmod=null,$extract=true,$lsonly=false,$findfile=null) {
+ return untar($tarfile,$outdir,$chmod,$extract,$lsonly,$findfile); }
?>
\ No newline at end of file