############################################################ # Written and copyright 2002 by # Jacqueline D. Hamilton (kira@cgi101.com) # # This code is excerpted from "CGI Programming 201" # (http://www.cgi101.com/advanced) # # You may use this code on your own website, however # you may not publish or sell any copy or derivative work # without permission of the author. ############################################################ package MyBoard; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(dienice do_header do_footer dbdie $dbh $cgi $url $btitle linkify smiliefy); @EXPORT_OK = qw(delete); use strict; use DBI; use CGI; use CGI::Carp qw(warningsToBrowser fatalsToBrowser); our $dbh = DBI->connect("dbi:mysql:cgiblog", "bloguser", "fnord", { RaiseError => 1, AutoCommit => 1 }) or &dienice("Can't connect to database: $DBI::errstr"); # create the instance of CGI.pm our $cgi = CGI->new; # URL our $url = "http://www.cgi101.com/advanced/blog"; our $btitle = "Test Blog"; our $has_header = 0; sub do_header { my($page_title) = @_; if ($has_header == 0) { print $cgi->header; print $cgi->start_html(-title=>$page_title, -bgcolor=>"#ffffff", -text=>"#000000"); $has_header = 1; } } sub do_footer{ print $cgi->end_html; } sub dienice { my($msg) = @_; &do_header("Error"); print qq(