-
Notifications
You must be signed in to change notification settings - Fork 0
/
browse.php
539 lines (531 loc) · 26.8 KB
/
browse.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
<?php
# +--------------------------------------------------------------------+
# | phpEasyVCS |
# | The file-based version control system |
# +--------------------------------------------------------------------+
# | Copyright (c) 2011 Martin Vlcek |
# | License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) |
# +--------------------------------------------------------------------+
require_once('inc/basic.php');
require_once('inc/template.php');
require_once('inc/filetype.class.php');
$dir = sanitizeDir(@$_REQUEST['dir']);
$vcs = new FileVCS(DATAPATH, @$_REQUEST['tag'], getUserName(), isReadOnly());
$tag = $vcs->getTag();
$tagname = $tag && $tag->name ? $tag->name : ($tag ? $_REQUEST['tag'] : null);
$v = @filemtime(ROOTPATH.'applet/vcsapplet.jar');
$uri = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === "on" ? "https" : "http";
$uri .= "://".$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"];
$uri = substr($uri,0,strlen($uri)-10) . 'rest.php/current';
template_header();
if (is_dir(DATAPATH.$dir)) {
$showdeleted = @$_REQUEST['all'] ? true : false;
$listing = $vcs->getListing($dir, $showdeleted);
$currlink = 'browse.php?'.($tagname ? 'tag='.urlencode($tagname).'&' : '').'dir='.urlencode($listing->dir);
if (!$listing->dir) {
$uplink = 'tags.php';
} else {
$updir = substr($listing->dir,0,strlen($listing->dir)-1);
$pos = strrpos($updir,'/');
$updir = $pos !== false ? substr($dir,0,$pos) : '';
$uplink = 'browse.php?'.($tagname ? 'tag='.urlencode($tagname).'&' : '').'dir='.urlencode($updir);
}
$tagtext = '';
if ($tag && $tag->date) $tagtext .= ' <span>at</span> <span class="date">'.timestamp2string($tag->date).'</span>';
if ($tag && $vcs->getTag($tag->name)) $tagtext .= ' ('.htmlspecialchars($tag->name).')';
$names = array();
if (@$_REQUEST['name'] && is_array($_REQUEST['name'])) {
foreach ($_REQUEST['name'] as $name) $names[] = sanitizeName($name);
}
?>
<ul class="actions">
<li><a href="<?php echo $currlink; ?>">Refresh</a></li>
<?php if (!@$tag && !isReadOnly()) { ?>
<li><a href="<?php echo $currlink; ?>&addfolder" class="addfolder">Create folder</a></li>
<li><a href="<?php echo $currlink; ?>&addfile" class="addfile">Upload file</a></li>
<?php } ?>
<?php if (false && !@$tag) { ?>
<li><a href="sync.php?dir=<?php echo htmlspecialchars($dir); ?>" class="sync">Synchronize</a></li>
<?php } ?>
</ul>
<h2>Directory /<?php echo htmlspecialchars(substr($dir,0,-1)); ?> <?php echo $tagtext; ?></h2>
<form action="action.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="dir" value="<?php echo htmlspecialchars($dir); ?>" />
<input type="hidden" name="tag" value="<?php echo isset($_REQUEST['tag']) ? htmlspecialchars($_REQUEST['tag']) : ''; ?>" />
<table class="list">
<thead>
<tr>
<th class="check">
<div class="pulldown"><div><img src="images/down.png" alt=""/></div>
<ul>
<?php if (!isReadOnly()) { ?>
<?php if (!@$tag) { ?>
<li><input type="submit" name="start-delete" value="Delete selected files"/></li>
<?php } ?>
<li><input type="submit" name="start-copy" value="Copy selected files"/></li>
<?php if (!@$tag) { ?>
<li><input type="submit" name="start-move" value="Move selected files"/></li>
<?php } ?>
<?php } ?>
<li><input type="submit" name="download" value="Download selected files"/></li>
<?php /*
<li style="height:22px; display:none" id="downloadAppletItem">
<div style="position:relative">
<applet id="downloadApplet" name="DownloadApplet" code="net.sf.phpeasyvcs.DownloadApplet"
archive="applet/vcsapplet.jar?v=<?php echo $v; ?>" width="150" height="20">
<param name="root" value="<?php echo htmlspecialchars($uri) . ($dir ? '/'.substr($dir,0,-1) : ''); ?>">
</applet>
</div>
</li>
*/ ?>
</ul>
</div>
</th>
<th>Name
<?php if ($showdeleted) { ?>
(<a href="<?php echo $currlink; ?>">Hide deleted</a>)
<?php } else { ?>
(<a href="<?php echo $currlink; ?>&all=1">Show deleted</a>)
<?php } ?>
</th>
<th class="version">Version</th>
<th class="size">Size</th>
<th class="date" title="<?php echo htmlspecialchars(TIMEZONE); ?>">Date</th>
<th>User</th>
<th>Comment</th>
<?php if (!@$tag && !isReadOnly()) { ?><th colspan="4"></th><?php } else { ?><th colspan="2"></th><?php } ?>
</tr>
</thead>
<tbody>
<tr>
<td class="check"></td>
<td class="name">
<img src="images/upfolder.png" alt=""/>
<a href="<?php echo $uplink.($showdeleted ? '&all=1' : ''); ?>">..</a>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<?php if (!@$tag && !isReadOnly()) { ?><td colspan="4"></td><?php } else { ?><td colspan="2"></td><?php } ?>
</tr>
<?php foreach ($listing->directories as $directory) { ?>
<tr>
<td class="check">
<?php if (!$directory->deleted) { ?>
<input type="checkbox" name="name[]" value="<?php echo htmlspecialchars($directory->name); ?>" <?php if (in_array($directory->name, $names)) echo 'checked="checked"'; ?>/>
<?php } ?>
</td>
<td class="name">
<img src="images/folder.png" alt=""/>
<a href="<?php echo 'browse.php?'.($tagname ? 'tag='.urlencode($tagname).'&' : '').'dir='.urlencode($dir.$directory->name).($showdeleted ? '&all=1' : ''); ?>" class="<?php echo ($directory->deleted ? 'deleted' : ''); ?>"><?php echo htmlspecialchars($directory->name); ?></a>
</td>
<td></td>
<td></td>
<td class="date"><?php echo timestamp2string($directory->date); ?></td>
<td><?php echo htmlspecialchars(@$directory->user); ?></td>
<td>
<?php echo str_replace('\n','<br/>',htmlspecialchars($directory->comment)); ?>
<?php display_move_copy($directory); ?>
</td>
<?php if (!@$tag && !$directory->deleted && !isReadOnly()) { ?>
<td colspan="2"></td>
<td class="link rename">
<a href="<?php echo 'browse.php?dir='.urlencode($dir).'&name='.urlencode($directory->name).'&rename'; ?>"
title="Rename directory: <?php echo htmlspecialchars($directory->name); ?>">R</a>
</td>
<td class="link delete">
<a href="<?php echo 'delete.php?dir='.urlencode($dir).'&name='.urlencode($directory->name); ?>"
title="Delete directory: <?php echo htmlspecialchars($directory->name); ?>">X</a>
</td>
<?php } else if (!@$tag && !isReadOnly()) { ?>
<td colspan="3"></td>
<td class="link undelete">
<a href="<?php echo 'undelete.php?dir='.urlencode($dir).'&name='.urlencode($directory->name); ?>"
title="Undelete directory: <?php echo htmlspecialchars($directory->name); ?>">U</a>
</td>
<?php } else { ?>
<td colspan="2"></td>
<?php } ?>
</tr>
<?php } ?>
<?php foreach ($listing->files as $file) { ?>
<?php $quickview = preg_match('@^(text|image)/@',$file->mimetype); ?>
<?php $icon = Filetype::getIcon($file->ext).'.png'; ?>
<tr>
<td class="check">
<?php if (!$file->deleted) { ?>
<input type="checkbox" name="name[]" value="<?php echo htmlspecialchars($file->name); ?>" <?php if (in_array($file->name, $names)) echo 'checked="checked"'; ?>/>
<?php } ?>
</td>
<td class="name <?php echo ($file->deleted ? 'deleted' : ''); ?>">
<img src="images/<?php echo $icon; ?>" alt="" />
<?php if (!$file->deleted) { ?>
<a href="<?php echo 'get.php?dir='.urlencode($dir).'&name='.urlencode($file->name).'&version='.$file->version; ?>"
title="Download: <?php echo htmlspecialchars($file->name); ?> (md5: <?php echo htmlspecialchars($file->md5); ?>)">
<?php echo htmlspecialchars($file->name); ?>
</a>
<?php } else { ?>
<?php echo htmlspecialchars($file->name); ?>
<?php } ?>
</td>
<td class="version <?php echo ($file->deleted ? 'deleted' : ''); ?>">
<?php echo $file->version; ?>
</td>
<td class="size"><?php echo !$file->deleted ? size2string($file->size) : ''; ?></td>
<td class="date"><?php echo timestamp2string($file->date); ?></td>
<td class="user"><?php echo htmlspecialchars(@$file->user); ?></td>
<td class="comment">
<?php echo str_replace('\n','<br/>',htmlspecialchars($file->comment)); ?>
<?php display_move_copy($file); ?>
</td>
<?php if ($quickview && !$file->deleted) { ?>
<td class="link quickview">
<a href="<?php echo 'view.php?'.($tagname ? 'tag='.urlencode($tagname).'&' : '').'dir='.urlencode($dir).'&name='.urlencode($file->name).'&version='.$file->version; ?>"
title="Quick view: <?php echo htmlspecialchars($file->name); ?>">Q</a>
</td>
<?php } else { ?>
<td></td>
<?php } ?>
<td class="link versions">
<a href="<?php echo 'versions.php?'.($tagname ? 'tag='.urlencode($tagname).'&' : '').'dir='.urlencode($dir).'&name='.urlencode($file->name); ?>"
title="Show history: <?php echo htmlspecialchars($file->name); ?>">H</a>
</td>
<?php if (!@$tag && !$file->deleted && !isReadOnly()) { ?>
<td class="link rename">
<a href="<?php echo 'browse.php?dir='.urlencode($dir).'&name='.urlencode($file->name).'&rename'; ?>"
title="Rename file: <?php echo htmlspecialchars($file->name); ?>">R</a>
</td>
<td class="link delete">
<a href="<?php echo 'delete.php?dir='.urlencode($dir).'&name='.urlencode($file->name); ?>"
title="Delete file: <?php echo htmlspecialchars($file->name); ?>">X</a>
</td>
<?php } else if (!@$tag && !isReadOnly()) { ?>
<td></td>
<td class="link undelete">
<a href="<?php echo 'undelete.php?dir='.urlencode($dir).'&name='.urlencode($file->name); ?>"
title="Undelete file: <?php echo htmlspecialchars($file->name); ?>">U</a>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
<a id="dialog-background-start" class="dialog-background" href="<?php echo $currlink; ?>"
style="display:<?php echo isset($_REQUEST['start-delete']) || isset($_REQUEST['start-copy']) || isset($_REQUEST['start-move']) ? 'block' : 'none'; ?>"></a>
<div class="dialog-container">
<?php
$dialogclass = '';
if (isset($_REQUEST['start-delete'])) $dialogclass = 'delete-dialog'; else
if (isset($_REQUEST['start-copy'])) $dialogclass = 'copy-dialog'; else
if (isset($_REQUEST['start-move'])) $dialogclass = 'move-dialog';
?>
<div id="start-dialog" class="dialog <?php echo $dialogclass; ?>" style="display:<?php echo isset($_REQUEST['start-delete']) || isset($_REQUEST['start-copy']) || isset($_REQUEST['start-move']) ? 'block' : 'none';?>;">
<a href="<?php echo $currlink; ?>"><img src="images/close.png" class="close" alt="Close dialog"/></a>
<h2 class="delete-item"><img src="images/delete.png" alt=""/> Delete Files</h2>
<h2 class="copy-item"><img src="images/copy.png" alt=""/> Copy Files</h2>
<h2 class="move-item"><img src="images/move.png" alt=""/> Move Files</h2>
<label for="comment">Comment:</label>
<textarea name="comment" style="width:90%; height:4em;"></textarea>
<label for="targetdir" class="move-item copy-item">To directory:</label>
<div id="tree" class="tree-container move-item copy-item">
<?php if (isset($_REQUEST['start-copy']) || isset($_REQUEST['start-move'])) display_tree('targetdir'); ?>
</div>
<div id="overwriteItem" class="move-item copy-item">
<input type="checkbox" name="overwrite" value="1" /> Overwrite
</div>
<input type="submit" class="submit delete-item" name="delete" value="Delete selected files"/>
<input type="submit" class="submit copy-item" name="copy" value="Copy selected files"/>
<input type="submit" class="submit move-item" name="move" value="Move selected files"/>
</div>
</div>
</form>
<?php if (!@$tag) { ?>
<a id="dialog-background" class="dialog-background" href="<?php echo $currlink; ?>"
style="display:<?php echo isset($_REQUEST['rename']) || isset($_REQUEST['addfolder']) || isset($_REQUEST['addfile']) ? 'block' : 'none'; ?>"></a>
<div class="dialog-container">
<div id="progress-dialog" class="dialog" style="display:none">
<h2>Downloading...</h2>
<div id="progress" class="progress">
<div class="progress-bar"></div>
<div class="progress-text"></div>
</div>
</div>
</div>
<?php if (isset($_REQUEST['name'])) :
foreach ($_REQUEST['name'] as $key => $name) :?>
<div class="dialog-container">
<div id="rename-dialog" class="dialog" style="display:<?php echo isset($_REQUEST['rename']) ? 'block' : 'none';?>;">
<a href="<?php echo $currlink; ?>"><img src="images/close.png" class="close" alt="Close dialog"/></a>
<form action="rename.php" method="POST">
<h2>Rename <span class="name"><?php echo htmlspecialchars($name); ?></span></h2>
<label for="comment">Comment:</label>
<textarea name="comment" style="width:90%; height:4em;"></textarea>
<input type="hidden" name="sourcedir" value="<?php echo htmlspecialchars($dir); ?>" />
<input type="hidden" name="sourcename" value="<?php echo htmlspecialchars($name); ?>" />
<label for="targetname">New name:</label>
<input type="text" name="targetname" value="<?php echo htmlspecialchars($name); ?>" style="width:90%"/>
<br />
<input type="submit" class="submit" name="rename" value="Rename"/>
</form>
</div>
</div>
<?php endforeach;
endif; ?>
<div class="dialog-container">
<div id="addfolder-dialog" class="dialog" style="display:<?php echo isset($_REQUEST['addfolder']) ? 'block' : 'none';?>;">
<a href="<?php echo $currlink; ?>"><img src="images/close.png" class="close" alt="Close dialog"/></a>
<form action="add.php" method="POST">
<h2><img src="images/folder.png" alt=""/> Create Folder</h2>
<label for="comment">Comment:</label>
<textarea name="comment" style="width:90%; height:4em;"></textarea>
<input type="hidden" name="dir" value="<?php echo htmlspecialchars($dir); ?>" />
<label for="name">Folder name:</label>
<input type="text" name="name" value="" style="width:90%"/>
<br />
<input type="submit" class="submit" name="addfolder" value="Create"/>
</form>
</div>
</div>
<div class="dialog-container">
<div id="addfile-dialog" class="dialog" style="display:<?php echo isset($_REQUEST['addfile']) ? 'block' : 'none';?>;">
<a href="<?php echo $currlink; ?>"><img src="images/close.png" class="close" alt="Close dialog"/></a>
<form action="add.php" method="POST" enctype="multipart/form-data">
<h2><img src="images/unknown.png" alt=""/> Upload file(s)</h2>
<input type="hidden" name="dir" value="<?php echo htmlspecialchars($dir); ?>" />
<label for="comment">Comment:</label>
<textarea name="comment" style="width:90%; height:4em;"></textarea>
<label for="file-0">File(s):</label>
<div class="applet" style="width:1px; height:1px; overflow:hidden;">
<div style="float:left; margin-right:10px;">
<button id="selectfile" name="selectfile">Select files</button> or
</div>
<applet id="uploadApplet" name="UploadApplet" code="net.sf.phpeasyvcs.UploadApplet"
archive="applet/vcsapplet.jar?v=<?php echo $v; ?>" width="200" height="25">
<param name="root" value="<?php echo htmlspecialchars($uri) . ($dir ? '/'.substr($dir,0,-1) : ''); ?>">
</applet>
<!--
<object type="application/x-java-applet;version=1.5" style="float:left;"
width="200px" height= "25px" id="uploadApplet" name="UploadApplet">
<param name="archive" value="applet/vcsapplet.jar?v=<?php echo $v; ?>">
<param name="code" value="net.sf.phpeasyvcs.UploadApplet">
<param name="MAYSCRIPT" value="yes">
<param name="root" value="<?php echo htmlspecialchars($uri) . ($dir ? '/'.substr($dir,0,-1) : ''); ?>">
</object>
-->
<div style="clear:both"></div>
<div class="filelist">
<table id="files" class="list">
<tbody></tbody>
</table>
</div>
</div>
<input type="file" name="file-0" style="width:90%;"/>
<input type="file" name="file-1" style="width:90%;"/>
<input type="file" name="file-2" style="width:90%;"/>
<input type="file" name="file-3" style="width:90%;"/>
<input type="file" name="file-4" style="width:90%;"/>
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
<div id="extractItem"><input type="checkbox" name="extract" value="1" /> Extract ZIP files</div>
<input type="submit" class="submit" name="addfile" value="Upload"/>
</form>
<script type="text/javascript">
function showSelectResult(path) {
var $td = $('<td/>').text(path);
$td.append($('<input type="hidden" name="path" value=""/>').val(path));
$td.append('<div class="progress-line"></div>');
var $tr = $('<tr/>').append($td).append('<td class="link delete"><a title="Remove file" href="#">X</a></td>');
$('#addfile-dialog table tbody').append($tr);
}
function showUploadProgress(path, progress, total, percent) {
$('#addfile-dialog input[name=path]').each(function(i,input) {
if (input.value == path) {
if (progress > 0 && total > 0) {
$(input).closest('td').find('.progress-line').removeClass('failed').css('width',percent+'%');
} else {
$(input).closest('td').find('.progress-line').addClass('failed').css('width','100%');
}
}
});
}
function showUploadResult(result) {
if (result == true) {
window.location = <?php echo json_encode($currlink); ?>;
} else {
var failedFiles = $.parseJSON(result);
alert("The following files could not be uploaded:\r\n - "+failedFiles.join('\r\n - '));
window.location = <?php echo json_encode($currlink); ?>;
}
}
function showDownload() {
$('#downloadAppletItem').show();
}
function showUpload() {
// called from the applet when it finished initializing
// the applet must be in a visible div (1px/1px), otherwise it won't load in some browsers
//$('#addfile-dialog .applet').show();
$('#addfile-dialog .applet').attr('style','');
$('#addfile-dialog input[type=file]').hide();
$('#addfile-dialog #extractItem').hide();
$('#addfile-dialog input[type=submit]').click(function(e) {
e.preventDefault();
var comment = $('#addfile-dialog [name=comment]').val();
var extract = $('#addfile-dialog [name=extract]:checked').size() > 0
document.UploadApplet.setComment(comment);
document.UploadApplet.upload(extract);
});
$('#selectfile').click(function(e) {
e.preventDefault();
document.UploadApplet.selectLocalFiles();
});
$('#addfile-dialog table').delegate('td.delete a','click',function(e) {
var path = $(e.target).closest('tr').find('input[name=path]').val();
document.UploadApplet.removeLocalFile(path);
$(e.target).closest('tr').remove();
})
}
</script>
</div>
</div>
<?php } ?>
<script type="text/javascript">
var downloading = false;
function startDownload() {
downloading = true;
}
function showDownloadProgress(text, progress, total, percent) {
if ($('#progress-dialog:visible').size() == 0) {
$('#progress-dialog').dialog();
}
if (progress == 0) {
$('#progress-dialog .progress-text').text(text);
} else {
$('#progress-dialog .progress-text').text("Downloading...");
}
$('#progress-dialog .progress-bar').show().css('width',percent+'%');
}
function showDownloadResult(ok) {
if ($('#progress-dialog:visible').size() != 0) {
$('#progress-dialog').dialog('close');
}
downloading = false;
}
function showError(error) {
alert("Error: "+error);
}
$(function() {
var isPulldownOpen = false;
$('td.rename a').click(function(e) {
e.preventDefault();
var name = $(e.target).closest('tr').find('input[type=checkbox]').val();
$('#rename-dialog span.name').text(name);
$('#rename-dialog [name=sourcename]').val(name);
$('#rename-dialog [name=targetname]').val(name);
$('#rename-dialog').dialog({background:$('#dialog-background')});
});
$('a.addfolder').click(function(e) {
e.preventDefault();
$('#addfolder-dialog').dialog({background:$('#dialog-background')});
});
$('a.addfile').click(function(e) {
e.preventDefault();
$('#addfile-dialog').dialog({background:$('#dialog-background')});
});
$('.close').click(function(e) {
e.preventDefault();
$(e.target).closest('.dialog').dialog('close');
});
if (document.DownloadApplet) {
$('.pulldown').mouseenter(function(e) {
// In Firefox applet is only initialized, when shown and destroyed, when hidden.
// Additionally mouseleave (see below) is triggered in Ubuntu, when the mouse moves onto the applet.
// Thus we have to force the pulldown menu to stay open:
$(e.target).closest('.pulldown').addClass('open');
isPulldownOpen = true;
// add checked files:
document.DownloadApplet.removeAllFiles();
$('.list tbody [type=checkbox]:checked').each(function(i,cb) {
document.DownloadApplet.addFile(cb.value);
})
});
$('.pulldown').mouseleave(function(e) {
// We have to force the pulldown menu to stay open, while the applet is needed (see above)
if (isPulldownOpen && !downloading && e.relatedTarget) {
$(e.target).closest('.pulldown').removeClass('open');
}
});
$('.list tbody td').mousemove(function(e) {
// We have to force the pulldown menu to stay open, while the applet is needed (see above)
if (isPulldownOpen && !downloading) {
$('.list thead .pulldown').removeClass('open');
}
});
$('input[name=download]').click(function(e) {
e.preventDefault();
document.DownloadApplet.download();
});
}
});
</script>
<?php
} else {
?>
<p>Directory does not exist!</p>
<?php
}
template_footer();
function display_move_copy($entry) {
if (($rel = $entry->movedfrom)) {
echo ' <i>(moved from <a href="'.get_display_link($rel).'">'.
htmlspecialchars($rel->dir.$rel->name).'</a>'.
($rel->isFile ? ', '.$rel->version : '').')</i>';
} else if (($rel = $entry->copyof)) {
echo ' <i>(copy of <a href="'.get_display_link($rel).'">'.
htmlspecialchars($rel->dir.$rel->name).'</a>'.
($rel->isFile ? ', '.$rel->version : '').')</i>';
} else if (($rel = $entry->movedto)) {
echo ' <i>(moved to <a href="'.get_display_link($rel).'">'.
htmlspecialchars($rel->dir.$rel->name).'</a>'.
($rel->isFile ? ', '.$rel->version : '').')</i>';
}
}
function get_display_link($entry) {
if ($entry->isDirectory) {
return 'browse.php?dir='.urlencode($entry->dir.$entry->name).($entry->movedfrom ? '&all=1' : '');
} else {
return 'versions.php?dir='.urlencode($entry->dir).'&name='.urlencode($entry->name);
}
}
function display_tree($paramname, $aDir=null, $i=0) {
global $vcs, $dir, $names;
if ($aDir === null) {
echo '<ul>';
echo '<li>';
echo '<input type="radio" name="'.$paramname.'" value="/" checked="checked"/>';
echo '<label for="folder'.$i.'">/</label>';
echo '<input type="checkbox" id="folder'.$i.'" class="toggle" checked="checked"/>';
$i++;
$i = display_tree($paramname, '', $i);
echo '</li>';
echo '</ul>';
} else {
$listing = $vcs->getListing($aDir);
if (count($listing->directories) > 0) {
echo '<ul>';
foreach ($listing->directories as $entry) {
if ($entry->dir != $dir || !in_array($entry->name, $names)) {
echo '<li>';
echo '<input type="radio" name="'.$paramname.'" value="'.htmlspecialchars($entry->dir.$entry->name).'"/>';
echo '<label for="folder'.$i.'">'.htmlspecialchars($entry->name).'</label>';
echo '<input type="checkbox" id="folder'.$i.'" class="toggle"/>';
$i++;
$i = display_tree($paramname, $entry->dir.$entry->name, $i);
echo '</li>';
}
}
echo '</ul>';
}
}
return $i;
}