diff --git a/README.md b/README.md index 8b98e7e..da64884 100644 --- a/README.md +++ b/README.md @@ -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 @@ -32,8 +32,8 @@ Beta version state, use at you own risk. Released under GNU/GPL v3 -## Screenshot - +## Screenshot + ## Updates @@ -41,4 +41,4 @@ Get latest code at https://github.com/ndeet/unzipper ## Credits -[See contributors on Github](https://github.com/ndeet/unzipper/graphs/contributors) \ No newline at end of file +[See contributors on Github](https://github.com/ndeet/unzipper/graphs/contributors) diff --git a/images/unzipperscreenshot.png b/images/unzipperscreenshot.png new file mode 100644 index 0000000..b123838 Binary files /dev/null and b/images/unzipperscreenshot.png differ diff --git a/unzipper.php b/unzipper.php index f7a19b2..0ca1b2d 100644 --- a/unzipper.php +++ b/unzipper.php @@ -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 */ @@ -41,18 +66,8 @@ 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'); @@ -60,7 +75,7 @@ public function __construct() { else { $GLOBALS['status'] = array('info' => 'No .zip or .gz or rar files found. So only zipping functionality available.'); } - } + } /** @@ -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 { @@ -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 { @@ -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 { @@ -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; + } + + } -->
- Status:
- Processing Time: seconds
-
Unzipper version:
+ Status: + Processing Time: = round($time, 5, PHP_ROUND_HALF_EVEN)?> seconds + +Unzipper version:
+