Thorin
Junior Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору
Код: <?php $pun_root = './'; if (!defined('PUN_ROOT')) define('PUN_ROOT','./'); require $pun_root.'include/common.php'; if ($pun_user['g_read_board'] == '0') message($lang_common['No view']); //Hide ChatBox from Guest if ($pun_user['is_guest']) message($lang_common['No permission']); $page_title=pun_htmlspecialchars($pun_config['o_board_title']).' / ChatBox'; require $pun_root.'lang/'.$pun_user['language'].'/'.'chatbox.php'; define('PUN_ALLOW_INDEX', 1); require PUN_ROOT.'header.php'; ###################### Configuration of ChatBox ######################## $hide_smilies = 0;// 1 = hide smilies, 0 = show smilies $msg_max = 50;// max. messages in chatbox $file_name = 'chatbox.txt'; // file where there are all messages $box_height = '200px';// height of chatbox ######################################################################## require PUN_ROOT.'include/parser.php'; $tpl_room = file_get_contents(PUN_ROOT.$file_name); $messages = explode("</MESSAGE>", $tpl_room); $nb_messages = count($messages); $room = ''; $room_txt = ''; $anti_flood = 0; if (isset($_GET['action']) && isset($_POST['message'])) $room_tmp_flood = '<MESSAGE><ID>'.$pun_user['id'].'</ID><TEXT>'.$_POST['message'].'</TEXT>'; else $room_tmp_flood = '<no_post>'; for($i=0;$i<$nb_messages - 1;$i++) { $grab = ereg("<ID>(.*)</ID>", $messages[$i], $mess_id); $grab = ereg("<PSEUDO>(.*)</PSEUDO>", $messages[$i], $mess_pseudo); $grab = ereg("<DATE>(.*)</DATE>", $messages[$i], $mess_date); $grab = ereg("<TEXT>(.*)</TEXT>", $messages[$i], $mess_text); $room .= '[<a href="profile.php?id='.$mess_id[1].'"><strong>'.pun_htmlspecialchars($mess_pseudo[1]).'</strong></a> - '.format_time($mess_date[1])."]".parse_message($mess_text[1], $hide_smilies)."\n".'<br />'."\n"; if ($i+1 < $msg_max) { $room_txt_flood = '<MESSAGE><ID>'.$mess_id[1].'</ID><TEXT>'.$mess_text[1].'</TEXT>'; if ($room_tmp_flood == $room_txt_flood) $anti_flood = 1; $room_txt .= '<MESSAGE>'."\r".' <ID>'.$mess_id[1].'</ID>'."\r".' <PSEUDO>'.$mess_pseudo[1].'</PSEUDO>'."\r".' <DATE>'.$mess_date[1].'</DATE>'."\r".' <TEXT>'.$mess_text[1].'</TEXT>'."\r".'</MESSAGE>'."\n\n"; } } if (isset($_GET['action']) && isset($_POST['message'])) { if ($anti_flood == 0 && $_POST['message'] != '') { $fp = fopen(PUN_ROOT.$file_name, "w"); if ($fp) { $room_txt = '<MESSAGE>'."\r".' <ID>'.$pun_user['id'].'</ID>'."\r".' <PSEUDO>'.$pun_user['username'].'</PSEUDO>'."\r".' <DATE>'.time().'</DATE>'."\r".' <TEXT>'.$_POST['message'].'</TEXT>'."\r".'</MESSAGE>'."\n\n".$room_txt; $r = fwrite($fp, $room_txt); } fclose($fp); $room = '[<a href="profile.php?id='.$pun_user['id'].'"><strong>'.pun_htmlspecialchars($pun_user['username']).'</strong></a> - '.format_time(time())."]".parse_message($_POST['message'], $hide_smilies)."\n".'<br />'."\n".$room; } elseif ($anti_flood == 1) { $room = '<strong><font color=red>'.$lang_chatbox['Anti flood'].'</font></strong>'."\n".'<br />'."\n".'<br />'."\n".$room; } else { $room = '<strong><font color=red>'.$lang_chatbox['Anti blank'].'</font></strong>'."\n".'<br />'."\n".'<br />'."\n".$room; } } ?> <script type="text/javascript"> <!-- function refreshRoom() { window.location="<?php echo $pun_root.'chatbox.php' ?>"; } // --> </script> <div class="block"> <h2><span><?php echo $lang_chatbox['Chatbox']; ?></span></h2> <div class="box"> <div class="inbox"> <div class="inform"> <fieldset> <legend><?php echo $lang_chatbox['Messages']; ?></legend> <div style="padding:5px;margin:0;overflow:auto;height:<?php echo $box_height; ?>;"> <?php echo $room; ?> </div> </fieldset> </div> <div class="inform"> <fieldset> <form method="post" name="form_room" action="?action=send"> <input type="text" name="message" size="125" maxlength="255" /> <input type="submit" name="send" value="<?php echo $lang_chatbox['Btn Send']; ?>" /> <input type="button" value="<?php echo $lang_chatbox['Btn Refresh']; ?>" onClick="refreshRoom()"></a> </form> </fieldset> </div> </div> </div> </div> <?php $footer_style = 'index'; require PUN_ROOT.'footer.php'; | для организации скрипта автоввода имени в строку Код: <script> function insUN(nick) { var d = document.sendform; d.req_message.focus(); d.req_message.value = ""+d.req_message.value+ nick+"\n"; } </script> | вызов Код: $username = '<a href="javascript:insUN('[b]'.pun_htmlspecialchars($cur_post['username']).'[/b]');">'.pun_htmlspecialchars($cur_post['username']).'</a>'; |
Еще раз говорю - тут приводятся элегантные решения различных проблем, а не задаются вопросы! /Cheery/ | Всего записей: 98 | Зарегистр. 07-09-2004 | Отправлено: 15:21 28-04-2005 | Исправлено: Cheery, 18:42 28-04-2005 |
|