Small update
[iDB.git] / inc / misc / compression.php
blobf5413df301e9da11b88d7bdafa16ca098a24b0cf
1 <?php
2 /*
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the Revised BSD License.
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 Revised BSD License for more details.
11 Copyright 2004-2019 iDB Support - https://idb.osdn.jp/support/category.php?act=view&id=1
12 Copyright 2004-2019 Game Maker 2k - https://idb.osdn.jp/support/category.php?act=view&id=2
13 GZip and Zlib by Jean-loup Gailly (compression) and Mark Adler (decompression) http://www.zlib.net/
14 BZip2 and libbzip2 by Julian Seward http://www.bzip.org/
16 $FileInfo: compression.php - Last Update: 08/02/2019 SVN 905 - Author: cooldude2k $
18 $File3Name = basename($_SERVER['SCRIPT_NAME']);
19 if ($File3Name=="compression.php"||$File3Name=="/compression.php") {
20 require('index.php');
21 exit(); }
22 //Check if zlib is loaded
23 if(extension_loaded("zlib")) {
24 function gunzip($infile, $outfile) {
25 $string = null;
26 $zp = gzopen($infile, "r");
27 while(!gzeof($zp))
28 $string .= gzread($zp, 4096);
29 gzclose($zp);
30 $fp = fopen($outfile, "w");
31 fwrite($fp, $string, strlen($string));
32 fclose($fp);
35 function gunzip2($infile, $outfile) {
36 $string = implode("", gzfile($infile));
37 $fp = fopen($outfile, "w");
38 fwrite($fp, $string, strlen($string));
39 fclose($fp);
41 function gzip($infile, $outfile, $param = 5) {
42 $fp = fopen($infile, "r");
43 $data = fread ($fp, filesize($infile));
44 fclose($fp);
45 $zp = gzopen($outfile, "w".$param);
46 gzwrite($zp, $data);
47 gzclose($zp);
48 } }
49 //Check if bz2 is loaded
50 if(extension_loaded("bz2")) {
51 function bzip($infile, $outfile) {
52 $fp = fopen($infile, "r");
53 $data = fread($fp, filesize($infile));
54 fclose($fp);
55 $zp = bzopen($outfile, "w");
56 bzwrite($zp, $data);
57 bzclose($zp);
60 function bunzip($infile, $outfile) {
61 $string = null;
62 $zp = bzopen($infile, "r");
63 while(!feof($zp))
64 $string .= bzread($zp, 4096);
65 bzclose($zp);
66 $fp = fopen($outfile, "w");
67 fwrite($fp, $string, strlen($string));
68 fclose($fp);
69 } }
70 //Check if zip is loaded
71 if(extension_loaded("zip")) {
72 /* Nothing for now... :P */ }
73 //Check if rar is loaded
74 if(extension_loaded("rar")) {
75 /* Nothing for now... :P */ }