| [ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_plugins/chatbox_menu/chatbox_menu.php,v $ 14 | $Revision: 1.77 $ 15 | $Date: 2007/01/28 14:08:11 $ 16 | $Author: e107steved $ 17 +----------------------------------------------------------------------------+ 18 */ 19 20 global $tp, $e107cache, $e_event, $e107, $pref, $footer_js, $PLUGINS_DIRECTORY; 21 22 if(($pref['cb_layer']==2) || isset($_POST['chatbox_ajax'])) 23 { 24 if(isset($_POST['chat_submit'])) 25 { 26 include_once ("../../class2.php"); 27 28 //Normally the menu.sc file will auto-load the language file, this is needed in case 29 //ajax is turned on and the menu is not loaded from the menu.sc 30 @include_lan(e_PLUGIN."chatbox_menu/languages/".e_LANGUAGE."/".e_LANGUAGE.".php"); 31 @include_lan(e_PLUGIN."chatbox_menu/languages/English/English.php"); 32 } 33 $footer_js[] = e_FILE_ABS.'e_ajax.js'; 34 } 35 36 if(!defined("e_HANDLER")){ exit; } 37 require_once(e_HANDLER."emote.php"); 38 39 $emessage=''; 40 if(isset($_POST['chat_submit']) && $_POST['cmessage'] != "") 41 { 42 if(!USER && !$pref['anon_post']) 43 { 44 // disallow post 45 } 46 else 47 { 48 $nick = trim(preg_replace("#\[.*\]#si", "", $tp -> toDB($_POST['nick']))); 49 50 $cmessage = $_POST['cmessage']; 51 $cmessage = preg_replace("#\[.*?\](.*?)\[/.*?\]#s", "\\1", $cmessage); 52 53 $fp = new floodprotect; 54 if($fp -> flood("chatbox", "cb_datestamp")) 55 { 56 if((strlen(trim($cmessage)) < 1000) && trim($cmessage) != "") 57 { 58 $cmessage = $tp -> toDB($cmessage); 59 if($sql -> db_Select("chatbox", "*", "cb_message='$cmessage' AND cb_datestamp+84600>".time())) 60 { 61 $emessage = CHATBOX_L17; 62 } 63 else 64 { 65 $datestamp = time(); 66 $ip = $e107->getip(); 67 if(USER) 68 { 69 $nick = USERID.".".USERNAME; 70 $sql -> db_Update("user", "user_chats=user_chats+1, user_lastpost='".time()."' WHERE user_id='".USERID."' "); 71 } 72 else if(!$nick) 73 { 74 $nick = "0.Anonymous"; 75 } 76 else 77 { 78 if($sql -> db_Select("user", "*", "user_name='$nick' ")){ 79 $emessage = CHATBOX_L1; 80 } 81 else 82 { 83 $nick = "0.".$nick; 84 } 85 } 86 if(!$emessage) 87 { 88 $sql -> db_Insert("chatbox", "0, '$nick', '$cmessage', '".time()."', '0' , '$ip' "); 89 $edata_cb = array("cmessage" => $cmessage, "ip" => $ip); 90 $e_event -> trigger("cboxpost", $edata_cb); 91 $e107cache->clear("nq_chatbox"); 92 } 93 } 94 } 95 else 96 { 97 $emessage = CHATBOX_L15; 98 } 99 } 100 else 101 { 102 $emessage = CHATBOX_L19; 103 } 104 } 105 } 106 107 if(!USER && !$pref['anon_post']){ 108 if($pref['user_reg']) 109 { 110 $texta = "<div style='text-align:center'>".CHATBOX_L3."</div><br /><br />"; 111 } 112 } 113 else 114 { 115 $cb_width = (defined("CBWIDTH") ? CBWIDTH : ""); 116 117 if($pref['cb_layer'] == 2) 118 { 119 $texta = "\n<form id='chatbox' action='".e_SELF."?".e_QUERY."' method='post' onsubmit='return(false);'> 120 <div><input type='hidden' id='chatbox_ajax' value='1' /></div> 121 "; 122 } 123 else 124 { 125 $texta = (e_QUERY ? "\n<form id='chatbox' method='post' action='".e_SELF."?".e_QUERY."'>" : "\n<form id='chatbox' method='post' action='".e_SELF."'>"); 126 } 127 $texta .= "<div style='text-align:center; width:100%'>"; 128 129 if(($pref['anon_post'] == "1" && USER == FALSE)) 130 { 131 $texta .= "\n<input class='tbox chatbox' type='text' id='nick' name='nick' value='' maxlength='50' ".($cb_width ? "style='width: ".$cb_width.";'" : '')." /><br />"; 132 } 133 134 if($pref['cb_layer'] == 2) 135 { 136 137 $oc = "onclick=\"javascript:sendInfo('".SITEURL.$PLUGINS_DIRECTORY."chatbox_menu/chatbox_menu.php', 'chatbox_posts', this.form);\""; 138 } 139 else 140 { 141 $oc = ""; 142 } 143 $texta .= " 144 <textarea class='tbox chatbox' id='cmessage' name='cmessage' cols='20' rows='5' style='".($cb_width ? "width:".$cb_width.";" : '')." overflow: auto' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea> 145 <br /> 146 <input class='button' type='submit' id='chat_submit' name='chat_submit' value='".CHATBOX_L4."' {$oc}/> 147 <input class='button' type='reset' name='reset' value='".CHATBOX_L5."' />"; 148 149 if($pref['cb_emote'] && $pref['smiley_activate']){ 150 $texta .= " 151 <input class='button' type ='button' style='cursor:pointer' size='30' value='".CHATBOX_L14."' onclick=\"expandit('emote')\" /> 152 <div style='display:none' id='emote'>".r_emote()." 153 </div>\n"; 154 } 155 156 $texta .="</div>\n</form>\n"; 157 } 158 159 if($emessage != ""){ 160 $texta .= "<div style='text-align:center'><b>".$emessage."</b></div>"; 161 } 162 163 if(!$text = $e107cache->retrieve("nq_chatbox")) 164 { 165 global $pref,$tp; 166 $pref['chatbox_posts'] = ($pref['chatbox_posts'] ? $pref['chatbox_posts'] : 10); 167 $chatbox_posts = $pref['chatbox_posts']; 168 if(!isset($pref['cb_mod'])) 169 { 170 $pref['cb_mod'] = e_UC_ADMIN; 171 } 172 define("CB_MOD", check_class($pref['cb_mod'])); 173 174 $qry = " 175 SELECT c.*, u.user_name FROM #chatbox AS c 176 LEFT JOIN #user AS u ON SUBSTRING_INDEX(c.cb_nick,'.',1) = u.user_id 177 ORDER BY c.cb_datestamp DESC LIMIT 0, ".intval($chatbox_posts); 178 179 if($sql -> db_Select_gen($qry)) 180 { 181 $obj2 = new convert; 182 $cbpost = $sql -> db_getList(); 183 foreach($cbpost as $cb) 184 { 185 // get available vars 186 list($cb_uid, $cb_nick) = explode(".", $cb['cb_nick'], 2); 187 if($cb['user_name']) 188 { 189 $cb_nick = "<a href='".e_BASE."user.php?id.{$cb_uid}'>{$cb['user_name']}</a>"; 190 } 191 else 192 { 193 $cb_nick = $tp -> toHTML($cb_nick,FALSE,'emotes_off, no_make_clickable'); 194 $cb_nick = str_replace("Anonymous", LAN_ANONYMOUS, $cb_nick); 195 } 196 197 $datestamp = $obj2->convert_date($cb['cb_datestamp'], "short"); 198 if(!$pref['cb_wordwrap']) { $pref['cb_wordwrap'] = 30; } 199 $emotes_active = $pref['cb_emote'] ? 'BODY, emotes_on' : 'BODY, emotes_off'; 200 201 $cb_message = $tp -> toHTML($cb['cb_message'], FALSE, $emotes_active, $cb_uid, $pref['menu_wordwrap']); 202 203 $replace[0] = "["; $replace[1] = "]"; 204 $search[0] = "["; $search[1] = "]"; 205 $cb_message = str_replace($search, $replace, $cb_message); 206 207 global $CHATBOXSTYLE; 208 if(!$CHATBOXSTYLE) 209 { 210 $bullet = (defined("BULLET") ? "<img src='".THEME_ABS."images/".BULLET."' alt='' style='vertical-align: middle;' />" : "<img src='".THEME_ABS."images/".(defined("BULLET") ? BULLET : "bullet2.gif")."' alt='' style='vertical-align: middle;' />"); 211 // default chatbox style 212 $CHATBOXSTYLE = "<!-- chatbox -->\n<div class='spacer'> 213 $bullet <b>{USERNAME}</b><br /><span class='smalltext'>{TIMEDATE}</span><br /><div class='smallblacktext'>{MESSAGE}</div></div><br />\n"; 214 } 215 216 $search[0] = "/\{USERNAME\}(.*?)/si"; 217 $replace[0] = $cb_nick; 218 $search[1] = "/\{TIMEDATE\}(.*?)/si"; 219 $replace[1] = $datestamp; 220 $search[2] = "/\{MESSAGE\}(.*?)/si"; 221 $replace[2] = ($cb['cb_blocked'] ? CHATBOX_L6 : $cb_message); 222 223 $text .= preg_replace($search, $replace, $CHATBOXSTYLE); 224 225 } 226 } 227 else 228 { 229 $text .= "<span class='mediumtext'>".CHATBOX_L11."</span>"; 230 } 231 $total_chats = $sql -> db_Count("chatbox"); 232 if($total_chats > $chatbox_posts || CB_MOD) 233 { 234 $text .= "<br /><div style='text-align:center'><a href='".e_PLUGIN."chatbox_menu/chat.php'>".(CB_MOD ? CHATBOX_L13 : CHATBOX_L12)."</a> (".$total_chats.")</div>"; 235 } 236 $e107cache->set("nq_chatbox", $text); 237 } 238 239 $caption = (file_exists(THEME."images/chatbox_menu.png") ? "<img src='".THEME_ABS."images/chatbox_menu.png' alt='' /> ".CHATBOX_L2 : CHATBOX_L2); 240 241 if($pref['cb_layer'] == 1) 242 { 243 $text = $texta."<div style='border : 0; padding : 4px; width : auto; height : ".$pref['cb_layer_height']."px; overflow : auto; '>".$text."</div>"; 244 $ns -> tablerender($caption, $text, 'chatbox'); 245 } 246 elseif($pref['cb_layer'] == 2 && isset($_POST['chat_submit'])) 247 { 248 $text = $texta.$text; 249 $text = str_replace(e_IMAGE, e_IMAGE_ABS, $text); 250 echo $text; 251 } 252 else 253 { 254 $text = $texta.$text; 255 if($pref['cb_layer'] == 2) 256 { 257 $text = "<div id='chatbox_posts'>".$text."</div>"; 258 } 259 $ns -> tablerender($caption, $text, 'chatbox'); 260 } 261 262 //$text = ($pref['cb_layer'] ? $texta."<div style='border : 0; padding : 4px; width : auto; height : ".$pref['cb_layer_height']."px; overflow : auto; '>".$text."</div>" : $texta.$text); 263 //if(ADMIN && getperms("C")){$text .= "<br /><div style='text-align: center'>[ <a href='".e_PLUGIN."chatbox_menu/admin_chatbox.php'>".CHATBOX_L13."</a> ]</div>";} 264 //$ns -> tablerender($caption, $text, 'chatbox'); 265 266 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |