section = $section; # Admin *g*
}
else {
$this->section = trim($mysql_object->real_escape_string(stripslashes($section)));
}
$this->limit = (int)$limit;
$this->talkline = trim($mysql_object->real_escape_string(stripslashes($talkline)));
$this->user = &$user;
$this->message = $message;
$this->coloremote = '`2';
$this->color3person = '`&';
$this->colortalkline = '`3';
$this->colorspeak = '`#';
$this->colorpet = '`7';
$this->colornpc = '`9';
}
public function ChangeDefaultColors($speak = false, $thirdperson = false, $emote = false) {
if($speak !== false) {
$this->colorspeak = $speak;
}
if($emote !== false) {
$this->coloremote = $emote;
}
if($thirdperson !== false) {
$this->color3person = $thirdperson;
}
}
// Funktionen
public function Add() {
if(isset($_SESSION['session']['comment_for_insert'])) {
$_POST = $_SESSION['session']['comment_for_insert'];
}
if(!empty($this->user['prefs']['commenttalkcolor'])) $this->colortalkline = $this->user['prefs']['commenttalkcolor'];
if(!empty($this->user['prefs']['commentemotecolor'])) $this->coloremote = $this->user['prefs']['commentemotecolor'];
if($_POST['section'] == HTMLEntities($this->section)) {
$commentary = trim($_POST['commentary']);
if($commentary != '') {
// Emotecheck
$emote = 0;
if(beginsWith($commentary,'::')) {
$commentary = $this->coloremote.substr($commentary,2);
$emote = 1;
} elseif(beginsWith($commentary,':')) {
$commentary = $this->coloremote.substr($commentary,1);
$emote = 1;
} elseif(beginsWith($commentary,'/me')) {
$commentary = $this->coloremote.substr($commentary,3);
$emote = 1;
} elseif(beginsWith($commentary,'/em')) {
$commentary = $this->color3person.substr($commentary,3);
$emote = 2;
} elseif(beginsWith($commentary,'/x')) {
$commentary = $this->color3person.substr($commentary,2);
$emote = 2;
} elseif(beginsWith($commentary,'/ms')) {
$commentary = $this->coloremote.substr($commentary,3);
$emote = 3;
// Erweiterte Überprüfung für Pet und NPC by Auric
} elseif(beginsWith($commentary,'/p')) {
$commentary = $this->colorpet.substr($commentary,3);
$emote = 4;
} elseif(beginsWith($commentary,'/npc')) {
$commentary = $this->colornpc.substr($commentary,5);
$emote = 5;
} else {
$commentary = $this->colorspeak.$commentary;
}
$this->emote = $emote;
$commentary = $this->Clear($commentary);
$this->Insert($commentary,$this->user['acctid']);
}
return true;
unset($session['comment_for_insert']);
$_POST = array();
}
else return false;
}
private function Clear($commentary) {
$commentary = str_replace('`n','',$commentary);
return $commentary;
}
private function Insert($commentary,$author) {
global $mysql_object;
// Kommentare kürzen, radikal *g*
$commentary = substr($commentary, 0, COMMENTARY_MAXLENGHT);
// Eintragen
$sql = 'INSERT INTO `commentary` (`author`,`comment`,`section`,`emote`,`postdate`'.($this->emote==5?',`control`':'').') '
.'VALUES ( '
.'"'.$author.'",'
.'"'.$mysql_object->real_escape_string(stripslashes($commentary)).'",'
.'"'.$this->section.'",'
.'"'.$this->emote.'",'
.'NOW()'
.($this->emote==5?", '".npc::getActOf($author)."'":'')
.') ';
db_query($sql) or die('MySQL-Error (#'.db_errno()."):
\r\n".db_error());
}
public function View($postfield = true) {
$com = (int)$_GET['comscroll'];
$REQUEST_URI = $_SERVER['REQUEST_URI'];
$sql = 'SELECT
`commentary`.*,
`accounts`.`name`,
`accounts`.`login`,
`accounts`.`loggedin`,
`accounts`.`location`,
`accounts`.`laston`,
`accounts`.`hashorse`,
`accounts`.`petname`,
`accounts`.`statusrp`,
`accounts`.`statusot`
FROM
`commentary`
INNER JOIN
`accounts`
ON
`accounts`.`acctid` = `commentary`.`author`
WHERE
`commentary`.`section` = "'.$this->section.'"
ORDER BY
`commentid` DESC
LIMIT '.($com*$this->limit).','.$this->limit.' ';
if(COMMENTARY_GUILDTAG_DISPLAY) {
$sql = $this->GuildPrefixes('overwrite_sql', COMMENTARY_GUILDTAG_VERSION, array('section' => $this->section, 'com' => $com, 'limit' => $this->limit));
}
$result = db_query($sql);
$i = 0;
$comments = array();
$postzeiten = array();
$search = array('`&');
$replace = array('`&');
define('endl',"\r\n");
if(NOBIO === false) {
$linktemplate = '`0'.endl.'`&{$NAME}`0'.endl;
$petlinktemplate = '`0'.endl;
$npclinktemplate = '`0'.endl.'`&{$NPC}`0'.endl;
} else {
$linktemplate = '{$NAME}';
$petlinktemplate = '{$PET}';
$npclinktemplate = '{$NPC}';
}
$sea4linktemplate = array('{$LOGIN}','{$REQUESTURI}','{$NAME}','{$STATUSRP}');
$sea4linktemplateP = array('{$LOGIN}','{$REQUESTURI}','{$PET}');
$sea4linktemplateN = array('{$ID}','{$REQUESTURI}','{$NPC}');
while($row = db_fetch_assoc($result)) {
$row['comment'] = preg_replace("'[`][^".COMMENTARY_ALLOWEDTAGS."]'","",$row['comment']);
$statusrp = "~".$row['statusrp']."~ ~".$row['statusot']."~";
$rep4linktemplate = array(RawURLEncode($row['login']),RawURLEncode($REQUEST_URI),$row['name'],$statusrp);
$row['namebackup'] = $row['name'];
$row['name'] = str_replace($sea4linktemplate,$rep4linktemplate,$linktemplate);
addnav('','bio.php?char='.RawURLEncode($row['login']).'&ret='.RawURLEncode($REQUEST_URI));
if(COMMENTARY_GUILDTAG_DISPLAY) {
$row['name'] = $this->GuildPrefixes('addprefix', COMMENTARY_GUILDTAG_VERSION, array('row' => $row, 'name' => $row['name']));
}
// Deleteprefix
if($this->user['superuser'] >= COMMENTARY_LIVEDELETING_SULEVEL) {
$prefix = '[X] ';
addnav("",COMMENTARY_LIVEDELETING_DELETETARGET.'&commentid='.$row['commentid'].'&return='.RawURLEncode($_SERVER['REQUEST_URI']));
}
else {
$prefix = '';
}
// Timestamp
if(COMMENTARY_TIMESTAMP_DISPLAY === true) {
$prefix .= '`0['.date(COMMENTARY_TIMESTAMP_FORMAT, strToTime($row['postdate'])).']`0';
}
$postzeiten[] = $row['postdate']; //substr($row['postdate'],11,12);
// Emotler entlarven
if(COMMENTARY_DISPLAYEMOTLERNAME === true AND $this->user['superuser'] >= COMMENTARY_DISPLAYEMOTLERNAME_SULEVEL) {
$emotename = ' `0('.trim($row['namebackup']).')`0 ';
} else {
$emotename = '';
}
switch($row['emote']) {
case 5: // NPC-Erweiterung von Auric
$npcsql = "SELECT `id`, `name` FROM `npc` WHERE `id`=".$row["control"]." LIMIT 1";
$npcres = db_query($npcsql) or die(db_error(LINK));
$npc = db_fetch_assoc($npcres);
$rep4linktemplateN = array($npc['id'],RawURLEncode($REQUEST_URI),$npc['name']);
$row['npc'] = str_replace($sea4linktemplateN,$rep4linktemplateN,$npclinktemplate);
$npclink = str_replace($sea4linktemplateN,$rep4linktemplateN,'npc.php?op=bio&id={$ID}&ret={$REQUESTURI}');
addnav('',$npclink);
$comments[] = $prefix.str_replace($search,$replace,'`&'.$row['npc'].' '.$this->nl2paragraph($row['comment'])."`0\r\n");
break;
case 4: // Pet-Erweiterung von Auric
$petname = $row['petname'];
$pet = getmount($row['hashorse']);
$rep4linktemplateP = array(RawURLEncode($row['login']),RawURLEncode($REQUEST_URI),$pet['mountname']." ".$petname);
$row['pet'] = str_replace($sea4linktemplateP,$rep4linktemplateP,$petlinktemplate);
$petlink = str_replace($sea4linktemplateP,$rep4linktemplate,'bio.php?char={$LOGIN}&what=pet&ret={$REQUESTURI}');
addnav("",$petlink);
$comments[] = $prefix.str_replace($search,$replace,'`&'.$row['pet'].' '.$this->nl2paragraph($row['comment'])."`0\r\n");
break;
case 3:
$lastchar = strToLower(substr($this->StripTag($row['namebackup']), -1));
switch($lastchar) {
case 's':
case 'z':
case 'c':
$comments[] = $prefix.str_replace($search,$replace,
'`&'.substr($row['name'], 0, -2)."`` ".$this->nl2paragraph($row['comment'])."`0\r\n");
break;
default:
$comments[] = $prefix.str_replace($search,$replace,
'`&'.substr($row['name'], 0, -2)."s ".$this->nl2paragraph($row['comment'])."`0\r\n");
break;
}
break;
case 2:
$comments[] = $prefix.str_replace($search,$replace,
$emotename.$this->nl2paragraph($row['comment'])."`0\r\n");
break;
case 1:
$comments[] = $prefix.str_replace($search,$replace,
'`&'.$row['name'].' '.$this->nl2paragraph($row['comment'])."`0\r\n");
break;
default:
$comments[] = $prefix.str_replace($search,$replace,
'`&'.$row['name'].' '.$this->colortalkline.$this->talkline.': "'.$this->nl2paragraph($row['comment']).$this->colortalkline."\"`0\r\n");
}
$i++;
}
// Ausgabe
krsort($comments);
reset($comments);
while (list($sec,$v)=each($comments)){
if(COMMENTARY_USEPARAGRAPHS === true) {
output('
'.$v.'
',true); } else { output($v.'', $exploded);
}
else {
$search = array("\r\n", "\r", "\n");
return str_Replace($search, '
', $input);
}
}
else return $input;
}
public function SuView($deletetarget = 'superuser.php?op=commentdelete', $sectionviewfile = 'superuser.php?op=checkcommentary') {
$com = (int)$_GET['comscroll'];
$REQUEST_URI = $_SERVER['REQUEST_URI'];
if(empty($_GET['section'])) {
$where = '';
$i = 0;
foreach($this->section as $disallowedsection) {
$where.= ($i > 0?'AND ':'WHERE ').'`commentary`.`section` NOT LIKE "'.$disallowedsection.'"';
$i++;
}
$sql = 'SELECT
`commentary`.`section`,
COUNT(`commentid`) as counter
FROM
`commentary`
INNER JOIN
`accounts`
ON
`accounts`.`acctid` = `commentary`.`author`
'.$where.'
GROUP BY
`section`
LIMIT '.($com*$this->limit).','.$this->limit.' ';
}
else {
$where = 'WHERE `section` = "'.$_GET['section'].'" ';
$sql = 'SELECT
`commentary`.*,
`accounts`.`name`,
`accounts`.`login`,
`accounts`.`loggedin`,
`accounts`.`location`,
`accounts`.`laston`
FROM
`commentary`
INNER JOIN
`accounts`
ON
`accounts`.`acctid` = `commentary`.`author`
'.$where.'
ORDER BY
`section` ASC,
`commentid` DESC
LIMIT '.($com*$this->limit).','.$this->limit.' ';
}
$result = db_query($sql);
$i = 0;
$comments = array();
$sections = array();
$counts = array();
$search = array('`&');
$replace = array('`&');
define('endl',"\r\n");
$linktemplate = '{$NAME}';
$acsection = '';
while($row = db_fetch_assoc($result)) {
$row['comment'] = preg_replace("'[`][^".COMMENTARY_ALLOWEDTAGS."]'","",$row['comment']);
$sea4linktemplate = array('{$NAME}');
$rep4linktemplate = array($row['name']);
$sections[] = $row['section'];
$row['namebackup'] = $row['name'];
$row['name'] = str_replace($sea4linktemplate,$rep4linktemplate,$linktemplate);
$delprefix = '[ X ] ';
addnav("",$deletetarget.'&commentid='.$row['commentid'].'&return='.RawURLEncode($_SERVER['REQUEST_URI']));
// Timestamp
if(COMMENTARY_TIMESTAMP_DISPLAY === true) {
$prefix .= '`0['.date(COMMENTARY_TIMESTAMP_FORMAT, strToTime($row['postdate'])).']`0';
}
// Emotler entlarven
if(COMMENTARY_DISPLAYEMOTLERNAME === true AND $this->user['superuser'] >= COMMENTARY_DISPLAYEMOTLERNAME_SULEVEL) {
$emotename = ' `0('.trim($row['namebackup']).')`0 ';
}
else {
$emotename = '';
}
switch($row['emote']) {
case 3:
$lastchar = strToLower(substr($this->StripTag($row['namebackup']), -1));
switch($lastchar) {
case 's':
case 'z':
case 'c':
$comments[] = $delprefix.str_replace($search,$replace,
'`&'.substr($row['name'], 0, -2)."`` ".$this->nl2paragraph($row['comment'])."`0\r\n");
break;
default:
$comments[] = $delprefix.str_replace($search,$replace,
'`&'.substr($row['name'], 0, -2)."s ".$this->nl2paragraph($row['comment'])."`0\r\n");
break;
}
break;
case 2:
$comments[] = $delprefix.str_replace($search,$replace,
$emotename.$this->nl2paragraph($row['comment'])."`0\r\n");
break;
case 1:
$comments[] = $delprefix.str_replace($search,$replace,
'`&'.$row['name'].' '.$this->nl2paragraph($row['comment'])."`0\r\n");
break;
default:
$comments[] = $delprefix.str_replace($search,$replace,
'`&'.$row['name'].' '.$this->colortalkline.$this->talkline.': "'.$this->nl2paragraph($row['comment']).$this->colortalkline."\"`0\r\n");
}
if(empty($_GET['section'])) {
$counts[] = $row['counter'];
}
$i++;
}
// Ausgabe
krsort($comments); krsort($sections); ksort($counts);
reset($comments); reset($sections); reset($counts);
$acsection = '';
while (list($sec,$v)=each($comments)){
if($acsection != $sections[$sec]) {
$acsection = $sections[$sec];
if(empty($_GET['section'])) {
$count = $counts[$sec];
output('
'.$v.'
',true); } else { output($v.'