function addcommentary() { global $session, $emptypost, $afk, $dni; $section = httppost('section'); $talkline = httppost('talkline'); $schema = httppost('schema'); $comment = trim(httppost('insertcommentary')); $counter = httppost('counter'); $remove = URLDecode(httpget('removecomment')); $restore = URLDecode(httpget('restorecomment')); //debug(httpallpost()); if (httpget("bulkdelete")) { $everything = httpallpost(); foreach ($everything as $key => $val) { if (substr($key, 0, 14) == "deletecomment_") { $del = str_replace("deletecomment_", "", $key); removecommentary($del, "Mass deletion by " . $session['user']['name'], $session['user']['acctid']); } } } if (!$comment) { return false; } if ($session['user']['chatloc'] == "DNI") { $dni = true; } if ($comment == strtoupper($comment)) { //this is an all-uppercase entry. Do not add this comment to the database; instead, check it for built-in stuff like AFK and GREM, then run it through the commentarycommand hook if ($comment == "AFK" || $comment == "BRB") { $session['user']['chatloc'] = "AFK"; $afk = true; output("`0`n`c`bYou are Away From the Keyboard until you load another page.`b`c`n"); return false; } if ($comment == "DNI") { if ($session['user']['chatloc'] == "DNI") { $session['user']['chatloc'] = $section; $dni = false; output("`0`n`c`bYou are no longer in Do Not Interrupt status.`b`c`n"); } else { $session['user']['chatloc'] = "DNI"; $dni = true; output("`0`n`c`bYou are in Do Not Interrupt status. Type DNI again to leave.`b`nDNI status is used for whenever you're doing or saying something that means other players shouldn't try to interact with you. For example, when two or more characters are chatting just outside of the main group of characters, and other characters shouldn't be able to hear them.`c`n"); } return false; } if ($comment == "GREM") { //handle deleting the player's last comment $sql = "SELECT * FROM " . db_prefix("commentary") . " WHERE author='" . $session['user']['acctid'] . "' ORDER BY commentid DESC LIMIT 1"; $result = db_query($sql); while ($row = db_fetch_assoc($result)) { $now = time(); $then = strtotime($row['postdate']); $ago = $now - $then; if ($ago < 120) { removecommentary($row['commentid'], "Typo Gremlin", $session['user']['acctid']); output("`0`n`c`bA nearby Typo Gremlin notices the peculiar tastiness of your previous comment. Within moments, a small horde of them have descended upon your words, and consumed them.`b`c`n"); } else { output("`0`n`c`bThe Typo Gremlins turn up their nose at your latest comment - it's just too old. They have no taste for stale words.`b`c`n"); } } return false; } $hookcommand = array('command' => $comment, 'section' => $section); $returnedhook = modulehook("commentarycommand", $hookcommand); if (!$returnedhook['processed']) { debug($returnedhook); output("`c`b`JCommand Not Recognized`b`0`nWhen you type in ALL CAPS, the game doesn't think you're talking to other players; it thinks you're trying to perform an action within the game. For example, typing `#GREM`0 will remove the last comment you posted, as long as you posted it less than two minutes ago. Typing `#AFK`0 or `#BRB`0 will turn your online status bar grey, so that people know you're `#A`0way `#F`0rom the `#K`0eyboard (or, if you prefer, that you'll `#B`0e `#R`0ight `#B`0ack). Typing `#DNI`0 will let other players know that you're busy talking to one particular player - maybe somewhere off-camera - and that you don't want to be interrupted right now.`nSome areas have special hidden commands or other easter eggs that you can hunt for. This time around, you didn't trigger anything special.`c`0`n"); } return false; } if ($remove > 0) { removecommentary($remove, "Moderated by " . $session['user']['name'], $session['user']['acctid']); } if ($restore > 0) { restorecommentary($restore, "Restored by " . $session['user']['name'], $session['user']['acctid']); } if (array_key_exists('commentcounter', $session) && $session['commentcounter'] == $counter) { if ($section || $talkline || $comment) { $tcom = color_sanitize($comment); if ($tcom == "" || $tcom == ":" || $tcom == "::" || $tcom == "/me") { $emptypost = 1; } else { injectcommentary($section, $talkline, $comment); } } } }
function addcommentary() { global $session, $emptypost; $section = httppost('section'); $talkline = httppost('talkline'); $schema = httppost('schema'); $comment = trim(httppost('insertcommentary')); $counter = httppost('counter'); $remove = URLDecode(httpget('removecomment')); if ($remove > 0) { $return = '/' . httpget('returnpath'); $section = httpget('section'); $sql = "SELECT " . db_prefix("commentary") . ".*," . db_prefix("accounts") . ".name," . db_prefix("accounts") . ".acctid, " . db_prefix("accounts") . ".clanrank," . db_prefix("clans") . ".clanshort FROM " . db_prefix("commentary") . " INNER JOIN " . db_prefix("accounts") . " ON " . db_prefix("accounts") . ".acctid = " . db_prefix("commentary") . ".author LEFT JOIN " . db_prefix("clans") . " ON " . db_prefix("clans") . ".clanid=" . db_prefix("accounts") . ".clanid WHERE commentid={$remove}"; $row = db_fetch_assoc(db_query($sql)); $sql = "INSERT LOW_PRIORITY INTO " . db_prefix("moderatedcomments") . " (moderator,moddate,comment) VALUES ('{$session['user']['acctid']}','" . date("Y-m-d H:i:s") . "','" . addslashes(serialize($row)) . "')"; db_query($sql); $sql = "DELETE FROM " . db_prefix("commentary") . " WHERE commentid='{$remove}';"; db_query($sql); invalidatedatacache("comments-{$section}"); // *** DRAGONBG.COM CORE PATCH START *** invalidatedatacache("comments-"); // *** DRAGONBG.COM CORE PATCH END *** $session['user']['specialinc'] == ''; //just to make sure he was not in a special $return = cmd_sanitize($return); $return = substr($return, strrpos($return, "/") + 1); if (strpos($return, "?") === false && strpos($return, "&") !== false) { $x = strpos($return, "&"); $return = substr($return, 0, $x - 1) . "?" . substr($return, $x + 1); } debug($return); redirect($return); } if (array_key_exists('commentcounter', $session) && $session['commentcounter'] == $counter) { if ($section || $talkline || $comment) { $tcom = color_sanitize($comment); if ($tcom == "" || $tcom == ":" || $tcom == "::" || $tcom == "/me") { $emptypost = 1; } else { injectcommentary($section, $talkline, $comment, $schema); } } } }
function pt_insert($text) { $id = httpget('id'); require_once "lib/commentary.php"; injectcommentary("pet-{$id}", "", $text); return; }
function jquerycommentary_run() { global $_SERVER, $output, $session; require_once 'lib/commentary.php'; $section = httpget('section'); $commentary = db_prefix('commentary'); $accounts = db_prefix('accounts'); if (($commid = httpget('rmvcmmnt')) != "") { $prefix = db_prefix('commentary'); check_su_access(SU_EDIT_COMMENTS); if ($session['user']['superuser'] & SU_EDIT_COMMENTS) { db_query("DELETE FROM {$prefix} WHERE commentid = '{$commid}'"); } db_query("INSERT INTO {$commentary} (section, author, comment, postdate) VALUES ('blackhole', '{$session['user']['acctid']}', 'I f****d up', '" . date('Y-m-d H:i:s') . "')"); invalidatedatacache("comments-{$section}"); invalidatedatacache("comments-blackhole"); } if (httpget('section') == get_module_pref('current_section') && httpget('section') != '') { //echo 'x'; //var_dump(get_all_module_settings()); $output = ""; $_SERVER['REQUEST_URI'] = httpget('r'); $session['counter'] = httpget('c'); viewcommentary(get_module_pref('current_section'), get_module_setting('message'), get_module_setting('limit'), get_module_setting('talkline')); $output = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $output); $output = substr($output, 0, strpos($output, "<jquerycommentaryend>")); db_query("UPDATE accounts SET laston = '" . date('Y-m-d H:i:s') . "' WHERE acctid = '{$session['user']['acctid']}'"); echo trim("{$output}"); invalidatedatacache("comments-{$section}"); /*$sql = db_query( "SELECT a.name, a.acctid FROM accounts AS a LEFT JOIN module_userprefs AS m ON m.userid = a.acctid LEFT JOIN module_userprefs AS u ON u.userid = m.userid WHERE m.modulename = 'jquerycommentary' AND m.setting = 'is_typing' AND m.value = '1' AND u.modulename = 'jquerycommentary' AND u.setting = 'current_section' and u.value = '" . get_module_pref('current_section') ."'" ); $typing = []; while ($row = db_fetch_assoc($sql)) { array_push($typing, [$row['acctid'], $row['name']]); } $isTyping = appoencode('`@'); $i = 0; echo appoencode('`@Who\'s typing: `n'); if (count($typing) != 0) { foreach ($typing as $key => $val) { $i++; if ($i == 1) { $isTyping .= appoencode($val[1]); } else if ($i > 1 && count($typing) > $i) { $isTyping .= appoencode("`@, {$val[1]}"); } else if ($i == count($typing)) { $isTyping .= appoencode("`@ and {$val[1]}"); } } echo $isTyping; } else { echo appoencode('`@No one'); }*/ } switch (httpget('op')) { case 'get_json': $sql = db_query("SELECT commentid, author, comment FROM commentary WHERE section = '{$session['current_commentary_area']}' AND deleted = '0' ORDER BY commentid+0 DESC LIMIT 0, 25"); $json = []; while ($row = db_fetch_assoc($sql)) { array_push($json, $row); } echo "<pre>"; echo json_encode($json, JSON_PRETTY_PRINT); echo "</pre>"; break; case 'post': $post = httpallpost(); $post = modulehook('jquery-post-commentary', $post); $commentary = db_prefix('commentary'); if ($post['method'] == 'insertcommentary') { require_once 'lib/commentary.php'; injectcommentary(get_module_pref('current_section'), get_module_setting('talkline'), $post['comment']); } else { $commentid = explode('_', $post['method']); require_once 'lib/systemmail.php'; require_once 'lib/sanitize.php'; $post['comment'] = htmlent($post['comment']); db_query("UPDATE {$commentary} SET comment = '{$post['comment']}' WHERE commentid = '{$commentid[1]}'"); db_query("INSERT INTO {$commentary} (section, author, comment, postdate) VALUES ('blackhole', '{$session['user']['acctid']}', 'I f****d up', '" . date('Y-m-d H:i:s') . "')"); invalidatedatacache("comments-{$session['current_commentary_section']}"); invalidatedatacache("comments-blackhole"); } break; case 'last_comment': require_once 'lib/sanitize.php'; db_query("UPDATE accounts SET laston = '" . date('Y-m-d H:i:s') . "' WHERE acctid = '{$session['user']['acctid']}'"); //$sql = db_query("SELECT comment, commentid FROM ".db_prefix('commentary')." WHERE author = '{$session['user']['acctid']}' AND section = '{$session['current_commentary_area']}' ORDER BY commentid DESC LIMIT 0,1"); $sql = db_query("SELECT comment, commentid FROM {$commentary}\n WHERE author = '{$session['user']['acctid']}'\n AND (section = 'globalooc'\n OR section = '{$session['current_commentary_area']}')\n ORDER BY commentid DESC\n LIMIT 0,1"); $row = db_fetch_assoc($sql); $data = $row; $sql = db_query("SELECT commentid, section, comment FROM {$commentary}\n WHERE (section = 'globalooc'\n OR section = '{$session['current_commentary_area']}'\n OR section = 'blackhole'\n )\n ORDER BY commentid+0 DESC\n LIMIT 0,1"); $row = db_fetch_assoc($sql); $data['last_section'] = $row['section']; $data['last_comment'] = $row['commentid']; $data['last_message'] = $row['comment']; echo json_encode($data); break; case 'is_typing': $post = httpallpost(); if ($post['typing'] == 'yes') { set_module_pref('is_typing', 1); } else { set_module_pref('is_typing', 0); } $sql = db_query("SELECT a.name, a.acctid\n FROM accounts AS a\n LEFT JOIN module_userprefs AS m\n ON m.userid = a.acctid\n LEFT JOIN module_userprefs AS u\n ON u.userid = m.userid\n WHERE m.modulename = 'jquerycommentary'\n AND m.setting = 'is_typing'\n AND m.value = '1'\n AND u.modulename = 'jquerycommentary'\n AND u.setting = 'current_section'\n and u.value = '" . get_module_pref('current_section') . "'"); $typing = []; while ($row = db_fetch_assoc($sql)) { array_push($typing, [$row['acctid'], $row['name']]); } $isTyping = appoencode('`@'); $i = 0; if (count($typing) != 0) { foreach ($typing as $key => $val) { $i++; if ($i == 1) { $isTyping .= appoencode($val[1]); } else { if ($i > 1 && count($typing) > $i) { $isTyping .= appoencode("`@, {$val[1]}"); } else { if ($i == count($typing)) { $isTyping .= appoencode("`@ and {$val[1]}"); } } } if ($i == count($typing)) { $isTyping .= appoencode("`@..."); } } echo "✏ {$isTyping}"; } else { echo "<br />"; } break; case 'api': header('Content-Type: application/json'); /*$sql = db_query( "SELECT c.*, a.name FROM $commentary AS c LEFT JOIN $accounts AS a ON a.acctid = c.author WHERE (section = '{$session['current_commentary_area']}' OR section = 'global-ooc') AND deleted = 0 ORDER BY commentid+0 DESC GROUP BY section LIMIT 0, 25" );*/ $sql = db_query("SELECT comm.*, acc.name FROM\n (\n (SELECT * FROM\n (SELECT * FROM commentary\n WHERE section = 'globalooc'\n AND deleted = '0'\n ORDER BY commentid+0 DESC\n LIMIT 0, 10)\n AS c\n ORDER BY c.commentid+0 ASC\n LIMIT 0, 10)\n UNION (\n SELECT * FROM\n (SELECT * FROM commentary\n WHERE section = 'superuser'\n AND deleted = '0'\n ORDER BY commentid+0 DESC\n LIMIT 0, 25)\n AS c\n ORDER BY c.commentid+0 ASC\n LIMIT 0, 25\n )\n ) AS comm\n LEFT JOIN accounts AS acc\n ON acc.acctid = comm.author"); $json = []; while ($row = db_fetch_assoc($sql)) { $row['name'] = appoencode($row['name']); $row['comment'] = appoencode($row['comment']); array_push($json, $row); } echo json_encode($json, JSON_PRETTY_PRINT); break; } }
output("<a href=\"home.php\">Log in again</a>", true); } else { $section = $_REQUEST['section']; $talkline = $_REQUEST['talkline']; //echo("talkline $talkline "); //$talkline = mb_convert_encoding($talkline,getsetting("charset", "ISO-8859-1"),'auto'); //echo("talkline $talkline "); $schema = $_REQUEST['schema']; $comment = trim($_REQUEST['insertcommentary']); $comment = mb_convert_encoding($comment, getsetting("charset", "ISO-8859-1"), 'auto'); if ($section || $talkline || $comment) { $tcom = color_sanitize($comment); if ($tcom == "" || $tcom == ":" || $tcom == "::" || $tcom == "/me") { $emptypost = 1; } else { injectcommentary($section, $talkline, $comment, $schema); } //echo("injectcommentary($section, $talkline, $comment, $schema)"); //exit; } $output = ''; $lastid = getcommentary($_REQUEST['section'], 25, $_REQUEST['talkline'], $_REQUEST['lastcommentid']); } } else { $output = ''; $lastid = getcommentary($_REQUEST['section'], 25, $_REQUEST['talkline'], $_REQUEST['lastcommentid']); if (array_key_exists("mute", $args) && $args['mute'] && !($session['user']['superuser'] & SU_EDIT_COMMENTS)) { $addboxreplace = 1; output_notl("%s", $args['mutemsg']); } elseif ($counttoday > 13 && !($session['user']['superuser'] & ~SU_DOESNT_GIVE_GROTTO)) { $addboxreplace = 1;
function addcommentary() { global $session, $emptypost, $afk, $dni; $section = httppost('section'); $talkline = httppost('talkline'); $schema = httppost('schema'); $comment = trim(httppost('insertcommentary')); $counter = httppost('counter'); $remove = URLDecode(httpget('removecomment')); $restore = URLDecode(httpget('restorecomment')); //debug(httpallpost()); if (httpget("bulkdelete")) { $everything = httpallpost(); foreach ($everything as $key => $val) { if (substr($key, 0, 14) == "deletecomment_") { $del = str_replace("deletecomment_", "", $key); removecommentary($del, "Mass deletion by " . $session['user']['name'], $session['user']['acctid']); } } } if ($remove > 0) { removecommentary($remove, "Moderated by " . $session['user']['name'], $session['user']['acctid']); } if ($restore > 0) { restorecommentary($restore, "Restored by " . $session['user']['name'], $session['user']['acctid']); } if (!$comment) { return false; } if ($session['user']['chatloc'] == "DNI") { $dni = true; } $colors = array("1" => "colDkBlue", "2" => "colDkGreen", "3" => "colDkCyan", "4" => "colDkRed", "5" => "colDkMagenta", "6" => "colDkYellow", "7" => "colDkWhite", "~" => "colBlack", "!" => "colLtBlue", "@" => "colLtGreen", "#" => "colLtCyan", "\$" => "colLtRed", "%" => "colLtMagenta", "^" => "colLtYellow", "&" => "colLtWhite", ")" => "colLtBlack", "e" => "colDkRust", "E" => "colLtRust", "g" => "colXLtGreen", "G" => "colXLtGreen", "j" => "colMdGrey", "k" => "colaquamarine", "K" => "coldarkseagreen", "l" => "colDkLinkBlue", "L" => "colLtLinkBlue", "m" => "colwheat", "M" => "coltan", "p" => "collightsalmon", "P" => "colsalmon", "q" => "colDkOrange", "Q" => "colLtOrange", "R" => "colRose", "T" => "colDkBrown", "t" => "colLtBrown", "V" => "colBlueViolet", "v" => "coliceviolet", "x" => "colburlywood", "X" => "colbeige", "y" => "colkhaki", "Y" => "coldarkkhaki"); if (substr($comment, 0, 9) == "/chatcol ") { $ucol = substr($comment, 9, 1); if (!isset($colors[$ucol])) { output("`c`b`4Invalid default talk colour`b`nYou entered an invalid colour code, please try again.`0`c`n"); return false; } else { $session['user']['prefs']['ucol'] = $ucol; output_notl("`c`bDefault talk colour changed`b`n`" . $ucol . "This is your new default commentary dialogue colour. When you type in commentary areas, this colour will show up automatically. If you're an Extra-Awesome Site Supporter, you can also change the colour of your character's dialogue during quests, monster fights and other in-game areas using the /talkcol switch, in the same way you just used the /chatcol switch.`0`c`n"); return false; } } else { if (substr($comment, 0, 9) == "/talkcol ") { $ucol = substr($comment, 9, 1); if (!isset($colors[$ucol])) { output("`c`b`4Invalid default talk colour`b`nYou entered an invalid colour code, please try again.`0`c`n"); return false; } else { $session['user']['prefs']['ugcol'] = $ucol; if ($session['user']['donation'] >= 2000) { output_notl("`c`bDefault talk colour changed`b`n`" . $ucol . "This is your new default in-game dialogue colour. This is the colour we'll use to represent your character's dialogue during quests, monster encounters, and other in-game things. If you choose a colour commonly used by monsters or other characters, you might have problems figuring out who's talking - if that's the case, you can reset to the default with \"/talkcol #\". You can also change your default colour for commentary areas by using the /chatcol switch, in the same way you just used /talkcol.`0`c`n"); } else { output("`c`bNot enough Supporter Points`b`nSorry, but due to the extra system load that the /talkcol switch uses, this feature is restricted to players with more than 2,000 Supporter Points.`0`c`n"); } return false; } } } if ($comment == strtoupper($comment)) { //this is an all-uppercase entry. Do not add this comment to the database; instead, check it for built-in stuff like AFK and GREM, then run it through the commentarycommand hook if ($comment == "AFK" || $comment == "BRB") { $session['user']['chatloc'] = "AFK"; $afk = true; output("`0`n`c`bYou are Away From the Keyboard until you load another page.`b`c`n"); return false; } if ($comment == "DNI") { if ($session['user']['chatloc'] == "DNI") { $session['user']['chatloc'] = $section; $dni = false; output("`0`n`c`bYou are no longer in Do Not Interrupt status.`b`c`n"); } else { $session['user']['chatloc'] = "DNI"; $dni = true; output("`0`n`c`bYou are in Do Not Interrupt status. Type DNI again to leave.`b`nDNI status is used for whenever you're doing or saying something that means other players shouldn't try to interact with you. For example, when two or more characters are chatting just outside of the main group of characters, and other characters shouldn't be able to hear them.`c`n"); } return false; } if ($comment == "GREM") { //handle deleting the player's last comment $sql = "SELECT * FROM " . db_prefix("commentary") . " WHERE author='" . $session['user']['acctid'] . "' ORDER BY commentid DESC LIMIT 1"; $result = db_query($sql); while ($row = db_fetch_assoc($result)) { $now = time(); $then = strtotime($row['postdate']); $ago = $now - $then; if ($ago < 120) { removecommentary($row['commentid'], "Typo Gremlin", $session['user']['acctid']); output("`0`n`c`bA nearby Typo Gremlin notices the peculiar tastiness of your previous comment. Within moments, a small horde of them have descended upon your words, and consumed them.`b`c`n"); } else { output("`0`n`c`bThe Typo Gremlins turn up their nose at your latest comment - it's just too old. They have no taste for stale words.`b`c`n"); } } return false; } $hookcommand = array('command' => $comment, 'section' => $section); $returnedhook = modulehook("commentarycommand", $hookcommand); if (!$returnedhook['skipcommand']) { //if for some reason you're going to involve a command that can be a mix of upper and lower case, set $args['skipcommand'] and $args['ignore'] to true and handle it in postcomment instead. if (!$returnedhook['processed']) { output("`c`b`JCommand Not Recognized`b`0`nWhen you type in ALL CAPS, the game doesn't think you're talking to other players; it thinks you're trying to perform an action within the game. For example, typing `#GREM`0 will remove the last comment you posted, as long as you posted it less than two minutes ago. Typing `#AFK`0 or `#BRB`0 will turn your online status bar grey, so that people know you're `#A`0way `#F`0rom the `#K`0eyboard (or, if you prefer, that you'll `#B`0e `#R`0ight `#B`0ack). Typing `#DNI`0 will let other players know that you're busy talking to one particular player - maybe somewhere off-camera - and that you don't want to be interrupted right now.`nSome areas have special hidden commands or other easter eggs that you can hunt for. This time around, you didn't trigger anything special.`c`0`n"); } return false; } } if ($section || $talkline || $comment) { $tcom = color_sanitize($comment); if ($tcom == "" || $tcom == ":" || $tcom == "::" || $tcom == "/me") { $emptypost = 1; } else { $comment = comment_sanitize($comment); injectcommentary($section, $talkline, $comment); } } }