(fa ancora parte dello script precedente)
codice:oSpan.appendChild(oURL); oSpan.appendChild(document.createTextNode(' : ')); oLi.appendChild(oSpan); oLi.innerHTML += jal_apply_filters(liText); insertO.insertBefore(oLi, insertO.firstChild); Fat.fade_element("comment-new"+liId, 30, <?php echo get_option('shoutbox_fade_length'); ?>, "#<?php echo get_option('shoutbox_fade_from'); ?>", "#<?php echo get_option('shoutbox_fade_to'); ?>"); } //stores a new comment on the server function sendComment() { currentChatText = document.forms['chatForm'].elements['chatbarText'].value; if (httpSendChat.readyState == 4 || httpSendChat.readyState == 0) { if (currentChatText == '') return; currentName = document.getElementById('shoutboxname').value; currentUrl = document.getElementById('shoutboxurl').value; param = 'n='+ encodeURIComponent(currentName)+'&c='+ encodeURIComponent(currentChatText) +'&u='+ encodeURIComponent(currentUrl); httpSendChat.open("POST", SendChaturl, true); httpSendChat.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); httpSendChat.onreadystatechange = receiveChatText; httpSendChat.send(param); document.forms['chatForm'].elements['chatbarText'].value = ''; } } // http://www.codingforums.com/showthread.php?t=63818 function pressedEnter(field,event) { var theCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if (theCode == 13) { sendComment(); return false; } else return true; } //does clever things to the input and submit function checkStatus(focusState) { currentChatText = document.forms['chatForm'].elements['chatbarText']; oSubmit = document.forms['chatForm'].elements['submit']; if (currentChatText.value != '' || focusState == 'active') { oSubmit.disabled = false; } else { oSubmit.disabled = true; } } function jal_getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } //autoasigns a random name to a new user //If the user has chosen a name, use that function checkName() { jalCookie = jal_getCookie("jalUserName"); currentName = document.getElementById('shoutboxname'); if (currentName.value != jalCookie) { document.cookie = "jalUserName="+currentName.value+"; expires=<?php echo gmdate("D, d M Y H:i:s",time() + $offset)." UTC"; ?>;" } if (jalCookie && currentName.value == '') { currentName.value = jalCookie; return; } if (currentName.value == '') { currentName.value = 'guest_'+ Math.floor(Math.random() * 10000); } } function checkUrl() { jalCookie = jal_getCookie("jalUrl"); currentName = document.getElementById('shoutboxurl'); if (currentName.value == '') return; if (currentName.value != jalCookie) { document.cookie = "jalUrl="+currentName.value+"; expires=<?php echo gmdate("D, d M Y H:i:s",time() + $offset)." UTC"; ?>;" return; } if (jalCookie && ( currentName.value == '' || currentName.value == "http://")) { currentName.value = jalCookie; return; } } //initiates the XMLHttpRequest object //as found here: http://www.webpasties.com/xmlHttpRequest function getHTTPObject() { var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; }
ecco l'ultimo dei 3 files.... si kiama wordspew.php è il nome dello script anke....
codice:<?php /* Plugin Name: Jalenack's Wordspew Plugin URI: http://blog.jalenack.com/ajax/ 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 Author: Andrew Sutherland Version: 1.16 Author URI: http://blog.jalenack.com */ // Version of this plugin. Not very useful for you, but for the dev $jal_version = "1.16"; // The required user level needed to access the admin page for this plugin $jal_admin_user_level = 8; // The number of comments that should show up in one viewing. $jal_number_of_comments = 35; /* ==================// Important Info //======================================= This file is called in three different places. First, it is called by Wordpress so that it can display the jal_get_shoutbox function. Secondly, it is called by javascript. Because it is called by javascript and not by wordpress, normal plugin procedure won't work without directly calling the wp-config file in your root directory. We cannot use the $wpdb object. So instead, we open up the config file, comment out the bit about calling the rest of Wordpress, and then evaluate the config file to extract how to access the database. We do all this so that the entirety of Wordpress is not loaded by each call to the server, which would put great unneccessary load on the server and conflict with other plugins. To differentiate between the two remote calls, I've used the $jalGetChat and $jalSendChat variables. These two variables are sent by the javascript file as "yes". That way, the script will only perform certain actions if it is called by the javascript file. Thirdly, it is called by the wordpress admin panel, which allows users to edit settings for this plugin ==================// End of Info //========================================== */ // Register globals - Thanks Karan et Etienne $jal_lastID = isset($_GET['jal_lastID']) ? $_GET['jal_lastID'] : ""; $jal_user_name = isset($_POST['n']) ? $_POST['n'] : ""; $jal_user_url = isset($_POST['u']) ? $_POST['u'] : ""; $jal_user_text = isset($_POST['c']) ? $_POST['c'] : ""; $jalGetChat = isset($_GET['jalGetChat']) ? $_GET['jalGetChat'] : ""; $jalSendChat = isset($_GET['jalSendChat']) ? $_GET['jalSendChat'] : ""; function jal_install_shout () { global $table_prefix, $wpdb, $user_level, $jal_admin_user_level; get_currentuserinfo(); if ($user_level < $jal_admin_user_level) return; $result = mysql_list_tables(DB_NAME); $tables = array(); while ($row = mysql_fetch_row($result)) { $tables[] = $row[0]; } if (!in_array($table_prefix."liveshoutbox", $tables)) { $first_install = "yes"; } require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta("CREATE TABLE ".$table_prefix."liveshoutbox ( id mediumint(7) NOT NULL AUTO_INCREMENT, time bigint(11) DEFAULT '0' NOT NULL, name tinytext NOT NULL, text text NOT NULL, url text NOT NULL, UNIQUE KEY id (id) );"); if ($first_install == "yes") { $welcome_name = "Jalenack"; $welcome_text = "Congratulations, you just completed the installation of this shoutbox."; $wpdb->query("INSERT INTO ".$table_prefix."liveshoutbox (time,name,text) VALUES ('".time()."','".$welcome_name."','".$welcome_text."')"); // Default shoutbox color config add_option('shoutbox_fade_from', "666666"); add_option('shoutbox_fade_to', "FFFFFF"); add_option('shoutbox_update_seconds', 4000); add_option('shoutbox_fade_length', 1500); add_option('shoutbox_text_color', "333333"); add_option('shoutbox_name_color', "0066CC"); add_option('shoutbox_regisitered_only', '0'); } } 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_wp_url = (dirname($_SERVER['PHP_SELF']) == "/") ? "/" : dirname($_SERVER['PHP_SELF']) . "/"; $jal_wp_url = get_bloginfo('wpurl') . "/"; echo ' <link rel="stylesheet" href="'.$jal_wp_url.'wp-content/plugins/wordspew/css.php" type="text/css" /> <script type="text/javascript" src="'.$jal_wp_url.'wp-content/plugins/wordspew/fatAjax.php"></script> '; } // In the administration page, add some style... function jal_add_to_admin_head () { ?> <style type="text/css"> /* Styles added by Wordspew shoutbox plugin */ input[name=jal_delete]:hover, #jal_truncate_all:hover { background: #c22; color: #fff; cursor: pointer; } input[name=jal_edit]:hover { background: #2c2; color: #fff; cursor: pointer; } #shoutbox_options p { text-indent: 15px; padding: 5px 0; color: #555; } #shoutbox_options span { border: 1px dotted #ccc; padding: 4px 14px; } </style> <?php } // HTML printed to the admin panel function jal_shoutbox_admin () { global $jal_admin_user_level, $wpdb, $user_level, $table_prefix, $jal_number_of_comments; get_currentuserinfo(); // Gets logged in user. // If user is not allowed to use the admin page if ($user_level < $jal_admin_user_level) { echo '<div class="wrap"><h2>No Access for you!</h2></div>'; } else { ?> <?php if (isset($_GET['jal_delete'])) { ?> <div class="updated"> The comment was deleted successfully.</p> </div> <?php } if (isset($_GET['jal_edit'])) { ?> <div class="updated"> The comment was edited successfully.</p> </div> <?php } if (isset($_GET['jal_truncate'])) { ?> <div class="updated"> The shoutbox database has been wiped. You now have a fresh slate!</p> </div> <?php } ?> <div class="wrap"> <h2>Jalenack's Live Shoutbox</h2> When you update the Times and Colors, you may need to refresh/empty cache before you see the changes take effect</p> There have been <?php $results = $wpdb->get_var("SELECT id FROM ".$table_prefix."liveshoutbox ORDER BY id DESC LIMIT 1"); echo $results; ?> messages in this shoutbox <form name="shoutbox_options" action="" method="get" id="shoutbox_options"> <fieldset> <legend>Colors (Must be 6 digit hex)</legend> <input type="hidden" name="page" value="wordspew" /> Fade from: #<input type="text" maxlength="6" name="fade_from" value="<?php echo get_option('shoutbox_fade_from'); ?>" size="6" /> <span style="background: #<?php echo get_option('shoutbox_fade_from'); ?>;"></span> The color that new messages fade in from. Default: <span style="color: #666">666666</span></p> Fade to: #<input type="text" maxlength="6" name="fade_to" value="<?php echo get_option('shoutbox_fade_to'); ?>" size="6" /> <span style="background: #<?php echo get_option('shoutbox_fade_to'); ?>;"></span> Also used as the background color of the box. Default: FFFFFF (white)</p> Text Color: #<input type="text" maxlength="6" name="text_color" value="<?php echo get_option('shoutbox_text_color'); ?>" size="6" /> <span style="background: #<?php echo get_option('shoutbox_text_color'); ?>;"></span> The color of text within the box. Default: <span style="color: #333">333333</span></p> Name Color: #<input type="text" maxlength="6" name="name_color" value="<?php echo get_option('shoutbox_name_color'); ?>" size="6" /> <span style="background: #<?php echo get_option('shoutbox_name_color'); ?>;"></span> The color of peoples' names. Default: <span style="color: #06c">0066CC</span></p> </fieldset>

Rispondi quotando