kb-show.php3 2.01 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 77 78 79 80 81 82 83 84 85 86 87
<?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'];

echo "<br><br><br><br>\n";
echo "<font size=-2>Posted by " . $row['creator_uid'] . " on " .
      $row['date_created'] . "</font><br><br>\n";

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

PAGEFOOTER();
?>