Initial commit of developer.linuxdoc.org

This commit is contained in:
david 2001-07-20 03:43:51 +00:00
parent f0e3634e72
commit e6902d7c1b
23 changed files with 1970 additions and 0 deletions

View File

@ -0,0 +1,58 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$conn=Pg::connectdb("dbname=$dbmain");
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
$caller = param('caller');
$sql = "SELECT max(doc_id) from document";
$result=$conn->exec($sql);
@row = $result->fetchrow;
$doc_id = $row[0] + 1;
$title = param('title');
$title =~ s/\'/\'\'/;
$class = param('class');
$format = param('format');
$dtd = param('dtd');
$pub_status = param('pub_status');
$sql = "INSERT INTO document(doc_id, title, filename, class, format, dtd, dtd_version, version, last_update, url, isbn, pub_status, author_status, review_status, tickle_date, pub_date, ref_url, tech_review_status, maintained)";
$sql = "$sql VALUES ($doc_id, '$title', NULL, '$class', '$format', '$dtd', NULL, NULL, NULL, NULL, NULL, $pub_status', '$author_status', 'U', NULL, NULL, NULL, 'U', 't')";
#print header;
#print start_html;
#print "<p>doc_id:$doc_id";
#print "<p>title:$title";
#print "<p>pub_status:$pub_status";
#print "<p>class:$class";
#print "<p>format:$format";
#print "<p>dtd:$dtd";
#print "<p>sql:$sql";
#print end_html;
#exit;
$conn->exec($sql);
print $query->redirect("document_edit.pl?doc_id=$doc_id");
#print $query->redirect($caller);

596
LDP/lampadas/www/document_edit.pl Executable file
View File

@ -0,0 +1,596 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$dbmain = "ldp";
@row;
# Read parameters
$doc_id = param('doc_id');
$conn=Pg::connectdb("dbname=$dbmain");
die $conn->errorMessage unless PGRES_CONNECTION_OK eq $conn->status;
$result = $conn->exec("SELECT doc_id, title, filename, class, format, dtd, dtd_version, version, last_update, url, isbn, pub_status, review_status, tickle_date, ref_url, pub_date, tech_review_status, maintained, license FROM document WHERE doc_id = $doc_id");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
@row = $result->fetchrow;
# Load from db
$doc_id = $row[0];
$title = $row[1];
$title =~ s/\s+$//;
$title =~ s/\'//;
$filename = $row[2];
$filename =~ s/\s+$//;
$class = $row[3];
$class =~ s/\s+$//;
$format = $row[4];
$format =~ s/\s+$//;
$dtd = $row[5];
$dtd =~ s/\s+$//;
$dtd_version = $row[6];
$dtd_version =~ s/\s+$//;
$version = $row[7];
$version =~ s/\s+$//;
$last_update = $row[8];
$url = $row[9];
$isbn = $row[10];
$pub_status = $row[11];
$review_status = $row[12];
$tickle_date = $row[13];
$ref_url = $row[14];
$pub_date = $row[15];
$tech_review_status = $row[16];
$maintained = $row[17];
$license = $row[18];
$license =~ s/\s+$//;
# Read the votes
$votes_result = $conn->exec("select vote from doc_vote where doc_id = $doc_id");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $votes_result->resultStatus;
$vote_count = 0;
$vote_total = 0;
$vote_avg = 0;
while (@row = $votes_result->fetchrow) {
$vote = $row[0];
$vote_count++;
$vote_total = $vote_total + $vote;
}
if ($vote_count > 0) {
$vote_avg = $vote_total / $vote_count;
}
$votes_result = $conn->exec("select vote from doc_vote where doc_id = $doc_id");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $votes_result->resultStatus;
@row = $votes_result->fetchrow;
$vote = $row[0];
print header(-expires=>'now');
print "<html><head><title>$title</title>";
print "<link rel=stylesheet href='../ldp.css' type='text/css'>";
print "</head>";
print "<body>";
print "<h1>$title</h1>\n";
print "<p><a href='../index.html'>Index</a> ";
print "<a href='topic_list.pl'>Topics</a> ";
print "<a href='document_list.pl'>Documents</a> ";
print "<a href='maintainer_list.pl'>Maintainers</a> ";
print "<a href='editor_list.pl'>Editors</a> ";
print "<p>ID: $doc_id";
print "<form method=POST action='document_save.pl' name='edit'>\n";
print "<input type=hidden name=doc_id value='$doc_id'>\n";
print "<table>\n";
print "<tr><th colspan=8>Document Details</th></tr>\n";
print "<tr><td align=right>Title:</td><td colspan=5><input type=text name=title size=60 value='$title'></td></tr>\n";
print "<tr><td align=right>Filename:</td><td colspan=5><input type=text name=filename size=60 value='$filename'></td></tr>\n";
print "<tr>";
print "<td align=right>Status:</td><td>";
print "<select name=pub_status>";
if ( $pub_status eq "N" ) { print '<option selected value="N">Active</option>'; } else { print '<option value="N">Active</option>' }
if ( $pub_status eq "?" ) { print '<option selected value="?">Unknown</option>'; } else { print '<option value="?">Unknown</option>' }
if ( $pub_status eq "A" ) { print '<option selected value="A">Archived</option>'; } else { print '<option value="A">Archived</option>' }
if ( $pub_status eq "D" ) { print '<option selected value="D">Deleted</option>'; } else { print '<option value="D">Deleted</option>' }
if ( $pub_status eq "O" ) { print '<option selected value="O">Offsite</option>'; } else { print '<option value="O">Offsite</option>' }
if ( $pub_status eq "P" ) { print '<option selected value="P">Pending</option>'; } else { print '<option value="P">Pending</option>' }
if ( $pub_status eq "R" ) { print '<option selected value="R">Replaced</option>'; } else { print '<option value="R">Replaced</option>' }
if ( $pub_status eq "W" ) { print '<option selected value="W">Wishlist</option>'; } else { print '<option value="W">Wishlist</option>' }
print "</select></td>";
print "<td align=right>Class:</td><td>\n";
print "<select name=class>";
if ( $class eq "BACKGROUNDER" ) { print '<option selected>BACKGROUNDER</option>'; } else { print '<option>BACKGROUNDER</option>' }
if ( $class eq "HOWTO" ) { print '<option selected>HOWTO</option>'; } else { print '<option>HOWTO</option>' }
if ( $class eq "MINI" ) { print '<option selected>MINI</option>'; } else { print '<option>MINI</option>' }
if ( $class eq "FAQ" ) { print '<option selected>FAQ</option>'; } else { print '<option>FAQ</option>' }
if ( $class eq "QUICK" ) { print '<option selected>QUICK</option>'; } else { print '<option>QUICK</option>' }
if ( $class eq "GUIDE" ) { print '<option selected>GUIDE</option>'; } else { print '<option>GUIDE</option>' }
if ( $class eq "TEMPLATE" ) { print '<option selected>TEMPLATE</option>'; } else { print '<option>TEMPLATE</option>' }
print "</select></td>";
print "<td align=right>Maintained:</td><td>\n";
if ( $maintained eq "t" ) { print 'Yes'; } else { print 'No' }
#print "<select name=maintained>";
#if ( $maintained eq "t" ) { print '<option selected value="t">Yes</option>'; } else { print '<option value="t">Yes</option>' }
#if ( $maintained eq "f" ) { print '<option selected value="f">No</option>'; } else { print '<option value="f">No</option>' }
#print "</select>";
print "</td>";
print "</tr>\n<tr>\n";
print "<td align=right>Review Status:</td><td>";
print "<select name=review_status>";
if ( $review_status eq "U" ) { print '<option selected value="U">Unreviewed</option>'; } else { print '<option value="U">Unreviewed</option>' }
if ( $review_status eq "N" ) { print '<option selected value="N">Need Identified</option>'; } else { print '<option value="N">Need Identified</option>' }
if ( $review_status eq "P" ) { print '<option selected value="P">Pending</option>'; } else { print '<option value="P">Pending</option>' }
if ( $review_status eq "R" ) { print '<option selected value="R">Completed</option>'; } else { print '<option value="R">Completed</option>' }
print "</select></td>";
print "<td align=right>Tech Review:</td><td>";
print "<select name=tech_review_status>";
if ( $tech_review_status eq "U" ) { print '<option selected value="U">Unreviewed</option>'; } else { print '<option value="U">Unreviewed</option>' }
if ( $tech_review_status eq "N" ) { print '<option selected value="N">Need Identified</option>'; } else { print '<option value="N">Need Identified</option>' }
if ( $tech_review_status eq "P" ) { print '<option selected value="P">Pending</option>'; } else { print '<option value="P">Pending</option>' }
if ( $tech_review_status eq "R" ) { print '<option selected value="R">Completed</option>'; } else { print '<option value="R">Completed</option>' }
print "</select></td>";
print "<td align=right>License:</td><td>";
print "<select name=license>";
if ( $license eq "" ) { print '<option selected></option>'; } else { print '<option></option>' }
if ( $license eq "GFDL" ) { print '<option selected>GFDL</option>'; } else { print '<option>GFDL</option>' }
if ( $license eq "LDPL" ) { print '<option selected>LDPL</option>'; } else { print '<option>LDPL</option>' }
if ( $license eq "OPL" ) { print '<option selected>OPL</option>'; } else { print '<option>OPL</option>' }
if ( $license eq "GPL" ) { print '<option selected>GPL</option>'; } else { print '<option>GPL</option>' }
if ( $license eq "NONE" ) { print '<option selected>NONE</option>'; } else { print '<option>NONE</option>' }
if ( $license eq "PD" ) { print '<option selected>PD</option>'; } else { print '<option>PD</option>' }
if ( $license eq "OTHER" ) { print '<option selected>OTHER</option>'; } else { print '<option>OTHER</option>' }
print "</select></td>";
print "</tr>\n<tr>\n";
print "<td align=right>Published:</td><td><input type=text name=pub_date size=10 value='$pub_date'></td>";
print "<td align=right>Updated:</td><td><input type=text name=last_update size=10 value='$last_update'></td>";
print "<td align=right>Version:</td><td><input type=text name=version size=10 value='$version'></td>";
print "</tr>\n<tr>\n";
print "<td align=right>Format:</td><td>";
print "<select name=format>";
if ( $format eq "" ) { print '<option selected></option>'; } else { print '<option></option>' }
if ( $format eq "SGML" ) { print '<option selected>SGML</option>'; } else { print '<option>SGML</option>' }
if ( $format eq "XML" ) { print '<option selected>XML</option>'; } else { print '<option>XML</option>' }
if ( $format eq "TEXT" ) { print '<option selected>TEXT</option>'; } else { print '<option>TEXT</option>' }
if ( $format eq "LaTeX" ) { print '<option selected>LaTeX</option>'; } else { print '<option>LaTeX</option>' }
if ( $format eq "PDF" ) { print '<option selected>PDF</option>'; } else { print '<option>PDF</option>' }
print "</select></td>";
print "<td align=right>DTD:</td><td>";
print "<select name=dtd>";
if ( $dtd eq "" ) { print '<option selected></option>'; } else { print '<option></option>' }
if ( $dtd eq "N/A" ) { print '<option selected>N/A</option>'; } else { print '<option>N/A</option>' }
if ( $dtd eq "HTML" ) { print '<option selected>HTML</option>'; } else { print '<option>HTML</option>' }
if ( $dtd eq "DocBook" ) { print '<option selected>DocBook</option>'; } else { print '<option>DocBook</option>' }
if ( $dtd eq "LinuxDoc" ) { print '<option selected>LinuxDoc</option>'; } else { print '<option>LinuxDoc</option>' }
print "</select></td>";
print "<td align=right>DTD Version:</td><td>";
print "<input type=text name=dtd_version size=10 value='$dtd_version'>";
print "</td>";
print "</tr>\n<tr>\n";
print "<td align=right><a href='$url'>URL</a>:</td><td colspan=7><input type=text name=url size=60 value='$url'></td>";
print "</tr>\n<tr>\n";
print "<td align=right><a href='$ref_url'>Home</a>:</td><td colspan=7><input type=text name=ref_url size=60 value='$ref_url'></td>";
print "</tr>\n<tr>\n";
print "<td align=right>Tickle Date</td><td><input type=text name=tickle_date size=10 value='$tickle_date'></td>";
print "<td align=right>ISBN:</td><td><input type=text name=isbn size=14 value='$isbn'></td>";
print "<td></td><td><input type=submit value=Save></td>";
print "</tr>\n<tr>\n";
print "<td align=right>Rating</td><td>";
if ( $vote > 0 ) {
print "<table border=0 bgcolor=black cellspacing=0 cellpadding=0>\n";
for ( $i = 1; $i <= 10; $i++ ) {
print "<td bgcolor=";
if ( $vote >= $i ) { print "green" } else { print "black" }
print ">&nbsp;&nbsp;</td>\n";
}
print "</tr></table>\n";
}
else {
print "Not rated";
}
print "</td>";
print "</tr></table>\n";
print "</form>";
print "<p><hr>";
print "<h2>Contributors</h2>";
$authors_result = $conn->exec("SELECT maintainer.maintainer_id, role, active, document_maintainer.email, maintainer.email as author_email, maintainer_name FROM document_maintainer, maintainer WHERE doc_id = $doc_id and document_maintainer.maintainer_id = maintainer.maintainer_id ORDER BY active desc, maintainer_name");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $authors_result->resultStatus;
print "<p><table>\n";
print "<tr><th>Status</th><th>Role</th><th>Name</th><th>Feedback Email</th><th colspan=2>Action</th></tr>";
while (@row = $authors_result->fetchrow) {
$maintainer_id = $row[0];
$role = $row[1];
$role =~ s/\s*$//;
if ( $row[2] eq 't' ) { $active = "Active" } else { $active = "Inactive" }
$feedback_email = $row[3];
$email = $row[4];
if ( $row[5] eq '' ) { $maintainer_name = 'J. Doe' } else { $maintainer_name = "$row[5]" }
print "<tr>";
print "<form method=POST action='document_maintainer_save.pl'>";
print "<input type=hidden name=caller value='document_edit.pl?doc_id=$doc_id'>";
print "<input type=hidden name=doc_id value=$doc_id>";
print "<input type=hidden name=maintainer_id value=$maintainer_id>";
print '<td valign=top><select name="active">';
if ( $active eq "Active" ) { print '<option selected value="t">Active</option>' } else { print '<option value="t">Active</option>' }
if ( $active eq "Inactive" ) { print '<option selected value="f">Inactive</option>' } else { print '<option value="f">Inactive</option>' }
print "</select></td>";
print "<td valign=top><select name='role'>";
if ( $role eq "Author" ) { print '<option selected>Author</option>' } else { print '<option>Author</option>' }
if ( $role eq "Co-Author" ) { print '<option selected>Co-Author</option>' } else { print '<option>Co-Author</option>' }
if ( $role eq "Maintainer" ) { print '<option selected>Maintainer</option>' } else { print '<option>Maintainer</option>' }
if ( $role eq "Converter" ) { print '<option selected>Converter</option>' } else { print '<option>Converter</option>' }
print "</select></td>\n";
print "<td valign=top><a href='maintainer_edit.pl?maintainer_id=$maintainer_id'>$maintainer_name</a></td>\n";
print "<td valign=top><input type=text name=email width=20 size=20 value='$feedback_email'></input></td>\n";
print "<td valign=top><input type=checkbox name=chkDel>Del</td>";
print "<td valign=top><input type=submit value=Save></td>\n";
print "</form>";
print "</tr>\n";
}
# For assigning a new contributor
#print "<tr><th colspan=6>New Contributor</th></tr>";
print "<tr>";
print "<form method=POST action='document_maintainer_add.pl'>";
print "<input type=hidden name=caller value='document_edit.pl?doc_id=$doc_id'>";
print "<input type=hidden name=doc_id value=$doc_id>";
print '<td valign=top><select name="active">';
print '<option value="t">Active</option>';
print '<option value="f">Inactive</option>';
print "</select></td>";
print "<td valign=top><select name='role'>";
print '<option>Author</option>';
print '<option>Co-Author</option>';
print '<option>Maintainer</option>';
print '<option>Converter</option>';
print "</select></td>\n";
print "<td valign=top>";
$sql = "SELECT maintainer_id, maintainer_name FROM maintainer ORDER BY maintainer_name";
$authors_result = $conn->exec($sql);
die $conn->errorMessage unless PGRES_TUPLES_OK eq $authors_result->resultStatus;
print "<select name=maintainer_id\n";
print "<option>\n";
while (@row = $authors_result->fetchrow) {
$maintainer_id = $row[0];
if ( $row[1] eq '' ) { $maintainer_name = 'J. Doe' } else { $maintainer_name = "$row[1]" }
print "<option value=$maintainer_id>$maintainer_name\n"
}
print "</select>\n";
print "</td>\n";
print "<td valign=top><input type=text name=email width=20 size=20></td>\n";
print "<td valign=top></td>\n";
print "<td valign=top><input type=submit value=Add></td>\n";
print "</form>";
print "</tr>\n";
print "</table>\n";
print "<br><small>Note: Deleting a record here doesn't delete the maintainer. It only deletes the association between the maintainer and this document.</small>\n";
print "<p><hr>";
print "<h2>Topic Assignments</h2>\n";
@topics;
@topic_names;
$topic_count = 0;
$topic_result = $conn->exec("SELECT topic.topic_num, subtopic.subtopic_num, topic.topic_name, subtopic.subtopic_name FROM topic, subtopic WHERE subtopic.topic_num = topic.topic_num ORDER BY topic_num, subtopic_num");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $topic_result->resultStatus;
while (@row = $topic_result->fetchrow) {
$topic_count++;
$topics[$topic_count] = $row[0] . "." . $row[1];
$topic_names[$topic_count] = $row[2] . ": " . $row[3];
# print "<p>found: " . $topics[$rownum] . " = " . $topic_names[$rownum];
}
print "<p><table>\n";
print "<tr><th>Topic</th><th>Action</th></tr>\n";
$document_topic_result = $conn->exec("SELECT topic.topic_num, topic.topic_name, subtopic.subtopic_num, subtopic.subtopic_name FROM document_topic, subtopic, topic WHERE document_topic.topic_num = subtopic.topic_num and document_topic.subtopic_num = subtopic.subtopic_num AND subtopic.topic_num = topic.topic_num AND doc_id=$doc_id ORDER BY topic_num, subtopic_num");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $document_topic_result->resultStatus;
while (@row = $document_topic_result->fetchrow) {
$topic_num = $row[0];
$topic_name = $row[1];
$subtopic_num = $row[2];
$subtopic_name = $row[3];
print "<tr>\n";
print "<form method=POST action='document_topic_del.pl'>\n";
print "<input type=hidden name=caller value='document_edit.pl?doc_id=$doc_id'>";
print "<input type=hidden name=doc_id value=$doc_id>";
print "<input type=hidden name=topic_num value=$topic_num>";
print "<input type=hidden name=subtopic_num value=$subtopic_num>";
print "<td>$topic_num.$subtopic_num $topic_name: $subtopic_name</td>";
print "<td valign=top><input type=submit value=Delete></td>\n";
print "</form>\n";
print "</tr>\n";
}
print "<tr>";
print "<form method=POST action='document_topic_add.pl'>";
print "<input type=hidden name=caller value='document_edit.pl?doc_id=$doc_id'>";
print "<input type=hidden name=doc_id value=$doc_id>";
print '<td valign=top><select name="topic">';
print "<option value=></option>\n";
for ($topic = 0; $topic < @topics; $topic++) {
$topic_num = $topics[$topic];
$topic_name = $topic_names[$topic];
print "<option value=" . $topic_num . ">" . $topic_num . " " . $topic_name . "</option>\n";
}
print "</select></td>\n";
print "<td valign=top><input type=submit value=Add></td>\n";
print "</form>\n";
print "</tr></table>\n";
print "<p><hr>";
print "<h2>Audience Assignments</h2>\n";
print "<p>under construction. move along...";
#print "<p><table>\n";
#print "<tr><th>Audience</th><th>Description</th></tr>\n";
#$audience_result = $conn->exec("SELECT audience, audience_level, audience_description FROM document_audience, audience WHERE document_audience.doc_id = $doc_id AND document_audience.audience = audience.audience ORDER BY audience_level");
#die $conn->errorMessage unless PGRES_TUPLES_OK eq $audience_result->resultStatus;
#while (@row = $Audience_result->fetchrow) {
# $audience = $row[0];
# $audience_level = $row[1];
# $audience_description = $row[2];
# print "<tr>\n";
# print "<form method=POST action='document audience_del.pl'>\n";
# print "<input type=hidden name=caller value='document_edit.pl?doc_id=$doc_id'>";
# print "<input type=hidden name=doc_id value=$doc_id>";
# print "<input type=hidden name=topic_num value=$topic_num>";
# print "<input type=hidden name=subtopic_num value=$subtopic_num>";
# print "<td>$topic_num.$subtopic_num $topic_name: $subtopic_name</td>";
# print "<td valign=top><input type=submit value=Delete></td>\n";
# print "</form>\n";
# print "</tr>\n";
#}
#print "<tr>";
#print "<form method=POST action='document_topic_add.pl'>";
#print "<input type=hidden name=caller value='document_edit.pl?doc_id=$doc_id'>";
#print "<input type=hidden name=doc_id value=$doc_id>";
#print '<td valign=top><select name="topic">';
#print "<option value=></option>\n";
#for ($topic = 0; $topic < @topics; $topic++) {
# $topic_num = $topics[$topic];
# $topic_name = $topic_names[$topic];
# print "<option value=" . $topic_num . ">" . $topic_num . " " . $topic_name . "</option>\n";
#}
#print "</select></td>\n";
#print "<td valign=top><input type=submit value=Add></td>\n";
#print "</form>\n";
#print "</tr></table>\n";
print "<p><hr>";
print "<h2>Editors</h2>";
$authors_result = $conn->exec("SELECT editor.editor_id, editor_role, active, editor.email, editor.editor_name FROM document_editor, editor WHERE doc_id = $doc_id and document_editor.editor_id = editor.editor_id ORDER BY active desc, editor_name");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $authors_result->resultStatus;
print "<p><table>\n";
print "<tr><th>Status</th><th>Role</th><th>Name</th><th>Email</th><th colspan=2>Action</th></tr>";
while (@row = $authors_result->fetchrow) {
$editor_id = $row[0];
$editor_role = $row[1];
$editor_role =~ s/\s*$//;
if ( $row[2] eq 't' ) { $active = "Active" } else { $active = "Inactive" }
if ( $row[4] eq '' ) { $editor_name = 'J. Doe' } else { $editor_name = $row[4] }
print "<tr>";
print "<form method=GET action='document_editor_save.pl'>";
print "<input type=hidden name=caller value='document_edit.pl?doc_id=$doc_id'>";
print "<input type=hidden name=doc_id value=$doc_id>";
print "<input type=hidden name=editor_id value=$editor_id>";
print '<td valign=top><select name="active">';
if ( $active eq "Active" ) { print '<option selected value="t">Active</option>' } else { print '<option value="t">Active</option>' }
if ( $active eq "Inactive" ) { print '<option selected value="f">Inactive</option>' } else { print '<option value="f">Inactive</option>' }
print "</select></td>";
print "<td valign=top><select name='editor_role'>";
if ( $editor_role eq "LANG" ) { print '<option selected value="LANG">Language Editor</option>' } else { print '<option value="LANG">Language Editor</option>' }
if ( $editor_role eq "TECH" ) { print '<option selected value="TECH">Technical Editor</option>' } else { print '<option value="TECH">Technical Editor</option>' }
print "</select></td>\n";
print "<td valign=top><a href='editor_edit.pl?editor_id=$editor_id'>$editor_name</a></td>\n";
print "<td valign=top>" . $row[3] . "</td>\n";
print "<td valign=top><input type=checkbox name=chkDel>Del</td>";
print "<td valign=top><input type=submit value=Save></td>\n";
print "</form>";
print "</tr>\n";
}
# For assigning a new editor
print "<tr>";
print "<form method=POST action='document_editor_add.pl'>";
print "<input type=hidden name=caller value='document_edit.pl?doc_id=$doc_id'>";
print "<input type=hidden name=doc_id value=$doc_id>";
print '<td valign=top><select name="active">';
print '<option value="t">Active</option>';
print '<option value="f">Inactive</option>';
print "</select></td>";
print "<td valign=top><select name='editor_role'>";
print '<option value="LANG">Language Editor</option>';
print '<option value="TECH">Technical Editor</option>';
print "</select></td>\n";
print "<td valign=top>";
$sql = "SELECT editor_id, editor_name FROM editor ORDER BY editor_name";
$editors_result = $conn->exec($sql);
die $conn->errorMessage unless PGRES_TUPLES_OK eq $editors_result->resultStatus;
print "<select name=editor_id\n";
print "<option>\n";
while (@row = $editors_result->fetchrow) {
$editor_id = $row[0];
if ( $row[1] eq '' ) { $editor_name = 'J. Doe' } else { $editor_name = "$row[1]" }
print "<option value=$editor_id>$editor_name</option>\n"
}
print "</select>\n";
print "</td>\n";
print "<td valign=top>&nbsp;</td>\n";
print "<td valign=top>&nbsp;</td>\n";
print "<td valign=top><input type=submit value=Add></td>\n";
print "</form>";
print "</tr>\n";
print "</table>\n";
print "<br><small>Note: Deleting a record here doesn't delete the editor. It only deletes the association between the editor and this document.</small>\n";
print "<p><hr>";
print "<h2>Rating</h2>\n";
print "<p><table border=0 cellspacing=0 cellpadding=0>\n";
for ( $i = 1; $i <= 10; $i++ ) {
print "<td bgcolor=";
if ( $vote >= $i ) { print "green" } else { print "black" }
print ">&nbsp;&nbsp;&nbsp;</td>\n";
}
print "</tr></table>\n";
print "<p>You can rate each document on a scale from 1 to 10, where 1 is very poor and 10 is excellent.\n";
print "Your vote is averaged with the votes of others to obtain a rating for the document.\n";
print "<form name=vote method=POST action='document_vote_save.pl'>";
print "<p><table>\n";
print "<tr><td align=right>Votes:</td><td>$vote_count</td></tr>\n";
print "<tr><td align=right>Average:</td><td>$vote_avg</td></tr>\n";
print "<tr><td align=right>Your Vote:</td><td>\n";
print "<input name=vote type=text size=2 width=2 value=$vote></input>\n";
print "<input type=hidden name=doc_id value=$doc_id>\n";
print "<input type=submit value='Rate'></td>\n";
print "</table>";
print "</form>";
print "<p><hr>";
$notes_result = $conn->exec("SELECT date_entered, notes, username FROM notes WHERE doc_id = $doc_id ORDER BY date_entered");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $notes_result->resultStatus;
print "<h2>Notes</h2>\n";
print "<form name=notes method=POST action='document_note_add.pl'>";
print "<p><table>\n";
print "<tr><th>Date and Time</th><th>User</th><th>Note</th></tr>";
while (@row = $notes_result->fetchrow) {
$date_entered = $row[0];
$notes = $row[1];
$notes =~ s/</&lt;/;
$notes =~ s/>/&gt;/;
$username = $row[2];
print "<tr><td valign=top>$date_entered</td><td valign=top>$username</td><td valign=top>$notes</td></tr>\n";
}
print "<tr><td colspan=2 align=right>To add a note, type the note, then click Save.</td>\n";
print "<td><textarea name=note rows=10 cols=40></textarea>\n";
print "<input type=hidden name=doc_id value=$doc_id>\n";
print "<input type=submit value='Save'></td>\n";
print "</tr>";
print "</table>\n";
print "</form>";
print end_html;

View File

@ -0,0 +1,45 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
# Read parameters
$caller = param('caller');
$doc_id = param('doc_id');
$editor_id = param('editor_id');
$active = param('active');
$editor_role = param('editor_role');
$conn=Pg::connectdb("dbname=$dbmain");
#print header;
#print start_html;
$sql = "INSERT INTO document_editor(doc_id, editor_id, active, editor_role) VALUES ($doc_id, $editor_id, '$active', '$editor_role')";
$result=$conn->exec($sql);
#print header;
#print start_html;
#print $sql;
#print end_html;
#exit;
print $query->redirect($caller)

View File

@ -0,0 +1,44 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
# Read parameters
$caller = param('caller');
$doc_id = param('doc_id');
$editor_id = param('editor_id');
$active = param('active');
$editor_role = param('editor_role');
$chkDel = param('chkDel');
$conn=Pg::connectdb("dbname=$dbmain");
if ( $chkDel eq 'on' ) {
$sql = "DELETE FROM document_editor WHERE doc_id = $doc_id and editor_id = $editor_id";
$result=$conn->exec($sql);
}
else {
$sql = "UPDATE document_editor SET active = '$active' WHERE doc_id = $doc_id and editor_id = $editor_id";
$result=$conn->exec($sql);
$sql = "UPDATE document_editor SET editor_role = '$editor_role' WHERE doc_id = $doc_id and editor_id = $editor_id";
$result=$conn->exec($sql);
}
print $query->redirect($caller)

View File

@ -0,0 +1,24 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$dbmain = "ldp";
@row;
$query = new CGI;
# Read parameters
$doc_id = param('doc_id');
$conn=Pg::connectdb("dbname=$dbmain");
die $conn->errorMessage unless PGRES_CONNECTION_OK eq $conn->status;
$result = $conn->exec("SELECT url FROM document WHERE doc_id=$doc_id");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
@row = $result->fetchrow;
# Load from db
$url = $row[0] =~ s/\s+$//;
print $query->redirect("$url");

310
LDP/lampadas/www/document_list.pl Executable file
View File

@ -0,0 +1,310 @@
#!/usr/bin/perl
use CGI qw(:standard);
use Pg;
use Time::localtime;
$dbmain='ldp';
@row;
$count = 0;
$query = new CGI;
# Read parameters
$chkBACKGROUNDER = param('chkBACKGROUNDER');
$chkHOWTO = param('chkHOWTO');
$chkMINI = param('chkMINI');
$chkGUIDE = param('chkGUIDE');
$chkFAQ = param('chkFAQ');
$chkQUICK = param('chkQUICK');
$chkTEMPLATE = param('chkTEMPLATE');
# Optional Fields
$chkSTATUS = param('chkSTATUS');
$chkCLASS = param('chkCLASS');
$chkFORMAT = param('chkFORMAT');
$chkDTD = param('chkDTD');
$chkPUBDATE = param('chkPUBDATE');
$chkLASTUPDATE = param('chkLASTUPDATE');
$chkTICKLEDATE = param('chkTICKLEDATE');
$chkREVIEWSTATUS = param('chkREVIEWSTATUS');
$chkTECHSTATUS = param('chkTECHSTATUS');
$chkURL = param('chkURL');
$chkMAINTAINED = param('chkMAINTAINED');
$chkLICENSE = param('chkLICENSE');
$SORT1 = param('strSORT1');
$SORT2 = "";
$SORT3 = "";
if ( $SORT1 ) {
$SORT2 = param('strSORT2');
$SORT3 = param('strSORT3');
}
else {
$SORT1 = "Title";
}
if ( $SORT2 ) { $SORT2 = ", $SORT2"; }
if ( $SORT3 ) { $SORT3 = ", $SORT3"; }
# Clear
$BACKGROUNDER = "";
$HOWTO = "";
$MINI = "";
$GUIDE = "";
$FAQ = "";
$QUICK = "";
$TEMPLATE = "";
$STATUS = "";
$CLASS = "";
$FORMAT = "";
$DTD = "";
$PUBDATE = "";
$LASTUPDATE = "";
$TICKLEDATE = "";
$REVIEWSTATUS = "";
$TECHSTATUS = "";
$URL = "";
$MAINTAINED = "";
$LICENSE = "";
# Translate them into checked phrases for checkboxes and WHERE clauses
$WHERE = "WHERE class in (''";
if ( $chkBACKGROUNDER eq "on" ) { $BACKGROUNDER = "checked "; $WHERE = $WHERE . ",'BACKGROUNDER'"; }
if ( $chkHOWTO eq "on" ) { $HOWTO = "checked "; $WHERE = $WHERE . ",'HOWTO'"; }
if ( $chkMINI eq "on" ) { $MINI = "checked "; $WHERE = $WHERE . ",'MINI'"; }
if ( $chkGUIDE eq "on" ) { $GUIDE = "checked "; $WHERE = $WHERE . ",'GUIDE'"; }
if ( $chkFAQ eq "on" ) { $FAQ = "checked "; $WHERE = $WHERE . ",'FAQ'"; }
if ( $chkQUICK eq "on" ) { $QUICK = "checked "; $WHERE = $WHERE . ",'QUICK'"; }
if ( $chkTEMPLATE eq "on" ) { $TEMPLATE = "checked "; $WHERE = $WHERE . ",'TEMPLATE'"; }
if ( length($WHERE) < 20 ) { $WHERE = $WHERE . ", 'BACKGROUNDER', 'HOWTO', 'MINI', 'GUIDE', 'FAQ', 'QUICK', 'TEMPLATE'" }
$WHERE = $WHERE . ") ";
if ( $chkSTATUS eq "on" ) { $STATUS = "checked "; }
if ( $chkCLASS eq "on" ) { $CLASS = "checked "; }
if ( $chkFORMAT eq "on" ) { $FORMAT = "checked "; }
if ( $chkDTD eq "on" ) { $DTD = "checked "; }
if ( $chkPUBDATE eq "on" ) { $PUBDATE = "checked "; }
if ( $chkLASTUPDATE eq "on" ) { $LASTUPDATE = "checked "; }
if ( $chkTICKLEDATE eq "on" ) { $TICKLEDATE = "checked "; }
if ( $chkREVIEWSTATUS eq "on" ) { $REVIEWSTATUS = "checked "; }
if ( $chkTECHSTATUS eq "on" ) { $TECHSTATUS = "checked "; }
if ( $chkURL eq "on" ) { $URL = "checked "; }
if ( $chkMAINTAINED eq "on" ) { $MAINTAINED = "checked "; }
if ( $chkLICENSE eq "on" ) { $LICENSE = "checked "; }
# print the page
print header(-expires=>'now');
print "<html><head>\n";
print "<title>Document List</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'>\n";
print "</head>\n";
print "<body>\n";
print "<h1>Document List</h1>\n";
#print "<p>Welcome, " . $query->remote_user();
print "<p><a href='../index.html'>Index</a> ";
print "<a href='topic_list.pl'>Topics</a>\n";
print "<a href='maintainer_list.pl'>Maintainers</a>\n";
print "<a href='editor_list.pl'>Editors</a>\n";
print "<p><form action='document_edit.pl' method=POST>\n";
print "<p>Jump to a document by ID: <input type=text size=5 name=doc_id>\n";
print "<input type=submit value=Jump>\n";
print "</form>\n";
print "<form name=filter method=POST action='document_list.pl'>";
print "<p><table border=2 cellspacing=5>";
print "<tr><th>Classes</th><th>Optional Fields</th><th>Sorting Options</th></tr>";
print "<tr><td valign=top>\n";
print "<input type=checkbox $BACKGROUNDER name=chkBACKGROUNDER>Backgrounder<br>\n";
print "<input type=checkbox $HOWTO name=chkHOWTO>HOWTOs<br>\n";
print "<input type=checkbox $MINI name=chkMINI>Mini-HOWTOs<br>\n";
print "<input type=checkbox $GUIDE name=chkGUIDE>Guides<br>\n";
print "<input type=checkbox $FAQ name=chkFAQ>FAQs<br>\n";
print "<input type=checkbox $QUICK name=chkQUICK>Quick References<br>\n";
print "<input type=checkbox $TEMPLATE name=chkTEMPLATE>Templates\n";
print "</td>\n";
print "<td valign=top>\n";
print "<input type=checkbox $STATUS name=chkSTATUS>Status<br>\n";
print "<input type=checkbox $CLASS name=chkCLASS>Class<br>\n";
print "<input type=checkbox $FORMAT name=chkFORMAT>Format<br>\n";
print "<input type=checkbox $DTD name=chkDTD>DTD<br>\n";
print "<input type=checkbox $PUBDATE name=chkPUBDATE>Publication Date<br>\n";
print "<input type=checkbox $LASTUPDATE name=chkLASTUPDATE>Last Update<br>\n";
print "<input type=checkbox $TICKLEDATE name=chkTICKLEDATE>Tickle Date<br>\n";
print "<input type=checkbox $REVIEWSTATUS name=chkREVIEWSTATUS>Review Status<br>\n";
print "<input type=checkbox $TECHSTATUS name=chkTECHSTATUS>Tech Review Status<br>\n";
print "<input type=checkbox $URL name=chkURL>URL<br>\n";
print "<input type=checkbox $MAINTAINED name=chkMAINTAINED>Maintained<br>\n";
print "<input type=checkbox $LICENSE name=chkLICENSE>License<br>\n";
print "</td>\n";
print "<td valign=top>\n";
print "<select name=strSORT1>\n";
print "<option></option>\n";
print "<option>Title</option>\n";
print "<option value='document.pub_status, title'>Status</option>\n";
print "<option value='review_status_name, title'>Review Status</option>\n";
print "<option value=tech_review_status_name, title'>Tech Review Status</option>\n";
print "<option value='class, title'>Class</option>\n";
print "<option value='format, title'>Format</option>\n";
print "<option value='dtd, title'>DTD</option>\n";
print "<option value='pub_date, title'>Publication Date</option>\n";
print "<option value='last_update, title'>Last Update</option>\n";
print "<option value='tickle_date, title'>Tickle Date</option>\n";
print "<option value='url, title'>URL</option>\n";
print "<option value='maintained, title'>Maintained</option>\n";
print "<option value='license, title'>License</option>\n";
print "</select><br>";
print "</td>\n";
print "</tr></table>\n";
print "<input type=submit value=Reload>\n";
print "</form>\n";
print "<p><hr>";
print "<p><table border=1>\n";
print "<tr><th>Title</th>";
if ( $STATUS ) { print "<th>Status</th>"; }
if ( $REVIEWSTATUS ) { print "<th>Review Status</th>"; }
if ( $TECHSTATUS ) { print "<th>Tech Status</th>"; }
if ( $MAINTAINED ) { print "<th>Maintained</th>"; }
if ( $LICENSE ) { print "<th>License</th>"; }
if ( $CLASS ) { print "<th>Class</th>"; }
if ( $FORMAT ) { print "<th>Format</th>"; }
if ( $DTD ) { print "<th>DTD</th>"; }
if ( $PUBDATE ) { print "<th>Pub Date</th>"; }
if ( $LASTUPDATE ) { print "<th>Last Update</th>"; }
if ( $TICKLEDATE ) { print "<th>Tickle Date</th>"; }
if ( $URL ) { print "<th>URL</th>"; }
print "</tr>\n";
# Connect and load the tuples
$conn=Pg::connectdb("dbname=$dbmain");
$sql = "SELECT doc_id, title, pub_status_name, class, format, tickle_date, dtd, lr.review_status_name, tr.review_status_name as tech_review_status_name, url, pub_date, last_update, maintained, license FROM document, pub_status, review_status lr, review_status tr $WHERE AND document.pub_status=pub_status.pub_status AND document.review_status = lr.review_status and document.tech_review_status = tr.review_status ORDER BY $SORT1";
#print "<tr><td colspan=20>$sql</td></tr>";
$result=$conn->exec("$sql");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
while (@row = $result->fetchrow) {
$doc_id = $row[0];
$title = $row[1];
$pub_status_name = $row[2];
$class = $row[3];
$format = $row[4];
$tickle_date = $row[5];
$dtd = $row[6];
$review_status_name = $row[7];
$tech_review_status_name = $row[8];
$url = $row[9];
$pub_date = $row[10];
$last_update = $row[11];
$maintained = $row[12];
$maintained =~ s/f/No/;
$maintained =~ s/t/Yes/;
$license = $row[13];
print "<tr>";
print "<td>";
print a({href=>"document_edit.pl?doc_id=$doc_id"},"$title");
if ( $url ne "" ) { print "&nbsp;&nbsp;&nbsp;<a href='$url'>Go!</a>" }
print "</td>";
if ( $STATUS) { print "<td>$pub_status_name</td>"; }
if ( $REVIEWSTATUS) { print "<td>$review_status_name</td>"; }
if ( $TECHSTATUS) { print "<td>$tech_review_status_name</td>"; }
if ( $MAINTAINED ) { print "<td>$maintained</td>"; }
if ( $LICENSE ) { print "<td>$license</td>"; }
if ( $CLASS ) { print "<td>$class</td>"; }
if ( $FORMAT) { print "<td>$format</td>"; }
if ( $DTD ) { print "<td>$dtd</td>"; }
if ( $PUBDATE ) { print "<td>$pub_date</td>"; }
if ( $LASTUPDATE ) { print "<td>$last_update</td>"; }
if ( $TICKLEDATE ) {
$date = `date -I`;
if ( $date gt $tickle_date ) {
print "<td><font color=red>$tickle_date</font></td>"
}
else {
print "<td>$tickle_date</td>"
}
}
if ( $URL ) { print "<td>$url</td>"; }
print "</tr>\n";
$count++;
}
print "</table>\n";
print "<p>Count: $count";
print "<p><hr>";
print "<h1>New Document</h1>\n";
print "<p><form method=POST action='document_add.pl'>\n";
print "<input type=hidden name=caller value='document_list.pl'>\n";
print "<table>\n";
print "<tr><td align=right>Title:</td><td><input type=text name=title size=60 width=60></td></tr>\n";
print "<tr><td align=right>Status:</td><td>";
print "<select name=pub_status>\n";
print "<option value='N'>Active</option>\n";
print "<option value='?'>Unknown</option>\n";
print "<option value='A'>Archived</option>\n";
print "<option value='D'>Deleted</option>\n";
print "<option value='O'>Offsite</option>\n";
print "<option value='P'>Pending</option>\n";
print "<option value='R'>Replaced</option>\n";
print "<option value='W'>Wishlist</option>\n";
print "</select>\n";
print "</td></tr>\n";
print "<tr><td align=right>Class:</td><td>";
print "<select name=class>\n";
print "<option>BACKGROUNDER</option>\n";
print "<option>HOWTO</option>\n";
print "<option>MINI</option>\n";
print "<option>FAQ</option>\n";
print "<option>QUICK</option>\n";
print "<option>GUIDE</option>\n";
print "<option>TEMPLATE</option>\n";
print "</select>\n";
print "</td></tr>\n";
print "<tr><td align=right>Format:</td><td>";
print "<select name=format>\n";
print "<option></option>\n";
print "<option>SGML</option>\n";
print "<option>XML</option>\n";
print "<option>TEXT</option>\n";
print "<option>LaTeX</option>\n";
print "<option>PDF</option>\n";
print "</select>\n";
print "</td></tr>\n";
print "<tr><td align=right>DTD:</td><td>";
print "<select name=dtd>\n";
print "<option></option>\n";
print "<option>N/A</option>\n";
print "<option>HTML</option>\n";
print "<option>DocBook</option>\n";
print "<option>LinuxDoc</option>\n";
print "</select>\n";
print "</td></tr>\n";
print "<tr><td></td><td><input type=submit value=Add></td></tr>\n";
print "</table></form>\n";
print end_html;

View File

@ -0,0 +1,54 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
# Read parameters
$caller = param('caller');
$doc_id = param('doc_id');
$maintainer_id = param('maintainer_id');
$active = param('active');
$role = param('role');
$email = param('email');
$conn=Pg::connectdb("dbname=$dbmain");
#print header;
#print start_html;
$sql = "INSERT INTO document_maintainer(doc_id, maintainer_id, active, role, email) VALUES ($doc_id, $maintainer_id, '$active', '$role', '$email' )";
$result=$conn->exec($sql);
#update the maintained field in the document record
$sql = "SELECT COUNT(*) as active_maintainers FROM document_maintainer WHERE doc_id=$doc_id AND (role='Author' OR role='Co-Author' OR role='Maintainer') AND active='t'";
$result=$conn->exec($sql);
@row = $result->fetchrow;
$active_maintainers = $row[0];
if ( $active_maintainers > 0 ) { $maintained = "t" } else { $maintained = "f" }
$sql = "UPDATE document SET maintained='$maintained' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
#print header;
#print start_html;
#print $sql;
#print end_html;
#exit;
print $query->redirect($caller)

View File

@ -0,0 +1,62 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
# Read parameters
$caller = param('caller');
$doc_id = param('doc_id');
$maintainer_id = param('maintainer_id');
$active = param('active');
$role = param('role');
$email = param('email');
$chkDel = param('chkDel');
$conn=Pg::connectdb("dbname=$dbmain");
#print header;
#print start_html;
if ( $chkDel eq 'on' ) {
$sql = "DELETE FROM document_maintainer WHERE doc_id = $doc_id and maintainer_id = $maintainer_id";
$result=$conn->exec($sql);
}
else {
$sql = "UPDATE document_maintainer SET active = '$active' WHERE doc_id = $doc_id and maintainer_id = $maintainer_id";
$result=$conn->exec($sql);
$sql = "UPDATE document_maintainer SET role = '$role' WHERE doc_id = $doc_id and maintainer_id = $maintainer_id";
$result=$conn->exec($sql);
$sql = "UPDATE document_maintainer SET email = '$email' WHERE doc_id = $doc_id and maintainer_id = $maintainer_id";
$result=$conn->exec($sql);
# print "$sql<br>\n";
# print "active_maintainers: $active_maintainers\n";
}
#update the maintained field in the document record
$sql = "SELECT COUNT(*) as active_maintainers FROM document_maintainer WHERE doc_id=$doc_id AND (role='Author' OR role='Co-Author' OR role='Maintainer') AND active='t'";
$result=$conn->exec($sql);
@row = $result->fetchrow;
$active_maintainers = $row[0];
if ( $active_maintainers > 0 ) { $maintained = "t" } else { $maintained = "f" }
$sql = "UPDATE document SET maintained='$maintained' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
print $query->redirect($caller)

View File

@ -0,0 +1,35 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
# Read parameters
$doc_id = param('doc_id');
$username = $query->remote_user();
$note = param('note');
$note =~ s/\'/\'\'/;
$conn=Pg::connectdb("dbname=$dbmain");
$sql = "INSERT INTO notes (doc_id, date_entered, username, notes) values ($doc_id, now(), '$username', '$note')";
$result=$conn->exec($sql);
print $query->redirect("document_edit.pl?doc_id=$doc_id");

101
LDP/lampadas/www/document_save.pl Executable file
View File

@ -0,0 +1,101 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
# Read parameters
$doc_id = param('doc_id');
$title = param('title');
$title =~ s/\'/\'\'/;
$filename = param('filename');
$filename =~ s/\'/\'\'/;
$class = param('class');
$format = param('format');
$dtd = param('dtd');
$dtd_version = param('dtd_version');
$version = param('version');
$version =~ s/\'/\'\'/;
$last_update = param('last_update');
$url = param('url');
$isbn = param('isbn');
$pub_status = param('pub_status');
$review_status = param('review_status');
$tickle_date = param('tickle_date');
$ref_url = param('ref_url');
$pub_date = param('pub_date');
$tech_review_status = param('tech_review_status');
$maintained = param('maintained');
$license = param('license');
$conn=Pg::connectdb("dbname=$dbmain");
#This is horribly inefficient, but allows partial saves.
#For our volume, it hardly matters.
$sql = "UPDATE document SET title='$title' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET filename='$filename' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET class='$class' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET format='$format' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET dtd='$dtd' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET dtd_version='$dtd_version' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET version='$version' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET last_update='$last_update' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET url='$url' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET isbn='$isbn' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET pub_status='$pub_status' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET review_status='$review_status' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
if ( $tickle_date eq '' )
{ $sql = "UPDATE document SET tickle_date=NULL WHERE doc_id=$doc_id"; }
else
{ $sql = "UPDATE document SET tickle_date='$tickle_date' WHERE doc_id=$doc_id"; }
$result=$conn->exec($sql);
$sql = "UPDATE document SET ref_url='$ref_url' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET pub_date='$pub_date' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET tech_review_status='$tech_review_status' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET maintained='$maintained' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
$sql = "UPDATE document SET license='$license' WHERE doc_id=$doc_id";
$result=$conn->exec($sql);
print $query->redirect("document_edit.pl?doc_id=$doc_id");
print header;
print start_html;
print "<p>$sql";
print end_html;
exit;

View File

@ -0,0 +1,38 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
# Read parameters
$caller = param('caller');
$doc_id = param('doc_id');
$topic = param('topic');
@topic_subtopic_num = split /\./, $topic;
$topic_num = $topic_subtopic_num[0];
$subtopic_num = $topic_subtopic_num[1];
$sql = "INSERT INTO document_topic (doc_id, topic_num, subtopic_num) VALUES ($doc_id, $topic_num, $subtopic_num)";
$conn=Pg::connectdb("dbname=$dbmain");
$result=$conn->exec($sql);
print $query->redirect($caller)

View File

@ -0,0 +1,35 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
# Read parameters
$doc_id = param('doc_id');
$topic_num = param('topic_num');
$subtopic_num = param('subtopic_num');
$caller = param('caller');
$conn=Pg::connectdb("dbname=$dbmain");
$sql = "DELETE FROM document_topic WHERE doc_id=$doc_id AND topic_num=$topic_num AND subtopic_num=$subtopic_num";
$result=$conn->exec($sql);
print $query->redirect($caller)

View File

@ -0,0 +1,38 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
$conn=Pg::connectdb("dbname=$dbmain");
$doc_id = param('doc_id');
$vote = param('vote');
$username = $query->remote_user();
$sql = "DELETE FROM doc_vote WHERE doc_id=$doc_id AND username='$username'";
$result=$conn->exec($sql);
$sql = "INSERT INTO doc_vote(doc_id, username, vote) values ($doc_id, '$username', $vote)";
$result=$conn->exec($sql);
$conn->exec($sql);
print $query->redirect("document_edit.pl?doc_id=$doc_id");

51
LDP/lampadas/www/editor_add.pl Executable file
View File

@ -0,0 +1,51 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
$conn=Pg::connectdb("dbname=$dbmain");
# Read parameters
$caller = param('caller');
$editor_name = param('editor_name');
$editor_name =~ s/\'/\'\'/;
$email = param('email');
$sql = "SELECT max(editor_id) from editor";
$result=$conn->exec($sql);
@row = $result->fetchrow;
$editor_id = $row[0] + 1;
$sql = "INSERT INTO editor(editor_id, editor_name, email) VALUES ($editor_id, '$editor_name', '$email')";
#print header;
#print start_html;
#print "<p>$editor_name";
#print "<p>$email";
#print "<p>$editor_id";
#print "<p>$sql";
#print end_html;
#exit;
$conn->exec($sql);
print $query->redirect($caller)

84
LDP/lampadas/www/editor_edit.pl Executable file
View File

@ -0,0 +1,84 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$dbmain = "ldp";
@row;
# Read parameters
$editor_id = param('editor_id');
# Load data from db and call edit form
$conn=Pg::connectdb("dbname=$dbmain");
$result = $conn->exec("SELECT editor_id, editor_name, email, notes from editor where editor_id = $editor_id");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
@row = $result->fetchrow;
# Load from db
$editor_id = $row[0];
$editor_name = $row[1];
$editor_name =~ s/\s*$//;
$email = $row[2];
$email =~ s/\s*$//;
$notes = $row[3];
$notes =~ s/\s*$//;
print header(-expires=>'now');
print "<html><head><title>$editor_name</title>";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>";
print "<body>";
print "<h1>$editor_name</h1>\n";
print "<p><a href='../index.html'>Index</a> \n";
print "<a href='topic_list.pl'>Topics</a> \n";
print "<a href='document_list.pl'>Documents</a> \n";
print "<a href='maintainer_list.pl'>Maintainers</a> ";
print "<a href='editor_list.pl'>Editors</a>";
print "<p>ID: $editor_id";
print "<form name=edit method=POST action='editor_save.pl'>";
print "<input type=hidden name=editor_id value=$editor_id></input>";
printf "<p><table>\n";
print '<tr><td>Name:</td><td><input type=text name="editor_name" size=30 value="' . $editor_name . '"></input></td></tr>';
print '<tr><td>Email:</td><td><input type=text name="email" size=30 value="' . $email . '"></input></td></tr>';
print "<tr><td valign=top>Notes:</td><td><textarea name=notes rows=10 cols=40>$notes</textarea></td></tr>\n";
print "<tr><td></td><td><input type=submit value=Save></td></tr>";
print "</table>";
print "</form>";
$docs_result = $conn->exec("SELECT document.doc_id, document.title, class, pub_status.pub_status_name, document_editor.editor_role, document_editor.active FROM document_editor, document, pub_status WHERE document_editor.editor_id = $editor_id AND document.pub_status = pub_status.pub_status AND document_editor.doc_id = document.doc_id ORDER BY document.title");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $docs_result->resultStatus;
print "\n<h2>Documents</h2>\n";
printf "<p><table border=1 cellspacing=2\n";
print "<tr><th>Title</th><th>Class</th><th>Doc Status</th><th>Role</th><th>Active</th></tr>";
while (@row = $docs_result->fetchrow) {
$doc_id = $row[0];
$title = $row[1];
$class = $row[2];
$pub_status_name = $row[3];
$editor_role = $row[4];
$active = $row[5];
if ( $active eq 't' ) { $active = "Active" } else { $active = "Inactive" }
print "<tr>";
print "<form method=POST action='document_editor_save.pl'>\n";
print "<td valign=top><a href='document_edit.pl?doc_id=$doc_id'>$title</a></td>\n";
print "<td valign=top>$class</td>\n";
print "<td valign=top>$pub_status_name</td>\n";
print "<td valign=top>$editor_role</td>\n";
print "<td valign=top>$active</td>\n";
print "</form>";
print "</tr>\n";
}
printf "</table>\n";
print end_html;

58
LDP/lampadas/www/editor_list.pl Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/perl
use CGI qw(:standard);
use Pg;
$dbmain='ldp';
@row;
$count = 0;
# Connect and load the tuples
$conn=Pg::connectdb("dbname=$dbmain");
$result=$conn->exec("SELECT editor_id, editor_name, email FROM editor ORDER BY editor_name");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
# print the page
print header(-expires=>'now');
print "<html><head><title>LDP Editors</title>";
print "<link rel=stylesheet href='../ldp.css' type='text/css'>";
print "</head>";
print "<body>";
print "<h1>LDP Editors</h1>\n";
print "<p><a href='../index.html'>Index</a> \n";
print "<a href='topic_list.pl'>Topics</a> \n";
print "<a href='document_list.pl'>Documents</a> \n";
print "<a href='maintainer_list.pl'>Maintainers</a> \n";
print "<p><table border=0>\n";
while (@row = $result->fetchrow) {
$editor_id = $row[0];
$editor_name = $row[1];
if ( $editor_name eq "" ) { $editor_name = 'J. Doe' }
$email = $row[2];
print "<tr><td>";
print a({href=>"editor_edit.pl?editor_id=$editor_id"},"$editor_name");
print "</td>";
print "</tr>";
$count++;
}
print "</table>\n";
print "<p>Count: $count";
print "<p><hr>\n";
print "<h1>New Editor</h1>\n";
print "<p><form method=POST action='editor_add.pl'>\n";
print "<input type=hidden name=caller value='editor_list.pl'>\n";
print "<table>\n";
print "<tr><td align=right>Name:</td><td><input type=text name=editor_name width=20 size=20></td></tr>\n";
print "<tr><td align=right>Email:</td><td><input type=text name=email width=20 size=20></td></tr>\n";
print "<tr><td></td><td><input type=submit value=Save></td></tr>\n";
print "</table></form>\n";
print end_html;

36
LDP/lampadas/www/editor_save.pl Executable file
View File

@ -0,0 +1,36 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
# Read parameters
$editor_id = param('editor_id');
$editor_name = param('editor_name');
$editor_name =~ s/\'/\'\'/;
$email = param('email');
$notes = param('notes');
$notes =~ s/\'/\'\'/;
$conn=Pg::connectdb("dbname=$dbmain");
$sql = "UPDATE editor SET editor_name='$editor_name', email='$email', notes='$notes' WHERE editor_id = $editor_id";
$result=$conn->exec($sql);
print $query->redirect("editor_edit.pl?editor_id=$editor_id");

View File

@ -0,0 +1,50 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$conn=Pg::connectdb("dbname=$dbmain");
$dbmain = "ldp";
@row;
# Read parameters
$caller = param('caller');
$maintainer_name = param('maintainer_name');
$maintainer_name =~ s/\'/\'\'/;
$email = param('email');
$sql = "SELECT max(maintainer_id) from maintainer";
$result=$conn->exec($sql);
@row = $result->fetchrow;
$maintainer_id = $row[0] + 1;
$sql = "INSERT INTO maintainer(maintainer_id, maintainer_name, email) VALUES ($maintainer_id, '$maintainer_name', '$email')";
$conn->exec($sql);
#print header;
#print start_html;
#print "<p>$maintainer_name";
#print "<p>$email";
#print "<p>$maintainer_id";
#print "<p>$sql";
#print end_html;
#exit;
print $query->redirect($caller)

View File

@ -0,0 +1,87 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$dbmain = "ldp";
@row;
# Read parameters
$maintainer_id = param('maintainer_id');
# Load data from db and call edit form
$conn=Pg::connectdb("dbname=$dbmain");
$result = $conn->exec("SELECT maintainer_id, maintainer_name, email from maintainer where maintainer_id = $maintainer_id");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
@row = $result->fetchrow;
# Load from db
$maintainer_id = $row[0];
$maintainer_name = $row[1];
$maintainer_name =~ s/\s*$//;
$email = $row[2];
$email =~ s/\s*$//;
print header(-expires=>'now');
print "<html><head><title>$maintainer_name</title>";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>";
print "<body>";
print "<h1>$maintainer_name</h1>\n";
print "<p><a href='../index.html'>Index</a> \n";
print "<a href='document_list.pl'>Documents</a> \n";
print "<a href='maintainer_list.pl'>Maintainers</a> \n";
print "<a href='editor_list.pl'>Editors</a> \n";
print "<p>ID: $maintainer_id";
print "<form name=edit method=POST action='maintainer_save.pl'>";
printf "<p>\n";
print "<input type=hidden name=maintainer_id value=$maintainer_id></input>";
printf "<p>\n";
print 'Name: <input type=text name="maintainer_name" size=30 value="' . $maintainer_name . '"></input><br>';
printf "<p>\n";
print 'Email: <input type=text name="email" size=30 value="' . $email . '"></input><br>';
printf "<p>\n";
print "<input type=submit value=Save>";
print "</form>";
$docs_result = $conn->exec("SELECT document.doc_id, document.title, class, pub_status.pub_status_name, document_maintainer.role, document_maintainer.active, document_maintainer.email FROM document_maintainer, document, pub_status WHERE document_maintainer.maintainer_id = $maintainer_id AND document.pub_status = pub_status.pub_status AND document_maintainer.doc_id = document.doc_id ORDER BY document.title");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $docs_result->resultStatus;
print "<h2>Documents</h2>\n";
printf "<p><table border=1 cellspacing=2\n";
print "<tr><th>Title</th><th>Class</th><th>Doc Status</th><th>Role</th><th>Active</th><th>Feedback Email</th></tr>";
while (@row = $docs_result->fetchrow) {
$doc_id = $row[0];
$title = $row[1];
$class = $row[2];
$pub_status_name = $row[3];
$role = $row[4];
$active = $row[5];
if ( $active eq 't' ) { $active = "Active" } else { $active = "Inactive" }
$feedback_email = $row[6];
print "<tr>";
print "<form method=POST action='document_maintainer_save.pl'>\n";
print "<td valign=top><a href='document_edit.pl?doc_id=$doc_id'>$title</a></td>\n";
print "<td valign=top>$class</td>\n";
print "<td valign=top>$pub_status_name</td>\n";
print "<td valign=top>$role</td>\n";
print "<td valign=top>$active</td>\n";
print "<td valign=top>$feedback_email</td>\n";
print "</form>";
print "</tr>\n";
}
printf "</table>\n";
print end_html;

View File

@ -0,0 +1,58 @@
#!/usr/bin/perl
use CGI qw(:standard);
use Pg;
$dbmain='ldp';
@row;
$count = 0;
# Connect and load the tuples
$conn=Pg::connectdb("dbname=$dbmain");
$result=$conn->exec("SELECT maintainer_id, maintainer_name, email FROM maintainer ORDER BY maintainer_name");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
# print the page
print header(-expires=>'now');
print "<html><head><title>LDP Maintainers</title>";
print "<link rel=stylesheet href='../ldp.css' type='text/css'>";
print "</head>";
print "<body>";
print "<h1>LDP Maintainers</h1>\n";
print "<p><a href='../index.html'>Index</a> \n";
print "<a href='topic_list.pl'>Topics</a> \n";
print "<a href='document_list.pl'>Documents</a> \n";
print "<a href='editor_list.pl'>Editors</a> \n";
print "<p><table border=0>\n";
while (@row = $result->fetchrow) {
$maintainer_id = $row[0];
$maintainer_name = $row[1];
if ( $maintainer_name eq "" ) { $maintainer_name = 'J. Doe' }
$email = $row[2];
print "<tr><td>";
print a({href=>"maintainer_edit.pl?maintainer_id=$maintainer_id"},"$maintainer_name");
print "</td>";
print "</tr>";
$count++;
}
print "</table>\n";
print "<p>Count: $count";
print "<p><hr>\n";
print "<h1>New Maintainer</h1>\n";
print "<p><form method=POST action='maintainer_add.pl'>\n";
print "<input type=hidden name=caller value='maintainer_list.pl'>\n";
print "<table>\n";
print "<tr><td align=right>Name:</td><td><input type=text name=maintainer_name width=20 size=20></td></tr>\n";
print "<tr><td align=right>Email:</td><td><input type=text name=email width=20 size=20></td></tr>\n";
print "<tr><td></td><td><input type=submit value=Save></td></tr>\n";
print "</table></form>\n";
print end_html;

View File

@ -0,0 +1,33 @@
#! /usr/bin/perl
use CGI qw(:standard);
use Pg;
$query = new CGI;
$username = $query->remote_user();
if ( $username eq "guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}
$dbmain = "ldp";
@row;
# Read parameters
$maintainer_id = param('maintainer_id');
$maintainer_name = param('maintainer_name');
$maintainer_name =~ s/\'/\'\'/;
$email = param('email');
$conn=Pg::connectdb("dbname=$dbmain");
$sql = "UPDATE maintainer SET maintainer_name='$maintainer_name', email='$email' WHERE maintainer_id = $maintainer_id";
$result=$conn->exec($sql);
print $query->redirect("maintainer_edit.pl?maintainer_id=$maintainer_id");

12
LDP/lampadas/www/permission.pl Executable file
View File

@ -0,0 +1,12 @@
$username = $query->remote_user();
if ( $username="guest") {
print header;
print "<html><head><title>No Permission</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'></head>\n";
print "<body>\n";
print "<h1>No Permission</h1>\n";
print "You do not have permission to modify the database.\n";
print "<p>You need to <a href='../'>get an account</a> before you can modify data.\n";
print end_html;
exit;
}

61
LDP/lampadas/www/topic_list.pl Executable file
View File

@ -0,0 +1,61 @@
#!/usr/bin/perl
use CGI qw(:standard);
use Pg;
$dbmain='ldp';
@row;
$last_topic_num = 0;
$last_subtopic_num = 0;
# Connect and load the tuples
$conn=Pg::connectdb("dbname=$dbmain");
$sql = "SELECT topic.topic_num, topic.topic_name, subtopic.subtopic_num, subtopic.subtopic_name, document.doc_id, document.title, topic_description, subtopic_description FROM topic, subtopic, document_topic, document WHERE topic.topic_num = subtopic.topic_num and topic.topic_num = document_topic.topic_num and subtopic.subtopic_num = document_topic.subtopic_num and document_topic.doc_id = document.doc_id ORDER BY topic_num, subtopic_num, title";
$result=$conn->exec("$sql");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
# print the page
#print header(-expires=>'now');
print header;
print "<html><head>\n";
print "<title>LDP Document Database</title>\n";
print "<link rel=stylesheet href='../ldp.css' type='text/css'>\n";
print "</head>\n";
print "<body>\n";
print "<h1>Topic Listing</h1>\n";
print "<p><a href='../index.html'>Index</a> \n";
print "<a href='document_list.pl'>Documents</a> \n";
print "<a href='maintainer_list.pl'>Maintainers</a>\n";
print "<a href='editor_list.pl'>Editors</a>\n";
while (@row = $result->fetchrow) {
$topic_num = $row[0];
$topic_name = $row[1];
$subtopic_num = $row[2];
$subtopic_name = $row[3];
$doc_id = $row[4];
$title = $row[5];
$topic_description = $row[6];
$subtopic_description = $row[7];
if ( $topic_num != $last_topic_num ) {
print "<p><hr>";
print "<h1>$topic_num $topic_name</h1>\n";
print "<blockquote>$topic_description</blockquote>\n";
}
if ( $subtopic_num != $last_subtopic_num ) {
print "<h2>$topic_num.$subtopic_num $subtopic_name</h2>\n";
print "<blockquote>$subtopic_description</blockquote>\n";
}
print a({href=>"document_edit.pl?doc_id=$doc_id"},"$title");
print "<br>\n";
$last_topic_num = $topic_num;
$last_subtopic_num = $subtopic_num;
}
print end_html;