-
Notifications
You must be signed in to change notification settings - Fork 0
/
versions.php
158 lines (149 loc) · 7.42 KB
/
versions.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
<?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');
$dir = sanitizeDir($_GET['dir']);
$name = sanitizeName($_GET['name']);
$vcs = new FileVCS(DATAPATH, @$_GET['tag'], getUserName(), isReadOnly());
$tag = $vcs->getTag();
$tagname = $tag && $tag->name ? $tag->name : ($tag ? $_GET['tag'] : null);
$files = $vcs->getHistory($dir, $name);
$currvcs = new FileVCS(DATAPATH, null, getUserName(), isReadOnly());
$allfiles = $currvcs->getHistory($dir, $name);
$currfile = $allfiles[count($allfiles)];
$fullhistory = count($allfiles) == count($files);
template_header();
$tagtext = '';
if ($tag && $tag->date) $tagtext .= ' <span>until</span> <span class="date">'.timestamp2string($tag->date).'</span>';
if ($tag && $vcs->getTag($tag->name)) $tagtext .= ' ('.htmlspecialchars($tag->name).')';
$numversions = 0;
foreach ($files as $f) if (!$f->deleted) $numversions++;
foreach ($files as $file) break;
$quickview = preg_match('@^(text|image)/@',$file->mimetype);
$diffable = preg_match('@^(text)/@',$file->mimetype);
$icon = Filetype::getIcon($file->ext).'.png';
$vfrom = 0;
$vto = 0;
?>
<ul class="actions">
<li><a href="<?php echo 'browse.php?'.($tagname ? 'tag='.urlencode($tagname).'&' : '').'dir='.urlencode($dir); ?>">Back to directory</a></li>
</ul>
<h2>
History of <img src="images/<?php echo $icon; ?>" alt=""/>
<a href="<?php echo 'browse.php?'.($tagname ? 'tag='.urlencode($tagname).'&' : '').'dir='.urlencode($dir); ?>">/<?php echo htmlspecialchars(substr($dir,0,-1)); ?></a><?php echo ($dir ? '/' : '').htmlspecialchars($name); ?>
<?php echo $tagtext; ?>
</h2>
<form action="diff.php" method="GET">
<input type="hidden" name="tag" value="<?php echo htmlspecialchars($tagname); ?>" />
<input type="hidden" name="dir" value="<?php echo htmlspecialchars($dir); ?>" />
<input type="hidden" name="name" value="<?php echo htmlspecialchars($name); ?>" />
<table class="list">
<thead>
<tr>
<th colspan="2" style="text-align:center;">
<?php if ($diffable && $numversions >= 2) { ?>
<input type="submit" name="diff" value="Diff"/>
<?php } ?>
</th>
<th class="version">Version</th>
<th>Name</th>
<th class="size">Size</th>
<th class="date" title="<?php echo htmlspecialchars(TIMEZONE); ?>">Date</th>
<th>User</th>
<th>Comment</th>
<?php if ($quickview && !isReadOnly()) { ?>
<th colspan="2"></th>
<?php } else if ($quickview || !isReadOnly()) { ?>
<th></th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php if (!$fullhistory) { ?>
<tr>
<td colspan="2"></td>
<td colspan="<?php echo $quickview ? '8' : '7'; ?>">
<a href="<?php echo 'versions.php?dir='.urlencode($dir).'&name='.urlencode($name); ?>">Show full history</a>
</td>
</tr>
<?php } ?>
<?php foreach ($files as $file) { ?>
<tr>
<td class="radio">
<?php if ($diffable && $numversions >= 2 && $vto && !$file->deleted) { ?>
<input type="radio" name="from" value="<?php echo $file->version; ?>" <?php echo !$vfrom && ($vfrom = $file->version) ? 'checked="checked"' : ''; ?> />
<?php } ?>
</td>
<td class="radio">
<?php if ($diffable && $numversions >= 2 && !$file->deleted) { ?>
<input type="radio" name="to" value="<?php echo $file->version; ?>" <?php echo !$vto && ($vto = $file->version) ? 'checked="checked"' : ''; ?> />
<?php } ?>
</td>
<td class="version">
<?php echo $file->version; ?>
</td>
<td class="name <?php echo $file->deleted ? 'deleted' : ''; ?>">
<?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 { ?>
(deleted)
<?php } ?>
</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 && !isReadOnly() && $file->deleted) { ?>
<td colspan="2"></td>
<?php } else { ?>
<?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 if ($quickview) { ?>
<td></td>
<?php } ?>
<?php if (!isReadOnly() && $file->version < $currfile->version) { ?>
<td class="link revert">
<a href="<?php echo 'revert.php?dir='.urlencode($dir).'&name='.urlencode($file->name).'&version='.$file->version; ?>"
title="Revert to version <?php echo $file->version; ?>: <?php echo htmlspecialchars($file->name); ?>">R</a>
</td>
<?php } else if (!isReadOnly()) { ?>
<td></td>
<?php } ?>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
</form>
<?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->version.')</i>';
} else if (($rel = $entry->copyof)) {
echo ' <i>(copy of <a href="'.get_display_link($rel).'">'.
htmlspecialchars($rel->dir.$rel->name).'</a>, '.$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->version.')</i>';
}
}
function get_display_link($entry) {
return 'versions.php?dir='.urlencode($entry->dir).'&name='.urlencode($entry->name);
}