-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy.php
30 lines (28 loc) · 1.46 KB
/
copy.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
<?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');
$msg = $err = '';
$srcdir = sanitizeDir($_REQUEST['sourcedir']);
$srcname = sanitizeName($_REQUEST['sourcename']);
$tgtdir = isset($_REQUEST['targetdir']) ? sanitizeDir($_REQUEST['targetdir']) : $srcdir;
$tgtname = sanitizeName($_REQUEST['targetname']);
$vcs = new FileVCS(DATAPATH, @$_REQUEST['tag'], getUserName(), isReadOnly());
$result = $vcs->copy($srcdir, $srcname, $tgtdir, $tgtname, true, @$_REQUEST['comment']);
if ($result >= 0) {
$msg = 'File/directory '.$name.' was successfully copied';
} else if ($result == VCS_NOACTION || $result == VCS_NOTFOUND) {
$err = 'File/directory '.$name.' not found';
} else {
$err = 'Error moving file/directory '.$name;
}
$url = 'browse.php?dir='.urlencode($srcdir);
if (@$_REQUEST['tag']) $url .= '&tag='.urlencode($_REQUEST['tag']);
if (@$msg) $url .= '&msg='.urlencode($msg);
if (@$err) $url .= '&error='.urlencode($err);
header('Location: '.$url);