toDB($_POST['nick']))); $cmessage = $_POST['cmessage']; $cmessage = preg_replace("#\[.*?\](.*?)\[/.*?\]#s", "\\1", $cmessage); $fp = new floodprotect; if ($fp->flood('chatbox', 'cb_datestamp')) { if ((strlen(trim($cmessage)) < 1000) && trim($cmessage) !== '') { $cmessage = $tp->toDB($cmessage); if ($sql->select('chatbox', '*', "cb_message='{$cmessage}' AND cb_datestamp+84600>" . time())) { $emessage = CHATBOX_L17; } else { $datestamp = time(); $ip = e107::getIPHandler()->getIP(false); if (USER) { $nick = USERID . "." . USERNAME; $postTime = time(); $sql->update('user', "user_chats = user_chats + 1, user_lastpost = {$postTime} WHERE user_id = " . USERID); } else if ( ! $nick) { $nick = '0.Anonymous'; } else { if ($sql->select('user', '*', "user_name='$nick' ")) { $emessage = CHATBOX_L1; } else { $nick = "0." . $nick; } } if ( ! $emessage) { $insertId = $sql->insert('chatbox', "0, '{$nick}', '{$cmessage}', '{$datestamp}', 0, '{$ip}' "); if ($insertId) { $edata_cb = [ 'id' => $insertId, 'nick' => $nick, 'cmessage' => $cmessage, 'datestamp' => $datestamp, 'ip' => $ip, ]; $e_event->trigger("cboxpost", $edata_cb); // deprecated e107::getEvent()->trigger('user_chatbox_post_created', $edata_cb); $e107cache->clear('nq_chatbox'); } } } } else { $emessage = CHATBOX_L15; } } else { $emessage = $tp->lanVars(CHATBOX_L19, FLOODPROTECT ?: 'n/a'); } } } if ( ! USER && ! $pref['anon_post']) { if ($pref['user_reg']) { $text1 = str_replace(['[', ']'], ["", ""], CHATBOX_L3); if ($pref['user_reg'] === 1) { $text1 .= str_replace(['[', ']'], ["", ""], CHATBOX_L3b); } $texta = "
" . $text1 . "


"; } } else { $cb_width = (defined('CBWIDTH') ? CBWIDTH : ''); if ($pref['cb_layer'] === 2) { $texta = "\n
"; } else { $texta = (e_QUERY ? "\n" : "\n"); } $texta .= "
"; if (($pref['anon_post'] == "1" && USER === false)) { $texta .= "\n
"; } if ($pref['cb_layer'] === 2) { $oc = "onclick=\"javascript:sendInfo('" . SITEURLBASE . e_PLUGIN_ABS . "chatbox_menu/chatbox_menu.php', 'chatbox_posts', this.form);\""; } else { $oc = ''; } $texta .= "
"; // $texta .= ""; // How often do we see these lately? ;-) if ($pref['cb_emote'] && $pref['smiley_activate']) { $texta .= " \n"; } $texta .= "
\n
\n"; } if ($emessage !== '') { $texta .= "
" . $emessage . "
"; } if ( ! $text = $e107cache->retrieve("nq_chatbox")) { global $pref, $tp; $pref['chatbox_posts'] = ($pref['chatbox_posts'] ? $pref['chatbox_posts'] : 10); $chatbox_posts = $pref['chatbox_posts']; if ( ! isset($pref['cb_mod'])) { $pref['cb_mod'] = e_UC_ADMIN; } if ( ! defined('CB_MOD')) { define("CB_MOD", check_class($pref['cb_mod'])); } $qry = "SELECT c.*, u.user_name, u.user_image FROM #chatbox AS c LEFT JOIN #user AS u ON SUBSTRING_INDEX(c.cb_nick, '.', 1) = u.user_id ORDER BY c.cb_datestamp DESC LIMIT 0, " . (int)$chatbox_posts; global $CHATBOXSTYLE; if($CHATBOXSTYLE) // legacy chatbox style { $legacyIconSrc = e_IMAGE_ABS . 'admin_images/chatbox_16.png'; $currentIconSrc = e_PLUGIN . 'chatbox_menu/images/chatbox_16.png'; $legacySrch = array($legacyIconSrc, '{USERNAME}', '{MESSAGE}', '{TIMEDATE}'); $legacyRepl = array($currentIconSrc, '{CB_USERNAME}','{CB_MESSAGE}','{CB_TIMEDATE}'); $CHATBOX_TEMPLATE['start'] = ''; $CHATBOX_TEMPLATE['item'] = str_replace($legacySrch, $legacyRepl, $CHATBOXSTYLE); $CHATBOX_TEMPLATE['end'] = ''; } else // default chatbox style { $CHATBOX_TEMPLATE = e107::getTemplate('chatbox_menu', null, 'menu'); } // FIX - don't call getScBatch() if don't need to globally register the methods // $sc = e107::getScBatch('chatbox'); // the good way in this case - it works with any object having sc_*, models too //$sc = new chatbox_shortcodes(); $sc = e107::getScBatch('chatbox_menu', true); if ($sql->gen($qry)) { $cbpost = $sql->rows(); $text .= "
\n"; $text .= $tp->parseTemplate($CHATBOX_TEMPLATE['start'], false, $sc); foreach ($cbpost as $cb) { $sc->setVars($cb); $text .= $tp->parseTemplate($CHATBOX_TEMPLATE['item'], false, $sc); } $text .= $tp->parseTemplate($CHATBOX_TEMPLATE['end'], false, $sc); $text .= "
"; } else { $text .= "" . CHATBOX_L11 . ""; } $total_chats = $sql->count("chatbox"); if ($total_chats > $chatbox_posts || CB_MOD) { $text .= "
" . (CB_MOD ? CHATBOX_L13 : CHATBOX_L12) . " (" . $total_chats . ")
"; } $e107cache->set("nq_chatbox", $text); } $caption = (file_exists(THEME . "images/chatbox_menu.png") ? " " . LAN_PLUGIN_CHATBOX_MENU_NAME : LAN_PLUGIN_CHATBOX_MENU_NAME); if ($pref['cb_layer'] === 1) { $text = $texta . "
" . $text . "
"; $ns->tablerender($caption, $text, 'chatbox'); } elseif ($pref['cb_layer'] === 2 && e_AJAX_REQUEST) { $text = $texta . $text; $text = str_replace(e_IMAGE, e_IMAGE_ABS, $text); echo $text; } else { $text = $texta . $text; if ($pref['cb_layer'] === 2) { $text = "
" . $text . "
"; } $ns->tablerender($caption, $text, 'chatbox'); }