#!/usr/bin/perl 
# Description
# Copyright: Flarup Web Teknik 2004, Kjeld Flarup

$template = "$ENV{DOCUMENT_ROOT}/template.html";
push @INC,"$ENV{DOCUMENT_ROOT}/cgi-bin";
$webpath=$ENV{HTTP_REFERER};
$host=$ENV{HTTP_HOST};

use CGI::Carp qw(fatalsToBrowser);
use CGI;
$cgi = new CGI;


use DBI;

$dbh = DBI->connect("DBI:mysql:max20", "max20", "nulskat") || die ("Failed to connect to database");

require "flarupdbi.pl";
#require "flaruphtml.pl";
#require "htmlconformity.pl"; # a perl file which contains layout rules for site
			     # sun HtmlConformity ( $htmlfile )


# retrieve data from sql
$sql = "select subject,body from phorum_messages where forum_id=6 order by datestamp desc";
$sqlresult = "";
$sth = SqlExec( $dbh, $sql );
$hash_ref = $sth->fetchrow_hashref;
if ( $hash_ref ) {
  #while($hash_ref)
  #{
	$sqlresult .= "<b>".$hash_ref->{subject}."</b><br>";
	$sqlresult .= $hash_ref->{body}."<br>";
	#$hash_ref = $sth->fetchrow_hashref;
  #}
} else {
	$sqlresult .= "SQL query failed: $sql";
}


# blank page
$html = '<html><title>Blog index</title><body>';
$html .= '<link rel="StyleSheet" href="/max20iframe.css">';
$html .= "Quick blog<br><a href='http://www.max20.dk/forum/list.php?6' target='_top'><small>$sqlresult</small></a>";


$html .= "</body></html>" if ( ! ($html =~ m@</html>@i) );

print <<EOF;
Content-type: text/html

$html
EOF

exit(0);

