Changeset 3288

Show
Ignore:
Timestamp:
09/02/05 00:05:43 (3 years ago)
Author:
jalenack
Message:

version 1.16 - new feature for allowing registered users only, extensive readme updates, minor code beautification

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wordspew/trunk/readme.txt

    r3044 r3288  
    1 === Jalenack's WordSpew === 
     1=== WordSpew === 
    22 
    33Tags: Shoutbox, AJAX, Jalenack, WordSpew, Chat 
     4Contributors: jalenack 
    45 
    5 Contributors: 
     6Author: Andrew Sutherland 
     7http://blog.jalenack.com 
     8Originally released May 2, 2005 
    69 
    7       Author: Andrew Sutherland 
    8       http://blog.jalenack.com 
    9       Originally released May 2, 2005 
     10This release: September 1, 2005 
     11Version: 1.16 
    1012 
    11       This release: August 16, 2005 
    12       Version: 1.15 
     13Based on an original idea by Alexander Kohlhofer: 
     14XHTML live Chat 
     15http://www.plasticshore.com/projects/chat/ 
    1316 
    14       Based on an original idea by Alexander Kohlhofer: 
    15       XHTML live Chat 
    16       http://www.plasticshore.com/projects/chat/ 
     17Uses Adam Michela's Fade Anything Technique 
     18http://www.axentric.com/posts/default/7 
    1719 
    18       Uses Adam Michela's Fade Anything Technique 
    19       http://www.axentric.com/posts/default/7 
    20  
    21       Released under Creative Commons license: 
    22       http://creativecommons.org/licenses/by-nc-sa/2.0/ 
    23  
    24 Table of Contents: 
    25  
    26       1. Summary of Functionality 
    27       2. Installation 
    28       3. Upgrading 
    29       4. FAQs 
    30       5. Contact Developer 
     20Released under Creative Commons license: 
     21http://creativecommons.org/licenses/by-nc-sa/2.0/ 
    3122 
    3223-------------------------------------------------- 
    3324 
    34 What this plugin does: 
     25== Description == 
    3526 
    36 This plugin will create a shoutbox on your wordpress blog. But it 
    37 isn't any old shoutbox. It uses AJAX, a technology that allows  
    38 information to be transmitted to the server without the user 
    39 refreshing the page. So what makes this special is that your users 
    40 can carry out live chats from your blog without having to refresh the page. 
    41 Kind of like an IM network! 
     27This plugin will create a shoutbox on your wordpress blog. But it isn't any old shoutbox. It uses AJAX, a technology that allows  information to be transmitted to the server without the user refreshing the page. So what makes this special is that your users can carry out live chats from your blog without having to refresh the page. It's kind of like instant messaging! 
    4228 
    43 Features: it distinguishes whether a user is logged in to wordpress, 
    44 and if he/she is, then it users their nickname as their name, so that they 
    45 don't have to type it in every time they refresh the page. Also, if that  
    46 user is an admin, they get a special link "Administrate" This will take them 
    47 to the admin panel for the plugin. This admin panel allows you to set colors, 
    48 change timing, and edit/delete comments. 
     29Features: It distinguishes whether a user is logged in to wordpress, and if he/she is, then it users their nickname as their name, so that they don't have to type it in every time they refresh the page. Also, if that user is an admin, they get a special link "Administrate" This will take them to the admin panel for the plugin. This admin panel allows you to set colors, change timing, and edit/delete comments. 
    4930 
    50 This plugin works in IE6/Windows, Firefox, Safari, Konqueror, and Opera 8.01 
    51 The fade fails in Opera, but the rest is fully functional 
     31This plugin works with AJAX in IE6/Windows, Firefox, Safari, Konqueror, and Opera 8.01. It will still work with any other browser, just sans-AJAX. 
    5232 
    5333== Installation == 
     
    5535WordSpew will only work in WordPress blogs version 1.5 or higher 
    5636    
    57 1. Put the folder labeled "wordspew" in your plugins folder. 
    58    This is located at /wp-content/plugins/. 
     371. Put the folder labeled "wordspew" in your plugins folder. This is located at /wp-content/plugins/. 
    5938 
    60 2. Browse to your plugins manager in the admin section of your blog. 
    61    Activate Jalenack's Wordspew plugin. This will automatically  
    62    create a table in your database that the plugin will use for its content. 
     392. Browse to your plugins manager in the admin section of your blog. Activate Jalenack's Wordspew plugin. This will automatically create a table in your database that the plugin will use for its content. 
    6340    
    64 3. Now you have to choose where you want the shoutbox to show on your blog. 
    65    I suggest putting it in your sidebar. To edit the sidebar, go to  
    66    /wp-content/themes/*yourtheme*/sidebar.php . Then place this snippet: 
     413. Now you have to choose where you want the shoutbox to show on your blog. I suggest putting it in your sidebar. To edit the sidebar, go to /wp-content/themes/*yourtheme*/sidebar.php . Then place this snippet: 
    6742    
    6843   <?php jal_get_shoutbox(); ?> 
    6944    
    70    in the template. This php function will print the shoutbox. Most wordpress 
    71    sidebars use unordered lists (<ul>) to organize their content. You probably 
    72    want to put it in its own list item. So to do this, 
    73    you would insert 
     45in the template. This php function will print the shoutbox. Generally, follow the convention that other sidebar items use. Never put the function within its own <ul> tags. Most wordpress sidebars use unordered lists (<ul>) to organize their content. You probably want to put it in its own list item. So to do this, you would insert 
    7446    
    7547   <li><h2>Live Shoutbox</h2> 
     
    7749   </li> 
    7850    
    79    After the </li> where you want it to go. Just to make sure, try validating your 
    80    html and make sure you got it right. Never put the function within its own <ul> tags. 
    81    If you can't figure it out, you know who to call! 
     51After the </li> where you want it to go. Just to make sure, try validating your html and make sure you got it right. If you can't figure it out, you know who to call! 
    8252 
    8353And now, enjoy! 
    8454 
    85 4. You can edit the look and functionality of your shoutbox by browsing 
    86    to your admin panel and clicking on Manage. Under there, there should 
    87    be a submenu titled "Live Shoutbox". Go there. By default, only  
    88    users with Level 8 or higher status can access it. Site Admins are  
    89    level 10, so you have nothing to worry about. 
     554. You can edit the look and functionality of your shoutbox by browsing to your admin panel and clicking on Manage. Under there, there should be a submenu titled "Live Shoutbox". Go there. By default, only users with Level 8 or higher status can access it. Site Admins are level 10, so you have nothing to worry about. 
    9056 
    9157== Upgrading ==  
    9258 
    93 People who used older versions of Wordspew (less than version 1.0 FINAL) will need to follow 
    94 these instructions to get the plugin up to date. 
     59For those with greater than that, just replacing the old files with the new ones will do. 
     60 
     61People who used older versions of Wordspew (less than version 1.0 FINAL) will need to follow these instructions to get the plugin up to date. 
    9562 
    96631. DEACTIVATE Wordspew in your plugins panel.  
    9764 
    98 2. Upload and replace all three files in the wordspew folder (wordspew.php, 
    99    css.php, and fatAjax.php). If you have customized your css file, you may not want to replace it. 
     652. Upload and replace all three files in the wordspew folder (wordspew.php, css.php, and fatAjax.php). If you have customized your css file, you may not want to replace it. 
    10066 
    101 3. ACTIVATE Wordspew in your plugins panel. This is key, because the plugin relies on activation 
    102    to create tables in the database. 
     673. ACTIVATE Wordspew in your plugins panel. This is key, because the plugin relies on activation to create tables in the database. 
    10368 
    104 4. You're done! You can now administer the plugin through 
    105       Admin Panel > Manage > Live Shoutbox. 
     694. You're done! You can now administer the plugin through Admin Panel > Manage > Live Shoutbox. 
    10670    
    107  
    10871== Frequently Asked Questions == 
    10972 
    110  = How do I change the style of the shoutbox? 
    111        
    112       The Administration panel allows you to edit some colors, but if that's 
    113       not enough, you can edit the css file directly. If you'd like 
    114       to edit it, just edit the css.php file in the plugin folder. If the 
    115       shoutbox doesn't fit in with your theme, and you don't know how to fix 
    116       up the css, I'm totally available to help. Just send me an email. 
     73= How do I change the style of the shoutbox? 
     74   
     75The Administration panel allows you to edit some colors, but if that's not enough, you can edit the css file directly. If you'd like to edit it, just edit the css.php file in the plugin folder. If the shoutbox doesn't fit in with your theme, and you don't know how to fix up the css, I'm totally available to help. Just send me an email. 
    11776 
    118   = How do I change my name from Administrator? 
     77= How do I change my name from Administrator? 
    11978 
    120       By default, Wordpress gives you a default nickname of "Administrator. 
    121       To change this, go to your admin panel, then to Users, then change your 
    122       nickname. 
     79By default, Wordpress gives you a default nickname of "Administrator. To change this, go to your admin panel, then to Users, then change your nickname. 
     80 
     81= I followed all of the instructions, but it doesn't find other users' messages and nothing ever fades in 
     82 
     83This means the plugin isn't loading correctly. First off, you should check to make sure in you have javascript on. Unless you've explicitly turned it off, you should be ok. The next thing to do is check the header.php file of your theme that <?php wp_head(); ?> is somewhere in there. This shouldn't be a problem, because any theme worth its salt would preserve all wordpress hooks. Check your source code on your site and there should be a comment that says <!-- Added By Wordspew Plugin -->. That is good. 
     84 
     85= I want users of lower user levels to be able to access the admin panel. 
    12386   
    124   = I followed all of the instructions, but it doesn't find other users' messages when I submit and nothing ever fades in 
     87By default, you must be level 8 or higher to have access. If you want to change this, go into  wordspew.php and change the very first line of actual code (jal_admin_user_level) and change the '8' to the level you want. 
    12588 
    126       This means the plugin isn't loading correctly. First off, you should check to make sure 
    127       in your header.php file of your theme that <?php wp_head(); ?> is somewhere in there. This shouldn't 
    128       be a problem, because any theme worth its salt would preserve all wordpress hooks. Check your source code 
    129       on your site and there should be a comment that says <!-- Added By Wordspew Plugin -->. That is good. 
     89= How do I change the number of posts that show up at one time? 
     90   
     91Because of logistics, this is not something that is possible to set from the admin panel. There is a variable at the top of wordspew.php called $jal_number_of_comments = 35; ... Change 35 to the number you want to display 
    13092 
    131   = I want users of lower user levels to be able to access the admin panel. 
    132        
    133       By default, you must be level 8 or higher to have access. If you want to change this, go into  
    134       wordspew.php and change the very first line of actual code (jal_admin_user_level) and change the '8' 
    135       to the level you want. 
     93= How do I get rid of the horizontal scrollbars? 
    13694 
    137   = How do I change the number of posts that show up at one time? 
    138        
    139       Because of logistics, this is not something that is possible to set from the admin panel. There is a  
    140       variable at the top of wordspew.php called $jal_number_of_comments = 35; ... Change 35 to the number  
    141       you want to display 
     95It has always somewhat mystified me why they show up in the first place. But they are easy enough to fix. Go into css.php of Wordspew and look for this line: 
    14296 
    143   = How do I get rid of the horizontal scrollbars? 
     97    padding: 6px 8px; /* Horizontal Scrollbar Killer */ 
    14498 
    145       It has always somewhat mystified me why they show up in the first place. But they are easy enough to 
    146       fix. Go into css.php of Wordspew and look for this line: 
     99Change the '8' to a higher number and the horizontal scrollbars should go away. You don't want it too high or the messages won't be very wide, so make it as low as possible while still getting rid of the scrollbars. 
    147100 
    148             padding: 6px 8px; /* Horizontal Scrollbar Killer */ 
    149        
    150       Change the '8' to a higher number and the horizontal scrollbars should go away. You don't want it too 
    151       high or the messages won't be very wide, so make it as low as possible while still getting rid of 
    152       the scrollbars. 
     101= I'm getting spam in WordSpew. What should I do? 
     102 
     103All of the spam I've seen occurring in Wordspew is easy to defeat. There's a generic spambot that goes around searching for <form> elements and inputting messages. This is easy to stop with the Bad Behavior plugin. Bad Behavior is a plugin that can recognize spambots and completely block them before they even reach your site. It is also very effective at stopping comment spam, while turning up very few, if any, false positives. I HIGHLY recommend it for your site. You can grab it at http://www.ioerror.us/software/bad-behavior/  
     104 
     105= How do I stop people from entering very long words in Wordspew? = 
     106 
     107If you're getting people that type things like 'fkaosfkdsoamrlkwamrlwkfnoasdifioasfdnainfownrl' in one long string and then getting unwanted scrollbars, it should be easy to stop. Just find the jal_addData function. It should be around the 375th line of the wordspew.php file. Then look for this code: 
     108 
     109 //   if (!preg_match("`(http|ftp)+(s)?:(//)((\w|\.|\-|_)+)(/)?(\S+)?`i", $jal_user_text, $matches)) 
     110 //         $jal_user_text = preg_replace("/([^\s]{25})/","$1 ",$jal_user_text); 
     111 
     112and uncomment those two lines. Uncommenting simply means taking the two '/' in front of each line. 
     113 
     114= How can I disallow/censor certain words? = 
     115 
     116In the jal_addData function of wordspew.php (should be around line 385), there's a commented out section that says CENSORS. Uncomment the line starting with $jal_user_text . Now whenever someone writes 'fuck' it will be changed to '****' . You can add more lines like that for more censors. Also, you can filter the name field in the same way. Just change $jal_user_text to $jal_user_name in both parts of the line. 
     117 
     118= The messages never appear = 
     119 
     120This probably means you're using an abnormal hosting set-up. This usually occurs when you're mirroring another site and your WP url is different from the one that your actual visitors go. This should be fixed by editing wordspew.php and going to around line 100 looking for the jal_add_to_head() function. Change this: 
     121 
     122      //$jal_wp_url = (dirname($_SERVER['PHP_SELF']) == "/") ? "/" : dirname($_SERVER['PHP_SELF']) . "/"; 
     123      $jal_wp_url = get_bloginfo('wpurl') . "/"; 
     124 
     125to: 
     126 
     127      $jal_wp_url = (dirname($_SERVER['PHP_SELF']) == "/") ? "/" : dirname($_SERVER['PHP_SELF']) . "/"; 
     128      // $jal_wp_url = get_bloginfo('wpurl') . "/"; 
     129 
     130This problem is rooted in the fact that AJAX cannot communicate with servers outside of the domain it's running on. 
     131 
     132= I love this plugin. How can I donate to you? = 
     133 
     134You can paypal it over to jalenack@gmail.com . Thanks! 
    153135 
    154136== Screenshots == 
    155137 
    156  1. /screenshots/admin.jpg 
    157       This is a screenshot of the Wordspew admin panel 
    158  2. /screenshots/in_action.jpg 
    159       I took this little shot of my plugin moving half-way through entering a new comment 
    160  3. /screenshots/sidebar.jpg 
    161       Here's a code sample for putting WordSpew in the sidebar 
     1381. /screenshots/admin.jpg 
     139This is a screenshot of the Wordspew admin panel 
     140 
     1412. /screenshots/in_action.jpg 
     142I took this little shot of my plugin moving half-way through entering a new comment 
     143 
     1443. /screenshots/sidebar.jpg 
     145Here's a code sample for putting WordSpew in the sidebar 
    162146 
    163147== Contact Developer == 
  • wordspew/trunk/wordspew/wordspew.php

    r3044 r3288  
    55Description: A plugin that creates a live shoutbox, using AJAX as a backend. Users can chat freely from your blog without refreshing the page! It uses the Fade Anything Technique for extra glamour 
    66Author: Andrew Sutherland 
    7 Version: 1.15 
     7Version: 1.16 
    88Author URI: http://blog.jalenack.com 
    99*/ 
    1010 
    1111// Version of this plugin. Not very useful for you, but for the dev 
    12 $jal_version = "1.15"; 
     12$jal_version = "1.16"; 
    1313 
    1414// The required user level needed to access the admin page for this plugin 
     
    4747$jalGetChat    = isset($_GET['jalGetChat']) ? $_GET['jalGetChat'] : ""; 
    4848$jalSendChat   = isset($_GET['jalSendChat']) ? $_GET['jalSendChat'] : ""; 
    49  
    5049 
    5150function jal_install_shout () { 
     
    8988            add_option('shoutbox_text_color', "333333"); 
    9089            add_option('shoutbox_name_color', "0066CC"); 
     90            add_option('shoutbox_regisitered_only', '0'); 
    9191      } 
    9292} 
     
    175175            <p>There have been <b><?php 
    176176             $results = $wpdb->get_var("SELECT id FROM ".$table_prefix."liveshoutbox ORDER BY id DESC LIMIT 1"); 
    177              if ($results == 1 || $results == 0) { echo "0 real"; } else { echo $results; } ?></b> messages in this shoutbox 
     177             echo $results; ?></b> messages in this shoutbox 
    178178            <form name="shoutbox_options" action="" method="get" id="shoutbox_options">  
    179179                  <fieldset>  
     
    197197                        Fade Length: <input type="text" maxlength="3" name="fade_length" value="<?php echo get_option('shoutbox_fade_length') / 1000; ?>" size="2" /> Seconds <br /> 
    198198                              <p>The amount of time it takes for the fader to completely blend with the background color. You may use decimals. Default 1.5 seconds</p> 
    199                 Use textarea: <input type="checkbox" name="use_textarea" <?php if(get_option('shoutbox_use_textarea') == 'true') { echo 'checked="checked" '; } ?>/> 
    200                     <p>A textarea is a bigger type of input box. Users will have more room to type their comments, but pressing return won't work for submission.</p> 
    201                 Use URL field: <input type="checkbox" name="use_url" <?php if(get_option('shoutbox_use_url') == 'true') { echo 'checked="checked" '; } ?>/> 
    202                     <p>Check this if you want users to have an option to add their URL when submitting a message.</p> 
    203                   </fieldset><br /> 
     199            Use textarea: <input type="checkbox" name="use_textarea" <?php if(get_option('shoutbox_use_textarea') == 'true') { echo 'checked="checked" '; } ?>/> 
     200               <p>A textarea is a bigger type of input box. Users will have more room to type their comments, but it will take up more space.</p> 
     201            Use URL field: <input type="checkbox" name="use_url" <?php if(get_option('shoutbox_use_url') == 'true') echo 'checked="checked" '; ?>/> 
     202               <p>Check this if you want users to have an option to add their URL when submitting a message.</p> 
     203                        Only allow registered users: <input type="checkbox" name="registered_only" <?php if(get_option('shoutbox_registered_only') == '1') echo 'checked="checked" '; ?>/> 
     204                              <p>This will only let your registered users use the form that allows one to type messages. Users who are NOT logged in will be able to watch the chat and a message saying they must be logged in to comment. <b>Note:</b> 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.</p> 
     205</fieldset><br /> 
    204206                                      
    205207                  <input type="submit" name="jal_admin_options" value="Save" class="button" style="font-size: 140%"  /><br /><br /> 
     
    242244function shoutbox_admin_page() { 
    243245      global $jal_admin_user_level; 
    244       add_management_page('Shoutbox Options', 'Live Shoutbox', $jal_admin_user_level, "wordspew", 'jal_shoutbox_admin'); 
     246      add_management_page('Shoutbox Management', 'Live Shoutbox', $jal_admin_user_level, "wordspew", 'jal_shoutbox_admin'); 
    245247} 
    246248 
     
    461463                              $use_url = (get_option('shoutbox_use_url') == "true") ? TRUE : FALSE; 
    462464                              $use_textarea = (get_option('shoutbox_use_textarea') == "true") ? TRUE : FALSE; 
     465                              $registered_only = (get_option('shoutbox_registered_only') == "1") ? TRUE : FALSE; 
     466                               
     467                              global $user_level, $user_nickname, $user_url, $user_ID, $jal_admin_user_level; 
     468                              get_currentuserinfo(); // Gets logged in user. 
    463469 
    464470                        ?> 
     
    466472 
    467473                        </div> 
     474            <?php if (!$registered_only || ($registered_only && $user_ID)) { ?> 
    468475                        <form id="chatForm" method="post" action="<?php bloginfo('wpurl'); ?>/wp-content/plugins/wordspew/wordspew.php"> 
    469                             <p> 
    470                            <?php 
    471                               global $user_level, $user_nickname, $user_url, $jal_admin_user_level; 
    472                               get_currentuserinfo(); // Gets logged in user. 
    473                                
    474                               ?> 
    475                                                              
    476                               <?php 
     476                            <p><?php 
    477477                               
    478478                              if ($user_level >= $jal_admin_user_level) { // If user is allowed to use the admin page 
    479479                                    echo '<a href="'.get_bloginfo("wpurl").'/wp-admin/edit.php?page=wordspew" id="shoutboxAdmin">'.__('Admin').'</a>'; 
    480480                              }  
    481                               if ( $user_nickname<> "" ) { echo "\n";/* If they are logged in, then print their nickname */ ?> 
     481                              if (!empty($user_nickname)) { /* If they are logged in, then print their nickname */ ?> 
     482                                     
    482483                              <label><?php _e('Name'); ?>: <em><?php echo $user_nickname ?></em></label> 
    483484                               
     
    503504                              </p> 
    504505                        </form> 
     506            <?php } else echo "<p>You must be a registered user to participate in this chat</p>"; ?> 
    505507            </div> 
    506508<?php } 
     
    528530      $use_url = ($_GET['use_url']) ? "true" : ""; 
    529531      $use_textarea = ($_GET['use_textarea']) ? "true" : ""; 
     532      $registered_only = ($_GET['registered_only']) ? "1" : "0"; 
    530533 
    531534      update_option('shoutbox_use_url', $use_url); 
    532535      update_option('shoutbox_use_textarea', $use_textarea); 
     536      update_option('shoutbox_registered_only', $registered_only); 
     537 
    533538} 
    534539 
     
    565570      $wpdb->query("TRUNCATE TABLE ".$table_prefix."liveshoutbox"); 
    566571                   
    567     $welcome_name = "Jalenack"; 
    568     $welcome_text = "Your shoutbox is blank. Add a message!"; 
     572   $welcome_name = "Jalenack"; 
     573   $welcome_text = "Your shoutbox is blank. Add a message!"; 
    569574 
    570575      $wpdb->query("INSERT INTO ".$table_prefix."liveshoutbox (time,name,text) VALUES ('".time()."','".$welcome_name."','".$welcome_text."')");