diff --git a/LDP/lampadas/www/document_add.pl b/LDP/lampadas/www/document_add.pl new file mode 100755 index 00000000..d999ce0f --- /dev/null +++ b/LDP/lampadas/www/document_add.pl @@ -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 "
You need to get an account 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 "
doc_id:$doc_id"; +#print "
title:$title"; +#print "
pub_status:$pub_status"; +#print "
class:$class"; +#print "
format:$format"; +#print "
dtd:$dtd"; +#print "
sql:$sql"; +#print end_html; +#exit; + +$conn->exec($sql); + +print $query->redirect("document_edit.pl?doc_id=$doc_id"); +#print $query->redirect($caller); + diff --git a/LDP/lampadas/www/document_edit.pl b/LDP/lampadas/www/document_edit.pl new file mode 100755 index 00000000..22660b9b --- /dev/null +++ b/LDP/lampadas/www/document_edit.pl @@ -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 "
Index "; +print "Topics "; +print "Documents "; +print "Maintainers "; +print "Editors "; + +print "
ID: $doc_id"; + +print "
"; + + + + + + + + + +print "Status | Role | Name | Feedback Email | Action | |
---|---|---|---|---|---|
New Contributor | |||||
found: " . $topics[$rownum] . " = " . $topic_names[$rownum]; +} + +print "
Topic | Action |
---|---|
under construction. move along..."; + +#print "
Audience | Description |
---|---|
Status | Role | Name | Action | ||
---|---|---|---|---|---|
\n"; +} +print " |
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 "
"; + + + + + + +print "You need to get an account 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) + diff --git a/LDP/lampadas/www/document_editor_save.pl b/LDP/lampadas/www/document_editor_save.pl new file mode 100755 index 00000000..9ae1cb8d --- /dev/null +++ b/LDP/lampadas/www/document_editor_save.pl @@ -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 "
You need to get an account 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) + diff --git a/LDP/lampadas/www/document_jump.pl b/LDP/lampadas/www/document_jump.pl new file mode 100755 index 00000000..05adad6e --- /dev/null +++ b/LDP/lampadas/www/document_jump.pl @@ -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"); diff --git a/LDP/lampadas/www/document_list.pl b/LDP/lampadas/www/document_list.pl new file mode 100755 index 00000000..6d4edcb4 --- /dev/null +++ b/LDP/lampadas/www/document_list.pl @@ -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 "
\n"; +print "Welcome, " . $query->remote_user(); + +print "
Index "; +print "Topics\n"; +print "Maintainers\n"; +print "Editors\n"; + +print "
\n"; + +print "\n"; + +print "Title | "; +if ( $STATUS ) { print "Status | "; } +if ( $REVIEWSTATUS ) { print "Review Status | "; } +if ( $TECHSTATUS ) { print "Tech Status | "; } +if ( $MAINTAINED ) { print "Maintained | "; } +if ( $LICENSE ) { print "License | "; } +if ( $CLASS ) { print "Class | "; } +if ( $FORMAT ) { print "Format | "; } +if ( $DTD ) { print "DTD | "; } +if ( $PUBDATE ) { print "Pub Date | "; } +if ( $LASTUPDATE ) { print "Last Update | "; } +if ( $TICKLEDATE ) { print "Tickle Date | "; } +if ( $URL ) { print "URL | "; } +print "|||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
$sql | |||||||||||||||||||
"; + print a({href=>"document_edit.pl?doc_id=$doc_id"},"$title"); + if ( $url ne "" ) { print " Go!" } + print " | "; + if ( $STATUS) { print "$pub_status_name | "; } + if ( $REVIEWSTATUS) { print "$review_status_name | "; } + if ( $TECHSTATUS) { print "$tech_review_status_name | "; } + if ( $MAINTAINED ) { print "$maintained | "; } + if ( $LICENSE ) { print "$license | "; } + if ( $CLASS ) { print "$class | "; } + if ( $FORMAT) { print "$format | "; } + if ( $DTD ) { print "$dtd | "; } + if ( $PUBDATE ) { print "$pub_date | "; } + if ( $LASTUPDATE ) { print "$last_update | "; } + if ( $TICKLEDATE ) { + $date = `date -I`; + if ( $date gt $tickle_date ) { + print "$tickle_date | " + } + else { + print "$tickle_date | " + } + } + if ( $URL ) { print "$url | "; } + print "
Count: $count"; + +print "
You need to get an account 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) + diff --git a/LDP/lampadas/www/document_maintainer_save.pl b/LDP/lampadas/www/document_maintainer_save.pl new file mode 100755 index 00000000..51723579 --- /dev/null +++ b/LDP/lampadas/www/document_maintainer_save.pl @@ -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 "
You need to get an account 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
\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)
+
diff --git a/LDP/lampadas/www/document_note_add.pl b/LDP/lampadas/www/document_note_add.pl
new file mode 100755
index 00000000..5434b180
--- /dev/null
+++ b/LDP/lampadas/www/document_note_add.pl
@@ -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 "
You need to get an account 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"); diff --git a/LDP/lampadas/www/document_save.pl b/LDP/lampadas/www/document_save.pl new file mode 100755 index 00000000..7cecd743 --- /dev/null +++ b/LDP/lampadas/www/document_save.pl @@ -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 "
You need to get an account 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 "
$sql"; +print end_html; +exit; + diff --git a/LDP/lampadas/www/document_topic_add.pl b/LDP/lampadas/www/document_topic_add.pl new file mode 100755 index 00000000..8259faae --- /dev/null +++ b/LDP/lampadas/www/document_topic_add.pl @@ -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 "
You need to get an account 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) + diff --git a/LDP/lampadas/www/document_topic_del.pl b/LDP/lampadas/www/document_topic_del.pl new file mode 100755 index 00000000..eb3d54a2 --- /dev/null +++ b/LDP/lampadas/www/document_topic_del.pl @@ -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 "
You need to get an account 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) + diff --git a/LDP/lampadas/www/document_vote_save.pl b/LDP/lampadas/www/document_vote_save.pl new file mode 100755 index 00000000..89539daf --- /dev/null +++ b/LDP/lampadas/www/document_vote_save.pl @@ -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 "
You need to get an account 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"); + diff --git a/LDP/lampadas/www/editor_add.pl b/LDP/lampadas/www/editor_add.pl new file mode 100755 index 00000000..a9170e84 --- /dev/null +++ b/LDP/lampadas/www/editor_add.pl @@ -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 "
You need to get an account 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 "
$editor_name"; +#print "
$email"; +#print "
$editor_id"; +#print "
$sql"; +#print end_html; +#exit; + +$conn->exec($sql); + +print $query->redirect($caller) + diff --git a/LDP/lampadas/www/editor_edit.pl b/LDP/lampadas/www/editor_edit.pl new file mode 100755 index 00000000..2bca07b8 --- /dev/null +++ b/LDP/lampadas/www/editor_edit.pl @@ -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 "
Index \n"; +print "Topics \n"; +print "Documents \n"; +print "Maintainers "; +print "Editors"; + +print "
ID: $editor_id"; +print "
"; + +$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 "\nTitle | Class | Doc Status | Role | Active | "; +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 "
---|
Index \n"; +print "Topics \n"; +print "Documents \n"; +print "Maintainers \n"; + +print "
"; + print a({href=>"editor_edit.pl?editor_id=$editor_id"},"$editor_name"); + print " | "; + print "
Count: $count"; + +print "
You need to get an account 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"); + diff --git a/LDP/lampadas/www/maintainer_add.pl b/LDP/lampadas/www/maintainer_add.pl new file mode 100755 index 00000000..e6d4a5a3 --- /dev/null +++ b/LDP/lampadas/www/maintainer_add.pl @@ -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 "
You need to get an account 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 "
$maintainer_name"; +#print "
$email"; +#print "
$maintainer_id"; +#print "
$sql"; +#print end_html; +#exit; + + +print $query->redirect($caller) + diff --git a/LDP/lampadas/www/maintainer_edit.pl b/LDP/lampadas/www/maintainer_edit.pl new file mode 100755 index 00000000..f2549f44 --- /dev/null +++ b/LDP/lampadas/www/maintainer_edit.pl @@ -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 "
Index \n"; +print "Documents \n"; +print "Maintainers \n"; +print "Editors \n"; + +print "
ID: $maintainer_id"; +print "
"; + +$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 "Title | Class | Doc Status | Role | Active | Feedback Email | "; +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 "
---|
Index \n"; +print "Topics \n"; +print "Documents \n"; +print "Editors \n"; + +print "
"; + print a({href=>"maintainer_edit.pl?maintainer_id=$maintainer_id"},"$maintainer_name"); + print " | "; + print "
Count: $count"; + +print "
You need to get an account 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"); + diff --git a/LDP/lampadas/www/permission.pl b/LDP/lampadas/www/permission.pl new file mode 100755 index 00000000..943d758c --- /dev/null +++ b/LDP/lampadas/www/permission.pl @@ -0,0 +1,12 @@ +$username = $query->remote_user(); +if ( $username="guest") { + print header; + print "
You need to get an account before you can modify data.\n"; + print end_html; + exit; +} diff --git a/LDP/lampadas/www/topic_list.pl b/LDP/lampadas/www/topic_list.pl new file mode 100755 index 00000000..249b8582 --- /dev/null +++ b/LDP/lampadas/www/topic_list.pl @@ -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 "
\n"; +print "Index \n"; +print "Documents \n"; +print "Maintainers\n"; +print "Editors\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 "
$topic_description\n"; + } + if ( $subtopic_num != $last_subtopic_num ) { + print "
$subtopic_description\n"; + } + print a({href=>"document_edit.pl?doc_id=$doc_id"},"$title"); + print "