kb-show.php3 2.55 KB
Newer Older
Leigh B. Stoller's avatar
Leigh B. Stoller committed
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
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");

#
# Standard Testbed Header
#
PAGEHEADER("Knowledge Base Entry");

#
# Admin users get a menu.
#
$uid     = GETLOGIN();
$isadmin = 0;
if (CHECKLOGIN($uid) & CHECKLOGIN_LOGGEDIN) {
    $isadmin = ISADMIN();
}

#
# Check record.
# 
if (isset($idx) && $idx != "") {
    if (! TBvalid_integer($idx)) {
	PAGEARGERROR("Invalid characters in $idx");
    }
    $query_result =
	DBQueryFatal("select * from knowledge_base_entries ".
		     "where idx='$idx'");
    if (! mysql_num_rows($query_result)) {
	USERERROR("No such knowledge_base entry: $idx", 1);
    }
    $row = mysql_fetch_array($query_result);
}
elseif (isset($xref_tag) && $xref_tag != "") {
    if (! preg_match("/^[-\w]+$/", $xref_tag)) {
	PAGEARGERROR("Invalid characters in $xref_tag");
    }
    $query_result =
	DBQueryFatal("select * from knowledge_base_entries ".
		     "where xref_tag='$xref_tag'");
    if (! mysql_num_rows($query_result)) {
	USERERROR("No such knowledge_base entry: $xref_tag", 1);
    }
    $row = mysql_fetch_array($query_result);
    $idx = $row['idx'];
}

else {
    PAGEARGERROR("Must supply a knowledge_base index or xref tag");
}

echo "<center><b>Knowledge Base Entry: $idx</b><br>".
     "(<a href=kb-search.php3>Search Again</a>)</center>\n";
echo "<br><br>\n";

if ($isadmin) {
    SUBPAGESTART();
    SUBMENUSTART("Options");
    
    WRITESUBMENUBUTTON("Modify Entry",
		       "kb-manage.php3?idx=$idx&action=edit");
    WRITESUBMENUBUTTON("Delete Entry",
		       "kb-manage.php3?idx=$idx&action=delete");
    WRITESUBMENUBUTTON("Add Entry", "kb-manage.php3");
    SUBMENUEND();
}

echo "<blockquote>\n";
echo "<font size=+1>" . $row['title'] . "</font>\n";
echo "<br><br>\n";
echo $row['body'];

77
echo "<br><br>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
78
echo "<font size=-2>Posted by " . $row['creator_uid'] . " on " .
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
      $row['date_created'] . "</font><br>\n";

#
# Get other similar topics and list the titles.
#
$query_result =
    DBQueryFatal("select * from knowledge_base_entries ".
		 "where section='". $row['section'] . "'");

if (mysql_num_rows($query_result)) {
    echo "<hr>";
    echo "<b>Other similar topics</b>:<br>\n";
    echo "<blockquote>\n";
    echo "<ul>\n";

    while ($row = mysql_fetch_array($query_result)) {
	$title    = $row['title'];
	$idx      = $row['idx'];
    
	echo "<li>";
	echo "<a href=kb-show.php3?idx=$idx>$title</a>\n";
    }
    echo "</ul>\n";
    echo "</blockquote>\n";
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
104
105
106
107
108
109
110
111

if ($isadmin) {
    echo "</blockquote>\n";
    SUBPAGEEND();
}

PAGEFOOTER();
?>