function viewcommentary($section,$message="Kommentar hinzufügen?",$limit=10,$talkline="sagt") {
global $HTTP_POST_VARS,$session,$REQUEST_URI,$HTTP_GET_VARS, $doublepost,$appoencode_str;
$nobios = array("motd.php"=>true);
if ($nobios[basename($_SERVER['SCRIPT_NAME'])]) $linkbios=false; else $linkbios=true;
//output("`b".basename($_SERVER['SCRIPT_NAME'])."`b`n");
if ($doublepost) output("`\$`bDoppelpost?`b`0`n");
$message = translate($message);
$com=(int)$HTTP_GET_VARS[comscroll];
// Guild/Clans code by Dasher
$sql = "SELECT commentary.*,
accounts.name,
accounts.login,
accounts.guildID,
lotbd_guilds.GuildPrefix
FROM commentary
INNER JOIN accounts
ON accounts.acctid = commentary.author
LEFT JOIN lotbd_guilds
ON lotbd_guilds.ID = accounts.GuildID
WHERE section = '$section'
AND accounts.locked=0
ORDER BY commentid DESC
LIMIT ".($com*$limit).",$limit";
$result = db_query($sql) or die(db_error(LINK));
$counttoday=0;
for ($i=0;$i < db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
$row[comment]=preg_replace("'[`][^".$appoencode_str."`]'","",$row[comment]);
$commentids[$i] = $row[commentid];
$x=0;
$ft="";
for ($x=0;strlen($ft)<3 && $x<strlen($row[comment]);$x++){
if (substr($row[comment],$x,1)=="`" && strlen($ft)==0) {
$x++;
}else{
$ft.=substr($row[comment],$x,1);
}
}
$link = "bio.php?char=".rawurlencode($row[login]) . "&ret=".URLEncode($_SERVER['REQUEST_URI']);
$link2 = "`2[`0<a href='showdetail.php?id=".$row['gildenid']."' target='window_popup' onClick=\"".popup("showdetail.php?id=".$row['gildenid'])."; return false;\">`&".stripslashes($row['gildenprefix'])."`&</a>`2]";
if (substr($ft,0,2)=="::") $ft = substr($ft,0,2);
if (substr($ft,0,2)=="/X") $ft = substr($ft,0,2);
else
if (substr($ft,0,1)==":") $ft = substr($ft,0,1);
/*
Landschafts-Emote by Eliwood
*/
if ($ft=="/X")
{
//Stealthwatcher by Wraith
if ($session[user][superuser]>=3){
if ($session['user']['prefs']["xmote"]==1){
$SW_sql = "SELECT name FROM accounts WHERE acctid='".$row[author]."'";
$SW_result = db_query($SW_sql) or die(db_error(LINK));
$SW_c=0;
for ($SW_c=0;$SW_c < db_num_rows($SW_result);$SW_c++){
$op[$i].=" `7[von `&".$row[name]."`7] ";
}
}
}
//end Stealthwatcher
$x = strpos($row[comment],$ft);
if ($x!==false)
{
if ($linkbios)
$op[$i] .= str_replace("&","&",HTMLEntities(substr($row[comment],0,$x)))
."`0\n`& "
.str_replace("&","&",HTMLEntities(substr($row[comment],$x+strlen($ft))))
."`0`n";
else
$op[$i] .= str_replace("&","&",HTMLEntities(substr($row[comment],0,$x)))
."`0\n`& "
.str_replace("&","&",HTMLEntities(substr($row[comment],$x+strlen($ft))))
."`0`n";
}
}
/*Landschaft-Emote Ende*/
elseif ($ft=="::" || $ft=="/me" || $ft==":"){
$x = strpos($row[comment],$ft);
if ($x!==false){
if ($linkbios)
$op[$i] = str_replace("&","&",HTMLEntities(substr($row[comment],0,$x)))
."`0".$link2."`0<a href='$link' style='text-decoration: none'>\n`&$row[name]`0</a>\n`& "
.str_replace("&","&",HTMLEntities(substr($row[comment],$x+strlen($ft))))
."`0`n";
else
$op[$i] = str_replace("&","&",HTMLEntities(substr($row[comment],0,$x)))
."`0\n`&$row[name]`0\n`& "
.str_replace("&","&",HTMLEntities(substr($row[comment],$x+strlen($ft))))
."`0`n";
}
}
/*beginn ms-rp Emote by
Rikkarda@silienta-logd.de for
http://www.silienta-logd.de*/
elseif ($ft=="/ms"){
$name = str_replace("`0","",$row['name']);
$namestrlen = strlen($name);
$lastchar = $name{$namestrlen-1};
$name = $name.($lastchar == "s" || $lastchar == "x"?"'`0":"s`0");
$x = strpos($row[comment],$ft);
if ($x!==false){
if ($linkbios)
$op[$i] = str_replace("&","&",HTMLEntities(substr($row[comment],0,$x)))
."`0<a href='$link' style='text-decoration: none' >\n<span onMouseOver=\"return escape('".HTMLEntities($string)."')\">`&$name`0</span></a>\n`& "
.str_replace("&","&",HTMLEntities(substr($row[comment],$x+strlen($ft))))
."`0`n";
else
$op[$i] = str_replace("&","&",HTMLEntities(substr($row[comment],0,$x)))
."`0\n<span onMouseOver=\"return escape('".HTMLEntities($string)."')\">`&$name`0</span>\n`& "
.str_replace("&","&",HTMLEntities(substr($row[comment],$x+strlen($ft))))
."`0`n";
}
}
/*rp-ms Emote-End*/
if ($op[$i]=="")
if ($linkbios)
$op[$i] = "`0".$link2."`0<a href='$link' style='text-decoration: none'>`&$row[name]`0</a>`3 sagt: \"`#"
.str_replace("&","&",HTMLEntities($row[comment]))."`3\"`0`n";
else
$op[$i] = "`0`&$row[name]`0`3 sagt: \"`#"
.str_replace("&","&",HTMLEntities($row[comment]))."`3\"`0`n";
if ($message=="X") $op[$i]="`0($row[section]) ".$op[$i];
$loggedin=(date("U") - strtotime($row[laston]) < getsetting("LOGINTIMEOUT",900) && $row[loggedin]);
if ($row['postdate']>=$session['user']['recentcomments']) $op[$i]=($loggedin?"<img src='images/new-online.gif' alt='>' width='3' height='5' align='absmiddle'> ":"<img src='images/new.gif' alt='>' width='3' height='5' align='absmiddle'> ").$op[$i];
addnav("",$link);
}
$i--;
$outputcomments=array();
$sect="x";
for (;$i>=0;$i--){
$out="";
if ($session[user][superuser]>=3 && $message=="X"){
$out.="`0[ <a href='superuser.php?op=commentdelete&commentid=$commentids[$i]&return=".URLEncode($_SERVER['REQUEST_URI'])."'>Löschen</a> ] ";
addnav("","superuser.php?op=commentdelete&commentid=$commentids[$i]&return=".URLEncode($_SERVER['REQUEST_URI']));
$matches=array();
preg_match("/[(][^)]*[)]/",$op[$i],$matches);
$sect=$matches[0];
}
//output($op[$i],true);
$out.=$op[$i];
if (!is_array($outputcomments[$sect])) $outputcomments[$sect]=array();
array_push($outputcomments[$sect],$out);
}
ksort($outputcomments);
reset($outputcomments);
while (list($sec,$v)=each($outputcomments)){
if ($sec!="x") output("`n`b$sec`b`n");
output(implode('',$v),true);
}
if ($session[user][loggedin]) {
//if ($counttoday<($limit/2) || $session['user']['superuser']>=2){
if ($message!="X"){
if ($talkline!="says") $tll = strlen($talkline)+11; else $tll=0;
output("<form action=\"$REQUEST_URI\" method='POST'>`@$message`n<input name='insertcommentary[$section]'
onkeyup=\"document.getElementById('chatpreview').innerHTML = appoencode(this.value);\"><input type='hidden' name='talkline' value='$talkline'><input type='hidden' name='section' value='$section'><input type='submit' class='button' value='Hinzufügen'><span id='chatpreview'></span>`n".(round($limit/2,0)-$counttoday<3?"`)(Du hast noch ".(round($limit/2,0)-$counttoday)." Beiträge für heute übrig)":"")."`0`n</form>",true);
addnav("",$REQUEST_URI);
}
// }else{
// output("`@$message`nSorry, du hast deine Beiträge in dieser Region für heute aufgebraucht.`0`n");
// }
}
if (db_num_rows($result)>=$limit){
$req = preg_replace("'[&]?c(omscroll)?=([[:digit:]-])*'","",$REQUEST_URI)."&comscroll=".($com+1);
//$req = substr($REQUEST_URI,0,strpos($REQUEST_URI,"c="))."&c=$HTTP_GET_VARS[c]"."&comscroll=".($com+1);
$req = str_replace("?&","?",$req);
if (!strpos($req,"?")) $req = str_replace("&","?",$req);
output("<a href=\"$req\"><< Vorherige</a>",true);
addnav("",$req);
}
$req = preg_replace("'[&]?c(omscroll)?=([[:digit:]]|-)*'","",$REQUEST_URI)."&comscroll=0";
//$req = substr($REQUEST_URI,0,strpos($REQUEST_URI,"c="))."&c=$HTTP_GET_VARS[c]"."&comscroll=".($com-1);
$req = str_replace("?&","?",$req);
if (!strpos($req,"?")) $req = str_replace("&","?",$req);
output(" <a href=\"$req\">Aktualisieren</a> ",true);
addnav("",$req);
if ($com>0){
$req = preg_replace("'[&]?c(omscroll)?=([[:digit:]]|-)*'","",$REQUEST_URI)."&comscroll=".($com-1);
//$req = substr($REQUEST_URI,0,strpos($REQUEST_URI,"c="))."&c=$HTTP_GET_VARS[c]"."&comscroll=".($com-1);
$req = str_replace("?&","?",$req);
if (!strpos($req,"?")) $req = str_replace("&","?",$req);
output(" <a href=\"$req\">Nächste >></a>",true);
addnav("",$req);
}
output("<a href='farben.php' onClick=\"".popup("farben.php").";return false;\" target='_blank' class='button' align='right'> `^Farben </a>",true);
addnav("","farben.php");
db_free_result($result);
}
December