= '2.3') ? "wp-admin/includes/upgrade.php" : "wp-admin/upgrade-functions.php"; require_once(ABSPATH . $pathtoFunction); dbDelta($qry); if ($first_install == "yes") { $welcome_name = "Pierre"; $welcome_text = __('Congratulations, you just completed the installation of this shoutbox.',wordspew); @mysql_query("SET CHARACTER SET 'utf8'"); @mysql_query("SET NAMES utf8"); $wpdb->query("INSERT INTO ".$jal_table_prefix."liveshoutbox (time,name,text) VALUES ('".time()."','".$welcome_name."','".$welcome_text."')"); // Default shoutbox config add_option('shoutbox_fade_from', "666666",'','yes'); add_option('shoutbox_fade_to', "FFFFFF",'','yes'); add_option('shoutbox_update_seconds', 4000,'','yes'); add_option('shoutbox_fade_length', 1500,'','yes'); add_option('shoutbox_text_color', "333333",'','yes'); add_option('shoutbox_name_color', "0066CC",'','yes'); add_option('shoutbox_registered_only', '0','','yes'); } else { $wpdb->query("ALTER TABLE ".$jal_table_prefix."liveshoutbox CHARACTER SET utf8"); $wpdb->query("ALTER TABLE ".$jal_table_prefix."liveshoutbox MODIFY `text` TEXT NOT NULL, CHARACTER SET utf8"); $wpdb->query("ALTER TABLE ".$jal_table_prefix."liveshoutbox MODIFY `name` TINYTEXT NOT NULL, CHARACTER SET utf8"); $wpdb->query("ALTER TABLE ".$jal_table_prefix."liveshoutbox_useronline CHARACTER SET utf8"); $wpdb->query("ALTER TABLE ".$jal_table_prefix."liveshoutbox_useronline MODIFY `username` VARCHAR(50) NOT NULL, CHARACTER SET utf8"); } add_option('shoutbox_sound', '0','','yes'); add_option('shoutbox_spam', '0','','yes'); add_option('shoutbox_XHTML', '0','','yes'); add_option('shoutbox_online', '0','','yes'); add_option('shoutbox_Smiley', '0','','yes'); add_option('shoutbox_Show_Spam', '0','','yes'); add_option('shoutbox_nb_comment', '35','','yes'); add_option('shoutbox_Captcha','0','','yes'); add_option('shoutbox_HideUsers','0','','yes'); } if (isset($_GET['activate']) && $_GET['activate'] == 'true') { add_action('init', 'jal_install_shout'); } // function to print the external javascript and css links function jal_add_to_head () { global $jal_version, $jal_table_prefix, $user_ID; $jal_wp_url = get_bloginfo('wpurl') . "/"; echo ' '; } // In the administration page, add some style and script... function jal_add_to_admin_head () { ?>

' . __("No Access for you!",wordspew) .'

'; } else { ?>

%s spams blocked)',wordspew),$nb);?> v.

get_var("SELECT id FROM ".$jal_table_prefix."liveshoutbox ORDER BY id DESC LIMIT 1"); printf(__('There have been %s messages in this shoutbox',wordspew),$results);?>

: #  

: 666666

: #  

: #  

: 333333

: #  

: 0066CC


:

:

:

: />

: />

: />

: />

: />

: />

: />

: />

: />

: />

Note: this is not completely "secure"... If someone REALLY wanted to, they could write a script that interacts directly with the message receiving file. They\'d have to know what they\'re doing and it would be quite pointless.',wordspew);?>




');" value="" />

%s messages)',wordspew),$jal_number_of_comments);?>

Click here to manage your banned words list and IP addresses.',wordspew),get_bloginfo('wpurl')."/wp-admin/options-discussion.php#moderation_keys");?>

Important ! To ban a single IP address just click on "Ban this IP" button. If you want to ban a range of IP, use this syntax (for this example i can say good bye to Vsevolod Stetsinsky) : 195.225.176/179.* where slash means from 176 to 179 and * from 0 to 255.
BTW i ban IP addresses from 195.225.176.0 to 195.225.179.255. You can mix the two options...',wordspew);?>

get_results("SELECT * FROM ".$jal_table_prefix."liveshoutbox ORDER BY id DESC LIMIT ". $jal_number_of_comments); $jal_first_time = "yes"; // Will only add the last message div if it is looping for the first time foreach( $results as $r ) { // Loops the messages into a list if($r->url!="") if (strpos($r->url, $Actual_URL)===false && $XHTML==0) $target=' target="_blank"'; $url = (empty($r->url) && $r->url = "http://") ? ''.$r->name.'' : ''.$r->name.''; if ($jal_first_time == "yes") { printf(__('
Last Message %s ago
',wordspew),jal_time_since($r->time)); echo '
    '; } echo '
  • '.stripslashes($url).' : *
  • '; $jal_first_time = "0"; } ?>
".$jal_lastID." ORDER BY id DESC"; $results = mysql_query($sql, $conn); $loop = ""; while ($row = mysql_fetch_array($results)) { $id = $row[0]; $time = $row[1]; $name = $row[2]; $text = $row[3]; $url = $row[4]; if(verifyName($name)) $user=1; else $user=0; // append the new id's to the beginning of $loop --- is being used to separate the fields in the output $loop = $id."---".stripslashes($name)."---".stripslashes($text)."---".stripslashes($url)."---".$user."---" . $loop; } $who=($_SESSION['Show_Users']==0) ? "" : jal_get_useronline_extended(); echo $who."\n".$loop; // if there's no new data, send one byte. Fixes a bug where safari gives up w/ no data if (empty($loop)) { echo "0"; } } } function jal_special_chars ($s) { $s = htmlspecialchars($s, ENT_COMPAT,'UTF-8'); return str_replace("---","−-−",$s); } function check_ip_address($from, $checkip) { global $spam_msg; $checkip=trim($checkip); if(strpos($checkip,"*") || strpos($checkip,"/")) { $checkip =str_replace("*", "([0-9]{1,3})", $checkip); if(strpos($checkip,"/")) { $ar=explode(".",$checkip); for($i=0; $i<@count($ar); $i++) { $ar2=explode("/",$ar[$i]); if(@count($ar2)==2) { $ip="("; for($j=intval($ar2[0]); $j1) { $spam_msg=$_SESSION['HTTPLimit']; return false; } $count_content_type=substr_count($theText,"content-type"); if($count_content_type>=1) { $spam_msg=$_SESSION['DLSpam']; return false; } $theText.=$TheURL; $ip = $_SERVER['REMOTE_ADDR']; $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME, $conn); @mysql_query("SET CHARACTER SET 'utf8'", $conn); @mysql_query("SET NAMES utf8", $conn); $spam=array(); $SQL="SELECT option_value FROM ".$jal_table_prefix."options WHERE option_name = 'moderation_keys'"; $spam=mysql_query($SQL,$conn); $sql_create_arr = mysql_fetch_array($spam); $spam= $sql_create_arr[0]; $spam=explode("\r\n",strtolower($spam)); if($spam[0]!="") { for($i=0;$i<@count($spam);$i++) { $str=$spam[$i]; if (strlen($str)>8 && intval($str)) { if(!check_ip_address($ip, $str)) { $spam_msg=$_SESSION['IPLogged']; return false; break; } } $pos=strpos($theText,$str); if(is_int($pos)) { $spam_msg=$_SESSION['DLSpam']; return false; break; } } } return true; } ////////////////////////////////////////////////////// // Functions Below are for submitting comments to the database ////////////////////////////////////////////////////// // When user submits and javascript fails if (isset($_POST['shout_no_js'])) { $myURL = isset($_POST['shoutboxU']) ? $_POST['shoutboxU'] : ""; if ($_POST['shoutboxname'] != '' && $_POST['chatbarText'] != '') jal_addData($_POST['shoutboxname'], $_POST['chatbarText'], $myURL); else echo "You must have a name and a comment..."; } //only if a name and a message have been provides the information is added to the db if ($jal_user_name != '' && $jal_user_text != '' && $jalSendChat == "yes") { jal_addData($jal_user_name,$jal_user_text,$jal_user_url); //adds new data to the database echo "0"; } function mySplit ($captures){ // si url ou email, on passe... if(preg_match('#^(?:(?:http|ftp)s?://|[-_a-z0-9]+(?:\.[-_a-z0-9]+)*@[-a-z0-9]+(?:\.[-a-z0-9]+)*\.[a-z]{2,6})#i',$captures[0])) { $return = $captures[0]; } else { $splited = preg_replace("/([^\s]{".split."})/iu","$1 ",$captures[0]); $return = trim($splited); } return $return; } function jal_addData($jal_user_name,$jal_user_text,$jal_user_url) { global $spam_msg, $jal_table_prefix, $jal_user_val, $jal_user_calc, $jal_user_Control, $ip; $SearchText=strtolower(trim($jal_user_text)); $SearchURL=strtolower(trim($jal_user_url)); //replacement of non-breaking spaces... $SearchName=str_replace(" "," ",$jal_user_name); $SearchName=trim($SearchName); $SearchName=strtolower($SearchName); $myBolean=""; //if the BadCalc variable is not set then it's a bot (direct access to wordspew) if(!isset($_SESSION['BadCalc'])) { AddSpam("I DON'T LIKE SPAM !!!"); exit; } if($SearchURL == "http://") $SearchURL=""; if($SearchName==$SearchText || isset($_POST['shoutboxurl'])) { AddSpam($_SESSION['DLSpam']); exit; } $hashtext = $_SESSION['hashtext']; $jal_user_calc=md5($jal_user_calc.$hashtext); if($jal_user_calc!=$jal_user_Control) { AddSpam($_SESSION['BadCalc']); exit; } /* if(!isset($_SESSION['Logged']) && verifyName($SearchName)) { AddSpam($_SESSION['LoggedMsg']); exit; } */ if(CheckSpam($SearchText.' '.$SearchName, $SearchURL)) { setcookie("jalUserName",$jal_user_name,time()+60*60*24*30*3,'/'); //the message is cut of after 500 letters $jal_user_text = trim(substr($jal_user_text,0,500)); // masque pour capturer toute chaîne de plus de $split car. $pattern = '#[^ ]{'.split.',}#u'; // appel à une fonction callback de remplacement (*beaucoup* plus rapide que preg_replace() option e) $jal_user_text = preg_replace_callback($pattern, 'mySplit', $jal_user_text); $jal_user_text=jal_special_chars($jal_user_text); $jal_user_name = substr(trim($jal_user_name), 0,18); $jal_user_name=jal_special_chars($jal_user_name); $jal_user_url = ($jal_user_url == "http://") ? "" : jal_special_chars($jal_user_url); if (substr($jal_user_url,0,3)=="www") $jal_user_url ="http://".$jal_user_url; if (strpos($jal_user_url,"@")!=false) $jal_user_url ="mailto:".$jal_user_url; $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME, $conn); @mysql_query("SET CHARACTER SET 'utf8'", $conn); @mysql_query("SET NAMES utf8", $conn); if($jal_user_url!="") { setcookie("jalUrl",str_replace("mailto:","",$jal_user_url),time()+60*60*24*30*3,'/'); if($_SESSION['useURL']=="") $myBolean="false"; } if($myBolean=="") { if($_SESSION['useCaptcha']=="1") setcookie("jalCaptcha","Ok",time()+60*60*24*30*3,'/'); mysql_query("INSERT INTO ".$jal_table_prefix."liveshoutbox (time,name,text,url,ipaddr) VALUES ('".time()."','".mysql_real_escape_string($jal_user_name)."','".mysql_real_escape_string($jal_user_text)."','".mysql_real_escape_string($jal_user_url)."', '".mysql_real_escape_string($ip)."')", $conn); jal_deleteOld(); //some database maintenance //take them right back where they left off header('location: '.$_SERVER['HTTP_REFERER']); } else { AddSpam($_SESSION['DLSpam']); } } else AddSpam($spam_msg); } function AddSpam($msg) { global $jal_table_prefix, $jalSendChat; $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME, $conn); $SQL= mysql_query("SELECT option_value FROM ".$jal_table_prefix."options WHERE option_name='shoutbox_spam'"); $nb= mysql_result($SQL, 0)+1; mysql_query("UPDATE ".$jal_table_prefix."options SET option_value='".$nb."' WHERE option_name='shoutbox_spam'",$conn); if($jalSendChat=="yes") { $_SESSION['spam_msg']= $msg; header('location: '.$_SERVER['HTTP_REFERER']); } else echo $msg; } //Maintains the database by deleting past comments function jal_deleteOld() { global $jal_table_prefix; $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME, $conn); $SQL=mysql_query("SELECT option_value FROM ".$jal_table_prefix."options WHERE option_name = 'shoutbox_nb_comment'"); $jal_number_of_comments=mysql_result($SQL,0); $results = mysql_query("SELECT * FROM ".$jal_table_prefix."liveshoutbox ORDER BY id DESC LIMIT ".$jal_number_of_comments, $conn); while ($row = mysql_fetch_array($results)) { $id = $row[0]; } if ($id) mysql_query("DELETE FROM ".$jal_table_prefix."liveshoutbox WHERE id < ".$id, $conn); } function sanitize_name($name) { $bad = array(" ", " ", "'", "."); $good= array("", "", "", ""); return str_replace($bad, $good, $name); } function verifyName($name) { $ar=explode(",",$_SESSION['LoggedUsers']); if(in_array(strtolower($name), $ar)) return true; else return false; } // Prints the html structure for the shoutbox function jal_get_shoutbox () { global $wpdb, $jal_table_prefix, $user_level, $user_nickname, $user_url, $user_ID, $jal_admin_user_level, $user_identity; get_currentuserinfo(); // Gets logged in user. $theuser_nickname=$user_nickname; $ActualVersion=round(get_bloginfo('version')); if($ActualVersion>=2) $theuser_nickname=$user_identity; if(get_option('shoutbox_spam')=="") jal_install_shout(); $XHTML=get_option('shoutbox_XHTML'); $Captcha=get_option('shoutbox_Captcha'); $jal_number_of_comments=get_option('shoutbox_nb_comment'); $Actual_URL=get_bloginfo('wpurl'); $_SESSION['Show_Users']=get_option('shoutbox_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']=get_option('shoutbox_hash'); $_SESSION['useURL']=get_option('shoutbox_use_url'); $_SESSION['useCaptcha']=get_option('shoutbox_Captcha'); ?>
hide_errors(); $results = $wpdb->get_results("SELECT * FROM ".$jal_table_prefix."liveshoutbox ORDER BY id DESC LIMIT ".$jal_number_of_comments); $wpdb->show_errors(); // Will only add the last message div if it is looping for the first time $jal_first_time = true; $registered_only = (get_option('shoutbox_registered_only') == "1") ? TRUE : FALSE; // Loops the messages into a list foreach( $results as $r ) { $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", "«$theLink»", $r->text); $r->text = preg_replace("`([-_a-z0-9]+(\.[-_a-z0-9]+)*@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{2,6})`i","«$theMail»", $r->text); if ($jal_first_time == true) { $rand1=mt_rand(0,10); $rand2=mt_rand(0,10); $total=intval($rand1+$rand2); if (get_option('shoutbox_sound') == "1") { $img_sound=($_COOKIE['jalSound']==1 || $_COOKIE['jalSound']=="") ? "sound_1.gif" : "sound_0.gif"; echo ' '; } if(get_option('shoutbox_Show_Spam')) { $nb = get_option('shoutbox_spam'); printf(__('
%s spams blocked
',wordspew),$nb); } printf(__('
Last Message %s ago
',wordspew),jal_time_since($r->time)); echo '
'.jal_get_useronline_extended().'
'; echo '
    '; } if ($jal_first_time == true) $lastID = $r->id; $target=""; if($r->url!="") if (strpos($r->url, $Actual_URL)===false && $XHTML==0) $target=' target="_blank"'; $url = (empty($r->url) && $r->url = "http://") ? $r->name : ''.$r->name.''; if($jal_first_time == true && !isset($_COOKIE['jalCaptcha']) && !$user_ID && !$registered_only && $_SESSION['useCaptcha'] == '1') echo '
  • '.__("Info",wordspew).' : '.__("Please, resolve the addition below before post any new comment...",wordspew).'
  • '; if(verifyName($r->name)) { $class="jal_user "; } echo '
  • '.stripslashes($url).' : '.convert_smilies(" ".stripslashes($r->text)).'
  • '; $jal_first_time = false; $class=""; } $use_url = (get_option('shoutbox_use_url') == "true") ? TRUE : FALSE; $use_textarea = (get_option('shoutbox_use_textarea') == "true") ? TRUE : FALSE; if (!defined("DB_CHARSET")) { @mysql_query("SET CHARACTER SET 'latin1'"); @mysql_query("SET NAMES latin1"); } ?>
= $jal_admin_user_level || $current==1) { // If user is allowed to use the admin page echo ''. __("Admin",wordspew).''; } if (!empty($theuser_nickname)) { /* If they are logged in, then print their nickname */ $_SESSION['Logged']="ok"; ?>
'; } else { ?> />

'); } /* Widget */ if (function_exists("add_action")) { include_once ('widgetized.php'); add_action("plugins_loaded","jal_on_plugins_loaded"); } /* End Widget */ function jal_admin_options() { global $wpdb, $jal_table_prefix, $user_level, $jal_admin_user_level; // Security get_currentuserinfo(); $current=current_user_can('level_'.$jal_admin_user_level); if ($user_level < $jal_admin_user_level && $current!=1) die(__("Cheatin' uh ?")); // Convert from milliseconds $fade_length = $_GET['fade_length'] * 1000; $update_seconds = $_GET['update_seconds'] * 1000; // Update choices from admin panel update_option('shoutbox_fade_from', $_GET['fade_from']); update_option('shoutbox_fade_to', $_GET['fade_to']); update_option('shoutbox_update_seconds', $update_seconds); update_option('shoutbox_fade_length', $fade_length); update_option('shoutbox_text_color', $_GET['text_color']); update_option('shoutbox_name_color', $_GET['name_color']); $use_url = ($_GET['use_url']) ? "true" : ""; $use_textarea = ($_GET['use_textarea']) ? "true" : ""; $registered_only = ($_GET['registered_only']) ? "1" : "0"; $use_sound = ($_GET['use_sound']) ? "1" : "0"; $XHTML=($_GET['XHTML']) ? "1" : "0"; $Online=($_GET['Show_Users']) ? "1" : "0"; $Smiley=($_GET['Show_Smiley']) ? "1" : "0"; $Show_Spam=($_GET['Show_Spam']) ? "1" : "0"; $Captcha=($_GET['Captcha']) ? "1" : "0"; $hash=($_GET['hash']!="") ? $_GET['hash'] : __("Your secret sentence",wordspew)."_".mt_rand(0,5000); $HideUsers=($_GET['Hide_Users']) ? "1" : "0"; if(!is_numeric($_GET['nb_comment'])) $nb_comment=35; else $nb_comment=intval($_GET['nb_comment']); update_option('shoutbox_use_url', $use_url); update_option('shoutbox_use_textarea', $use_textarea); update_option('shoutbox_registered_only', $registered_only); update_option('shoutbox_sound', $use_sound); update_option('shoutbox_XHTML', $XHTML); update_option('shoutbox_online', $Online); update_option('shoutbox_Smiley', $Smiley); update_option('shoutbox_Show_Spam', $Show_Spam); update_option('shoutbox_nb_comment', $nb_comment); update_option('shoutbox_Captcha', $Captcha); update_option('shoutbox_hash', $hash); update_option('shoutbox_HideUsers', $HideUsers); } function jal_shout_edit() { global $wpdb, $jal_table_prefix, $user_level, $jal_admin_user_level; // Security get_currentuserinfo(); $current=current_user_can('level_'.$jal_admin_user_level); if ($user_level < $jal_admin_user_level && $current!=1) die(__("Cheatin' uh ?")); @mysql_query("SET CHARACTER SET 'utf8'"); @mysql_query("SET NAMES utf8"); $wpdb->query("UPDATE ".$jal_table_prefix."liveshoutbox SET text = '".$wpdb->escape($_GET['jal_text'])."',ipaddr='".trim($_GET['ip'])."' WHERE id = ".$wpdb->escape($_GET['jal_comment_id'])); } function jal_shout_delete() { global $wpdb, $jal_table_prefix, $user_level, $jal_admin_user_level; // Security get_currentuserinfo(); $current=current_user_can('level_'.$jal_admin_user_level); if ($user_level < $jal_admin_user_level && $current!=1) die(__("Cheatin' uh ?")); $results = count($wpdb->get_results("SELECT * FROM ".$jal_table_prefix."liveshoutbox")); if(1==$results) jal_shout_truncate(); else { if($_GET['jal_comment_id']) { $wpdb->query("DELETE FROM ".$jal_table_prefix."liveshoutbox WHERE id = ".$wpdb->escape($_GET['jal_comment_id'])); } } } function jal_shout_truncate() { global $wpdb, $jal_table_prefix, $user_level, $jal_admin_user_level; // Security get_currentuserinfo(); $current=current_user_can('level_'.$jal_admin_user_level); if ($user_level < $jal_admin_user_level && $current!=1) die(__("Cheatin' uh ?")); $wpdb->query("TRUNCATE TABLE ".$jal_table_prefix."liveshoutbox"); $welcome_name = "Pierre"; $welcome_text = __('Your shoutbox is blank. Add a message!',wordspew); $wpdb->query("INSERT INTO ".$jal_table_prefix."liveshoutbox (time,name,text) VALUES ('".time()."','".$welcome_name."','".$welcome_text."')"); } function jal_shout_spam() { global $user_level, $jal_admin_user_level, $ip; $ip=trim($_GET['ip']); $pos=0; get_currentuserinfo(); $current=current_user_can('level_'.$jal_admin_user_level); if ($user_level < $jal_admin_user_level && $current!=1) die(__("Cheatin' uh ?")); $spam=get_option('moderation_keys'); $ar=explode("\r\n",$spam); if(!in_array($ip, $ar)) update_option('moderation_keys', $ip."\r\n".$spam); jal_shout_delete(); } // If user has updated the admin panel if (isset($_GET['jal_admin_options'])) add_action('init', 'jal_admin_options'); // If someone has deleted an entry through the admin panel if (isset($_GET['jal_delete'])) add_action('init', 'jal_shout_delete'); // If someone has edited an entry through the admin panel if (isset($_GET['jal_edit'])) add_action('init', 'jal_shout_edit'); // If someone has clicked the "delete all" button if (isset($_GET['jal_truncate'])) add_action('init', 'jal_shout_truncate'); // If it's a spam if (isset($_GET['jal_ban'])) add_action('init', 'jal_shout_spam'); // Print to the