From f71149e1af4ac0b03678fc80da73a7cdc352c3aa Mon Sep 17 00:00:00 2001 From: "gerv%gerv.net" <> Date: Thu, 25 Jul 2002 06:22:55 +0000 Subject: Bug 67950 - Move the quip list into the database. Patch by davef@tetsubo.com; r=gerv, preed. --- quips.cgi | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'quips.cgi') diff --git a/quips.cgi b/quips.cgi index 7441f51fc..be773e1e1 100755 --- a/quips.cgi +++ b/quips.cgi @@ -20,6 +20,7 @@ # # Contributor(s): Owen Taylor # Gervase Markham +# David Fallon use diagnostics; use strict; @@ -34,8 +35,6 @@ use lib qw(.); require "CGI.pl"; -# Even though quips aren't (yet) in the database, we need to check -# logins for the footer ConnectToDatabase(); quietly_check_login(); @@ -43,14 +42,16 @@ my $action = $::FORM{'action'} || ""; if ($action eq "show") { # Read in the entire quip list - if (open (COMMENTS, "); - close COMMENTS; - - $vars->{'quips'} = \@quips; - $vars->{'show_quips'} = 1; + SendSQL("SELECT quip FROM quips"); + + my @quips; + while (MoreSQLData()) { + my ($quip) = FetchSQLData(); + push(@quips, $quip); } + + $vars->{'quips'} = \@quips; + $vars->{'show_quips'} = 1; } if ($action eq "add") { @@ -67,9 +68,7 @@ if ($action eq "add") { exit(); } - open(COMMENTS, ">>data/comments"); - print COMMENTS $comment . "\n"; - close(COMMENTS); + SendSQL("INSERT INTO quips (userid, quip) VALUES (". $::userid . ", " . SqlQuote($comment) . ")"); $vars->{'added_quip'} = $comment; } -- cgit v1.2.1