$extension = explode(".", $PHP_SELF);
$ext_count = count($extension);
$extension = "." . $extension[$ext_count-1];
require("config".$extension);
require_once("coresql".$extension);
if (!function_exists("showCSSHeader")) {
function showCSSHeader()
{
global $styledata;
$styledata[css_header] = str_replace("{header_size}", $styledata[header_size], $styledata[css_header]);
$styledata[css_header] = str_replace("{header_color}", $styledata[header_color], $styledata[css_header]);
$styledata[css_header] = str_replace("{news_size}", $styledata[news_size], $styledata[css_header]);
$styledata[css_header] = str_replace("{news_color}", $styledata[news_color], $styledata[css_header]);
$styledata[css_header] = str_replace("{smalltext_size}", $styledata[smalltext_size], $styledata[css_header]);
$styledata[css_header] = str_replace("{smalltext_color}", $styledata[smalltext_color], $styledata[css_header]);
print $styledata[css_header];
print "\n";
}
}
if (!function_exists("printNews")) {
function printNews()
{
global $extension,
$show,
$styledata,
$options,
$month,
$year,
$searchstring,
$QUERY_STRING;
require("config".$extension);
$dbconn = new Coresql($db_server, $db_database, $db_account, $db_password);
if ((isset($month)) && ($month != "") && (isset($year)) && ($year != "")) {
switch ($month) {
case "January":
$lastday = 31;
break;
case "February":
if ($year % 4 == 0) {
$lastday = 29;
} else {
$lastday = 28;
}
break;
case "March":
$lastday = 31;
break;
case "April":
$lastday = 30;
break;
case "May":
$lastday = 31;
break;
case "June":
$lastday = 30;
break;
case "July":
$lastday = 31;
break;
case "August":
$lastday = 31;
break;
case "September":
$lastday = 30;
break;
case "October":
$lastday = 31;
break;
case "November":
$lastday = 30;
break;
case "December":
$lastday = 31;
break;
default:
$lastday = 30;
}
$from = strtotime("1 $month $year 00:00:00");
$to = strtotime("$lastday $month $year 23:59:59");
$query = "SELECT * FROM $newstable WHERE time > $from AND time < $to ORDER BY id DESC";
} elseif ((isset($searchstring)) && ($searchstring != "")) {
$query = "SELECT * FROM $newstable WHERE news_title LIKE '%$searchstring%' OR news_text LIKE '%$searchstring%' ORDER BY id DESC";
} else {
$query = "SELECT * FROM $newstable ORDER BY id DESC LIMIT 0,$options[news_nr]";
}
$newsdata = $dbconn->fetchMultiple($query);
if ($newsdata != "") {
foreach ($newsdata as $result_detailed) {
foreach ($result_detailed as $key=>$elem) {
$userdata = $dbconn->fetchArray("SELECT * FROM $usertable WHERE id = $elem[author_id]");
$elem[news_title] = str_replace("\\'", "'", $elem[news_title]);
$elem[news_text] = str_replace("\\'", "'", $elem[news_text]);
$news_template = addslashes($styledata[template]);
$news_template = str_replace("{newstitel}", $elem[news_title], $news_template);
$news_template = str_replace("{news}", $elem[news_text], $news_template);
$news_template = str_replace("<a ", "<a class=\\\"cnnews\\\" ", $news_template);
if ($elem[show_email]) {
$userdata[username] = "<a href=\\\"mailto:$userdata[email]\\\" class=\\\"cnsmalltext\\\">$userdata[username]</a>";
}
if (($options[use_icons]) && ($elem[icon_id])) {
$icondata = $dbconn->fetchArray("SELECT * FROM $icontable WHERE id = $elem[icon_id]");
$icon = "<img src=\\\"corenews2/$options[icon_dir]$icondata[name]\\\" alt=\\\"$icondata[title]\\\">";
} else {
$icon = "";
}
$news_template = str_replace("{icon}", $icon, $news_template);
$news_template = str_replace("{user}", $userdata[username], $news_template);
$news_template = str_replace("{datum}", date($options[date_format], $elem[time]), $news_template);
if (($options[comments_allowed])) {
$countcomments = $dbconn->countRows("SELECT NULL FROM $commentstable WHERE news_id = $elem[id]");
$comments = "<a href=\\\"$PHP_SELF?$QUERY_STRING&news_id=$elem[id]\\\" class=\\\"cnsmalltext\\\">[ $countcomments Kommentar";
if ($countcomments != 1) {
$comments = $comments . "e";
}
$comments = $comments . " ]</a>";
} else {
$comments = "";
}
$news_template = str_replace("{kommentare}", $comments, $news_template);
if (($elem[link] != "") && ($elem[link_text] != "")) {
if ($elem[link] == "") {
$link = $elem[link_text];
} else {
$link = "<a href=\\\"$elem[link]\\\" target=\\\"_blank\\\" class=\\\"cnsmalltext\\\">$elem[link_text]</a>";
}
} else {
$link = "";
}
$news_template = str_replace("{link}", $link, $news_template);
$news_template = str_replace("{ausrichtung}", $options[news_alignment], $news_template);
$news_template = str_replace("?>", "?><?php print \"", $news_template);
$news_template = str_replace("<?php", "\"; ?><?php", $news_template);
$news_template = str_replace("?>\"; ?><?php print \"", "?><?php print \"", $news_template);
$news_template = "<?php print \"".$news_template."\"; ?>";
eval ("?>".$news_template);
}
}
}else {
print "<div class=\"cnnews\">Keine News gefunden!</div>\n";
}
$close = $dbconn->close();
}
}
if (!function_exists("printSingleNews")) {
function printSingleNews()
{
global $extension,
$newsdata,
$styledata,
$options,
$news_id;
require("config".$extension);
$dbconn = new Coresql($db_server, $db_database, $db_account, $db_password);
$result = $dbconn->fetchArray("SELECT * FROM $newstable WHERE id = $news_id");
$userdata = $dbconn->fetchArray("SELECT * FROM $usertable WHERE id = $result[author_id]");
$result[news_title] = str_replace("\\'", "'", $result[news_title]);
$result[news_text] = str_replace("\\'", "'", $result[news_text]);
$news_template = addslashes($styledata[template]);
$news_template = str_replace("{newstitel}", $result[news_title], $news_template);
$news_template = str_replace("{news}", $result[news_text], $news_template);
$news_template = str_replace("<a ", "<a class=\\\"cnnews\\\" ", $news_template);
if ($result[show_email]) {
$userdata[username] = "<a href=\\\"mailto:$userdata[email]\\\" class=\\\"cnsmalltext\\\">$userdata[username]</a>";
}
if (($options[use_icons]) && ($result[icon_id])) {
$icondata = $dbconn->fetchArray("SELECT * FROM $icontable WHERE id = $result[icon_id]");
$icon = "<img src=\\\"corenews2/$options[icon_dir]$icondata[name]\\\" alt=\\\"$icondata[title]\\\">";
} else {
$icon = "";
}
$news_template = str_replace("{icon}", $icon, $news_template);
$news_template = str_replace("{user}", $userdata[username], $news_template);
$news_template = str_replace("{datum}", date($options[date_format], $result[time]), $news_template);
$comments = "";
$news_template = str_replace("{kommentare}", $comments, $news_template);
if (($result[link] != "") && ($result[link_text] != "")) {
$link = "<a href=\\\"$result[link]\\\" target=\\\"_blank\\\" class=\\\"cnsmalltext\\\">$result[link_text]</a>";
} else {
$link = "";
}
$news_template = str_replace("{link}", $link, $news_template);
$news_template = str_replace("?>", "?><?php print \"", $news_template);
$news_template = str_replace("<?php", "\"; ?><?php", $news_template);
$news_template = str_replace("?>\"; ?><?php print \"", "?><?php print \"", $news_template);
$news_template = "<?php print \"".$news_template."\"; ?>";
eval("?>".$news_template);
$close = $dbconn->close();
}
}