Skip to content
This repository was archived by the owner on May 5, 2022. It is now read-only.

Commit 4dfc8d3

Browse files
adding session
1 parent 4542a63 commit 4dfc8d3

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

index.php

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,32 @@
33
* The Unzipper extracts .zip or .rar archives and .gz files on webservers.
44
* It's handy if you do not have shell access. E.g. if you want to upload a lot
55
* of files (php framework or image collection) as an archive to save time.
6-
* As of version 0.1.0 it also supports creating archives.
76
*
87
* @author Andreas Tasch, at[tec], attec.at; Stefan Boguth, Boguth.org
98
* @license GNU GPL v3
10-
* @version 0.2.4
9+
* @version 0.2.8
1110
*/
12-
define('VERSION', '0.2.4');
13-
$GLOBALS['status'] = array();
11+
define('VERSION', '0.2.8');
12+
1413
include 'resources/classes/unzip.php';
15-
$unzipper = new Unzipper;
14+
$unzipper = new Unzipper();
15+
session_start();
16+
$_SESSION['status'] = array();
17+
$_SESSION['status'] = array('info' => 'Zippy erfolgreich gestartet. Bereit für weitere Aufgaben.');
1618

1719
if (isset($_POST['dounzip'])) {
18-
$postcont = "unzip";
20+
$postcont = 'unzip';
1921
}
2022
if (isset($_POST['dozip'])) {
21-
$postcont = "zip";
23+
$postcont = 'zip';
2224
}
2325
if (isset($_POST['upload'])) {
24-
$postcont = "upload";
26+
$postcont = 'upload';
2527
}
2628
if (isset($_POST['explorer'])) {
27-
$postcont = "explorer";
29+
$postcont = 'explorer';
2830
} else {
29-
$setexp = false;
31+
$setexp = false;
3032
}
3133

3234
switch ($postcont) {
@@ -38,18 +40,15 @@
3840
include 'resources/classes/explorer.php';
3941
$exppath = !empty($_POST['exppath']) ? strip_tags($_POST['exppath']) : '.';
4042
$setexp = true;
41-
if (!empty($_POST['exppath'])) {
42-
$GLOBALS['status'] = array('success' => 'Verzeichnis erfolgreich geöffnet.');
43-
}
44-
else {
45-
$GLOBALS['status'] = array('error' => 'Kein Pfad angegeben!');
43+
if (empty($_POST['exppath'])) {
44+
$_SESSION['status'] = array('error' => 'Kein Pfad angegeben!');
4645
}
4746
break;
4847
case zip:
4948
include 'resources/classes/zipper.php';
5049
$zippath = !empty($_POST['zippath']) ? strip_tags($_POST['zippath']) : '.';
5150
// Resulting zipfile e.g. zipper--2016-07-23--11-55.zip
52-
$zipfile = 'zipper-' . date("Y-m-d--H-i") . '.zip';
51+
$zipfile = 'zipper-'.date('Y-m-d--H-i').'.zip';
5352
Zipper::zipDir($zippath, $zipfile);
5453
break;
5554
case unzip:
@@ -87,8 +86,8 @@
8786
<body>
8887
<div class="animated zoomIn wrapper">
8988
<div class="innerwrapper">
90-
<p class="status status--<?php echo strtoupper(key($GLOBALS['status'])); ?>">
91-
<b>Status:</b> <?php echo reset($GLOBALS['status']); ?><br/>
89+
<p class="status status--<?php echo strtoupper(key($_SESSION['status'])); ?>">
90+
<b>Status:</b> <?php echo reset($_SESSION['status']); ?><br/>
9291
</p>
9392
<div id="logo">
9493
<img src="resources/gfx/logo.png" alt="Logo" />
@@ -100,13 +99,13 @@
10099
<label for="zipfile">Wählen Sie ein .rar, .zip oder .gz-Archiv das sie entpacken wollen:</label>
101100
<select name="zipfile" size="1" class="select">
102101
<?php foreach ($unzipper->zipfiles as $zip) {
103-
echo "<option>$zip</option>";
104-
}
102+
echo "<option>$zip</option>";
103+
}
105104
?>
106105
</select>
107106
<?php if (count($unzipper->zipfiles) == 0) {
108-
echo "<b>Keine Dateien zum entpacken vorhanden!</b>";
109-
};
107+
echo '<b>Keine Dateien zum entpacken vorhanden!</b>';
108+
}
110109
?>
111110
<p class="info">Die zu entpackenden Archive müssen sich in folgendem Pfad befinden: <?php echo __DIR__ ?></p>
112111
<label for="extpath">Pfad zum Entpacken (Optional):</label>
@@ -133,42 +132,38 @@
133132
<label for="uploader">Hochzuladende Datei:</label>
134133
<input type="file" name="uploaded" class="form-field" id="fileinput" />
135134
<output id="list"></output>
136-
<p class="info">Der Uploader benötigt Schreibrechte im Verzeichnis! Die Dateien werden in den Pfad Upload verschoben.<br> <b>Der Uploader akzeptiert nur .rar, .zip und .gz-Dateien mit maximal 10MB.</b></p>
135+
<p class="info">Der Uploader benötigt Schreibrechte im Verzeichnis! Die Dateien werden in den Pfad Upload verschoben.<br> <b>Der Uploader akzeptiert nur .rar, .zip und .gz-Dateien mit maximal <?php echo ("<span id='maxsize' value='" . ini_get('upload_max_filesize') . "'</span>" . ini_get('upload_max_filesize') . "B.") ?></b></p>
137136
<input type="submit" name="upload" class="submit" value="Hochladen" id="uploadclick"/>
138-
139137
</div>
140138
</fieldset>
141139
</form>
142140
<form action="" method="POST">
143141
<fieldset class="field">
144-
<h1>Datei-Explorer (beta)</h1><div class="<?php
145-
if($setexp == true) {
146-
echo ('icon icon-up');
147-
}
148-
else {
149-
echo ('icon');
142+
<h1>Datei-Explorer (alpha)</h1><div class="<?php
143+
if ($setexp == true) {
144+
echo 'icon icon-up';
145+
} else {
146+
echo 'icon';
150147
} ?>"></div>
151148
<div class="innercont<?php
152-
if($setexp == true) {
153-
echo ('');
154-
}
155-
else {
156-
echo (' hide');
149+
if ($setexp == true) {
150+
echo '';
151+
} else {
152+
echo ' hide';
157153
} ?> animated fadeIn">
158154
<label for="exppath">Anzuzeigender Pfad:</label>
159155
<input type="text" name="exppath" class="form-field" />
160156
<p class="info">Sie navigieren vom Verzeichnis des Scriptes aus, verwenden sie also z.B. ../ um eine Ebene höher zu springen.</p>
161157
<input type="submit" name="explorer" class="submit" value="Anzeigen"/>
162158
<?php
163159
if ($setexp == true && strlen($exppath) > 1) {
164-
echo ("<p>Geöffneter Pfad: " . $exppath . " </p>");
165-
Explorer::createExplorer($exppath);
160+
echo '<p>Geöffneter Pfad: '.$exppath.' </p>';
161+
Explorer::createExplorer($exppath);
166162
}
167163
?>
168164
</div>
169165
</fieldset>
170166
</form>
171-
172167
<p class="version">Unzipper Version: <?php echo VERSION; ?></p>
173168
</div>
174169
</div>

0 commit comments

Comments
 (0)