ZIP Extractor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Khilaf Zip Extractor</title>
<meta name="robots" content="noindex,nofollow">
<body>
<div style="text-align:center; font-family:verdana; font-size:12px; margin-top:20px;">
<div style="text-align:center; font-weight:bold; padding:15px; background:#eee; font-size:14px;"><a href="zipextractor.php" style="color:#666;">Khilaf Zip Extractor</a></div>
<?php
if(!class_exists('ZipArchive')) {
echo 'It seems that Zip extension support is not enabled in your hosting! <br> Zip extension is enabled at <a href="http://www.ppc-sites.com/hostgator.php">Hostgator</a> ;)';
} else {
$this_dir = dirname(__FILE__);
if(!empty($_POST) && $_POST['extract'] == 'true' && !empty($_POST['zipfile']) && !empty($_POST['extractto'])) {
if(!is_dir($_POST['extractto'])) {
mkdir_recursive($_POST['extractto']);
}
$get_zip_file = $_POST['fullpath'] == 'true' ? $_POST['zipfile'] : $this_dir . '/' . $_POST['zipfile'];
if(zipExtract ($get_zip_file, $_POST['extractto'])) {
echo '<br><br><span style="color:green;font-weight:bold;">Zip content extracted successfully!</span><br><br>';
echo '<span style="font-size:14px;font-weight:bold;"><span style="color:red;">IMPORTANT:</span> Delete <span style="color:blue;">zipextractor.php</span> and <span style="color:blue;">' . $_POST['zipfile'] . '</span>!</span>';
} else {
echo "Failed extracting the zip content!<br>";
}
} else {
$autofound = false;
if($handle = opendir($this_dir) ) {
echo "<p><b>List of auto detected .zip archives!</b></p>";
while(false !== ($file = readdir($handle))){
if( isZip($file) ) {
$autofound = true;
echo '<form action="zipextractor.php" method="POST">';
echo '<input type="hidden" name="zipfile" value="' . $file . '">';
echo '<input type="hidden" name="extract" value="true">';
echo '<input type="hidden" name="fullpath" value="false">';
echo '<b>' . $file . '</b> &nbsp; <i>Extract to:</i><input type="text" name="extractto" size="50" value="' .$this_dir. '"> <input type="submit" value="Extract">';
echo '</form><br>';
}
}
}
if(!$autofound) {
echo '<p><i><span style="color:#666;">Not found and .zip archives in <b>' . $this_dir .'</b>. Please select manually your archives full path!</span></i></p>';
echo '<form action="zipextractor.php" method="POST">';
echo '<input type="hidden" name="extract" value="true">';
echo '<input type="hidden" name="fullpath" value="true">';
echo 'Zip Filename Full Path: <input type="text" name = "zipfile" size="50" > &nbsp; &nbsp; <i>Extract to:</i><input type="text" name="extractto" size="50" value="' .$this_dir. '"> <input type="submit" value="Extract">';
echo '</form><br>';
}
}
}
function zipExtract ($src, $dest)
{
$zip = new ZipArchive();
if ($zip->open($src)===true)
{
$zip->extractTo($dest);
$zip->close();
return true;
}
return false;
}
function isZip ($src)
{
$get_ext = strrchr(strtolower($src), '.');
$allowed_ext = array('.zip');
if(in_array($get_ext, $allowed_ext)) {
return true;
} else {
return false;
}
}
function mkdir_recursive($pathname)
{
is_dir(dirname($pathname)) || mkdir_recursive(dirname($pathname));
return is_dir($pathname) || @mkdir($pathname);
}
?>
<div style="text-align:center; font-weight:normal; padding:5px; background:#eee; font-size:12px; margin-top:10px">Copyr<a href="http://kantongkresek073.blogspot.com/" style="color:#666;">i</a>ght &copy; <a href="http://kantongkresek073.blogspot.com/" style="color:#666;">BLOG</a> | <a href="http://fb.com/myutermyutherr" style="color:#666;">find us 0n FB</a> | <a href="http://twitter.com/simod_v2" style="color:#666;">find us 0n Twitter</a> | <a href="http://fb.com/myutermyutherr" style="color:#666;">Support</a></div>
</div>
</body>
</html>