-
Notifications
You must be signed in to change notification settings - Fork 0
/
revision.php
95 lines (64 loc) · 2.27 KB
/
revision.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
<?php
/* think tank forums
*
* revision.php
*/
$ttf_title = $ttf_label = "revision browser";
require_once "include_common.php";
require_once "include_finediff.php";
// pull through the variables
$ref_id = clean($_GET["ref_id"]);
$type = clean($_GET["type"]);
// if either of the variables is empty
if (empty($ref_id) || empty($type)) {
message($ttf_label, $ttf_msg["fatal_error"], $ttf_msg["noitemspec"]);
die();
};
// make some nice titles/labels
switch ($type) {
case 'post':
$ttf_label .= " » post $ref_id";
break;
case 'profile':
$ttf_label .= " » profile for user $ref_id";
break;
case 'title':
$ttf_label .= " » title for user $ref_id";
break;
};
$ttf_title = $ttf_label;
// let's output a page to the user
require_once "include_header.php";
// start counting revisions
$revnum = 0;
// grab the revisions
$sql = "SELECT ttf_revision.*, ttf_user.username ".
"FROM ttf_revision, ttf_user ".
"WHERE ttf_revision.author_id = ttf_user.user_id ".
" && type='$type' && ref_id='$ref_id' ".
"ORDER BY date ASC";
if (!$result = mysql_query($sql)) showerror();
while ($rev = mysql_fetch_array($result)) {
$date = formatdate($rev["date"]);
if (isset($lastrev)) {
$opcodes = FineDiff::getDiffOpcodes(output($lastrev), output($rev["body"]), FineDiff::$wordGranularity);
$revbody = FineDiff::renderDiffToHTMLFromOpcodes(output($lastrev), $opcodes);
$lastrev = $rev["body"];
} else {
$revbody = $rev["body"];
$lastrev = $rev["body"];
};
echo " <div class=\"contenttitle_sm\">\n";
echo " rev $revnum, rev_id {$rev["rev_id"]} by\n";
echo " <a class=\"link\" href=\"profile.php?user_id={$rev["author_id"]}\">".output($rev["username"])."</a>";
if (!empty($rev["ip"])) {
echo " ({$rev["ip"]})\n";
};
echo " <span title=\"{$date[1]}\">{$date[0]}</span>\n";
echo " </div>\n";
echo " <div class=\"contentbox_sm\">\n";
echo nl2br($revbody)."\n";
echo " </div>\n";
$revnum++;
};
require_once "include_footer.php";