|
a48474b…
|
drh
|
1 |
/* |
|
c19f34c…
|
drh
|
2 |
** Copyright (c) 2008 D. Richard Hipp |
|
a48474b…
|
drh
|
3 |
** |
|
a48474b…
|
drh
|
4 |
** This program is free software; you can redistribute it and/or |
|
c06edd2…
|
drh
|
5 |
** modify it under the terms of the Simplified BSD License (also |
|
c06edd2…
|
drh
|
6 |
** known as the "2-Clause License" or "FreeBSD License".) |
|
c06edd2…
|
drh
|
7 |
|
|
a48474b…
|
drh
|
8 |
** This program is distributed in the hope that it will be useful, |
|
c06edd2…
|
drh
|
9 |
** but without any warranty; without even the implied warranty of |
|
c06edd2…
|
drh
|
10 |
** merchantability or fitness for a particular purpose. |
|
a48474b…
|
drh
|
11 |
** |
|
a48474b…
|
drh
|
12 |
** Author contact information: |
|
a48474b…
|
drh
|
13 |
** [email protected] |
|
a48474b…
|
drh
|
14 |
** http://www.hwaci.com/drh/ |
|
a48474b…
|
drh
|
15 |
** |
|
a48474b…
|
drh
|
16 |
******************************************************************************* |
|
a48474b…
|
drh
|
17 |
** |
|
a48474b…
|
drh
|
18 |
** This file contains code used to manage SHUN table of the repository |
|
a48474b…
|
drh
|
19 |
*/ |
|
a48474b…
|
drh
|
20 |
#include "config.h" |
|
a48474b…
|
drh
|
21 |
#include "shun.h" |
|
a48474b…
|
drh
|
22 |
#include <assert.h> |
|
a48474b…
|
drh
|
23 |
|
|
a48474b…
|
drh
|
24 |
/* |
|
766bec0…
|
drh
|
25 |
** Return true if the given artifact ID should be shunned. |
|
a48474b…
|
drh
|
26 |
*/ |
|
a48474b…
|
drh
|
27 |
int uuid_is_shunned(const char *zUuid){ |
|
a48474b…
|
drh
|
28 |
static Stmt q; |
|
a48474b…
|
drh
|
29 |
int rc; |
|
a48474b…
|
drh
|
30 |
if( zUuid==0 || zUuid[0]==0 ) return 0; |
|
e92133a…
|
drh
|
31 |
if( g.eHashPolicy==HPOLICY_SHUN_SHA1 && zUuid[HNAME_LEN_SHA1]==0 ) return 1; |
|
a48474b…
|
drh
|
32 |
db_static_prepare(&q, "SELECT 1 FROM shun WHERE uuid=:uuid"); |
|
a48474b…
|
drh
|
33 |
db_bind_text(&q, ":uuid", zUuid); |
|
a48474b…
|
drh
|
34 |
rc = db_step(&q); |
|
a48474b…
|
drh
|
35 |
db_reset(&q); |
|
a48474b…
|
drh
|
36 |
return rc==SQLITE_ROW; |
|
a48474b…
|
drh
|
37 |
} |
|
a48474b…
|
drh
|
38 |
|
|
a48474b…
|
drh
|
39 |
/* |
|
a48474b…
|
drh
|
40 |
** WEBPAGE: shun |
|
7ab0328…
|
drh
|
41 |
** |
|
fd9b7bd…
|
drh
|
42 |
** View the hashes of all shunned artifacts. Add new hashes |
|
7ab0328…
|
drh
|
43 |
** to the shun set. Requires Admin privilege. |
|
a48474b…
|
drh
|
44 |
*/ |
|
a48474b…
|
drh
|
45 |
void shun_page(void){ |
|
a48474b…
|
drh
|
46 |
Stmt q; |
|
a48474b…
|
drh
|
47 |
int cnt = 0; |
|
a48474b…
|
drh
|
48 |
const char *zUuid = P("uuid"); |
|
9b30c01…
|
drh
|
49 |
const char *zShun = P("shun"); |
|
9b30c01…
|
drh
|
50 |
const char *zAccept = P("accept"); |
|
9b30c01…
|
drh
|
51 |
const char *zRcvid = P("rcvid"); |
|
5e19daf…
|
preben
|
52 |
int reviewList = P("review")!=0; |
|
e7518b4…
|
mistachkin
|
53 |
int nRcvid = 0; |
|
9b30c01…
|
drh
|
54 |
int numRows = 3; |
|
9b30c01…
|
drh
|
55 |
char *zCanonical = 0; |
|
a48474b…
|
drh
|
56 |
|
|
a48474b…
|
drh
|
57 |
login_check_credentials(); |
|
b344d3c…
|
drh
|
58 |
if( !g.perm.Admin ){ |
|
653dd40…
|
drh
|
59 |
login_needed(0); |
|
653dd40…
|
drh
|
60 |
return; |
|
3f6edbc…
|
drh
|
61 |
} |
|
3f6edbc…
|
drh
|
62 |
if( P("rebuild") ){ |
|
c2f5dbe…
|
drh
|
63 |
db_close(1); |
|
8040619…
|
drh
|
64 |
db_open_repository(g.zRepositoryName); |
|
e1962ef…
|
drh
|
65 |
db_begin_transaction(); |
|
298ccff…
|
stephan
|
66 |
rebuild_db(0, 0); |
|
f3455a5…
|
drh
|
67 |
admin_log("Rebuilt database."); |
|
3f6edbc…
|
drh
|
68 |
db_end_transaction(0); |
|
a48474b…
|
drh
|
69 |
} |
|
a48474b…
|
drh
|
70 |
if( zUuid ){ |
|
9b30c01…
|
drh
|
71 |
char *p; |
|
9b30c01…
|
drh
|
72 |
int i = 0; |
|
9b30c01…
|
drh
|
73 |
int j = 0; |
|
9b30c01…
|
drh
|
74 |
zCanonical = fossil_malloc(strlen(zUuid)+2); |
|
9b30c01…
|
drh
|
75 |
while( zUuid[i] ){ |
|
9b30c01…
|
drh
|
76 |
if( fossil_isspace(zUuid[i]) ){ |
|
9b30c01…
|
drh
|
77 |
if( j && zCanonical[j-1] ){ |
|
9b30c01…
|
drh
|
78 |
zCanonical[j] = 0; |
|
9b30c01…
|
drh
|
79 |
j++; |
|
9b30c01…
|
drh
|
80 |
} |
|
9b30c01…
|
drh
|
81 |
}else{ |
|
9b30c01…
|
drh
|
82 |
zCanonical[j] = zUuid[i]; |
|
9b30c01…
|
drh
|
83 |
j++; |
|
9b30c01…
|
drh
|
84 |
} |
|
9b30c01…
|
drh
|
85 |
i++; |
|
9b30c01…
|
drh
|
86 |
} |
|
9b30c01…
|
drh
|
87 |
zCanonical[j+1] = zCanonical[j] = 0; |
|
9b30c01…
|
drh
|
88 |
p = zCanonical; |
|
9b30c01…
|
drh
|
89 |
while( *p ){ |
|
e7518b4…
|
mistachkin
|
90 |
int nUuid = strlen(p); |
|
5e19daf…
|
preben
|
91 |
if( !(reviewList || hname_validate(p, nUuid)) ){ |
|
9b30c01…
|
drh
|
92 |
@ <p class="generalError">Error: Bad artifact IDs.</p> |
|
9b30c01…
|
drh
|
93 |
fossil_free(zCanonical); |
|
9b30c01…
|
drh
|
94 |
zCanonical = 0; |
|
9b30c01…
|
drh
|
95 |
break; |
|
9b30c01…
|
drh
|
96 |
}else{ |
|
fd9b7bd…
|
drh
|
97 |
canonical16(p, nUuid); |
|
fd9b7bd…
|
drh
|
98 |
p += nUuid+1; |
|
9b30c01…
|
drh
|
99 |
} |
|
9b30c01…
|
drh
|
100 |
} |
|
9b30c01…
|
drh
|
101 |
zUuid = zCanonical; |
|
a48474b…
|
drh
|
102 |
} |
|
a48474b…
|
drh
|
103 |
style_header("Shunned Artifacts"); |
|
920ace1…
|
drh
|
104 |
if( zUuid && P("sub") && cgi_csrf_safe(2) ){ |
|
9b30c01…
|
drh
|
105 |
const char *p = zUuid; |
|
9b30c01…
|
drh
|
106 |
int allExist = 1; |
|
9b30c01…
|
drh
|
107 |
while( *p ){ |
|
49b0ff1…
|
drh
|
108 |
db_multi_exec("DELETE FROM shun WHERE uuid=%Q", p); |
|
49b0ff1…
|
drh
|
109 |
if( !db_exists("SELECT 1 FROM blob WHERE uuid=%Q", p) ){ |
|
9b30c01…
|
drh
|
110 |
allExist = 0; |
|
9b30c01…
|
drh
|
111 |
} |
|
f3455a5…
|
drh
|
112 |
admin_log("Unshunned %Q", p); |
|
fd9b7bd…
|
drh
|
113 |
p += strlen(p)+1; |
|
9b30c01…
|
drh
|
114 |
} |
|
9b30c01…
|
drh
|
115 |
if( allExist ){ |
|
f5482a0…
|
wyoung
|
116 |
@ <p class="noMoreShun">Artifact(s)<br> |
|
fd9b7bd…
|
drh
|
117 |
for( p = zUuid ; *p ; p += strlen(p)+1 ){ |
|
f5482a0…
|
wyoung
|
118 |
@ <a href="%R/artifact/%s(p)">%s(p)</a><br> |
|
9b30c01…
|
drh
|
119 |
} |
|
9b30c01…
|
drh
|
120 |
@ are no longer being shunned.</p> |
|
5a48a9b…
|
drh
|
121 |
}else{ |
|
f5482a0…
|
wyoung
|
122 |
@ <p class="noMoreShun">Artifact(s)<br> |
|
fd9b7bd…
|
drh
|
123 |
for( p = zUuid ; *p ; p += strlen(p)+1 ){ |
|
f5482a0…
|
wyoung
|
124 |
@ %s(p)<br> |
|
fd9b7bd…
|
drh
|
125 |
} |
|
dee17d9…
|
stephan
|
126 |
@ will no longer be shunned but they may not exist in the repository. |
|
dee17d9…
|
stephan
|
127 |
@ It may be necessary to rebuild the repository |
|
dee17d9…
|
stephan
|
128 |
@ before the artifact content can be pulled in |
|
dee17d9…
|
stephan
|
129 |
@ from other repositories.</p> |
|
1654456…
|
drh
|
130 |
} |
|
1654456…
|
drh
|
131 |
} |
|
920ace1…
|
drh
|
132 |
if( zUuid && P("add") && cgi_csrf_safe(2) ){ |
|
9b30c01…
|
drh
|
133 |
const char *p = zUuid; |
|
1654456…
|
drh
|
134 |
int rid, tagid; |
|
9b30c01…
|
drh
|
135 |
while( *p ){ |
|
9b30c01…
|
drh
|
136 |
db_multi_exec( |
|
9b30c01…
|
drh
|
137 |
"INSERT OR IGNORE INTO shun(uuid,mtime)" |
|
49b0ff1…
|
drh
|
138 |
" VALUES(%Q, now())", p); |
|
9b30c01…
|
drh
|
139 |
db_multi_exec("DELETE FROM attachment WHERE src=%Q", p); |
|
9b30c01…
|
drh
|
140 |
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", p); |
|
9b30c01…
|
drh
|
141 |
if( rid ){ |
|
9b30c01…
|
drh
|
142 |
db_multi_exec("DELETE FROM event WHERE objid=%d", rid); |
|
9b30c01…
|
drh
|
143 |
} |
|
9b30c01…
|
drh
|
144 |
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='tkt-%q'", p); |
|
9b30c01…
|
drh
|
145 |
if( tagid ){ |
|
9b30c01…
|
drh
|
146 |
db_multi_exec("DELETE FROM ticket WHERE tkt_uuid=%Q", p); |
|
9b30c01…
|
drh
|
147 |
db_multi_exec("DELETE FROM tag WHERE tagid=%d", tagid); |
|
9b30c01…
|
drh
|
148 |
db_multi_exec("DELETE FROM tagxref WHERE tagid=%d", tagid); |
|
9b30c01…
|
drh
|
149 |
} |
|
f3455a5…
|
drh
|
150 |
admin_log("Shunned %Q", p); |
|
fd9b7bd…
|
drh
|
151 |
p += strlen(p)+1; |
|
9b30c01…
|
drh
|
152 |
} |
|
f5482a0…
|
wyoung
|
153 |
@ <p class="shunned">Artifact(s)<br> |
|
fd9b7bd…
|
drh
|
154 |
for( p = zUuid ; *p ; p += strlen(p)+1 ){ |
|
f5482a0…
|
wyoung
|
155 |
@ <a href="%R/artifact/%s(p)">%s(p)</a><br> |
|
9b30c01…
|
drh
|
156 |
} |
|
9b30c01…
|
drh
|
157 |
@ have been shunned. They will no longer be pushed. |
|
9b30c01…
|
drh
|
158 |
@ They will be removed from the repository the next time the repository |
|
5a48a9b…
|
drh
|
159 |
@ is rebuilt using the <b>fossil rebuild</b> command-line</p> |
|
5e19daf…
|
preben
|
160 |
} |
|
5e19daf…
|
preben
|
161 |
if( zUuid && reviewList ){ |
|
5e19daf…
|
preben
|
162 |
const char *p; |
|
5e19daf…
|
preben
|
163 |
int nTotal = 0; |
|
5e19daf…
|
preben
|
164 |
int nOk = 0; |
|
5e19daf…
|
preben
|
165 |
@ <table class="shun-review"><tbody><tr><td> |
|
5e19daf…
|
preben
|
166 |
for( p = zUuid ; *p ; p += strlen(p)+1 ){ |
|
5e19daf…
|
preben
|
167 |
int rid = symbolic_name_to_rid(p, 0); |
|
5e19daf…
|
preben
|
168 |
nTotal++; |
|
5e19daf…
|
preben
|
169 |
if( rid < 0 ){ |
|
5e19daf…
|
preben
|
170 |
@ Ambiguous<br> |
|
5e19daf…
|
preben
|
171 |
}else if( rid == 0 ){ |
|
5e19daf…
|
preben
|
172 |
if( !hname_validate(p, strlen(p)) ){ |
|
5e19daf…
|
preben
|
173 |
@ Bad artifact<br> |
|
5e19daf…
|
preben
|
174 |
}else if(db_int(0, "SELECT 1 FROM shun WHERE uuid=%Q", p)){ |
|
5e19daf…
|
preben
|
175 |
@ Already shunned<br> |
|
5e19daf…
|
preben
|
176 |
}else{ |
|
5e19daf…
|
preben
|
177 |
@ Unknown<br> |
|
5e19daf…
|
preben
|
178 |
} |
|
5e19daf…
|
preben
|
179 |
}else{ |
|
5e19daf…
|
preben
|
180 |
char *zCmpUuid = db_text(0, |
|
5e19daf…
|
preben
|
181 |
"SELECT uuid" |
|
5e19daf…
|
preben
|
182 |
" FROM blob, rcvfrom" |
|
5e19daf…
|
preben
|
183 |
" WHERE rid=%d" |
|
5e19daf…
|
preben
|
184 |
" AND rcvfrom.rcvid=blob.rcvid", |
|
5e19daf…
|
preben
|
185 |
rid); |
|
5e19daf…
|
preben
|
186 |
if( fossil_strcmp(p, zCmpUuid)==0 ){ |
|
5e19daf…
|
preben
|
187 |
nOk++; |
|
5e19daf…
|
preben
|
188 |
@ OK</br> |
|
5e19daf…
|
preben
|
189 |
}else{ |
|
5e19daf…
|
preben
|
190 |
@ Abbreviated<br> |
|
5e19daf…
|
preben
|
191 |
} |
|
5e19daf…
|
preben
|
192 |
} |
|
5e19daf…
|
preben
|
193 |
} |
|
5e19daf…
|
preben
|
194 |
@ </td><td> |
|
5e19daf…
|
preben
|
195 |
for( p = zUuid ; *p ; p += strlen(p)+1 ){ |
|
5e19daf…
|
preben
|
196 |
int rid = symbolic_name_to_rid(p, 0); |
|
5e19daf…
|
preben
|
197 |
if( rid > 0 ){ |
|
5e19daf…
|
preben
|
198 |
@ <a href="%R/artifact/%s(p)">%s(p)</a><br> |
|
5e19daf…
|
preben
|
199 |
}else{ |
|
5e19daf…
|
preben
|
200 |
@ %s(p)<br> |
|
5e19daf…
|
preben
|
201 |
} |
|
5e19daf…
|
preben
|
202 |
} |
|
5e19daf…
|
preben
|
203 |
@ </td></tr></tbody></table> |
|
5e19daf…
|
preben
|
204 |
@ <p class="shunned"> |
|
5e19daf…
|
preben
|
205 |
if( nOk < nTotal){ |
|
5e19daf…
|
preben
|
206 |
@ <b>Warning:</b> Not all artifacts |
|
5e19daf…
|
preben
|
207 |
}else if( nTotal==1 ){ |
|
5e19daf…
|
preben
|
208 |
@ The artifact is present and |
|
5e19daf…
|
preben
|
209 |
}else{ |
|
5e19daf…
|
preben
|
210 |
@ All %i(nOk) artifacts are present and |
|
5e19daf…
|
preben
|
211 |
} |
|
5e19daf…
|
preben
|
212 |
@ can be shunned with its hash above.</p> |
|
e7518b4…
|
mistachkin
|
213 |
} |
|
9b30c01…
|
drh
|
214 |
if( zRcvid ){ |
|
9b30c01…
|
drh
|
215 |
nRcvid = atoi(zRcvid); |
|
e7518b4…
|
mistachkin
|
216 |
numRows = db_int(0, "SELECT min(count(), 10) FROM blob WHERE rcvid=%d", |
|
e7518b4…
|
mistachkin
|
217 |
nRcvid); |
|
50ab5c3…
|
drh
|
218 |
} |
|
50ab5c3…
|
drh
|
219 |
@ <p>A shunned artifact will not be pushed nor accepted in a pull and the |
|
50ab5c3…
|
drh
|
220 |
@ artifact content will be purged from the repository the next time the |
|
50ab5c3…
|
drh
|
221 |
@ repository is rebuilt. A list of shunned artifacts can be seen at the |
|
50ab5c3…
|
drh
|
222 |
@ bottom of this page.</p> |
|
3df526c…
|
jan.nijtmans
|
223 |
@ |
|
50ab5c3…
|
drh
|
224 |
@ <a name="addshun"></a> |
|
fd9b7bd…
|
drh
|
225 |
@ <p>To shun artifacts, enter their artifact hashes (the 40- or |
|
fd9b7bd…
|
drh
|
226 |
@ 64-character lowercase hexadecimal hash of the artifact content) in the |
|
9b30c01…
|
drh
|
227 |
@ following box and press the "Shun" button. This will cause the artifacts |
|
9b30c01…
|
drh
|
228 |
@ to be removed from the repository and will prevent the artifacts from being |
|
50ab5c3…
|
drh
|
229 |
@ readded to the repository by subsequent sync operation.</p> |
|
50ab5c3…
|
drh
|
230 |
@ |
|
b3e8253…
|
stephan
|
231 |
@ <p>Note that you must enter full artifact hashes, not abbreviations |
|
b3e8253…
|
stephan
|
232 |
@ or symbolic tags.</p> |
|
50ab5c3…
|
drh
|
233 |
@ |
|
50ab5c3…
|
drh
|
234 |
@ <p>Warning: Shunning should only be used to remove inappropriate content |
|
50ab5c3…
|
drh
|
235 |
@ from the repository. Inappropriate content includes such things as |
|
50ab5c3…
|
drh
|
236 |
@ spam added to Wiki, files that violate copyright or patent agreements, |
|
50ab5c3…
|
drh
|
237 |
@ or artifacts that by design or accident interfere with the processing |
|
50ab5c3…
|
drh
|
238 |
@ of the repository. Do not shun artifacts merely to remove them from |
|
50ab5c3…
|
drh
|
239 |
@ sight - set the "hidden" tag on such artifacts instead.</p> |
|
3df526c…
|
jan.nijtmans
|
240 |
@ |
|
50ab5c3…
|
drh
|
241 |
@ <blockquote> |
|
a40e8a0…
|
drh
|
242 |
@ <form method="post" action="%R/%s(g.zPath)"><div> |
|
50ab5c3…
|
drh
|
243 |
login_insert_csrf_secret(); |
|
f749f20…
|
andygoth
|
244 |
@ <textarea class="fullsize-text" cols="70" rows="%d(numRows)" name="uuid"> |
|
9b30c01…
|
drh
|
245 |
if( zShun ){ |
|
9b30c01…
|
drh
|
246 |
if( strlen(zShun) ){ |
|
9b30c01…
|
drh
|
247 |
@ %h(zShun) |
|
e7518b4…
|
mistachkin
|
248 |
}else if( nRcvid ){ |
|
9b30c01…
|
drh
|
249 |
db_prepare(&q, "SELECT uuid FROM blob WHERE rcvid=%d", nRcvid); |
|
9b30c01…
|
drh
|
250 |
while( db_step(&q)==SQLITE_ROW ){ |
|
9b30c01…
|
drh
|
251 |
@ %s(db_column_text(&q, 0)) |
|
9b30c01…
|
drh
|
252 |
} |
|
9b30c01…
|
drh
|
253 |
db_finalize(&q); |
|
9b30c01…
|
drh
|
254 |
} |
|
5e19daf…
|
preben
|
255 |
}else if( zUuid && reviewList ){ |
|
5e19daf…
|
preben
|
256 |
const char *p; |
|
5e19daf…
|
preben
|
257 |
for( p = zUuid ; *p ; p += strlen(p)+1 ){ |
|
5e19daf…
|
preben
|
258 |
@ %s(p) |
|
5e19daf…
|
preben
|
259 |
} |
|
9b30c01…
|
drh
|
260 |
} |
|
9b30c01…
|
drh
|
261 |
@ </textarea> |
|
f5482a0…
|
wyoung
|
262 |
@ <input type="submit" name="add" value="Shun"> |
|
5e19daf…
|
preben
|
263 |
@ <input type="submit" name="review" value="Review"> |
|
3243e63…
|
drh
|
264 |
@ </div></form> |
|
50ab5c3…
|
drh
|
265 |
@ </blockquote> |
|
50ab5c3…
|
drh
|
266 |
@ |
|
cc9b04b…
|
drh
|
267 |
@ <a name="delshun"></a> |
|
9b30c01…
|
drh
|
268 |
@ <p>Enter the UUIDs of previously shunned artifacts to cause them to be |
|
9b30c01…
|
drh
|
269 |
@ accepted again in the repository. The artifacts content is not |
|
50ab5c3…
|
drh
|
270 |
@ restored because the content is unknown. The only change is that |
|
9b30c01…
|
drh
|
271 |
@ the formerly shunned artifacts will be accepted on subsequent sync |
|
50ab5c3…
|
drh
|
272 |
@ operations.</p> |
|
50ab5c3…
|
drh
|
273 |
@ |
|
50ab5c3…
|
drh
|
274 |
@ <blockquote> |
|
a40e8a0…
|
drh
|
275 |
@ <form method="post" action="%R/%s(g.zPath)"><div> |
|
cc9b04b…
|
drh
|
276 |
login_insert_csrf_secret(); |
|
f749f20…
|
andygoth
|
277 |
@ <textarea class="fullsize-text" cols="70" rows="%d(numRows)" name="uuid"> |
|
9b30c01…
|
drh
|
278 |
if( zAccept ){ |
|
9b30c01…
|
drh
|
279 |
if( strlen(zAccept) ){ |
|
9b30c01…
|
drh
|
280 |
@ %h(zAccept) |
|
e7518b4…
|
mistachkin
|
281 |
}else if( nRcvid ){ |
|
9b30c01…
|
drh
|
282 |
db_prepare(&q, "SELECT uuid FROM blob WHERE rcvid=%d", nRcvid); |
|
9b30c01…
|
drh
|
283 |
while( db_step(&q)==SQLITE_ROW ){ |
|
9b30c01…
|
drh
|
284 |
@ %s(db_column_text(&q, 0)) |
|
9b30c01…
|
drh
|
285 |
} |
|
9b30c01…
|
drh
|
286 |
db_finalize(&q); |
|
9b30c01…
|
drh
|
287 |
} |
|
9b30c01…
|
drh
|
288 |
} |
|
9b30c01…
|
drh
|
289 |
@ </textarea> |
|
f5482a0…
|
wyoung
|
290 |
@ <input type="submit" name="sub" value="Accept"> |
|
3243e63…
|
drh
|
291 |
@ </div></form> |
|
50ab5c3…
|
drh
|
292 |
@ </blockquote> |
|
50ab5c3…
|
drh
|
293 |
@ |
|
7c0f4ec…
|
jan.nijtmans
|
294 |
@ <p>Press the Rebuild button below to rebuild the repository. The |
|
50ab5c3…
|
drh
|
295 |
@ content of newly shunned artifacts is not purged until the repository |
|
50ab5c3…
|
drh
|
296 |
@ is rebuilt. On larger repositories, the rebuild may take minute or |
|
50ab5c3…
|
drh
|
297 |
@ two, so be patient after pressing the button.</p> |
|
50ab5c3…
|
drh
|
298 |
@ |
|
a48474b…
|
drh
|
299 |
@ <blockquote> |
|
a40e8a0…
|
drh
|
300 |
@ <form method="post" action="%R/%s(g.zPath)"><div> |
|
50ab5c3…
|
drh
|
301 |
login_insert_csrf_secret(); |
|
f5482a0…
|
wyoung
|
302 |
@ <input type="submit" name="rebuild" value="Rebuild"> |
|
3243e63…
|
drh
|
303 |
@ </div></form> |
|
50ab5c3…
|
drh
|
304 |
@ </blockquote> |
|
3df526c…
|
jan.nijtmans
|
305 |
@ |
|
f5482a0…
|
wyoung
|
306 |
@ <hr><p>Shunned Artifacts:</p> |
|
3243e63…
|
drh
|
307 |
@ <blockquote><p> |
|
3df526c…
|
jan.nijtmans
|
308 |
db_prepare(&q, |
|
a48474b…
|
drh
|
309 |
"SELECT uuid, EXISTS(SELECT 1 FROM blob WHERE blob.uuid=shun.uuid)" |
|
a48474b…
|
drh
|
310 |
" FROM shun ORDER BY uuid"); |
|
a48474b…
|
drh
|
311 |
while( db_step(&q)==SQLITE_ROW ){ |
|
a48474b…
|
drh
|
312 |
const char *zUuid = db_column_text(&q, 0); |
|
a48474b…
|
drh
|
313 |
int stillExists = db_column_int(&q, 1); |
|
a48474b…
|
drh
|
314 |
cnt++; |
|
a48474b…
|
drh
|
315 |
if( stillExists ){ |
|
f5482a0…
|
wyoung
|
316 |
@ <b><a href="%R/artifact/%s(zUuid)">%s(zUuid)</a></b><br> |
|
a48474b…
|
drh
|
317 |
}else{ |
|
f5482a0…
|
wyoung
|
318 |
@ <b>%s(zUuid)</b><br> |
|
a48474b…
|
drh
|
319 |
} |
|
a48474b…
|
drh
|
320 |
} |
|
a48474b…
|
drh
|
321 |
if( cnt==0 ){ |
|
a48474b…
|
drh
|
322 |
@ <i>no artifacts are shunned on this server</i> |
|
a48474b…
|
drh
|
323 |
} |
|
a48474b…
|
drh
|
324 |
db_finalize(&q); |
|
3243e63…
|
drh
|
325 |
@ </p></blockquote> |
|
112c713…
|
drh
|
326 |
style_finish_page(); |
|
9b30c01…
|
drh
|
327 |
fossil_free(zCanonical); |
|
a48474b…
|
drh
|
328 |
} |
|
a48474b…
|
drh
|
329 |
|
|
a48474b…
|
drh
|
330 |
/* |
|
a48474b…
|
drh
|
331 |
** Remove from the BLOB table all artifacts that are in the SHUN table. |
|
a48474b…
|
drh
|
332 |
*/ |
|
a48474b…
|
drh
|
333 |
void shun_artifacts(void){ |
|
a48474b…
|
drh
|
334 |
Stmt q; |
|
a48474b…
|
drh
|
335 |
db_multi_exec( |
|
a48474b…
|
drh
|
336 |
"CREATE TEMP TABLE toshun(rid INTEGER PRIMARY KEY);" |
|
a48474b…
|
drh
|
337 |
"INSERT INTO toshun SELECT rid FROM blob, shun WHERE blob.uuid=shun.uuid;" |
|
a48474b…
|
drh
|
338 |
); |
|
a48474b…
|
drh
|
339 |
db_prepare(&q, |
|
a48474b…
|
drh
|
340 |
"SELECT rid FROM delta WHERE srcid IN toshun" |
|
a48474b…
|
drh
|
341 |
); |
|
a48474b…
|
drh
|
342 |
while( db_step(&q)==SQLITE_ROW ){ |
|
a48474b…
|
drh
|
343 |
int srcid = db_column_int(&q, 0); |
|
a48474b…
|
drh
|
344 |
content_undelta(srcid); |
|
a48474b…
|
drh
|
345 |
} |
|
a48474b…
|
drh
|
346 |
db_finalize(&q); |
|
a48474b…
|
drh
|
347 |
db_multi_exec( |
|
a48474b…
|
drh
|
348 |
"DELETE FROM delta WHERE rid IN toshun;" |
|
a48474b…
|
drh
|
349 |
"DELETE FROM blob WHERE rid IN toshun;" |
|
a48474b…
|
drh
|
350 |
"DROP TABLE toshun;" |
|
02a584f…
|
drh
|
351 |
"DELETE FROM private " |
|
02a584f…
|
drh
|
352 |
" WHERE NOT EXISTS (SELECT 1 FROM blob WHERE rid=private.rid);" |
|
766bec0…
|
drh
|
353 |
); |
|
766bec0…
|
drh
|
354 |
} |
|
766bec0…
|
drh
|
355 |
|
|
766bec0…
|
drh
|
356 |
/* |
|
766bec0…
|
drh
|
357 |
** WEBPAGE: rcvfromlist |
|
766bec0…
|
drh
|
358 |
** |
|
766bec0…
|
drh
|
359 |
** Show a listing of RCVFROM table entries. |
|
7ab0328…
|
drh
|
360 |
** |
|
7ab0328…
|
drh
|
361 |
** The RCVFROM table records where this repository received each |
|
7ab0328…
|
drh
|
362 |
** artifact, including the time of receipt, user, and IP address. |
|
7ab0328…
|
drh
|
363 |
** |
|
7ab0328…
|
drh
|
364 |
** Access requires Admin privilege. |
|
766bec0…
|
drh
|
365 |
*/ |
|
766bec0…
|
drh
|
366 |
void rcvfromlist_page(void){ |
|
766bec0…
|
drh
|
367 |
int ofst = atoi(PD("ofst","0")); |
|
a81a47f…
|
drh
|
368 |
int showAll = P("all")!=0; |
|
766bec0…
|
drh
|
369 |
int cnt; |
|
766bec0…
|
drh
|
370 |
Stmt q; |
|
386191d…
|
drh
|
371 |
const int perScreen = 500; /* RCVIDs per page */ |
|
766bec0…
|
drh
|
372 |
|
|
766bec0…
|
drh
|
373 |
login_check_credentials(); |
|
b344d3c…
|
drh
|
374 |
if( !g.perm.Admin ){ |
|
653dd40…
|
drh
|
375 |
login_needed(0); |
|
653dd40…
|
drh
|
376 |
return; |
|
766bec0…
|
drh
|
377 |
} |
|
c675484…
|
drh
|
378 |
style_header("Xfer Log"); |
|
b28badb…
|
drh
|
379 |
style_submenu_element("Log-Menu", "setup-logmenu"); |
|
a81a47f…
|
drh
|
380 |
if( showAll ){ |
|
a81a47f…
|
drh
|
381 |
ofst = 0; |
|
a81a47f…
|
drh
|
382 |
}else{ |
|
187424e…
|
andygoth
|
383 |
style_submenu_element("All", "rcvfromlist?all=1"); |
|
a81a47f…
|
drh
|
384 |
} |
|
766bec0…
|
drh
|
385 |
if( ofst>0 ){ |
|
187424e…
|
andygoth
|
386 |
style_submenu_element("Newer", "rcvfromlist?ofst=%d", |
|
386191d…
|
drh
|
387 |
ofst>perScreen ? ofst-perScreen : 0); |
|
a81a47f…
|
drh
|
388 |
} |
|
0594266…
|
drh
|
389 |
style_submenu_element("Artifacts", "bloblist"); |
|
0594266…
|
drh
|
390 |
style_submenu_element("Top-250", "bigbloblist"); |
|
a81a47f…
|
drh
|
391 |
db_multi_exec( |
|
a81a47f…
|
drh
|
392 |
"CREATE TEMP TABLE rcvidUsed(x INTEGER PRIMARY KEY);" |
|
386191d…
|
drh
|
393 |
"CREATE TEMP TABLE rcvidSha1(x INTEGER PRIMARY KEY);" |
|
386191d…
|
drh
|
394 |
"CREATE TEMP TABLE rcvidSha3(x INTEGER PRIMARY KEY);" |
|
a81a47f…
|
drh
|
395 |
"INSERT OR IGNORE INTO rcvidUsed(x) SELECT rcvid FROM blob;" |
|
386191d…
|
drh
|
396 |
"INSERT OR IGNORE INTO rcvidSha1(x)" |
|
386191d…
|
drh
|
397 |
" SELECT rcvid FROM blob WHERE length(uuid)==40;" |
|
386191d…
|
drh
|
398 |
"INSERT OR IGNORE INTO rcvidSha3(x)" |
|
386191d…
|
drh
|
399 |
" SELECT rcvid FROM blob WHERE length(uuid)==64;" |
|
a81a47f…
|
drh
|
400 |
); |
|
8972aae…
|
drh
|
401 |
if( db_table_exists("repository","unversioned") ){ |
|
8972aae…
|
drh
|
402 |
db_multi_exec( |
|
8972aae…
|
drh
|
403 |
"INSERT OR IGNORE INTO rcvidUsed(x) SELECT rcvid FROM unversioned;" |
|
386191d…
|
drh
|
404 |
"INSERT OR IGNORE INTO rcvidSha1(x)" |
|
386191d…
|
drh
|
405 |
" SELECT rcvid FROM unversioned WHERE length(hash)==40;" |
|
386191d…
|
drh
|
406 |
"INSERT OR IGNORE INTO rcvidSha3(x)" |
|
386191d…
|
drh
|
407 |
" SELECT rcvid FROM unversioned WHERE length(hash)==64;" |
|
8972aae…
|
drh
|
408 |
); |
|
8972aae…
|
drh
|
409 |
} |
|
3df526c…
|
jan.nijtmans
|
410 |
db_prepare(&q, |
|
a81a47f…
|
drh
|
411 |
"SELECT rcvid, login, datetime(rcvfrom.mtime), rcvfrom.ipaddr," |
|
386191d…
|
drh
|
412 |
" EXISTS(SELECT 1 FROM rcvidUsed WHERE x=rcvfrom.rcvid)," |
|
386191d…
|
drh
|
413 |
" EXISTS(SELECT 1 FROM rcvidSha1 WHERE x=rcvfrom.rcvid)," |
|
386191d…
|
drh
|
414 |
" EXISTS(SELECT 1 FROM rcvidSha3 WHERE x=rcvfrom.rcvid)" |
|
766bec0…
|
drh
|
415 |
" FROM rcvfrom LEFT JOIN user USING(uid)" |
|
a81a47f…
|
drh
|
416 |
" ORDER BY rcvid DESC LIMIT %d OFFSET %d", |
|
386191d…
|
drh
|
417 |
showAll ? -1 : perScreen+1, ofst |
|
766bec0…
|
drh
|
418 |
); |
|
9c89b0e…
|
drh
|
419 |
@ <p>Whenever new artifacts are added to the repository, either by |
|
c675484…
|
drh
|
420 |
@ push or using the web interface or by "fossil commit" or similar, |
|
c675484…
|
drh
|
421 |
@ an entry is made in the RCVFROM table |
|
c675484…
|
drh
|
422 |
@ to record the source of those artifacts. This log facilitates |
|
9c89b0e…
|
drh
|
423 |
@ finding and fixing attempts to inject illicit content into the |
|
9c89b0e…
|
drh
|
424 |
@ repository.</p> |
|
9c89b0e…
|
drh
|
425 |
@ |
|
9c89b0e…
|
drh
|
426 |
@ <p>Click on the "rcvid" to show a list of specific artifacts received |
|
9c89b0e…
|
drh
|
427 |
@ by a transaction. After identifying illicit artifacts, remove them |
|
a81a47f…
|
drh
|
428 |
@ using the "Shun" button. If an "rcvid" is not hyperlinked, that means |
|
a81a47f…
|
drh
|
429 |
@ all artifacts associated with that rcvid have already been shunned |
|
a81a47f…
|
drh
|
430 |
@ or purged.</p> |
|
9c89b0e…
|
drh
|
431 |
@ |
|
3243e63…
|
drh
|
432 |
@ <table cellpadding="0" cellspacing="0" border="0"> |
|
3243e63…
|
drh
|
433 |
@ <tr><th style="padding-right: 15px;text-align: right;">rcvid</th> |
|
3243e63…
|
drh
|
434 |
@ <th style="padding-right: 15px;text-align: left;">Date</th> |
|
3243e63…
|
drh
|
435 |
@ <th style="padding-right: 15px;text-align: left;">User</th> |
|
386191d…
|
drh
|
436 |
@ <th style="padding-right: 15px;text-align: left;">Hash</th> |
|
3243e63…
|
drh
|
437 |
@ <th style="text-align: left;">IP Address</th></tr> |
|
766bec0…
|
drh
|
438 |
cnt = 0; |
|
766bec0…
|
drh
|
439 |
while( db_step(&q)==SQLITE_ROW ){ |
|
766bec0…
|
drh
|
440 |
int rcvid = db_column_int(&q, 0); |
|
766bec0…
|
drh
|
441 |
const char *zUser = db_column_text(&q, 1); |
|
766bec0…
|
drh
|
442 |
const char *zDate = db_column_text(&q, 2); |
|
766bec0…
|
drh
|
443 |
const char *zIpAddr = db_column_text(&q, 3); |
|
386191d…
|
drh
|
444 |
int usesSha1 = db_column_int(&q, 5)!=0; |
|
386191d…
|
drh
|
445 |
int usesSha3 = db_column_int(&q, 6)!=0; |
|
70a94d0…
|
jan.nijtmans
|
446 |
static const char *const zHashType[] = { "", "sha1", "sha3", "both" }; |
|
386191d…
|
drh
|
447 |
const char *zHash = zHashType[usesSha1+usesSha3*2]; |
|
386191d…
|
drh
|
448 |
if( cnt==perScreen && !showAll ){ |
|
386191d…
|
drh
|
449 |
style_submenu_element("Older", "rcvfromlist?ofst=%d", ofst+perScreen); |
|
766bec0…
|
drh
|
450 |
}else{ |
|
766bec0…
|
drh
|
451 |
cnt++; |
|
766bec0…
|
drh
|
452 |
@ <tr> |
|
a81a47f…
|
drh
|
453 |
if( db_column_int(&q,4) ){ |
|
a81a47f…
|
drh
|
454 |
@ <td style="padding-right: 15px;text-align: right;"> |
|
a81a47f…
|
drh
|
455 |
@ <a href="rcvfrom?rcvid=%d(rcvid)">%d(rcvid)</a></td> |
|
a81a47f…
|
drh
|
456 |
}else{ |
|
a81a47f…
|
drh
|
457 |
@ <td style="padding-right: 15px;text-align: right;">%d(rcvid)</td> |
|
a81a47f…
|
drh
|
458 |
} |
|
3243e63…
|
drh
|
459 |
@ <td style="padding-right: 15px;text-align: left;">%s(zDate)</td> |
|
3243e63…
|
drh
|
460 |
@ <td style="padding-right: 15px;text-align: left;">%h(zUser)</td> |
|
386191d…
|
drh
|
461 |
@ <td style="padding-right: 15px;text-align: left;">%s(zHash)</td> |
|
3243e63…
|
drh
|
462 |
@ <td style="text-align: left;">%s(zIpAddr)</td> |
|
766bec0…
|
drh
|
463 |
@ </tr> |
|
766bec0…
|
drh
|
464 |
} |
|
766bec0…
|
drh
|
465 |
} |
|
766bec0…
|
drh
|
466 |
db_finalize(&q); |
|
766bec0…
|
drh
|
467 |
@ </table> |
|
112c713…
|
drh
|
468 |
style_finish_page(); |
|
766bec0…
|
drh
|
469 |
} |
|
766bec0…
|
drh
|
470 |
|
|
766bec0…
|
drh
|
471 |
/* |
|
766bec0…
|
drh
|
472 |
** WEBPAGE: rcvfrom |
|
766bec0…
|
drh
|
473 |
** |
|
7ab0328…
|
drh
|
474 |
** Show a single RCVFROM table entry identified by the rcvid= query |
|
7ab0328…
|
drh
|
475 |
** parameters. Requires Admin privilege. |
|
766bec0…
|
drh
|
476 |
*/ |
|
766bec0…
|
drh
|
477 |
void rcvfrom_page(void){ |
|
766bec0…
|
drh
|
478 |
int rcvid = atoi(PD("rcvid","0")); |
|
766bec0…
|
drh
|
479 |
Stmt q; |
|
8972aae…
|
drh
|
480 |
int cnt; |
|
766bec0…
|
drh
|
481 |
|
|
766bec0…
|
drh
|
482 |
login_check_credentials(); |
|
b344d3c…
|
drh
|
483 |
if( !g.perm.Admin ){ |
|
653dd40…
|
drh
|
484 |
login_needed(0); |
|
653dd40…
|
drh
|
485 |
return; |
|
9b30c01…
|
drh
|
486 |
} |
|
a81a47f…
|
drh
|
487 |
style_header("Artifact Receipt %d", rcvid); |
|
9b30c01…
|
drh
|
488 |
if( db_exists( |
|
9b30c01…
|
drh
|
489 |
"SELECT 1 FROM blob WHERE rcvid=%d AND" |
|
9b30c01…
|
drh
|
490 |
" NOT EXISTS (SELECT 1 FROM shun WHERE shun.uuid=blob.uuid)", rcvid) |
|
9b30c01…
|
drh
|
491 |
){ |
|
187424e…
|
andygoth
|
492 |
style_submenu_element("Shun All", "shun?shun&rcvid=%d#addshun", rcvid); |
|
3df526c…
|
jan.nijtmans
|
493 |
} |
|
9b30c01…
|
drh
|
494 |
if( db_exists( |
|
9b30c01…
|
drh
|
495 |
"SELECT 1 FROM blob WHERE rcvid=%d AND" |
|
9b30c01…
|
drh
|
496 |
" EXISTS (SELECT 1 FROM shun WHERE shun.uuid=blob.uuid)", rcvid) |
|
9b30c01…
|
drh
|
497 |
){ |
|
187424e…
|
andygoth
|
498 |
style_submenu_element("Unshun All", "shun?accept&rcvid=%d#delshun", rcvid); |
|
9b30c01…
|
drh
|
499 |
} |
|
3df526c…
|
jan.nijtmans
|
500 |
db_prepare(&q, |
|
766bec0…
|
drh
|
501 |
"SELECT login, datetime(rcvfrom.mtime), rcvfrom.ipaddr" |
|
766bec0…
|
drh
|
502 |
" FROM rcvfrom LEFT JOIN user USING(uid)" |
|
766bec0…
|
drh
|
503 |
" WHERE rcvid=%d", |
|
766bec0…
|
drh
|
504 |
rcvid |
|
766bec0…
|
drh
|
505 |
); |
|
3243e63…
|
drh
|
506 |
@ <table cellspacing="15" cellpadding="0" border="0"> |
|
a60b008…
|
joel
|
507 |
@ <tr><th valign="top" align="right">rcvid:</th> |
|
766bec0…
|
drh
|
508 |
@ <td valign="top">%d(rcvid)</td></tr> |
|
766bec0…
|
drh
|
509 |
if( db_step(&q)==SQLITE_ROW ){ |
|
766bec0…
|
drh
|
510 |
const char *zUser = db_column_text(&q, 0); |
|
766bec0…
|
drh
|
511 |
const char *zDate = db_column_text(&q, 1); |
|
766bec0…
|
drh
|
512 |
const char *zIpAddr = db_column_text(&q, 2); |
|
a60b008…
|
joel
|
513 |
@ <tr><th valign="top" align="right">User:</th> |
|
766bec0…
|
drh
|
514 |
@ <td valign="top">%s(zUser)</td></tr> |
|
a60b008…
|
joel
|
515 |
@ <tr><th valign="top" align="right">Date:</th> |
|
766bec0…
|
drh
|
516 |
@ <td valign="top">%s(zDate)</td></tr> |
|
a60b008…
|
joel
|
517 |
@ <tr><th valign="top" align="right">IP Address:</th> |
|
766bec0…
|
drh
|
518 |
@ <td valign="top">%s(zIpAddr)</td></tr> |
|
766bec0…
|
drh
|
519 |
} |
|
766bec0…
|
drh
|
520 |
db_finalize(&q); |
|
a81a47f…
|
drh
|
521 |
db_multi_exec( |
|
a81a47f…
|
drh
|
522 |
"CREATE TEMP TABLE toshow(rid INTEGER PRIMARY KEY);" |
|
a81a47f…
|
drh
|
523 |
"INSERT INTO toshow SELECT rid FROM blob WHERE rcvid=%d", rcvid |
|
a81a47f…
|
drh
|
524 |
); |
|
a81a47f…
|
drh
|
525 |
describe_artifacts("IN toshow"); |
|
766bec0…
|
drh
|
526 |
db_prepare(&q, |
|
a81a47f…
|
drh
|
527 |
"SELECT blob.rid, blob.uuid, blob.size, description.summary\n" |
|
a81a47f…
|
drh
|
528 |
" FROM blob LEFT JOIN description ON (blob.rid=description.rid)" |
|
a81a47f…
|
drh
|
529 |
" WHERE blob.rcvid=%d", rcvid |
|
a48474b…
|
drh
|
530 |
); |
|
8972aae…
|
drh
|
531 |
cnt = 0; |
|
766bec0…
|
drh
|
532 |
while( db_step(&q)==SQLITE_ROW ){ |
|
766bec0…
|
drh
|
533 |
const char *zUuid = db_column_text(&q, 1); |
|
766bec0…
|
drh
|
534 |
int size = db_column_int(&q, 2); |
|
a81a47f…
|
drh
|
535 |
const char *zDesc = db_column_text(&q, 3); |
|
a81a47f…
|
drh
|
536 |
if( zDesc==0 ) zDesc = ""; |
|
8972aae…
|
drh
|
537 |
if( cnt==0 ){ |
|
8972aae…
|
drh
|
538 |
@ <tr><th valign="top" align="right">Artifacts:</th> |
|
8972aae…
|
drh
|
539 |
@ <td valign="top"> |
|
8972aae…
|
drh
|
540 |
} |
|
8972aae…
|
drh
|
541 |
cnt++; |
|
1fee037…
|
drh
|
542 |
@ <a href="%R/info/%s(zUuid)">%s(zUuid)</a> |
|
f5482a0…
|
wyoung
|
543 |
@ %h(zDesc) (size: %d(size))<br> |
|
8972aae…
|
drh
|
544 |
} |
|
8972aae…
|
drh
|
545 |
if( cnt>0 ){ |
|
8972aae…
|
drh
|
546 |
@ <p> |
|
8972aae…
|
drh
|
547 |
if( db_exists( |
|
8972aae…
|
drh
|
548 |
"SELECT 1 FROM blob WHERE rcvid=%d AND" |
|
8972aae…
|
drh
|
549 |
" NOT EXISTS (SELECT 1 FROM shun WHERE shun.uuid=blob.uuid)", rcvid) |
|
8972aae…
|
drh
|
550 |
){ |
|
8972aae…
|
drh
|
551 |
@ <form action='%R/shun'> |
|
8972aae…
|
drh
|
552 |
@ <input type="hidden" name="shun"> |
|
8972aae…
|
drh
|
553 |
@ <input type="hidden" name="rcvid" value='%d(rcvid)'> |
|
8972aae…
|
drh
|
554 |
@ <input type="submit" value="Shun All These Artifacts"> |
|
8972aae…
|
drh
|
555 |
@ </form> |
|
8972aae…
|
drh
|
556 |
} |
|
8972aae…
|
drh
|
557 |
if( db_exists( |
|
8972aae…
|
drh
|
558 |
"SELECT 1 FROM blob WHERE rcvid=%d AND" |
|
8972aae…
|
drh
|
559 |
" EXISTS (SELECT 1 FROM shun WHERE shun.uuid=blob.uuid)", rcvid) |
|
8972aae…
|
drh
|
560 |
){ |
|
8972aae…
|
drh
|
561 |
@ <form action='%R/shun'> |
|
8972aae…
|
drh
|
562 |
@ <input type="hidden" name="unshun"> |
|
8972aae…
|
drh
|
563 |
@ <input type="hidden" name="rcvid" value='%d(rcvid)'> |
|
8972aae…
|
drh
|
564 |
@ <input type="submit" value="Unshun All These Artifacts"> |
|
8972aae…
|
drh
|
565 |
@ </form> |
|
8972aae…
|
drh
|
566 |
} |
|
8972aae…
|
drh
|
567 |
@ </td></tr> |
|
3243e63…
|
drh
|
568 |
} |
|
8972aae…
|
drh
|
569 |
if( db_table_exists("repository","unversioned") ){ |
|
8972aae…
|
drh
|
570 |
cnt = 0; |
|
8972aae…
|
drh
|
571 |
if( PB("uvdelete") && PB("confirmdelete") ){ |
|
8972aae…
|
drh
|
572 |
db_multi_exec( |
|
8972aae…
|
drh
|
573 |
"DELETE FROM unversioned WHERE rcvid=%d", rcvid |
|
8972aae…
|
drh
|
574 |
); |
|
8972aae…
|
drh
|
575 |
} |
|
8972aae…
|
drh
|
576 |
db_finalize(&q); |
|
d32155d…
|
jan.nijtmans
|
577 |
db_prepare(&q, |
|
8972aae…
|
drh
|
578 |
"SELECT name, hash, sz\n" |
|
8972aae…
|
drh
|
579 |
" FROM unversioned " |
|
8972aae…
|
drh
|
580 |
" WHERE rcvid=%d", rcvid |
|
d32155d…
|
jan.nijtmans
|
581 |
); |
|
8972aae…
|
drh
|
582 |
while( db_step(&q)==SQLITE_ROW ){ |
|
8972aae…
|
drh
|
583 |
const char *zName = db_column_text(&q,0); |
|
8972aae…
|
drh
|
584 |
const char *zHash = db_column_text(&q,1); |
|
8972aae…
|
drh
|
585 |
int size = db_column_int(&q,2); |
|
8972aae…
|
drh
|
586 |
int isDeleted = zHash==0; |
|
8972aae…
|
drh
|
587 |
if( cnt==0 ){ |
|
8972aae…
|
drh
|
588 |
@ <tr><th valign="top" align="right">Unversioned Files:</th> |
|
8972aae…
|
drh
|
589 |
@ <td valign="top"> |
|
8972aae…
|
drh
|
590 |
} |
|
8972aae…
|
drh
|
591 |
cnt++; |
|
8972aae…
|
drh
|
592 |
if( isDeleted ){ |
|
f5482a0…
|
wyoung
|
593 |
@ %h(zName) (deleted)<br> |
|
8972aae…
|
drh
|
594 |
}else{ |
|
f5482a0…
|
wyoung
|
595 |
@ <a href="%R/uv/%h(zName)">%h(zName)</a> (size: %d(size))<br> |
|
8972aae…
|
drh
|
596 |
} |
|
8972aae…
|
drh
|
597 |
} |
|
8972aae…
|
drh
|
598 |
if( cnt>0 ){ |
|
8972aae…
|
drh
|
599 |
@ <p><form action='%R/rcvfrom'> |
|
8972aae…
|
drh
|
600 |
@ <input type="hidden" name="rcvid" value='%d(rcvid)'> |
|
8972aae…
|
drh
|
601 |
@ <input type="hidden" name="uvdelete" value="1"> |
|
8972aae…
|
drh
|
602 |
if( PB("uvdelete") ){ |
|
8972aae…
|
drh
|
603 |
@ <input type="hidden" name="confirmdelete" value="1"> |
|
8972aae…
|
drh
|
604 |
@ <input type="submit" value="Confirm Deletion of These Files"> |
|
8972aae…
|
drh
|
605 |
}else{ |
|
8972aae…
|
drh
|
606 |
@ <input type="submit" value="Delete These Unversioned Files"> |
|
8972aae…
|
drh
|
607 |
} |
|
8972aae…
|
drh
|
608 |
@ </form> |
|
8972aae…
|
drh
|
609 |
@ </td></tr> |
|
8972aae…
|
drh
|
610 |
} |
|
8972aae…
|
drh
|
611 |
} |
|
766bec0…
|
drh
|
612 |
@ </table> |
|
3243e63…
|
drh
|
613 |
db_finalize(&q); |
|
112c713…
|
drh
|
614 |
style_finish_page(); |
|
a48474b…
|
drh
|
615 |
} |