LoGD Standardrelease steht hier zum Download zur Verfügung!
<?php
function addcommentary() {
global $_POST,$session,$REQUEST_URI,$_GET,$doublepost,$revert_rp,$revert_dp,$rporte,$gott;
$doublepost=0;
$section=$_POST['section'];
$talkline=$_POST['talkline'];
if ($_POST[insertcommentary][$section]!==NULL &&
trim($_POST[insertcommentary][$section])!="") {
$commentary = str_replace("`n","",soap($_POST[insertcommentary][$section]));
if (strlen($commentary)>2048) $commentary=substr($commentary,0,2048);
$y = strlen($commentary);
for ($x=0;$x<$y;$x++){
if (substr($commentary,$x,1)=="`"){
$colorcount++;
if ($colorcount>=getsetting("maxcolors",10)){
$commentary = substr($commentary,0,$x).preg_replace("'[`].'","",substr($commentary,$x));
$x=$y;
}
$x++;
}
}
if (substr($commentary,0,1)!=":" &&
substr($commentary,0,2)!="::" &&
substr($commentary,0,3)!="/me" &&
substr($commentary,0,3)!="/ms" &&
substr($commentary,0,2)!="/X" &&
$session['user']['drunkenness']>0) {
//drunk people shouldn't talk very straight.
$straight = $commentary;
$replacements=0;
while ($replacements/strlen($straight) < ($session['user']['drunkenness'])/500 ){
$slurs = array("a"=>"aa","e"=>"ee","f"=>"ff","h"=>"hh","i"=>"ij","l"=>"ll","m"=>"mm","n"=>"nn","o"=>"oo","r"=>"rr","s"=>"sh","u"=>"uu","v"=>"vv","w"=>"ww","y"=>"yy","z"=>"zz");
if (e_rand(0,9)) {
srand(e_rand());
$letter = array_rand($slurs);
$x = strpos(strtolower($commentary),$letter);
if ($x!==false &&
substr($comentary,$x,5)!="*hic*" &&
substr($commentary,max($x-1,0),5)!="*hic*" &&
substr($commentary,max($x-2,0),5)!="*hic*" &&
substr($commentary,max($x-3,0),5)!="*hic*" &&
substr($commentary,max($x-4,0),5)!="*hic*"
){
if (substr($commentary,$x,1)<>strtolower($letter)) $slurs[$letter] = strtoupper($slurs[$letter]); else $slurs[$letter] = strtolower($slurs[$letter]);
$commentary = substr($commentary,0,$x).$slurs[$letter].substr($commentary,$x+1);
$replacements++;
}
}else{
$x = e_rand(0,strlen($commentary));
if (substr($commentary,$x,5)=="*hic*") {$x+=5; } //output("moved 5 to $x ");
if (substr($commentary,max($x-1,0),5)=="*hic*") {$x+=4; } //output("moved 4 to $x ");
if (substr($commentary,max($x-2,0),5)=="*hic*") {$x+=3; } //output("moved 3 to $x ");
if (substr($commentary,max($x-3,0),5)=="*hic*") {$x+=2; } //output("moved 2 to $x ");
if (substr($commentary,max($x-4,0),5)=="*hic*") {$x+=1; } //output("moved 1 to $x ");
$commentary = substr($commentary,0,$x)."*hic*".substr($commentary,$x);
//output($commentary."`n");
$replacements++;
}//end if
}//end while
//output("$replacements replacements (".($replacements/strlen($straight)).")`n");
while (strpos($commentary,"*hic**hic*"))
$commentary = str_replace("*hic**hic*","*hic*hic*",$commentary);
}//end if
$commentary = preg_replace("'([^[:space:]]{45,45})([^[:space:]])'","\\1 \\2",$commentary);
if ($session['user']['drunkenness']>50) $talkline = "lallt";
$talkline = translate($talkline);
// Chatcolor 196
if (substr($commentary,0,1)==':' || substr($commentary,0,3)=='/me' || substr($commentary,0,3)=='/ms' || substr($commentary,0,3)=='/X ') {
if (substr($commentary,0,3)=='/me') $strpos = 3;
elseif (substr($commentary,0,3)=='/ms') $strpos = 3;
elseif (substr($commentary,0,2)=='::') $strpos = 2;
elseif (substr($commentary,0,3)=='/X ') $strpos = 3;
else $strpos = 1;
if ($session['user']['prefs']['commentemotecolor']) $commentary = substr($commentary,0,$strpos).$session['user']['prefs']['commentemotecolor'].substr($commentary,$strpos);
} else {
if ($session['user']['prefs']['commenttalkcolor']) $commentary = $session['user']['prefs']['commenttalkcolor'].$commentary;
}
if ($talkline!="sagt" // do an emote if the area has a custom talkline and the user isn't trying to emote already.
&& substr($commentary,0,1)!=":"
&& substr($commentary,0,2)!="::"
&& substr($commentary,0,2)!="/X"
&& substr($commentary,0,3)!="/ms"
&& substr($commentary,0,3)!="/me")
$commentary = ":`3$talkline: \\\"`#$commentary`3\\\"";
$sql = "SELECT commentary.comment,commentary.author FROM commentary WHERE section='$section' ORDER BY commentid DESC LIMIT 1";
$result = db_query($sql) or die(db_error(LINK));
$row = db_fetch_assoc($result);
db_free_result($result);
if ($row[comment]!=stripslashes($commentary) || $row[author]!=$session[user][acctid]){
//RPG-Chars Addon (c) 2006 by Meralou & Alexiel modified by Linus in 2007
$points=floor(strlen(str_replace(' ','',$commentary))/128);
if($points<1 && strlen(str_replace(' ','',$commentary))>=128) $points=1;
if ($points>0 && in_array($section,$rporte)) {
$session['user']['rp_points']+=$points;
$revert_rp=$session['user']['rp_points'];
if ($session[user][rp_only]>=1) $session[user][donation]+=$points;
$revert_dp=$session[user][donation];
db_query("UPDATE gilden SET gildenpunkte=gildenpunkte+1 WHERE gildenid='".$session['user']['memberid']."'");
$session['guild']['gildenpunkte']++;
} elseif (!in_array($section,$rporte)) $points=0;
// ALTER TABLE `commentary` ADD `gildenpre` varchar(18) NOT NULL DEFAULT '';
// Gildenprefix in der commetary-Tabelle
$prefix = db_fetch_assoc(db_query("SELECT gildenprefix, gildenname FROM gilden WHERE gildenid='".$session['user']['memberid']."'"));
//Abkürzungen (Platzhalter) im Chat by Linus
if ($session['user']['prefs']['chatabk']){
$name=closetags($session['user']['name'],'`i`b`c');
if($session['user']['ctitle']!=''){
$title=closetags($session['user']['ctitle'],'`i`b`c');
$trans = array($session['user']['ctitle'].' ' => '');
$nameonly=closetags(strtr($session['user']['name'],$trans),'`i`b`c');
}elseif($session['user']['title']!=''){
$title=$session['user']['title'];
$trans = array($session['user']['title'].' ' => '');
$nameonly=closetags(strtr($session['user']['name'],$trans),'`i`b`c');
}else{
$title='';
$nameonly=$session['user']['name'];
}
if($session['user']['marriedto']>0){
$sqlm="SELECT `login`,`name`,`title`,`ctitle` FROM `accounts` WHERE `acctid`={$session['user']['marriedto']}";
$resm=db_query($sqlm);
if(db_num_rows($resm)==1){
$m_name=db_fetch_assoc($resm);
$mname=closetags($m_name['name'],'`i`b`c');
if($m_name['ctitle']!=''){
$trans = array($m_name['ctitle'].' ' => '');
$mnameonly=closetags(strtr($m_name['name'],$trans),'`i`b`c');
$mtitle=closetags($m_name['ctitle'],'`i`b`c');
}elseif($m_name['title']!=''){
$trans = array($m_name['title'].' ' => '');
$nameonly=closetags(strtr($m_name['name'],$trans),'`i`b`c');
$mtitle=$m_name['title'];
}else{
$mtitle='';
$mnameonly=$m_name['name'];
}
$mlogin=$m_name['login'];
} else {
$mname='';
$mlogin='';
$mnameonly='';
}
} else $mname=$mlogin=$mnameonly=$mtitle='';
$sqlb="SELECT `tiername`,`gottname`,`platzhalter_0`, `platzhalter_1`, `platzhalter_2`, `platzhalter_3`, `platzhalter_4` FROM `bio` WHERE `acctid`={$session['user']['acctid']}";
$resb=db_query($sqlb);
if(db_num_rows($resb)==1) $bname=db_fetch_assoc($resb);
if($session['user']['hashorse']>0){
$tier=getmount($session['user']['hashorse']);
if($bname['tiername']==''){
$tname=$tier['mountname'];
}else{
$tname=closetags($bname['tiername'],'`i`b`c');
}
} else $tname='';
if($session['user']['gott']>0){
if($bname['gottname']==''){
$gname=$gott[$session['user']['gott']];
}else{
$gname=closetags($bname['gottname'],'`i`b`c');
}
} else $gname='';
$trans = array('%%n' => $name, '%%l' => $session['user']['login'], '%%t' => $title, '%%m' => $nameonly, '%%p' => $mname,
'%%r' => $mnameonly, '%%o' => $mlogin, '%%s' => $mtitle, '%%b' => $tname, '%%c' => $tier['mountname'],'%%g' => $gname,
'%%h' => $gott[$session['user']['gott']], '%%i' => $prefix['gildenname'], '%%j' => $prefix['gildenprefix'],
'%%0' => $bname['platzhalter_0'], '%%1' => $bname['platzhalter_1'], '%%2' => $bname['platzhalter_2'],
'%%3' => $bname['platzhalter_3'], '%%4' => $bname['platzhalter_4']
);
$commentary=strtr($commentary, $trans);
}
//Ende Abkürzungen (Platzhalter) im Chat by Linus
$sql = "INSERT INTO commentary (postdate,section,author,comment,punkte,gildenpre) VALUES (now(),'$section',".$session[user][acctid].",\"$commentary\",$points,'".$prefix['gildenprefix']."')";
db_query($sql) or die(db_error(LINK));
return true;
} else {
$doublepost = 1;
}
}
return false;
}
?>