$files = array("mysql.class.inc", "template.inc");
while (list(, $val) = each($files)) {
include("inc/$val");
}
$self = basename($PHP_SELF);
error_reporting(5);
$t = new Template(".", "keep");
$db = new mysql_db;
$t->set_file(array(
"list" => "news_list.html",
"detail" => "news_detail.html",
"poster" => "news_poster.html",
"empty" => "news_empty.html"));
$t->set_var(array(
"SELF" => $self,
"PAGETITLE" => "UTs News"));
function show_list() {
global $t, $db;
$sql_p = "SELECT * FROM aktion";
$db->db_query($sql_p);
if ($db->db_num_rows()) {
$rows_p = $db->db_fetch_array();
$t->set_var(array(
"HEADLINE" => $rows_p[headline],
"BESCHREIBUNG" => $rows_p[beschreibung],
"BILD" => $rows_p[bild]));
$t->parse("OUT", "poster");
}
else {
$sql = "SELECT * FROM news ORDER BY timestamp DESC LIMIT 50";
$db->db_query($sql);
$t->set_block("list", "row", "rows");
if ($db->db_num_rows()) {
while ($rows = $db->db_fetch_array()) {
$t->set_var(array(
"NEWSID" => $rows[id],
"HEADLINE" => $rows[headline],
"SUBLINE" => $rows[subline],
"DATUM" => date("d.m.Y", $rows[timestamp])));
$t->parse("rows", "row", true);
}
$t->parse("OUT", "list");
}
else {
$t->parse("OUT", "empty");
}
}
$t->p("OUT");
}
function show_detail() {
global $t, $db, $newsid;
$sql = "SELECT * FROM news WHERE id=$newsid";
$db->db_query($sql);
$rows = $db->db_fetch_array();
if (!empty($rows[bild_kl])) {
$t->set_var(array(
"HEADLINE" => $rows[headline],
"SUBLINE" => $rows[subline],
"AUTOR" => $rows[autor],
"EMAIL" => $rows[email],
"BILD" => "<a href=\"newspics/$rows[bild_gr]\" target=\"_blank\">
<img src=\"newspics/$rows[bild_kl]\" border=\"0\" align=\"right\"></a>",
"NEWSTEXT" => $rows[newstext],
"DATUM" => date("d.m.Y", $rows[timestamp])));
}
else {
$t->set_var(array(
"HEADLINE" => $rows[headline],
"SUBLINE" => $rows[subline],
"AUTOR" => $rows[autor],
"EMAIL" => $rows[email],
"BILD" => "",
"NEWSTEXT" => $rows[newstext],
"DATUM" => date("d.m.Y", $rows[timestamp])));
}
$t->parse("OUT", "detail");
$t->p("OUT");
}
if (isset($newsid)) {
show_detail ();
}
else {
show_list();
}