<?php
// Copyright by: Manuel Staechele
// Support: www.ilch.de
// Modded by Mairu für News Extended
defined('main') or die ('no direct access');
$title = $allgAr['title'] . ' :: News';
$hmenu = 'News';
$design = new design ($title, $hmenu);
$design->addheader('<link rel="alternate" type="application/atom+xml" title="News (Atom)" href="index.php?news-atom" />
<link rel="alternate" type="application/rss+xml" title="News (RSS)" href="index.php?news-rss" />');
function news_find_kat($kat)
{
$katpfad = 'include/images/news/';
$katjpg = $katpfad . $kat . '.jpg';
$katgif = $katpfad . $kat . '.gif';
$katpng = $katpfad . $kat . '.png';
if (file_exists($katjpg)) {
$pfadzumBild = $katjpg;
} elseif (file_exists($katgif)) {
$pfadzumBild = $katgif;
} elseif (file_exists($katpng)) {
$pfadzumBild = $katpng;
}
if (!empty($pfadzumBild)) {
$kategorie = '<img style="" src="' . $pfadzumBild . '" width="230" height="137" alt="' . $kat . '">';
} else {
$kategorie = '<b>' . $kat . '</b><br /><br />';
}
return ($kategorie);
}
// Schaut ob ein Name so oder ähnlich in der Datenbank vorhanden ist
// gibt true zurück falls der Name noch nicht verwendet ist
function checkName($name)
{
if (db_count_query("SELECT COUNT(name) FROM xic_user WHERE name LIKE '$name'")) {
return false;
} else {
return true;
}
}
function checkKomName($name)
{
$resp = new xajaxResponse();
if (checkName($name) OR loggedin()) {
$name = utf8_decode($name);
$resp->script('document.forms["komform"].submit();');
} else {
$resp->assign('komname', 'value', '');
$resp->alert('Dieser Name ist bereits an einen User vergeben, benutze bitte einen anderen.');
$resp->script("document.getElementById('komname').focus();");
}
return $resp;
}
// xajax für namencheck
$xajax = new xajax('index.php?news-ajax');
$xajax->registerFunction('checkKomName');
$xajax->processRequest();
if ($menu->get(1) == 'ajax') {
exit();
}
if (!is_numeric($menu->get(1))) {
if ($menu->get(1) == 'rss' || $menu->get(1) == 'atom') {
// ob_clean();
$feed_type = $menu->get(1);
$abf = "SELECT MAX(news_time) AS last_update FROM xic_news";
$erg = db_query($abf);
$row = db_fetch_assoc($erg);
$dbavatar = @db_result(db_query("SELECT avatar FROM xic_user WHERE id = '" . user_id . "'"), 0);
if (!empty($dbavatar)) {
$avatar = '<img src="' . $avatar . '" border="0">';
} else {
$avatar = '<img src="noavatar.jpg" border="0">';
}
$last_update = str_replace(' ', 'T', $row['last_update']) . 'Z';
$tn_id = intval(@db_result($news_opts = db_query("SELECT v1 FROM xic_allg WHERE k = 'news' LIMIT 1"), 0));
$abf = "SELECT
a.news_title as title,
a.news_id as id,";
$abf .= ($feed_type == 'atom') ? 'a.news_time as datum,' : "DATE_FORMAT(a.news_time,'%a, %e %b %y %H:%i:%s') as datum,";
$abf .=
"a.news_kat as kate,
a.news_text as text,
b.name as username,
a.html
FROM xic_news as a
LEFT JOIN xic_user as b ON a.user_id = b.id
WHERE (a.news_recht | 1) = a.news_recht AND a.`show` > 0 AND a.`show` <= UNIX_TIMESTAMP() AND a.news_id != $tn_id AND a.`archiv` != 1 AND (a.endtime IS NULL OR a.endtime > UNIX_TIMESTAMP())
ORDER BY news_time DESC LIMIT 15";
$erg = db_query($abf);
$tpl = new tpl('news_' . $menu->get(1) . '.htm');
header('Content-type: application/' . $menu->get(1) . '+xml');
$tpl->set_ar_out(array('FEEDTITLE' => $allgAr['title'],
'UPDATED' => $last_update,
'SITEURL' => 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF'])), 0);
while ($row = db_fetch_assoc($erg)) {
if ($feed_type == 'atom') {
$Z = (date('Z') > 0 ? '+' : '') . date('H:i:s', date('Z') + 23 * 3600);
$row['datum'] = str_replace(' ', 'T', $row['datum']) . $Z;
}
$a = explode('[PREVIEWENDE]', $row['text']);
$tpl->set_ar_out(array('TITLE' => $row['title'],
'TXT' => $row['html'] ? $a[0] : bbcode($a[0]),
'LINK' => 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/index.php?news-' . $row['id'],
'AUTHOR' => $row['username'],
'DATE' => $row['datum']
), 1);
}
$tpl->out(2);
exit;
} else {
$design->header();
$limit = $allgAr['Nlimit'];
$page = ($menu->getA(1) == 'p' ? $menu->getE(1) : 1);
// Topnews ausgeben
$tn_id = intval(@db_result($news_opts = db_query("SELECT v1, v2 FROM xic_allg WHERE k = 'news' LIMIT 1"), 0, 0));
$tn_koms = @db_result($news_opts, 0, 1);
$tn_sql = db_query("SELECT news_title, news_text, news_recht, news_groups, html FROM xic_news WHERE news_id = $tn_id AND `show` > 0 AND `show` <= UNIX_TIMESTAMP() AND (endtime IS NULL OR endtime > UNIX_TIMESTAMP())");
if (db_num_rows($tn_sql) > 0) {
$tn_r = db_fetch_object($tn_sql);
$dontShow = false;
if ((pow(2, abs($_SESSION['authright'])) | $tn_r->news_recht) != $tn_r->news_recht) {
$dontShow = true;
}
if ($dontShow) {
foreach ($_SESSION['authgrp'] as $id => $bool) {
if ($bool and (pow(2, abs($id)) | $tn_r->news_groups) == $tn_r->news_groups) {
$dontShow = false;
break;
}
}
}
if (!$dontShow) {
$tn_tpl = new tpl ('news/top');
$tn_tpl->set('title', $tn_r->news_title);
$tn_tpl->set('koms', $tn_koms == '1' ? '<br /><a href="index.php?news-' . $tn_id . '">' . db_count_query("SELECT COUNT(id) FROM xic_koms WHERE uid = $tn_id AND cat = 'NEWS'") . ' ' . $lang['comments'] . ' </a>' : '');
$tn_tpl->set_out('txt', $tn_r->html ? $tn_r->news_text : bbcode($tn_r->news_text), 0);
unset($tn_tpl);
}
}
//Kategorie einschränken
if ($menu->get(1) != '' and ($menu->getA(1) != 'p' or $menu->getE(1) == 0)) {
$news_kat = 'news_kat = "' . $menu->get(1) . '" AND';
$katmpl = '-' . $menu->get(1);
$page = ($menu->getA(2) == 'p' ? $menu->getE(2) : 1);
} else {
$news_kat = $katmpl = '';
$page = ($menu->getA(1) == 'p' ? $menu->getE(1) : 1);
}
$anfang = ($page - 1) * $limit;
//Gruppenrechte
$groups = getGroupRights();
$MPL = db_make_sites2($page, "WHERE (((" . pow(2, abs($_SESSION['authright'])) . " | news_recht) = news_recht) OR
(news_groups != 0 AND ((news_groups ^ $groups) != (news_groups | $groups)))) AND $news_kat `show` > 0 AND `show` <= UNIX_TIMESTAMP() AND news_id != $tn_id AND archiv != 1 AND (endtime IS NULL OR endtime > UNIX_TIMESTAMP())", $limit, '?news' . $katmpl, 'news');
// Normale News
$tpl = new tpl ('news/news.htm');
$abf = "SELECT
a.news_title as title,
a.news_id as id,
DATE_FORMAT(a.news_time,' %d. %m. %Y - %H:%i Uhr') as datum,
DATE_FORMAT(a.news_time,'%d.') as dat,
DATE_FORMAT(a.news_time,'%m') as mon,
a.news_kat as kate,
a.news_text as text,
a.prev,
b.name as username,
c.name as editorname,
a.html,
a.edit_time,
a.klicks,
b.avatar as avatar,
b.id as uid
FROM xic_news as a
LEFT JOIN xic_user as b ON a.user_id = b.id
LEFT JOIN xic_user as c ON a.editor_id = c.id
WHERE (((" . pow(2, abs($_SESSION['authright'])) . " | a.news_recht) = a.news_recht) OR
(a.news_groups != 0 AND ((a.news_groups ^ $groups) != (a.news_groups | $groups)))) AND $news_kat
a.`show` > 0 AND a.`show` <= UNIX_TIMESTAMP() AND news_id != $tn_id AND a.`archiv` != 1 AND
(a.endtime IS NULL OR a.endtime > UNIX_TIMESTAMP())
ORDER BY a.news_time DESC
LIMIT " . $anfang . "," . $limit;
// echo '<pre>'.$abf.'</pre>';
$erg = db_query($abf);
if (db_num_rows($erg) == 0 and !empty($news_kat)) {
echo 'Keine News in dieser Kategorie gefunden.<br />
<a href="index.php?news">Newsübersichtsseite aufrufen</a>';
$design->footer(1);
}
while ($row = db_fetch_assoc($erg)) {
$row['mon'] = getDmon($row['mon']);
//$group = @db_result(db_query('SELECT name FROM xic_groups LEFT JOIN xic_groupusers ON xic_groups.id = xic_groupusers.gid WHERE xic_groupusers.uid = "'. $row['uid'].'" GROUP BY name'));
$groupf = @db_result(db_query('SELECT color FROM xic_groups INNER JOIN xic_groupusers ON xic_groups.id = xic_groupusers.gid WHERE xic_groupusers.uid = "' . $row['uid'] . '" GROUP BY color ORDER BY id DESC'));
$row['username1'] = $row['username'];
$erg45 = @db_result(db_query('SELECT name FROM xic_koms WHERE cat= "NEWS" AND uid = "' . $row['id'] . '" ORDER by id DESC LIMIT 1'));
$row['name1'] = '<div>von: ' . $erg45 . '</div>';
$k0m = db_query("SELECT COUNT(ID) FROM `xic_koms` WHERE uid = " . $row['id'] . " AND cat = 'NEWS'");
$row['kom'] = db_result($k0m, 0);
$row['useravatar'] = !empty($row['avatar']) && file_exists($row['avatar']) ? '<a href="index.php?user-details-' . $row['uid'] . '"><img src="' . $row['avatar'] . '" border="0" alt="' . $row['username'] . '" title="' . $row['username'] . '" /></a>' : 'n/a';
$row['kate'] = news_find_kat($row['kate']);
if (strpos($row['text'], '[PREVIEWENDE]') !== false) {
$a = explode('[PREVIEWENDE]', $row['text']);
$row['text'] = $a[0];
$row['readwholenews'] = '<a href="index.php?news-' . $row['id'] . '" alt="mehr lesen" title="mehr lesen"><img src="include/images/icons/news/more.gif" alt="mehr lesen" border="0"></a>';
} else {
$row['readwholenews'] = '';
}
$row['klicks'] = '<img src="include/images/icons/news/counter.gif" alt="' . $row['klicks'] . ' mal gelesen" title="' . $row['klicks'] . ' mal gelesen" border="0">';
$sum = @ db_result(db_query('SELECT SUM(vote) FROM xic_koms WHERE cat="NEWS" and uid=' . $row['id']));
$ges = @ db_result(db_query('SELECT COUNT(id) FROM xic_koms WHERE cat="NEWS" and uid=' . $row['id'] . ' and vote != 0'));
if (empty($ges)) {
$proz = 0;
} else {
$proz = round($sum / 5 / $ges * 5);
}
if ($ges == 1) {
$bwort = 'Bewertung';
} else {
$bwort = 'Bewertungen';
}
if ($proz == 0) {
$row['pimg'] = '<img src="include/images/icons/votes/0.png" title="Noch keine Bewertungen">';
} else {
$row['pimg'] = '<img src="include/images/icons/votes/' . $proz . '.png" title="' . $ges . ' ' . $bwort . '">';
}
if (!$row['html']) {
$row['prev'] = bbcode($row['prev']) . ', <a href="?news-' . $row['id'] . '"><span style="color:#656565;font-weight:bold;">more</span></a>';
}
$row['edit'] = is_null($row['edit_time']) ? '' : '<br /><i>zuletzt geändert am ' . date('d.m.Y - H:i', strtotime($row['edit_time'])) . ' Uhr';
if (!empty($row['edit']) and $row['editorname'] != $row['username']) {
$row['edit'] .= ' von ' . $row['editorname'] . '</i>';
} elseif (!empty($row['edit'])) {
$row['edit'] .= '</i>';
}
$tpl->set_ar_out($row, 0);
}
$tpl->set_out('SITELINK', $MPL, 1);
unset($tpl);
}
} else {
$design->header();
$xajax->printJavascript();
$nid = escape($menu->get(1), 'integer');
$erg = db_query("SELECT a.news_title,
a.news_id,
DATE_FORMAT(a.news_time,'%d. %m. %Y') as datum,
DATE_FORMAT(a.news_time,'%W') as dayofweek,
DATE_FORMAT(a.news_time,'%d. %M. %Y um %H:%i Uhr') as dats,
a.news_kat,
a.newskate,
a.news_text,
a.news_recht,
a.klicks,
a.news_groups,
a.html,
a.show,
b.name as username,
b.avatar as avatar,
b.id as userid
FROM xic_news as a
LEFT JOIN xic_user as b ON a.user_id = b.id
WHERE `a`.`show` > 0 AND `a`.`show` <= UNIX_TIMESTAMP() AND `a`.`news_id` = '" . $nid . "'");
if (db_num_rows($erg) == 0) {
$dontShow = true;
} else {
$dontShow = false;
$row = db_fetch_object($erg);
if ((pow(2, abs($_SESSION['authright'])) | $row->news_recht) != $row->news_recht) {
$dontShow = true;
}
if ($dontShow) {
foreach ($_SESSION['authgrp'] as $id => $bool) {
if ($bool and (pow(2, abs($id)) | $row->news_groups) == $row->news_groups) {
$dontShow = false;
break;
}
}
}
}
if ($dontShow) {
echo 'News existiert nicht oder Sie haben keine Rechte sie zu sehen. <a href="javascript:history.back();">zurück</a>';
$design->footer(1);
}
$komsOK = true;
if ($allgAr['Ngkoms'] == 0) {
if (loggedin()) {
$komsOK = true;
} else {
$komsOK = false;
}
}
if ($allgAr['Nukoms'] == 0) {
$komsOK = false;
}
$kom_info = '';
//blake
// kommentar add
if ((loggedin() OR chk_antispam('newskom')) AND $komsOK AND !empty($_POST['name']) AND !empty($_POST['txt'])) {
$_POST['txt'] = escape($_POST['txt'], 'string');
$_POST['name'] = escape($_POST['name'], 'string');
$rate = escape($_POST['rate'], 'integer');
$uar = array();
$abgleich = db_query('SELECT vote FROM xic_koms WHERE name = "' . $_POST['name'] . '" and uid = ' . $nid);
while ($rof = db_fetch_object($abgleich)) {
$uar[] = $rof->vote;
}
$difs = implode($uar);
if (checkName($_POST['name']) or loggedin()) {
if (loggedin()) {
$_POST['name'] = $_SESSION['authname'];
$time = time();
}
if ($difs > 0 and $rate > 0) {
wd('index.php?news-' . $nid . '', 'Du hast dieses Video schon bewertet!', 3);
$design->footer(1);
} else {
db_query("INSERT INTO `xic_koms` (`uid`,`cat`,`name`,`text`,`time`,vote) VALUES (" . $nid . ",'NEWS','" . $_POST['name'] . "','" . $_POST['txt'] . "'," . $time . ",'.$rate.')");
//points
$kompost = @db_result(db_query('SELECT kom FROM xic_pointsys'));
db_query("UPDATE `xic_user` SET points = points + " . $kompost . " WHERE name = '" . $_POST['name'] . "'");
wd('index.php?news-' . $nid . '', 'Kommentar erfolgreich eingetragen<br><br>Du erhälst <b>' . $kompost . '</b> Punkte!', 3);
}
$design->footer(1);
//
} else {
$kom_info = '<span style="color:red;">Dieser Name ist bereits an einen User vergeben, benutze bitte einen anderen.</span><br />';
}
//end blake
}
// kommentar add
// kommentar loeschen
if ($menu->getA(2) == 'd' AND is_numeric($menu->getE(2)) AND has_right(-7, 'news')) {
$kommentar_id = escape($menu->getE(2), 'integer');
db_query("DELETE FROM xic_koms WHERE uid = " . $nid . " AND cat = 'NEWS' AND id = " . $kommentar_id);
}
// kommentar loeschen
$kategorie = news_find_kat($row->news_kat);
//$group = @db_result(db_query('SELECT name FROM xic_groups LEFT JOIN xic_groupusers ON xic_groups.id = xic_groupusers.gid WHERE xic_groupusers.uid = "'. $row->userid.'" GROUP BY name'));
$groupf = @db_result(db_query('SELECT color FROM xic_groups INNER JOIN xic_groupusers ON xic_groups.id = xic_groupusers.gid WHERE xic_groupusers.uid = "' . $row->userid . '" GROUP BY color ORDER BY id DESC'));
$row->username = '<span style="' . $groupf . '">' . $row->username . '</span>';
$textToShow = $row->html ? $row->news_text : bbcode($row->news_text);
$textToShow = str_replace('[PREVIEWENDE]', '', $textToShow);
if (!empty($such)) {
$textToShow = markword($textToShow, $such);
}
$avatar = !empty($row->avatar) && file_exists($row->avatar) ? '<a href="index.php?user-details-' . $row->userid . '"><img style="-webkit-border-radius:4px;-moz-border-radius:4px; border-radius: 4px;" height="48" width="40" src="' . $row->avatar . '" border="0"></a>' : 'n/a';
// klicks zaehlen
db_query("UPDATE xic_news SET klicks = klicks + 1 WHERE news_id = " . $nid);
$newd = db_fetch_object(db_query('SELECT * FROM xic_newska WHERE id = ' . $row->newskate));
$vthemen = db_query('SELECT * FROM xic_news WHERE news_id NOT IN(' . $nid . ') and newskate = ' . $row->newskate . ' ORDER BY news_id DESC LIMIT 0,5');
while ($vt = db_fetch_object($vthemen)) {
$newst .= '<div align="left" style="width:326px;"><div style="float:left;width:42%;margin-left:12px;padding:4px;""><span style="color:#959595;font-size:11px;">' . $row->datum . '</span><br><a style="color:#959595;font-size:13px;font-weight:bold;" href="?news-' . $vt->news_id . '">' . ((strlen($vt->news_title) < 16) ? $vt->news_title : substr($vt->news_title, 0, 17) . '...') . '</a></div></div>';
}
$tpl = new tpl ('news/news.htm');
$ar = array(
'TITEL' => $newd->titel,
'VTHEMEN' => $newst,
'DATS' => $row->dats,
'READS' => $row->klicks,
'GENRE' => $newd->genre,
'FREIGABE' => $newd->freigabe,
'RELEASE' => $newd->release,
'ENTWICKLER' => $newd->entwickler,
'ANBIETER' => $newd->anbieter,
'PLATTFORM' => $newd->plattform,
'LINKS' => $newd->links,
'TEXT' => $textToShow,
'KATE' => $kategorie,
'DATUM' => $row->datum,
'DATUMD' => $lang[$row->dayofweek],
'AVATAR' => $avatar,
'USERID' => $row->userid,
'USERNAME' => $row->username,
'NID' => $nid,
'uname' => $_SESSION['authname'],
'ANTISPAM' => (loggedin() ? '' : get_antispam('newskom', 0)),
'NAME' => $row->news_title,
'info' => $kom_info
);
$tpl->set_ar_out($ar, 2);
if ($komsOK) {
$tpl->set_ar_out(array('NAME' => $row->news_title, 'NID' => $nid, 'style' => loggedin() ? 'style="display:none;"' : ''), 3);
}
$erg1 = db_query("SELECT `a`.`text`,`a`.`name`, `a`.`id`,`a`.`time`, `b`.`id` AS `userid`, `b`.`name` AS `username`, `b`.`avatar`,`b`.`geschlecht`
FROM `xic_koms` AS `a`
LEFT JOIN `xic_user` AS `b` ON `a`.`name` = `b`.`name`
WHERE `a`.`uid` = " . $nid . " AND `a`.`cat` = 'NEWS' ORDER BY `a`.`id` DESC");
$ergAnz1 = db_num_rows($erg1);
if ($ergAnz1 == 0) {
echo '';
} else {
$zahl = $ergAnz1;
while ($row1 = db_fetch_assoc($erg1)) {
$time1 = $row1['time'];
$time2 = $time1 = date("d.m.Y - H:i", $row1['time']);
$time3 = '';
if ($time1 == 0) {
$time4 = $time3;
} else {
$time4 = 'am ' . $time2 . '';
}
if ($row1['userid']) {
$avatarrecht = @db_result(db_query('SELECT avarecht FROM xic_user WHERE id = ' . $row1['userid']));
$namfarbe = @db_result(db_query('SELECT namefarbe FROM xic_user WHERE id = ' . $row1['userid']));
$groupf = @db_result(db_query('SELECT color FROM xic_groups INNER JOIN xic_groupusers ON xic_groups.id = xic_groupusers.gid WHERE xic_groupusers.uid = "' . $row1['userid'] . '" GROUP BY color ORDER BY id DESC'));
} else {
$avatarrecht = '';
$namfarbe = '';
$groupf = '';
}
if ($avatarrecht == 1) {
if (file_exists($row1['avatar'])) {
$avatar = '<img src=' . $row1['avatar'] . ' border="0" height="60" width="60"/>';
} else if ($row1['geschlecht'] == 1) {
$avatar = '<img src=include/images/avatars/maennlich.jpg border="0" height="60" width="60" />';
} else if ($row1['geschlecht'] == 2) {
$avatar = '<img src=include/images/avatars/weiblich.jpg border="0" height="60" width="60" />';
} else {
$avatar = '<img src=include/images/avatars/wurstegal.jpg border="0" height="60" width="60" />';
}
} else {
$avatar = '<a href="?shop-recht"><img src=include/images/avatars/noarecht.png border="0" height="60" width="60" /></a>';
}
if ($groupf) {
$row1['username'] = '<span style="' . $groupf . '">' . $row1['username'] . '</span>';
} else {
$row1['username'] = '<span style="color:#' . $namfarbe . '">' . $row1['username'] . '</span>';
}
$username = empty($row1['userid']) ? '<em>Gast:</em> ' . $row1['name'] : '<a class="in" href="index.php?user-details-' . $row1['userid'] . '">' . $row1['username'] . '</a>';
$row1['text'] = bbcode(trim($row1['text']));
if (has_right(-7, 'news')) {
$row1['text'] .= '<a href="?news-' . $nid . '-d' . $row1['id'] . '"><img src="include/images/icons/del.gif" alt="löschen" border="0" title="löschen" /></a>';
}
$tpl->set_ar_out(array('NAME' => $username,
'TIME' => $time4,
'AVATAR' => $avatar,
'TEXT' => $row1['text'],
'ZAHL' => $zahl), 4);
$zahl--;
}
}
$tpl->out(5);
}
$design->footer();
?>
Sorry, habs nicht richtig gelesen. Das wäre die.
MfG