So habs jetzt nicht getestet, von daher nicht unwahrscheinlich, dass ich einen Fehler eingebaut hab.
<?php
// Copyright by: Manuel Staechele
// Support: www.ilch.de
defined ('main') or die ('no direct access');
$title = $allgAr['title'] . ' :: Tutorials';
$hmenu = 'Tutorials';
$design = new design ($title , $hmenu);
error_reporting(E_ALL);
if (!is_numeric($menu->get(1))) {
$design->header();
$limit = $allgAr['Nlimit']; //ggf. eigenes Limit setzen
$page = ($menu->getA(1) == 'p' ? $menu->getE(1) : 1);
$MPL = db_make_sites ($page , "WHERE recht >= " . $_SESSION['authright'] , $limit , '?tut' , 'tut');
$anfang = ($page - 1) * $limit;
$tpl = new tpl ('tut.htm');
echo '<table>';
$abf = "SELECT
a.title as title,
a.id as id,
a.time as datum,
a.kat as kate,
a.text as text,
a.recht as nrecht,
b.name as username,
FROM prefix_tut as a
LEFT JOIN prefix_user as b ON a.uid = b.id
WHERE (" . $_SESSION['authright'] . " <= a.recht
OR a.recht = 0) and a.kat = '" . $katn->kat . "'ORDER BY a.kat, a.title LIMIT $anfang, $limit";
// echo '<pre>'.$abf.'</pre>';
$erg = db_query($abf);
$oldcat = $class = '';
while ($row = db_fetch_assoc($erg)) {
if ($oldcat != $row['kate']) {
$oldcat = $row['kate'];
echo '<tr><td class="Cdark" colspan="2"><b>' . $row['kate'] . '</b></td></tr>';
}
//$k0m = db_query("SELECT COUNT(ID) FROM `prefix_koms` WHERE uid = " . $row['id'] . " AND cat = 'TUT'");
$datum = date("d.m.Y", $row['datum']);
//$text = bbcode($row['text']);
if ($class == 'Cmite') {
$class = 'Cnorm';
} else {
$class = 'Cmite';
}
echo '<tr><td class="' . $class . '"><strong><a href="index.php?tut-' . $row['id'] . '">' . $row['title'] . '</a></strong></td><td class="' . $class . '"> Geschrieben von ' . $row['username'] . ' am ' . $datum . '</td></tr>';
}
echo '</table>';
echo $MPL;
} else {
$design->header();
$nid = escape($menu->get(1), 'integer');
$row = db_fetch_object(db_query("SELECT * FROM `prefix_tut` WHERE id = '" . $nid . "'"));
if (has_right(array($row->recht))) {
$komsOK = true;
if ($allgAr['Ngkoms'] == 0) {
if (loggedin()) {
$komsOK = true;
} else {
$komsOK = false;
}
}
if ($allgAr['Nukoms'] == 0) {
$komsOK = false;
}
// kommentar add
if ((loggedin() OR chk_antispam ('tutkom')) AND $komsOK AND !empty($_POST['name']) AND !empty($_POST['txt'])) {
$_POST['txt'] = escape($_POST['txt'], 'string');
$_POST['name'] = escape($_POST['name'], 'string');
db_query("INSERT INTO `prefix_koms` VALUES (''," . $nid . ",'TUT','" . $_POST['name'] . "','" . $_POST['txt'] . "')");
}
// kommentar add
// kommentar loeschen
if ($menu->getA(2) == 'd' AND is_numeric($menu->getE(2)) AND has_right(- 7, 'tut')) {
$kommentar_id = escape($menu->getE(2), 'integer');
db_query("DELETE FROM prefix_koms WHERE uid = " . $nid . " AND cat = 'TUT' AND id = " . $kommentar_id);
}
// kommentar loeschen
$kategorie = $row->kat;
$textToShow = bbcode($row->text);
if (!empty($such)) {
$textToShow = markword($textToShow, $such);
}
$tpl = new tpl ('tut.htm');
$ar = array (
'TEXT' => $textToShow,
'KATE' => $kategorie,
'NID' => $nid,
'uname' => $_SESSION['authname'],
'ANTISPAM' => (loggedin()?'':get_antispam ('tutkom', 0)),
'NAME' => $row->title
);
$tpl->set_ar_out($ar, 2);
if ($komsOK) {
$tpl->set_ar_out (array ('NAME' => $row->title , 'NID' => $nid), 3);
}
$erg1 = db_query("SELECT text, name, id FROM `prefix_koms` WHERE uid = " . $nid . " AND cat = 'TUT' ORDER BY id DESC");
$ergAnz1 = db_num_rows($erg1);
if ($ergAnz1 == 0) {
echo '<b>' . $lang['nocomments'] . '</b>';
} else {
$zahl = $ergAnz1;
while ($row1 = db_fetch_assoc($erg1)) {
$row1['text'] = bbcode(trim($row1['text']));
if (has_right(- 7, 'tut')) {
$row1['text'] .= '<a href="?tut-' . $nid . '-d' . $row1['id'] . '"><img src="include/images/icons/del.gif" alt="löschen" border="0" title="löschen" /></a>';
}
$abf2 = 'SELECT id, name, avatar FROM prefix_user WHERE name = "' . $row1['name'] . '" ';
$erg2 = db_query($abf2);
$row2 = db_fetch_object($erg2);
$tpl->set_ar_out(array('NAME' => $row1['name'], 'TEXT' => $row1['text'], 'ZAHL' => $zahl) , 4);
$zahl--;
}
}
}
$tpl->out(5);
}
$design->footer();
?>
Zuletzt modifiziert von Mairu am 25.04.2010 - 10:54:33