-
Notifications
You must be signed in to change notification settings - Fork 9
/
fileman-xml.php
executable file
·171 lines (156 loc) · 5.97 KB
/
fileman-xml.php
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/*
*
* Filecharger
* by Zarel of Novawave
* PHP XML AJAX reply
*
*/
$time = time();
if (isset($_REQUEST['frame']) && !isset($_REQUEST['d']))
{
?>
<!DOCTYPE html>
<html style="margin:0;padding:0;">
<head>
<title>Throbber</title>
<script type="text/javascript">
<!--
function load(l)
{ document.getElementById('loading').src = 'images/throbber'+(l?'-loading.gif':'.gif'); var limg = new Image(); limg.src = 'images/throbber-loading.gif';
}
//-->
</script>
</head>
<body style="margin:0;padding:0;" onload="load(0);parent.fmf_okay(1);">
<img id="loading" src="images/throbber-loading.gif" alt="" width="20" height="20" />
</body>
</html>
<?php
die();
}
include 'config.inc.php';
include 'fileman.lib.php';
if ($ftpmode)
include_once 'ftpsession.lib.php';
else
include_once 'session.lib.php';
//====================
// Frame
//====================
//if it's being used as a frame, we'll need to do some more stuff.
if (isset($_REQUEST['frame']))
{
if (isset($_POST['act'])) switch ($_POST['act'])
{
case 'textedit':
if (fm_iswritable($d))
{
if (!is_string($_POST['val']))
die('<!DOCTYPE html><script language="javascript">parent.fmf_error("Malformed request.");</script>');
if (strpos(fm_contents($d),"\r\n")===false)
$_POST['val'] = str_replace("\r\n","\n",$_POST['val']);
if (!fm_editfile($d, $_POST['val']))
{
fm_close();
die('<!DOCTYPE html><script language="javascript">parent.fmf_error("Cannot edit file \''.basename($d).'\'.");</script>');
}
}
else
die('<!DOCTYPE html><script language="javascript">parent.fmf_error("File \''.basename($d).'\' is not writable.");</script>');
}
// Written in HTML 5 because I'm too lazy to write XHTML
?>
<!DOCTYPE html>
<html style="margin:0;padding:0;">
<head>
<title>Throbber</title>
<script type="text/javascript">
<!--
function load(l)
{ document.getElementById('loading').src = 'images/throbber'+(l?'-loading.gif':'.gif'); var limg = new Image(); limg.src = 'images/throbber-loading.gif';
}
//-->
</script>
</head>
<body style="margin:0;padding:0;" onload="load(0);parent.fmf_okay(1);">
<img id="loading" src="images/throbber-loading.gif" alt="" width="20" height="20" />
</body>
</html>
<?php
die();
}
//====================
// Otherwise... GO!
//====================
// Deprecated. I'll probably never salvage this code, but
// it's here in case I ever need it again.
/*
header('Content-type: text/xml');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // disable IE caching
header('Last-Modified: '.gmdate("D, d M Y H:i:s").'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
echo '<?xml version="1.0" ?>';
?>
<fileman>
<s><?php echo $sess; ?></s>
<p><?php echo $preurl.$presub; ?></p><d><?php echo $d; ?></d>
<?
//====================
// Are we doing something?
//====================
if ($_POST['a'])
{
$act = $_POST['a'];
switch ($act)
{
case 'ren':
if (strpos($_POST['f1'],'/')!==false || strpos($_POST['f1'],'\\')!==false || strpos($_POST['f2'],'/')!==false || strpos($_POST['f2'],'\\')!==false) echo '<ferr>s</ferr>';
else fm_rename($fullpath.$_POST['f1'],$fullpath.$_POST['f2']);
break;
case 'del':
if (strpos($_POST['f1'],'/')!==false || strpos($_POST['f1'],'\\')!==false) echo '<ferr>s</ferr>';
else fm_fdelete($fullpath.$_POST['f1'],$fullpath.$_POST['f2']);
break;
case 'ndir':
if (strpos($_POST['f1'],'/')!==false || strpos($_POST['f1'],'\\')!==false) echo '<ferr>s</ferr>';
else fm_newdir($fullpath.$_POST['f1']);
break;
case 'nfile':
if (strpos($_POST['f1'],'/')!==false || strpos($_POST['f1'],'\\')!==false) echo '<ferr>s</ferr>';
else fm_newfile($fullpath.$_POST['f1']);
break;
default:
echo '<ferr>?</ferr>';
}
}
//====================
// All the stuff they need and some they don't for good measure
//====================
$dfile = fm_fileinfo($fullpath);
?>
<fl>
<cf><n><?=$dfile['name']?></n><id><?=$dfile['id']?></id><d><?=($dfile['isdir']?'1':'')?></d><s><?=$dfile['size']?></s><ts><?=$dfile['tsize']?></ts><m><?=$dfile['modified']?></m><tm><?=$dfile['tmodified']?></tm><p><?=$dfile['perms']?></p><e><?=$dfile['ext']?></e><i><?=$dfile['img']?></i><t><?=$dfile['type']?></t><ft><?=$dfile['ft']?></ft><ea><?=$dfile['extac']?></ea><vi><?=$dfile['isvimg']?></vi><is><? if ($dfile['imgsize']) echo '<w>'.$dfile['imgsize'][0].'</w><h>'.$dfile['imgsize'][1].'</h><t>'.$dfile['imgsize'][2].'</t>'; ?></is></cf>
<?php
$dfiles = fm_getdfiles($fullpath);
foreach ($dfiles as $dfile)
{
?>
<fi><n><?=$dfile['name']?></n><id><?=$dfile['id']?></id><d><?=($dfile['isdir']?'1':'')?></d><s><?=$dfile['size']?></s><ts><?=$dfile['tsize']?></ts><m><?=$dfile['modified']?></m><tm><?=$dfile['tmodified']?></tm><p><?=$dfile['perms']?></p><e><?=$dfile['ext']?></e><i><?=$dfile['img']?></i><t><?=$dfile['type']?></t><ft><?=$dfile['ft']?></ft><ea><?=$dfile['extac']?></ea><vi><?=$dfile['isvimg']?></vi><is><? if ($dfile['imgsize']) echo '<w>'.$dfile['imgsize'][0].'</w><h>'.$dfile['imgsize'][1].'</h><t>'.$dfile['imgsize'][2].'</t>'; ?></is></fi>
<?php
}
$dfiles = fm_getdfiles('cache/clip/');
fm_close();
foreach ($dfiles as $dfile)
{
?>
<ci><n><?=$dfile['name']?></n><id><?=$dfile['id']?></id><d><?=($dfile['isdir']?'1':'')?></d><s><?=$dfile['size']?></s><ts><?=$dfile['tsize']?></ts><m><?=$dfile['modified']?></m><tm><?=$dfile['tmodified']?></tm><p><?=$dfile['perms']?></p><e><?=$dfile['ext']?></e><i><?=$dfile['img']?></i><t><?=$dfile['type']?></t><ft><?=$dfile['ft']?></ft><ea><?=$dfile['extac']?></ea><vi><?=$dfile['isvimg']?></vi><is><? if ($dfile['imgsize']) echo '<w>'.$dfile['imgsize'][0].'</w><h>'.$dfile['imgsize'][1].'</h><t>'.$dfile['imgsize'][2].'</t>'; ?></is></ci>
<?php
}
?>
</fl>
</fileman>
<?php
*/
?>