function jal_get_shoutboxarchive($cat = "") { global $wpdb, $user_ID, $user_level, $user_identity, $limit, $offset, $shout_cat, $Actual_URL, $shout_opt; $jal_admin_user_level = get_option('shoutbox_admin_level') != "" ? get_option('shoutbox_admin_level') : 10; $cat = $cat != "" ? $cat : $shout_cat; $XHTML = $shout_opt['xhtml']; $show_to_level = $shout_opt['level_for_shoutbox']; $alt = "alternate"; $link = ""; $link_cat = $cat != "" ? "&shout_cat=" . urlencode(stripslashes($cat)) : ""; $link_cat2 = str_replace("&shout_cat=", "?shout_cat=", $link_cat); $show = $shout_opt['show_avatar']; $size = $shout_opt['avatar_size']; $level_for_archive = $shout_opt['level_for_archive']; $level_for_theme = $shout_opt['level_for_theme']; $user_level = isset($user_level) ? $user_level : -1; $Show_IP = true; $current = $level_for_archive == -1 || $show_to_level == -1 ? 1 : current_user_can('level_' . $show_to_level); $curarc = $level_for_archive == -1 ? 1 : current_user_can('level_' . $level_for_archive); $curthe = $level_for_theme == -1 ? 1 : current_user_can('level_' . $level_for_theme); $curadm = current_user_can('level_' . $jal_admin_user_level); //if user can see archive, can see theme or theme is not set. if ($current == 1 && $curarc == 1 && ($cat == "" || $curthe == 1)) { @mysql_query("SET CHARACTER SET 'utf8'"); @mysql_query("SET NAMES utf8"); if (!isset($_SESSION['LoggedUsers'])) { $LoggedUsers = $wpdb->get_col("SELECT display_name FROM " . $wpdb->users); $_SESSION['LoggedUsers'] = $LoggedUsers; } $wpdb->hide_errors(); $SQL = "SELECT SQL_CALC_FOUND_ROWS id, time, name, text, url, ipaddr, email FROM " . $_SESSION['tb_prefix'] . "liveshoutboxarchive "; $SQL .= "WHERE cat='" . mysql_real_escape_string($cat) . "' ORDER BY id DESC LIMIT " . $offset . "," . $limit; $results = $wpdb->get_results($SQL); $wpdb->show_errors(); $result = mysql_query('SELECT FOUND_ROWS() AS total'); $data = mysql_fetch_assoc($result); $total = $data['total']; ?> <table width="100%" border="0" id="wordspew"> <?php $colspan = $user_level >= $jal_admin_user_level || $curadm == 1 ? 5 : 3; if ($user_level >= $jal_admin_user_level && !current_user_can('manage_options')) { $colspan = 4; $Show_IP = false; } echo '<tr> <th colspan="' . $colspan . '"> <div class="goback"><a href="' . $Actual_URL . '"><img src="' . $Actual_URL . '/wp-content/plugins/pierres-wordspew/img/home.png" border="0" width="32" height="32" alt="" title="' . __("Click here to go to the Homepage", wordspew) . '"/></a></div> <h3><a href="wordspew_archive.php' . $link_cat2 . '" title="' . __("Click here to refresh the page", wordspew) . '">' . __("Shoutbox archive", wordspew); if ($cat != "") { echo ' ' . __("Theme:", wordspew) . ' ' . stripslashes($cat); } echo '</a></h3> '; if ($shout_opt['show_spam'] == '1') { $nb = get_option('shoutbox_spam'); printf(__('<div id="Show_Spam">%s spams blocked</div>', wordspew), $nb); } echo '</th> </tr> <tr class="header"> <th class="date">' . __("Date/Time", wordspew) . '</th> <th class="name">' . __("Name", wordspew) . '</th> <th class="msg">' . __("Message", wordspew) . '</th>'; if ($user_level >= $jal_admin_user_level || $curadm == 1) { $_SESSION['isAdmin' . $_SESSION['tb_prefix']] = true; $link = '<a href="' . $Actual_URL . '/wp-admin/edit.php?page=wordspew_admin' . $link_cat . '" id="shoutboxAdmin">' . __("Admin", wordspew) . '</a>'; if ($Show_IP) { echo '<th class="IP">' . __("IP", wordspew) . '</th>'; } echo '<td></td>'; } else { unset($_SESSION['isAdmin' . $_SESSION['tb_prefix']]); } echo ' </tr> '; if ($results) { setlocale(LC_ALL, WPLANG . ".UTF8"); foreach ($results as $r) { $alt = $alt == " alternate" ? "" : " alternate"; $target = ""; if (strpos($r->text, $Actual_URL) === false && $XHTML == 0) { $target = ' target="_blank"'; } $theLink = __("link", wordspew); $theMail = __("email", wordspew); $r->text = preg_replace("`(http|ftp)+(s)?:(//)((\\w|\\.|\\-|_)+)(/)?(\\S+)?`i", "<a rel=\"nofollow\" href=\"\\0\"{$target}>«{$theLink}»</a>", $r->text); $r->text = preg_replace("`([-_a-z0-9]+(\\.[-_a-z0-9]+)*@[-a-z0-9]+(\\.[-a-z0-9]+)*\\.[a-z]{2,6})`i", "<a href=\"mailto:\\1\">«{$theMail}»</a>", $r->text); $target = ""; if ($r->url != "") { if (strpos($r->url, $Actual_URL) === false && $XHTML == 0) { $target = ' target="_blank"'; } } if (!empty($r->url)) { if (strpos($r->url, "@") === false) { $url = '<a rel="nofollow" href="' . $r->url . '"' . $target . '>' . $r->name . '</a>'; } else { if ($user_level >= $jal_admin_user_level || $curadm == 1) { $url = $r->name . ' <a href="' . $r->url . '"><img width="16" height="16" src="' . $Actual_URL . '/wp-content/plugins/pierres-wordspew/img/mail.png" alt="' . __("email", wordspew) . '"/></a>'; } else { $url = $r->name; } } } else { $url = $r->name; } if (verifyName($r->name)) { $class = "jal_user "; } $TheName = $r->name; $TheMail = $r->email; $TheText = $r->text; if (substr($TheText, 0, 2) == "@@") { $PosSpace = strpos($TheText, " "); $To = substr($TheText, 2, $PosSpace - 2); $Deb = strlen($To) + 2; $TheText = '<span class="InfoUser">' . __("Private message for", wordspew) . ' ' . $To . ':</span>' . substr($TheText, $Deb) . ''; $the_nickname = isset($user_identity) ? $user_identity : str_replace("\\'", "'", $_COOKIE['jalUserName']); if (strtolower($the_nickname) == strtolower($To) || strtolower($the_nickname) == strtolower($TheName) || ($user_level >= $jal_admin_user_level || $curadm == 1)) { $verif = true; } else { $TheName = ""; $url = __("Private", wordspew); $TheMail = ""; $TheText = '<span class="InfoUser">' . __("Private message", wordspew) . '.</span>'; $class = ""; } } $delete = ""; if ($user_level >= $jal_admin_user_level || $curadm == 1) { $delete .= ' <span onclick="deleteComment(' . $r->id . ', ' . $offset . ', ' . $limit . ')" class="delShout" title="' . __("Delete", wordspew) . '">x</span>'; } $avatar = ""; if ($show == '1' && $TheMail != "") { $avatar = shout_get_avatar($TheMail, $size, "left"); } echo '<tr class="bg' . $alt . '" id="comment-new' . $r->id . '"><td class="date">' . strftime("%A %d %B %Y", $r->time) . ' <br/>' . strftime("%H:%M", $r->time) . '</td> <td class="name">' . $avatar . '<span class="' . $class . sanitize_name($TheName) . '">' . stripslashes($url) . '</span></td> <td class="msg">' . convert_smilies(stripslashes($TheText)) . '</td>'; if ($user_level >= $jal_admin_user_level || $curadm == 1) { if ($Show_IP) { echo ' <td class="IP"><a href="http://whois.domaintools.com/' . $r->ipaddr . '" target="_blank" title="Whois">' . $r->ipaddr . '</a></td>'; } echo '<td>' . $delete . '</td>'; } echo ' </tr> '; $class = ""; } } if (!defined("DB_CHARSET")) { @mysql_query("SET CHARACTER SET 'latin1'"); @mysql_query("SET NAMES latin1"); } ?> <tr> <td colspan="<?php echo $colspan; ?> "> <div align="center"><?php echo '<span id="count">' . $total . '</span> ' . __('records', wordspew); ?> </div> <div class="navigation"> <?php if ($offset > 0) { echo '<div style="float:left;"><a href="wordspew_archive.php?offset=' . ($offset - $limit) . $link_cat . '">< ' . __("Newer", wordspew) . '</a></div> '; } if ($offset + $limit < $total) { echo '<div style="float:right;" id="older"><a href="wordspew_archive.php?offset=' . ($offset + $limit) . $link_cat . '">' . __("Older", wordspew) . ' ></a></div>'; } ?> </div> </td> </tr> </table> <?php echo $link; ?> <?php } else { ?> <p> </p> <div align="center"> <?php _e('Sorry, but you don\'t have sufficient rights to see the archives of the shoutbox.', wordspew); ?> <br/> <?php printf(__('You can click <a href="%s">here</a> to go back to the homepage of the site.', wordspew), $Actual_URL); ?> </div> <?php } }
function jal_get_shoutbox($cat = "", $comboTheme = 1) { global $wpdb, $user_level, $user_identity, $user_url, $user_ID, $jal_admin_user_level, $show, $size, $position, $shout_opt, $shout_tb; $HiddenCat = ""; $show_to_level = $shout_opt['level_for_shoutbox']; $level_for_archive = $shout_opt['level_for_archive']; $level_for_archive = $level_for_archive == -1 ? 1 : current_user_can('level_' . $level_for_archive); $level_for_theme = $shout_opt['level_for_theme']; $user_level = isset($user_level) ? $user_level : -1; $current = $show_to_level == -1 ? 1 : current_user_can('level_' . $show_to_level); $curthe = $level_for_theme == -1 ? 1 : current_user_can('level_' . $level_for_theme); $only_registered = $shout_opt['registered_only']; $only_registered = $only_registered == -1 ? 1 : current_user_can('level_' . $only_registered); $curadmin = current_user_can('level_' . $jal_admin_user_level); $use_theme = $shout_opt['use_theme']; $lastID = 0; if ($cat != "") { $HiddenCat = $cat; } if ($current == 1) { if ($cat == "") { if ($curthe == 1 && $use_theme == 1) { $HiddenCat = $cat = str_replace("\\", "", $_COOKIE['jalCombo']); } } $XHTML = $shout_opt['xhtml']; $Captcha = $shout_opt['use_captcha']; $jal_number_of_comments = get_option('shoutbox_nb_comment'); $Actual_URL = get_bloginfo('wpurl'); $_SESSION['Show_Users'] = $shout_opt['show_user_online']; $_SESSION['BadCalc'] = __("You should learn to count before use the shoutbox :)", wordspew); $_SESSION['DLSpam'] = __("I DON'T LIKE SPAM !!!", wordspew); $_SESSION['HTTPLimit'] = __("Sorry, but you can post only one url by message...", wordspew); $_SESSION['IPLogged'] = __("Your IP address have been banned from this blog, if you feel this is in error please contact the webmaster.", wordspew); $_SESSION['hashtext' . $shout_tb] = $shout_opt['hash']; $_SESSION['useURL'] = $shout_opt['use_url']; $_SESSION['useCaptcha'] = $Captcha; ?> <div id="wordspew"> <div id="chatoutput"> <?php @mysql_query("SET CHARACTER SET 'utf8'"); @mysql_query("SET NAMES utf8"); $wpdb->hide_errors(); $SQLCat = html_entity_decode($cat, ENT_COMPAT, 'UTF-8'); $SQLCat = str_replace("'", "\\'", $SQLCat); $SQL = "SELECT * FROM " . mysql_real_escape_string($shout_tb) . "liveshoutbox WHERE cat='" . mysql_real_escape_string($SQLCat) . "'"; $SQL .= " ORDER BY id DESC LIMIT " . $jal_number_of_comments; $results = $wpdb->get_results($SQL); $wpdb->show_errors(); // Will only add the last message div if it is looping for the first time $jal_first_time = true; $registered_only = $only_registered ? false : true; $rand1 = mt_rand(0, 10); $rand2 = mt_rand(0, 10); $total = intval($rand1 + $rand2); if ($shout_opt['use_sound'] == 1) { $img_sound = !isset($_COOKIE['jalSound' . $shout_tb]) || $_COOKIE['jalSound' . $shout_tb] == 1 || $_COOKIE['jalSound' . $shout_tb] == "" ? "sound_1.gif" : "sound_0.gif"; echo '<img src="' . $Actual_URL . '/wp-content/plugins/pierres-wordspew/img/' . $img_sound . '" alt="" onclick="setSound();" id="JalSound" title="' . __("Click this to turn on/off sound", wordspew) . '"/>'; } if ($shout_opt['show_spam'] == 1) { $nb = get_option('shoutbox_spam'); printf(__('<div id="Show_Spam">%s spams blocked</div>', wordspew), $nb); } // Loops the messages into a list foreach ($results as $r) { if ($jal_first_time) { $_SESSION['Chrono'] = $r->time; printf(__('<div id="lastMessage"><span>Last Message</span><br/><div id="responseTime">%s</div> ago</div>', wordspew), jal_time_since($r->time)); echo '<div id="usersOnline">' . jal_get_useronline_extended() . '</div> <ul id="outputList">'; } $target = ""; // Add links if (strpos($r->text, $Actual_URL) === false && $XHTML == 0) { $target = ' target="_blank"'; } $theLink = __("link", wordspew); $theMail = __("email", wordspew); $r->text = preg_replace("`(http|ftp)+(s)?:(//)((\\w|\\.|\\-|_)+)(/)?(\\S+)?`i", "<a rel=\"nofollow\" href=\"\\0\"{$target}>«{$theLink}»</a>", $r->text); $r->text = preg_replace("`([-_a-z0-9]+(\\.[-_a-z0-9]+)*@[-a-z0-9]+(\\.[-a-z0-9]+)*\\.[a-z]{2,6})`i", "<a href=\"mailto:\\1\">«{$theMail}»</a>", $r->text); if ($jal_first_time) { $lastID = $r->id; } $target = ""; if ($r->url != "") { if (strpos($r->url, $Actual_URL) === false && $XHTML == 0) { $target = ' target="_blank"'; } } $url = empty($r->url) ? $r->name : '<a rel="nofollow" href="' . $r->url . '"' . $target . '>' . $r->name . '</a>'; if ($jal_first_time && !isset($_COOKIE['jalCaptcha']) && !$user_ID && !$registered_only && $_SESSION['useCaptcha'] == '1') { echo '<li><span>' . __("Info", wordspew) . ' : </span><b>' . __("Please, resolve the addition below before post any new comment...", wordspew) . '</b></li>'; } $TheText = $r->text; $verif = true; if (substr($TheText, 0, 2) == "@@") { $verif = false; $PosSpace = strpos($TheText, " "); $To = substr($TheText, 2, $PosSpace - 2); $Deb = strlen($To) + 2; $TheText = '<span class="InfoUser">' . __("Private message for", wordspew) . ' ' . $To . ':</span>' . substr($TheText, $Deb); $the_nickname = isset($user_identity) ? $user_identity : str_replace("\\'", "'", $_COOKIE['jalUserName']); if (strtolower($the_nickname) == strtolower($To) || strtolower($the_nickname) == strtolower($r->name) || ($user_level >= $jal_admin_user_level || $curadmin == 1)) { $verif = true; } } if (verifyName($r->name)) { $class = "jal_user "; } $delete = ""; if ($user_level >= $jal_admin_user_level || $curadmin == 1) { $delete .= ' <span onclick="deleteComment(' . $r->id . ')" class="delShout" title="' . __("Delete", wordspew) . '">x</span>'; } $avatar = ""; if ($show == '1' && $r->email != "") { $avatar = shout_get_avatar($r->email, $size, $position); } if ($verif) { echo '<li id="comment-new' . $r->id . '">' . $avatar . '<span title="' . jal_time_since($r->time) . '" class="' . $class . sanitize_name($r->name) . '">' . stripslashes($url) . ' : </span>' . convert_smilies(" " . stripslashes($TheText)) . $delete . '</li> '; } $jal_first_time = false; $class = ""; } if (!$results) { printf(__('<div id="lastMessage"><span>Last Message</span><br/><div id="responseTime">%s</div> ago</div>', wordspew), '0 ' . __('minute', wordspew)); echo ' <div id="usersOnline">' . jal_get_useronline_extended() . '</div> <ul id="outputList"> <li> </li> '; } $use_url = $shout_opt['use_url'] == 1 ? TRUE : FALSE; $use_textarea = $shout_opt['use_textarea'] == 1 ? TRUE : FALSE; $combo = '<input type="hidden" name="shout_cat" id="shout_cat" value="' . $HiddenCat . '"/>'; if ($use_theme == 1 && ($comboTheme == 1 || $user_level >= $jal_admin_user_level)) { $SQL = "SELECT DISTINCT cat FROM " . mysql_real_escape_string($shout_tb) . "liveshoutbox WHERE cat!='' ORDER BY cat"; $theme = $wpdb->get_results($SQL); $wpdb->show_errors(); if ($curthe == 1) { if ($theme || $curadmin == 1) { $combo .= '<div id="shout_theme" style="display:none;"><b>' . __("Theme:", wordspew) . '</b><br/>'; $combo .= '<select name="shout_cat_theme" id="shout_cat_theme" onchange="document.getElementById(\'chatbarText\').focus();" onblur="CleanBox()" onfocus="oldval=this.options[this.selectedIndex].value"> <option value="">' . __("Miscellaneous", wordspew) . '</option>'; foreach ($theme as $theme_name) { $the_theme = stripslashes($theme_name->cat); $selected = $SQLCat == $the_theme || $HiddenCat == $the_theme ? ' selected="true"' : ''; $combo .= '<option value="' . $the_theme . '"' . $selected . '>' . $the_theme . '</option>'; } if ($user_level >= $jal_admin_user_level || $curadmin == 1) { $combo .= '<option value="add_custom" style="font-weight:bold">' . __("New theme", wordspew) . '</option>'; } $combo .= '</select></div>'; } } } if (!defined("DB_CHARSET")) { @mysql_query("SET CHARACTER SET 'latin1'"); @mysql_query("SET NAMES latin1"); } ?> </ul> </div> <div id="chatInput"> <?php $hashtext = $_SESSION['hashtext' . $shout_tb]; if (!$registered_only) { $display_name = isset($_COOKIE['jalUserName']) ? $_COOKIE['jalUserName'] : __("Guest_", wordspew) . rand(0, 5000); $display_name = str_replace("\\'", "'", $display_name); ?> <form id="chatForm" method="post" action="<?php echo $Actual_URL; ?> /wp-content/plugins/pierres-wordspew/wordspew.php"> <input type="hidden" name="shoutboxControl" id="shoutboxControl" value="<?php echo md5($total . $hashtext); ?> "/> <?php if ($user_level >= $jal_admin_user_level || $curadmin == 1) { // If user is allowed to use the admin page $_SESSION['isAdmin' . $shout_tb] = true; echo '<a href="' . $Actual_URL . '/wp-admin/edit.php?page=wordspew_admin" onmouseover="ChangeURL(\'shoutboxAdmin\',\'' . $Actual_URL . '/wp-admin/edit.php?page=wordspew_admin\',\'&shout_cat=\')" id="shoutboxAdmin">' . __("Admin", wordspew) . '</a>'; } else { unset($_SESSION['isAdmin' . $shout_tb]); } echo '<div style="text-align:right;">'; if ($level_for_archive == 1) { echo '<a href="' . $Actual_URL . '/wp-content/plugins/pierres-wordspew/wordspew_archive.php" onmouseover="ChangeURL(\'shoutboxArchive\',\'' . $Actual_URL . '/wp-content/plugins/pierres-wordspew/wordspew_archive.php\',\'?shout_cat=\')" id="shoutboxArchive">' . __("Archive", wordspew) . '</a>| '; } echo '<a style="cursor:pointer;" onclick="ChangeBoxSize(1)" title="' . __("Click here to increase the height of the shoutbox.", wordspew) . '">+</a> <a style="cursor:pointer;" onclick="ChangeBoxSize(0)" title="' . __("Click here to decrease the height of the shoutbox.", wordspew) . '">-</a> </div>'; if (!empty($user_identity)) { /* If they are logged in, then print their nickname */ $_SESSION['Logged'] = "ok"; ?> <input type="hidden" name="shoutboxOp" id="shoutboxOp" value="<?php echo $total; ?> "/> <label><?php _e('Name', wordspew); ?> : <em><?php echo $user_identity; ?> </em></label> <input type="hidden" name="shoutboxname" id="shoutboxname" value="<?php echo $user_identity; ?> "/> <input type="hidden" name="shoutboxU" id="shoutboxU" value="<?php if ($use_url) { echo $user_url; } ?> "/> <?php } else { unset($_SESSION['Logged']); echo "\n"; /* Otherwise allow the user to pick their own name */ ?> <?php if ($Captcha == 1) { ?> <div id="shoutbox_captcha"> <label><?php _e('Captcha', wordspew); ?> :</label> <select name="shoutboxOp" id="shoutboxOp" onchange="MasqueSelect()" onclick="MasqueSelect()"> <option value="-3"><?php echo $rand1 . "+" . $rand2 . "="; ?> </option> <?php for ($i = 0; $i < 21; $i++) { echo '<option value="' . $i . '">' . $i . '</option>'; } echo '</select></div>'; } else { ?> <input type="hidden" name="shoutboxOp" id="shoutboxOp" value="<?php echo $total; ?> "/> <?php } ?> <label for="shoutboxname"><?php _e('Name', wordspew); ?> :</label> <input type="text" name="shoutboxname" id="shoutboxname" value="<?php echo $display_name; ?> " onfocus="Old_Sname=this.value;this.value='';"/> <label for="shoutboxU"<?php if (!$use_url) { echo ' style="display: none"'; } ?> ><?php _e('URL/Email', wordspew); ?> :</label> <input type="text" name="shoutboxU" id="shoutboxU" value="<?php if ($use_url) { echo $_COOKIE['jalUrl']; } ?> "<?php if (!$use_url) { echo ' style="display: none"'; } ?> /> <?php } echo "\n"; ?> <label for="chatbarText"><?php _e('Message', wordspew); ?> :</label> <?php if ($use_textarea) { ?> <textarea rows="4" cols="16" name="chatbarText" id="chatbarText" onkeypress="return pressedEnter(this,event);"></textarea> <?php } else { ?> <input type="text" name="chatbarText" id="chatbarText" onkeypress="return pressedEnter(this,event);"/> <?php } ?> <input type="hidden" id="jal_lastID" value="<?php echo $lastID + 1; ?> " name="jal_lastID"/> <?php echo $combo; ?> <input type="hidden" name="shout_no_js" value="true"/> <div id="SmileyList"></div> <input type="submit" id="submitchat" name="submit" value="<?php _e('Send', wordspew); ?> "/> </form> <?php } else { if ($level_for_archive == 1) { echo '<div style="text-align:right;"> <a href="' . $Actual_URL . '/wp-content/plugins/pierres-wordspew/wordspew_archive.php?shout_cat=' . $cat . '">' . __("Archive", wordspew) . '</a> </div>'; } ?> <form id="chatForm" action=""> <p align="center"><?php _e('You don\'t have sufficient rights to participate to this chat', wordspew); ?> </p> <input type="hidden" name="shoutboxOp" id="shoutboxOp" value="<?php echo $total; ?> "/> <input type="hidden" id="shoutboxname" value="<?php echo __("Guest_", wordspew) . rand(0, 5000); ?> "/> <input type="hidden" id="shoutboxU"/> <input type="hidden" id="chatbarText"/> <input type="hidden" id="shout_cat" value="<?php echo $HiddenCat; ?> "/> <input type="hidden" id="jal_lastID" value="<?php echo $lastID + 1; ?> "/> <input type="submit" id="submitchat" name="submit" style="display:none;"/> </form> <?php } ?> </div> </div> <?php if ($shout_opt['use_sound'] == 1) { //Thanks to Eric HEUNTHEP -> http://portfolio.neolao.com/ for its cool free mp3 player -> http://flash-mp3-player.net/en/players/js/preview/ echo '<object id="TheBox" type="application/x-shockwave-flash" data="' . $Actual_URL . '/wp-content/plugins/pierres-wordspew/player.swf" width="1" height="1"><param name="movie" value="' . $Actual_URL . '/wp-content/plugins/pierres-wordspew/player.swf"/><param name="AllowScriptAccess" value="always" /><param name="FlashVars" value="listener=myBox"/></object> '; } } }