Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PHP 5.3 and newer


## Usage
* Download unzipper.php and place it in the same directory as your .zip archive.
* Download unzipper.php and place it in the same directory as your .zip archive or place it in the root directory as unzipper.php file can scan all the directores in a filesystem.
* In Browser type URL to unzipper.php

### Archive unzipper
Expand All @@ -32,13 +32,13 @@ Beta version state, use at you own risk.
Released under GNU/GPL v3


## Screenshot
![Screenshot of unzipper](https://cloud.githubusercontent.com/assets/1136761/17080297/1bccbd60-512a-11e6-89cb-c6c112270154.png)
## Screenshot
![Screenshot of unzipper newer version](https://raw.githubusercontent.com/Chamuth/unzipper/master/images/unzipperscreenshot.png)


## Updates
Get latest code at https://github.com/ndeet/unzipper


## Credits
[See contributors on Github](https://github.com/ndeet/unzipper/graphs/contributors)
[See contributors on Github](https://github.com/ndeet/unzipper/graphs/contributors)
Binary file added images/unzipperscreenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
268 changes: 214 additions & 54 deletions unzipper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@
$timeend = microtime(TRUE);
$time = $timeend - $timestart;

function scanFiles($localdir)
{
$result = array();

foreach (scandir($localdir) as $file)
{
if ($file != "." && $file != ".."){
$filename = $localdir . "/" . $file;

if (is_dir($filename))
$result = array_merge($result, scanFiles($filename));
else
{
if (pathinfo($filename, PATHINFO_EXTENSION) === 'zip'
|| pathinfo($filename, PATHINFO_EXTENSION) === 'gz'
|| pathinfo($filename, PATHINFO_EXTENSION) === 'rar')
{
$result[] = $filename;
}
}
}
}

return $result;
}
/**
* Class Unzipper
*/
Expand All @@ -41,26 +66,16 @@ class Unzipper {
public $zipfiles = array();

public function __construct() {

//read directory and pick .zip and .gz files
if ($dh = opendir($this->localdir)) {
while (($file = readdir($dh)) !== FALSE) {
if (pathinfo($file, PATHINFO_EXTENSION) === 'zip'
|| pathinfo($file, PATHINFO_EXTENSION) === 'gz'
|| pathinfo($file, PATHINFO_EXTENSION) === 'rar'
) {
$this->zipfiles[] = $file;
}
}
closedir($dh);

$this->zipfiles = scanFiles($this->localdir);

if (!empty($this->zipfiles)) {
$GLOBALS['status'] = array('info' => '.zip or .gz or .rar files found, ready for extraction');
}
else {
$GLOBALS['status'] = array('info' => 'No .zip or .gz or rar files found. So only zipping functionality available.');
}
}

}

/**
Expand Down Expand Up @@ -292,6 +307,22 @@ public static function zipDir($sourcePath, $outZipPath) {
body {
font-family: Arial, sans-serif;
line-height: 150%;
width:50%;
background-color:#eee;
}

.container
{
position:absolute;
left:50%;
top:50%;
transform:translateX(-50%) translateY(-50%);
}

.status .small
{
float:right;
margin-right:20px;
}

label {
Expand All @@ -301,8 +332,13 @@ public static function zipDir($sourcePath, $outZipPath) {

fieldset {
border: 0;
background-color: #EEE;
margin: 10px 0 10px 0;
background-color: #FFF;
margin: 10px 0 25px 0;
border-radius:10px;
padding:10px 20px;
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);

transition:height 1s;
}

.select {
Expand All @@ -311,25 +347,45 @@ public static function zipDir($sourcePath, $outZipPath) {
}

.status {
margin: 0;
margin-bottom: 20px;
margin:0;
float:left;
padding: 10px;
font-size: 80%;
background: #EEE;
border: 1px dotted #DDD;
background: #FFF;
box-shadow: 0 -2px 1px dodgerblue;

position:fixed;
z-index:100;
bottom:0;
left:0;

width:100%;

animation: statusAnimation 1s;
}

@keyframes statusAnimation
{
0% { opacity: 0; transform:translateY(100%);}
100% {opacity: 1; transform:translateY(0%);}
}

.status-text
{
font-weight:bold;
}

.status--ERROR {
background-color: red;
color: white;
font-size: 120%;
font-size: 100%;
}

.status--SUCCESS {
background-color: green;
background-color: dodgerblue;
font-weight: bold;
color: white;
font-size: 120%
font-size: 100%;
}

.small {
Expand All @@ -339,66 +395,170 @@ public static function zipDir($sourcePath, $outZipPath) {

.version {
font-size: 80%;
text-align:center;
margin-top:20px;
color:gray
}

.form-field {
border: 1px solid #AAA;
padding: 8px;
width: 280px;
}
}

.info {
margin-top: 0;
margin-top: 7px;
font-size: 80%;
color: #777;
}

.submit {
background-color: #378de5;
background-color: dodgerblue;
border: 0;
color: #ffffff;
font-size: 15px;
border-radius:5px;
padding: 10px 24px;
margin: 20px 0 20px 0;
text-decoration: none;
font-weight:bold;
border:solid 2px dodgerblue;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

transition: background-color 1s, color 1s, box-shadow 1s;
}

.submit:hover {
background-color: #2c6db2;
color: dodgerblue;
background-color: #fff;
cursor: pointer;
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);

transition: background-color 250ms, color 250ms, box-shadow 500ms
}

h1
{
margin-bottom:25px;
}

input[type="text"]:focus,
select:focus,
textarea:focus,
button:focus {
outline: none;
border-color:dodgerblue;
border-width:1.5px;

transition: border 500ms;
}

input[type="text"],
select,
textarea
{

border-radius:5px;
margin-top:5px;
border-color:#AAA;
border-width:1.5px;
width: 100%;
box-sizing: border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing: border-box;


transition: border 500ms;
}

h1
{
text-transform:uppercase;
font-size:15px;
color:dodgerblue
}


@media screen and (max-width:1000px)
{
.container
{
width:90%;
}

.status .small
{
display:none;
}
}

@media screen and (max-height:768px)
{
.status
{
position:fixed;
width:auto;
bottom:20px;
left:20px;
height:20px;
border-radius:10px;

box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

animation: statusAnimation 1s;

border:solid 2px dodgerblue;

transition: width 500ms;
}

.status .small
{
display:none;
}


}
-->
</style>
</head>
<body>
<p class="status status--<?php echo strtoupper(key($GLOBALS['status'])); ?>">
Status: <?php echo reset($GLOBALS['status']); ?><br/>
<span class="small">Processing Time: <?php echo $time; ?> seconds</span>
</p>
<form action="" method="POST">
<fieldset>
<h1>Archive Unzipper</h1>
<label for="zipfile">Select .zip or .rar archive or .gz file you want to extract:</label>
<select name="zipfile" size="1" class="select">
<?php foreach ($unzipper->zipfiles as $zip) {
echo "<option>$zip</option>";
}
?>
</select>
<label for="extpath">Extraction path (optional):</label>
<input type="text" name="extpath" class="form-field" />
<p class="info">Enter extraction path without leading or trailing slashes (e.g. "mypath"). If left empty current directory will be used.</p>
<input type="submit" name="dounzip" class="submit" value="Unzip Archive"/>
</fieldset>

<fieldset>
<h1>Archive Zipper</h1>
<label for="zippath">Path that should be zipped (optional):</label>
<input type="text" name="zippath" class="form-field" />
<p class="info">Enter path to be zipped without leading or trailing slashes (e.g. "zippath"). If left empty current directory will be used.</p>
<input type="submit" name="dozip" class="submit" value="Zip Archive"/>
</fieldset>
</form>
<p class="version">Unzipper version: <?php echo VERSION; ?></p>
<span class="status-text">Status: <?php echo reset($GLOBALS['status']); ?></span>
<span class="small">Processing Time: <?= round($time, 5, PHP_ROUND_HALF_EVEN)?> seconds</span>
</p>
<div class="container">

<form action="" method="POST">
<fieldset>
<h1>Archive Unzipper</h1>
<label for="zipfile">Select .zip or .rar archive or .gz file you want to extract:</label>
<select name="zipfile" size="1" class="select">
<?php if (!empty($unzipper->zipfiles)) { ?>
<?php foreach ($unzipper->zipfiles as $zip) {
echo "<option>$zip</option>";
}
}else{
?><option value="" disabled selected>No archives found</option>
<?php
}
?>
</select>
<label for="extpath">Extraction path (optional):</label>
<input type="text" name="extpath" class="form-field" />
<p class="info">Enter extraction path without leading or trailing slashes (e.g. "mypath"). If left empty current directory will be used.</p>
<input type="submit" name="dounzip" class="submit" value="Unzip Archive"/>
</fieldset>

<fieldset>
<h1>Archive Zipper</h1>
<label for="zippath">Path that should be zipped (optional):</label>
<input type="text" name="zippath" class="form-field" />
<p class="info">Enter path to be zipped without leading or trailing slashes (e.g. "zippath"). If left empty current directory will be used.</p>
<input type="submit" name="dozip" class="submit" value="Zip Archive"/>
</fieldset>
</form>
<p class="version">Unzipper version: <?php echo VERSION; ?></p>
</div>
</body>
</html>