mirror of https://github.com/tLDP/LDP
added wiki field for document contents.
This commit is contained in:
parent
3e021dc94a
commit
c3a4a045df
|
@ -99,7 +99,8 @@ print "<input type=hidden name=doc_id value='$doc_id'>\n";
|
|||
|
||||
print "<table>\n";
|
||||
print "<tr><th colspan=6>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>Title:</td><td colspan=4><input type=text name=title size=60 value='$title'></td>\n";
|
||||
print "<td><a href='document_wiki.pl?doc_id=$doc_id'>Edit (test)</a></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>";
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#! /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 title, wiki FROM document WHERE doc_id = $doc_id");
|
||||
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
|
||||
|
||||
@row = $result->fetchrow;
|
||||
|
||||
|
||||
|
||||
# Load from db
|
||||
$title = $row[0];
|
||||
$title =~ s/\s+$//;
|
||||
|
||||
$wiki = $row[1];
|
||||
$wiki =~ s/\s+$//;
|
||||
|
||||
print header(-expires=>'now');
|
||||
|
||||
print "<html><head><title>$title Wiki</title>";
|
||||
print "<link rel=stylesheet href='../ldp.css' type='text/css'>";
|
||||
print "</head>";
|
||||
print "<body>";
|
||||
|
||||
print "<h1>$title Wiki</h1>\n";
|
||||
|
||||
print "<p><a href='/index.html'>Index</a> ";
|
||||
print "<a href='/cgi-bin/document_list.pl'>Documents</a> ";
|
||||
print "<a href='/cgi-bin/topic_list.pl'>Topics</a> ";
|
||||
print "<a href='/cgi-bin/maintainer_list.pl'>Maintainers</a> ";
|
||||
print "<a href='/cgi-bin/editor_list.pl'>Editors</a> ";
|
||||
print "<a href='/cgi-bin/ldp_stats.pl'>Statistics</a> ";
|
||||
print "<a href='/help/'>Help</a> ";
|
||||
|
||||
print "<p>ID: $doc_id";
|
||||
|
||||
print "<form method=POST action='document_wiki_save.pl' name='edit'>\n";
|
||||
print "<input type=hidden name=doc_id value='$doc_id'>\n";
|
||||
|
||||
print "<table>\n";
|
||||
print "<tr><th>Document Text</th></tr>\n";
|
||||
print "<tr><td><textarea name=wiki rows=10 cols=60 wrap>$wiki</textarea></td></tr>\n";
|
||||
print "</table>\n";
|
||||
|
||||
print "<input type=submit value=Save>\n";
|
||||
print "</form>\n";
|
||||
|
||||
print end_html;
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#! /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');
|
||||
$wiki = param('wiki');
|
||||
while ($wiki =~ /\'/) {
|
||||
$wiki =~ s/\'/a1s2d3f4/;
|
||||
}
|
||||
while ($wiki =~ /a1s2d3f4/) {
|
||||
$wiki =~ s/a1s2d3f4/\'\'/;
|
||||
}
|
||||
|
||||
$conn=Pg::connectdb("dbname=$dbmain");
|
||||
|
||||
$sql = "UPDATE document SET wiki='$wiki' WHERE doc_id=$doc_id";
|
||||
$result=$conn->exec($sql);
|
||||
|
||||
print $query->redirect("document_wiki.pl?doc_id=$doc_id");
|
||||
|
||||
|
||||
print header;
|
||||
print start_html;
|
||||
print "<p>$sql";
|
||||
print end_html;
|
||||
exit;
|
||||
|
Loading…
Reference in New Issue