Changeset 3288
- Timestamp:
- 09/02/05 00:05:43 (3 years ago)
- Files:
-
- wordspew/trunk/readme.txt (modified) (3 diffs)
- wordspew/trunk/wordspew/wordspew.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wordspew/trunk/readme.txt
r3044 r3288 1 === Jalenack'sWordSpew ===1 === WordSpew === 2 2 3 3 Tags: Shoutbox, AJAX, Jalenack, WordSpew, Chat 4 Contributors: jalenack 4 5 5 Contributors: 6 Author: Andrew Sutherland 7 http://blog.jalenack.com 8 Originally released May 2, 2005 6 9 7 Author: Andrew Sutherland 8 http://blog.jalenack.com 9 Originally released May 2, 2005 10 This release: September 1, 2005 11 Version: 1.16 10 12 11 This release: August 16, 2005 12 Version: 1.15 13 Based on an original idea by Alexander Kohlhofer: 14 XHTML live Chat 15 http://www.plasticshore.com/projects/chat/ 13 16 14 Based on an original idea by Alexander Kohlhofer: 15 XHTML live Chat 16 http://www.plasticshore.com/projects/chat/ 17 Uses Adam Michela's Fade Anything Technique 18 http://www.axentric.com/posts/default/7 17 19 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 20 Released under Creative Commons license: 21 http://creativecommons.org/licenses/by-nc-sa/2.0/ 31 22 32 23 -------------------------------------------------- 33 24 34 What this plugin does: 25 == Description == 35 26 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! 27 This 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! 42 28 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. 29 Features: 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. 49 30 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 31 This 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. 52 32 53 33 == Installation == … … 55 35 WordSpew will only work in WordPress blogs version 1.5 or higher 56 36 57 1. Put the folder labeled "wordspew" in your plugins folder. 58 This is located at /wp-content/plugins/. 37 1. Put the folder labeled "wordspew" in your plugins folder. This is located at /wp-content/plugins/. 59 38 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. 39 2. 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. 63 40 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: 41 3. 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: 67 42 68 43 <?php jal_get_shoutbox(); ?> 69 44 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 45 in 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 74 46 75 47 <li><h2>Live Shoutbox</h2> … … 77 49 </li> 78 50 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! 51 After 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! 82 52 83 53 And now, enjoy! 84 54 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. 55 4. 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. 90 56 91 57 == Upgrading == 92 58 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. 59 For those with greater than that, just replacing the old files with the new ones will do. 60 61 People 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. 95 62 96 63 1. DEACTIVATE Wordspew in your plugins panel. 97 64 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. 65 2. 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. 100 66 101 3. ACTIVATE Wordspew in your plugins panel. This is key, because the plugin relies on activation 102 to create tables in the database. 67 3. ACTIVATE Wordspew in your plugins panel. This is key, because the plugin relies on activation to create tables in the database. 103 68 104 4. You're done! You can now administer the plugin through 105 Admin Panel > Manage > Live Shoutbox. 69 4. You're done! You can now administer the plugin through Admin Panel > Manage > Live Shoutbox. 106 70 107 108 71 == Frequently Asked Questions == 109 72 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 75 The 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. 117 76 118 = How do I change my name from Administrator?77 = How do I change my name from Administrator? 119 78 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. 79 By 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 83 This 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. 123 86 124 = I followed all of the instructions, but it doesn't find other users' messages when I submit and nothing ever fades in 87 By 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. 125 88 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 91 Because 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 130 92 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? 136 94 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 95 It 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: 142 96 143 = How do I get rid of the horizontal scrollbars?97 padding: 6px 8px; /* Horizontal Scrollbar Killer */ 144 98 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: 99 Change 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. 147 100 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 103 All 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 107 If 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 112 and 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 116 In 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 120 This 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 125 to: 126 127 $jal_wp_url = (dirname($_SERVER['PHP_SELF']) == "/") ? "/" : dirname($_SERVER['PHP_SELF']) . "/"; 128 // $jal_wp_url = get_bloginfo('wpurl') . "/"; 129 130 This 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 134 You can paypal it over to jalenack@gmail.com . Thanks! 153 135 154 136 == Screenshots == 155 137 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 138 1. /screenshots/admin.jpg 139 This is a screenshot of the Wordspew admin panel 140 141 2. /screenshots/in_action.jpg 142 I took this little shot of my plugin moving half-way through entering a new comment 143 144 3. /screenshots/sidebar.jpg 145 Here's a code sample for putting WordSpew in the sidebar 162 146 163 147 == Contact Developer == wordspew/trunk/wordspew/wordspew.php
r3044 r3288 5 5 Description: 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 6 6 Author: Andrew Sutherland 7 Version: 1.1 57 Version: 1.16 8 8 Author URI: http://blog.jalenack.com 9 9 */ 10 10 11 11 // Version of this plugin. Not very useful for you, but for the dev 12 $jal_version = "1.1 5";12 $jal_version = "1.16"; 13 13 14 14 // The required user level needed to access the admin page for this plugin … … 47 47 $jalGetChat = isset($_GET['jalGetChat']) ? $_GET['jalGetChat'] : ""; 48 48 $jalSendChat = isset($_GET['jalSendChat']) ? $_GET['jalSendChat'] : ""; 49 50 49 51 50 function jal_install_shout () { … … 89 88 add_option('shoutbox_text_color', "333333"); 90 89 add_option('shoutbox_name_color', "0066CC"); 90 add_option('shoutbox_regisitered_only', '0'); 91 91 } 92 92 } … … 175 175 <p>There have been <b><?php 176 176 $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 shoutbox177 echo $results; ?></b> messages in this shoutbox 178 178 <form name="shoutbox_options" action="" method="get" id="shoutbox_options"> 179 179 <fieldset> … … 197 197 Fade Length: <input type="text" maxlength="3" name="fade_length" value="<?php echo get_option('shoutbox_fade_length') / 1000; ?>" size="2" /> Seconds <br /> 198 198 <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 /> 204 206 205 207 <input type="submit" name="jal_admin_options" value="Save" class="button" style="font-size: 140%" /><br /><br /> … … 242 244 function shoutbox_admin_page() { 243 245 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'); 245 247 } 246 248 … … 461 463 $use_url = (get_option('shoutbox_use_url') == "true") ? TRUE : FALSE; 462 464 $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. 463 469 464 470 ?> … … 466 472 467 473 </div> 474 <?php if (!$registered_only || ($registered_only && $user_ID)) { ?> 468 475 <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 477 477 478 478 if ($user_level >= $jal_admin_user_level) { // If user is allowed to use the admin page 479 479 echo '<a href="'.get_bloginfo("wpurl").'/wp-admin/edit.php?page=wordspew" id="shoutboxAdmin">'.__('Admin').'</a>'; 480 480 } 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 482 483 <label><?php _e('Name'); ?>: <em><?php echo $user_nickname ?></em></label> 483 484 … … 503 504 </p> 504 505 </form> 506 <?php } else echo "<p>You must be a registered user to participate in this chat</p>"; ?> 505 507 </div> 506 508 <?php } … … 528 530 $use_url = ($_GET['use_url']) ? "true" : ""; 529 531 $use_textarea = ($_GET['use_textarea']) ? "true" : ""; 532 $registered_only = ($_GET['registered_only']) ? "1" : "0"; 530 533 531 534 update_option('shoutbox_use_url', $use_url); 532 535 update_option('shoutbox_use_textarea', $use_textarea); 536 update_option('shoutbox_registered_only', $registered_only); 537 533 538 } 534 539 … … 565 570 $wpdb->query("TRUNCATE TABLE ".$table_prefix."liveshoutbox"); 566 571 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!"; 569 574 570 575 $wpdb->query("INSERT INTO ".$table_prefix."liveshoutbox (time,name,text) VALUES ('".time()."','".$welcome_name."','".$welcome_text."')");
