#!/usr/bin/perl -wT # small addition by gyp yes. # Make it harder for us to do dangerous things in Perl. use strict; use lib qw(. lib); use Bugzilla; use Bugzilla::Constants; use Bugzilla::Error; use Bugzilla::Util; use Bugzilla::Search; use Bugzilla::Search::Quicksearch; use Bugzilla::Search::Saved; use Bugzilla::User; use Bugzilla::Bug; use Bugzilla::Product; use Bugzilla::Keyword; use Bugzilla::Field; use Bugzilla::Status; use Bugzilla::Token; use Date::Parse; my $cgi = Bugzilla->cgi; my $dbh = Bugzilla->dbh; my $action = $cgi->param('action') || ""; sub GetQuip { my $dbh = Bugzilla->dbh; # COUNT is quick because it is cached for MySQL. We may want to revisit # this when we support other databases. my $count = $dbh->selectrow_array("SELECT COUNT(quip)" . " FROM quips WHERE approved = 1"); my $random = int(rand($count)); my $quip = $dbh->selectrow_array("SELECT quip FROM quips WHERE approved = 1 " . $dbh->sql_limit(1, $random)); return $quip; } print $cgi->header(); if ($action eq "getjs") { my $quip = GetQuip(); $quip =~ s/'/\'/; print "showQuip('$quip');"; } else { print GetQuip(); }