|
PCCS MySQLDatabase Admin Tool version 1.3.4
|
/genapp/ -> webadmin_fm.php
1 <?php
2 // Found on freshmeat.net in the fm.zip archive 3 // 4
5 // updated 10-23-2000 6 // -- moving to a single file for global include files 7
8 require('../mysqldb_app_includes.php');
9
10 common_header($_title);
11
12 $thispath = system("pwd");
13 $webshare = $thispath . "/" . $dirprefix . $dbnamn;
14 ?>
15
16 <script language=javascript>
17 <!--
18 function submit(form) {
19 form.submit()
20 }
21 //--> 22 </script>
23
24 <?php
25
26 if (isset($exit)) { unset($edit); unset($upload); }
27
28 if (empty($pwd)) $pwd = "/";
29
30 if ($action == "upload") exec("cp $userfile $webshare$pwd$userfile_name");
31
32 $file = $webshare.$pwd.$fn;
33
34 function read_file($file) {
35
36 if (!($fp = fopen($file, 'r' ))) return false;
37
38 $contents = fread($fp, filesize($file));
39
40 fclose($fp);
41
42 return $contents;
43 }
44
45 function write_file($file, $contents) {
46
47 if ($fp = fopen($file, "w")) {
48
49 fputs($fp, $contents, strlen($contents));
50
51 fclose($fp);
52
53 return 1;
54
55 } else {
56
57 return 0;
58 }
59 }
60
61 //------------------------------------------------------------------------------------------------- 62
63 if ($copy) {
64
65 if ($action == "copy") {
66
67 exec("cp -R ".$webshare.$oldname." ".$webshare.$newname);
68
69 } else {
70
71 ?>
72 <table align=center border=2 cellspacing=0 cellpadding=3>
73 <tr>
74 <form name=copy method=post action=<?php echo $PHP_SELF; ?>>
75 <td>
76 <input type=hidden name=oldname value="<?php echo $pwd.$fn; ?>">
77 <input type=hidden name=action value=copy>
78 <input type=hidden name="pwd" value="<?php echo $pwd; ?>">
79 <font face=Verdana><small>Clipboard Contents: <?php echo $pwd.$fn; ?></small></font><br>
80 <input type=submit name="copy" value="Copy as:">
81 <input type=text size="56" name="newname" value="<?php echo $pwd.$fn; ?>"><br>
82 <input type=submit name="exit" value="Cancel"></td>
83 </form>
84 </tr>
85 </table><br><br>
86 <?php
87
88 }
89 }
90
91 //------------------------------------------------------------------------------------------------- 92
93 if ($move) {
94
95 if ($action == "move") {
96
97 exec("mv ".$webshare.$oldname." ".$webshare.$newname);
98
99 } else {
100
101 ?>
102 <table align=center bgcolor=#999999 border=2 cellspacing=0 cellpadding=3>
103 <tr>
104 <td>
105 <form name=move method=post action=<?php echo $PHP_SELF; ?>>
106 <input type=hidden name="pwd" value="<?php echo $pwd; ?>">
107 <font face=Verdana><small>Clipboard Contents: <?php echo $pwd.$fn; ?></small></font><br>
108 <input type=submit name="move" value="Move to:">
109 <input type=text size="56" name="newname" value="<?php echo $pwd.$fn; ?>"><br>
110 <input type=hidden name=oldname value="<?php echo $pwd.$fn; ?>">
111 <input type=hidden name=action value=move>
112 <input type=submit name="exit" value="Cancel"></td></form>
113 </tr>
114 </table><br><br>
115 <?php
116
117 }
118 }
119
120 //------------------------------------------------------------------------------------------------- 121
122 if ($rename) {
123
124 if ($action == "rename") {
125
126 exec("mv ".$webshare.$oldname." ".$webshare.$newname);
127
128 } else {
129
130 ?>
131 <table align=center bgcolor=#999999 border=2 cellspacing=0 cellpadding=3>
132 <tr>
133 <td>
134 <form name=move method=post action=<?php echo $PHP_SELF; ?>>
135 <input type=hidden name="pwd" value="<?php echo $pwd; ?>">
136 <font face=Verdana><small>Clipboard Contents: <?php echo $pwd.$fn; ?></small></font><br>
137 <input type=submit name="rename" value="Rename to:">
138 <input type=text size="56" name="newname" value="<?php echo $pwd.$fn; ?>"><br>
139 <input type=hidden name=oldname value="<?php echo $pwd.$fn; ?>">
140 <input type=hidden name=action value=rename>
141 <input type=submit name="exit" value="Cancel"></td></form>
142 </tr>
143 </table><br><br>
144 <?php
145
146 }
147 }
148
149 //------------------------------------------------------------------------------------------------- 150
151 if ($newfile) {
152
153 if (isset($fn)) {
154
155 write_file($file, "");
156
157 $edit = 1;
158
159 } else {
160
161 echo "You must specify a name for the file you wish to create.";
162 }
163
164 echo $result;
165
166 }
167
168 //------------------------------------------------------------------------------------------------- 169
170 if ($newdir) {
171
172 if (isset($newdirname)) {
173
174 exec("mkdir ".$webshare.$pwd.$newdirname);
175
176 } else {
177
178 echo "You must specify a name for the directory you wish to create.";
179 }
180
181 echo $result;
182 }
183
184 //------------------------------------------------------------------------------------------------- 185
186 if ($delete) {
187
188 if ($action == "delete") {
189
190 exec("rm -R $file");
191
192 } else {
193
194 ?>
195 <table align=center bgcolor=#999999 border=2 cellspacing=0 cellpadding=3>
196 <tr>
197 <td>
198 <form name=delete method=post action=<?php echo $PHP_SELF; ?>>
199 <font face=Verdana><small>Delete <?php echo $pwd.$fn; ?>?</small></font>
200 <input type=submit name="delete" value="Yes">
201 <input type=submit name="exit" value="No">
202 <input type=hidden name="pwd" value="<?php echo $pwd; ?>">
203 <input type=hidden name="fn" value="<?php echo $fn; ?>">
204 <input type=hidden name=action value=delete></td></form>
205 </tr>
206 </table><br><br>
207 <?php
208
209 }
210 }
211
212 //------------------------------------------------------------------------------------------------- 213
214 if (isset($edit)) {
215
216 if (!(isset($fn))) echo "No filename was specified.";
217
218 else {
219
220 if ($save) {
221
222 if ((isset($file)) && (isset($contents))) {
223
224 $contents = stripslashes($contents);
225
226 write_file($file, $contents);
227
228 } else {
229
230 echo "Error saving file to disk";
231 }
232 }
233 ?>
234 <table bgcolor="#999999" border=2 cellspacing=0 cellpadding=3 align=center>
235 <tr>
236 <td>Current File: <?php echo $fn; ?></td>
237 </tr>
238 <tr>
239 <td align=center>
240 <form method="post" action="<?php echo $PHP_SELF; ?>">
241 <textarea name="contents" cols=60 rows=20><?php $contents = read_file($webshare.$pwd.$fn); echo htmlentities($contents); ?></textarea><br>
242 <input type=submit name="save" value="Save">
243 <input type=submit name="exit" value="Exit">
244 <input type=hidden name="pwd" value="<?php echo $pwd; ?>">
245 <input type=hidden name="fn" value="<?php echo $fn; ?>">
246 <input type=hidden name="edit" value="Edit"></td></form>
247 </tr>
248 </table></form><br>
249 <?php
250
251 }
252 }
253
254 //------------------------------------------------------------------------------------------------- 255
256 exec("ls -l ".$webshare.$pwd, $result, $id);
257
258 $up_pwd = eregi_replace("/$", "", $pwd);
259
260 $up_pwd = eregi_replace("[_a-z0-9\.-]+$", "", $up_pwd);
261
262 echo "
263 <table align=center bgcolor=#FFFFFF border=2 cellspacing=1 cellpadding=3>
264 <tr>
265 <td><a href=../>MAIN</a> : WebAdmin FileManager Current
266 Directory: ".$pwd."</td>
267 </tr>
268 <tr>
269 <td>
270 <table>
271 <tr>
272 <td colspan=2><font face=Verdana><small>Folders:</small></font><td>
273 </tr>
274 <tr>
275 <td><form name=up action=$PHP_SELF method=post><input type=hidden name=pwd value=$up_pwd>
276 <img src=../images/dbfolder.gif border=0 alt=\"PHP Filemanager\"> </form></td>
277 <td><form method=post action=$PHP_SELF name=folders>
278 <select name=pwd>";
279 $i = 1;
280
281 while (isset($result[$i])) {
282
283 $result[$i] = eregi_replace(" +", ",", $result[$i]);
284
285 $line = explode(",", $result[$i]);
286
287 if (ereg("^d", $line[0])) {
288
289 echo "<option value=\"".$pwd.$line[8]."/\">".$line[8]."\n";
290 }
291
292 $i++;
293 }
294 ?>
295 </select>
296 <input type=submit value=">
297 <input type=submit name="move" value="Move">
298 <input type=submit name="copy" value="Copy">
299 <input type=submit name="delete" value="Delete">
300 <input type=submit name="rename" value="Rename">
301 </form></td>
302 </tr>
303
304
305 </table></td>
306 </tr>
307 <tr>
308 <td>
309 <form method=post action="<?php echo $PHP_SELF; ?>" name="files">
310 <font face=Verdana><small>Files:</small></font><br>
311 <select name=fn>
312 <?php
313
314 $i = 1;
315
316 while (isset($result[$i])) {
317
318 $result[$i] = eregi_replace(" +", ",", $result[$i]);
319
320 $line = explode(",", $result[$i]);
321
322 if (!(ereg("^d", $line[0]))) {
323
324 echo "<option value=\"".$line[8]."\">".$line[8]."\n";
325 }
326
327 $i++;
328 }
329 ?>
330 </select>
331 <input type=hidden name="pwd" value="<?php echo $pwd; ?>">
332 <input type=submit name="edit" value="Edit">
333 <input type=submit name="move" value="Move">
334 <input type=submit name="copy" value="Copy">
335 <input type=submit name="delete" value="Delete">
336 <input type=submit name="rename" value="Rename">
337 <input type=submit name="untargz" value="Untar.gz">
338 </form></td>
339 </tr>
340 <tr>
341 <td>
342 <table width=100%>
343 <tr>
344 <td width=50% nowrap>
345 <form method=post action="<?php echo $PHP_SELF; ?>" name="newfile">
346 <input type=hidden name="pwd" value="<?php echo $pwd; ?>">
347 <font face=Verdana><small>New File:</small></font><br>
348 <input type=text name=fn size=20 maxlength=100>
349 <input type=submit name=newfile value="Create">
350 </form></td>
351 <td width=50% nowrap>
352 <form method=post action="<?php echo $PHP_SELF; ?>" name="newfolder">
353 <input type=hidden name="pwd" value="<?php echo $pwd; ?>">
354 <font face=Verdana><small>New Folder:</small></font><br>
355 <input type=text name=newdirname size=20 maxlength=100>
356 <input type=submit name=newdir value="Create">
357 </form></td>
358 </tr>
359 </table></td>
360 </tr>
361 <tr>
362 <td>
363 <form method=post enctype="multipart/form-data" action=<?php echo $PHP_SELF; ?>>
364 <font face=Verdana><small>File Upload:</small></font><br>
365 <input type=hidden name="pwd" value=<?php echo $pwd; ?>>
366 <input type=hidden name="action" value=upload>
367 <input type=file name=userfile size=40>
368 <input name=upload value=" Upload " type=submit>
369 </form></td>
370 </tr>
371 </table>
372 <br>
373 <br>
374 <?
375
376 if ($untargz) {
377
378 if ($action == "untar") {
379 $cmd = "/bin/tar -xvzf " .$webshare.$pwd.$fn;
380 exec("$cmd") or die("Error Executing: $cmd$fn ");
381
382 } else {
383
384 ?>
385 <table align=center bgcolor=#999999 border=2 cellspacing=0 cellpadding=3>
386 <tr>
387 <td>
388 <form name=move method=post action=<?php echo $PHP_SELF; ?>>
389 <input type=hidden name="pwd" value="<?php echo $pwd; ?>">
390 <font face=Verdana><small>Clipboard Contents: <?php echo $fn; ?></small></font><br>
391 <input type=submit name="untargz" value="Untar to:">
392 <input type=text size="56" name="fn" value="<?php echo $fn; ?>"><br>
393
394 <input type=hidden name=action value=untar>
395 <input type=submit name="exit" value="Cancel"></td></form>
396 </tr>
397 </table><br><br>
398 <? }
399 } ?>
400
401
402 <?php
403
404 // include("footer.inc"); 405
406 ?>
| |