From: skodak Date: Thu, 3 Feb 2005 20:39:27 +0000 (+0000) Subject: radical chat clean up, see forum for details X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=516121bd0d001433eba0d1bb54220bc64b0a9d74;p=moodle.git radical chat clean up, see forum for details --- diff --git a/mod/chat/chatd.php b/mod/chat/chatd.php index 0bf0a812d7..21770cf87b 100755 --- a/mod/chat/chatd.php +++ b/mod/chat/chatd.php @@ -531,7 +531,7 @@ class ChatDaemon { $this->dismiss_half($sessionid, false); $this->write_data($this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL], $CHAT_HTMLHEAD_JS); $this->trace('Connection accepted: '.$this->conn_sets[$sessionid][CHAT_CONNECTION_CHANNEL].', SID: '.$sessionid.' UID: '.$chatuser->userid.' GID: '.intval($groupid), E_USER_WARNING); - +/* // Finally, broadcast the "entered the chat" message $msg = &New stdClass; @@ -544,7 +544,7 @@ class ChatDaemon { insert_record('chat_messages', $msg); $this->message_broadcast($msg, $this->sets_info[$sessionid]['user']); - +*/ return true; } @@ -973,7 +973,7 @@ while(true) { if($changed > 0) { // Let's see what it has to say - $data = socket_read($handle, 512); + $data = socket_read($handle, 2048); // should be more to prevent empty pages and repeated messages!! if(empty($data)) { continue; } diff --git a/mod/chat/db/mysql.php b/mod/chat/db/mysql.php index 7c0ebb6c51..9693b10a41 100644 --- a/mod/chat/db/mysql.php +++ b/mod/chat/db/mysql.php @@ -53,6 +53,11 @@ function chat_upgrade($oldversion) { modify_database('','ALTER TABLE prefix_chat_users ADD INDEX `groupid` (`groupid`);'); } + if ($oldversion < 2005020300) { + table_column('chat_users', '', 'course'); + table_column('chat_users', '', 'lang', 'varchar', '10', '', ''); + } + return true; } diff --git a/mod/chat/db/mysql.sql b/mod/chat/db/mysql.sql index 68365a8dd8..2972a0debc 100644 --- a/mod/chat/db/mysql.sql +++ b/mod/chat/db/mysql.sql @@ -52,6 +52,8 @@ CREATE TABLE `prefix_chat_users` ( `lastping` int(10) unsigned NOT NULL default '0', `lastmessageping` int(10) unsigned NOT NULL default '0', `sid` varchar(32) NOT NULL default '', + `course` int(10) NOT NULL default '0', + `lang` varchar(10) NOT NULL default '', PRIMARY KEY (`id`), KEY `userid` (`userid`), KEY `lastping` (`lastping`), diff --git a/mod/chat/db/oci8po.sql b/mod/chat/db/oci8po.sql index b31fa04280..e082c15661 100755 --- a/mod/chat/db/oci8po.sql +++ b/mod/chat/db/oci8po.sql @@ -93,7 +93,9 @@ CREATE TABLE prefix_chat_users ( firstping number(10) default '0' not null, lastping number(10) default '0' not null, lastmessageping number(10) default '0' not null, - sid varchar2(32) default '' not null + sid varchar2(32) default '' not null, + course number(10) default '0' not null, + lang varchar2(10) default '' not null ); create index userid on prefix_chat_users(userid); diff --git a/mod/chat/db/postgres7.php b/mod/chat/db/postgres7.php index 23b683fe86..86586390eb 100644 --- a/mod/chat/db/postgres7.php +++ b/mod/chat/db/postgres7.php @@ -42,9 +42,13 @@ function chat_upgrade($oldversion) { modify_database('','CREATE INDEX prefix_chat_users_lastping_idx ON prefix_chat_users (lastping);'); } + if ($oldversion < 2005020300) { + table_column('chat_users', '', 'course'); + table_column('chat_users', '', 'lang', 'varchar', '10', '', ''); + } + return true; } ?> - diff --git a/mod/chat/db/postgres7.sql b/mod/chat/db/postgres7.sql index c1928e4af9..5d70f9af1a 100644 --- a/mod/chat/db/postgres7.sql +++ b/mod/chat/db/postgres7.sql @@ -56,6 +56,8 @@ CREATE TABLE prefix_chat_users ( lastping integer NOT NULL default '0', lastmessageping integer NOT NULL default '0', sid varchar(32) NOT NULL default '', + course integer NOT NULL default '0', + lang varchar(10) NOT NULL default '', PRIMARY KEY (id) ); diff --git a/mod/chat/drawboard.php b/mod/chat/drawboard.php deleted file mode 100644 index 099b1e7c33..0000000000 --- a/mod/chat/drawboard.php +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - Abacho - Drawboard - - - - " height=""> - "> - - - - - - - Unfortunatelly, your browser doesn't support Java applets. You have to use another one. - - - - \ No newline at end of file diff --git a/mod/chat/gui_header/chatinput.php b/mod/chat/gui_header/chatinput.php deleted file mode 100644 index 83338b5927..0000000000 --- a/mod/chat/gui_header/chatinput.php +++ /dev/null @@ -1,33 +0,0 @@ -= 0) - { - echo $arsc_parameters["htmlhead_msginput"]; - ?> -
- - - " value="" /> - " /> -
- - - diff --git a/mod/chat/gui_header/chatmsg.php b/mod/chat/gui_header/chatmsg.php deleted file mode 100644 index afa4e6cda0..0000000000 --- a/mod/chat/gui_header/chatmsg.php +++ /dev/null @@ -1,74 +0,0 @@ -".$arsc_message."", $arsc_room, 0); - ?> - - - '$arsc_lastid' ORDER BY timeid ASC"); - while ($arsc_a = mysql_fetch_array($arsc_result)) - { - echo arsc_filter_posting($arsc_a["user"], $arsc_a["sendtime"], $arsc_a["message"], $arsc_room, $arsc_a["flag_ripped"])."\n"; - } - $arsc_ping = time(); - $arsc_ip = getremoteaddr(); - mysql_query("UPDATE arsc_users SET lastping = '$arsc_ping', ip = '$arsc_ip' WHERE user = '$arsc_user'"); - ?> - - - - diff --git a/mod/chat/gui_header/index.php b/mod/chat/gui_header/index.php deleted file mode 100644 index ea29bf7bbe..0000000000 --- a/mod/chat/gui_header/index.php +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - ARSC - ARSC Really Simple Chat - - - - - - - - - - - - Sorry, this version of ARSC needs a browser that understands framesets. We have a Lynx friendly version too. - - diff --git a/mod/chat/gui_header_js/chatinput.php b/mod/chat/gui_header_js/chatinput.php index 4c2461e42b..e7477b7fe6 100644 --- a/mod/chat/gui_header_js/chatinput.php +++ b/mod/chat/gui_header_js/chatinput.php @@ -1,64 +1,50 @@ -chatid)) { - error("No chat found"); -} -require_login($chat->course); + if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { + error('Not logged in!'); + } -?> - - - - -Message Input - -javascript"); ?> - - - + chat_force_language($chatuser->lang); - + ob_start(); + ?> + + ->> - - - -
- - - - -
+ $meta = ob_get_clean(); + print_header('', '', '', 'f.chat_message', $meta, false); +?> +
+ >> + +
+ +
+ + +
- - + \ No newline at end of file diff --git a/mod/chat/gui_header_js/index.php b/mod/chat/gui_header_js/index.php index 5e9c25f1ca..008f53e3ea 100644 --- a/mod/chat/gui_header_js/index.php +++ b/mod/chat/gui_header_js/index.php @@ -1,73 +1,75 @@ -course)) { - error("Could not find the course this belongs to!"); + + if (!$course = get_record('course', 'id', $chat->course)) { + error('Could not find the course this belongs to!'); } - if (!$cm = get_coursemodule_from_instance("chat", $chat->id, $course->id)) { - error("Course Module ID was incorrect"); + if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { + error('Course Module ID was incorrect'); } - + require_login($course->id); - + if (isguest()) { - error("Guest does not have access to chat rooms"); + error('Guest does not have access to chat rooms'); + } + + if (!$cm->visible and !isteacher($course->id)) { + print_header(); + notice(get_string("activityiscurrentlyhidden")); } /// Check to see if groups are being used here - if ($groupmode = groupmode($course, $cm)) { // Groups are being used - if ($currentgroup = get_and_set_current_group($course, $groupmode, $groupid)) { - if (!$group = get_record('groups', 'id', $currentgroup)) { - error("That group (id $currentgroup) doesn't exist!"); + if ($groupmode = groupmode($course, $cm)) { // Groups are being used + if ($groupid = get_and_set_current_group($course, $groupmode, $groupid)) { + if (!$group = get_record('groups', 'id', $groupid)) { + error("That group (id $groupid) doesn't exist!"); } $groupname = ': '.$group->name; } else { $groupname = ': '.get_string('allparticipants'); } } else { - $currentgroup = false; + $groupid = 0; $groupname = ''; } - if (!$chat_sid = chat_login_user($chat->id, "header_js", $currentgroup)) { - error("Could not log in to chat room!!"); + if (!$chat_sid = chat_login_user($chat->id, 'header_js', $groupid, $course)) { + error('Could not log in to chat room!!'); } - if ($currentgroup !== false) { - $params = "chat_enter=true&chat_sid=$chat_sid&groupid=$currentgroup"; - } else { - $params = "chat_enter=true&chat_sid=$chat_sid"; - } + $params = "chat_sid=$chat_sid"; - $strchat = get_string("modulename", "chat"); - + $strchat = get_string('modulename', 'chat'); ?> + + <?php echo "$strchat: $course->shortname: $chat->name$groupname" ?> - + - + - + Sorry, this version of Moodle Chat needs a browser that handles frames. diff --git a/mod/chat/gui_header_js/insert.php b/mod/chat/gui_header_js/insert.php new file mode 100644 index 0000000000..7b197164ff --- /dev/null +++ b/mod/chat/gui_header_js/insert.php @@ -0,0 +1,65 @@ +<?php // $Id$ + + include('../../../config.php'); + include('../lib.php'); + + $chat_sid = required_param('chat_sid', PARAM_ALPHANUM); + $chat_message = required_param('chat_message', PARAM_RAW); + + if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { + error('Not logged in!'); + } + + if (!$chat = get_record('chat', 'id', $chatuser->chatid)) { + error('No chat found'); + } + + if (!$course = get_record('course', 'id', $chat->course)) { + error('Could not find the course this belongs to!'); + } + + require_login($course->id); + + if (isguest()) { + error('Guest does not have access to chat rooms'); + } + + session_write_close(); + +/// Delete old users now + + chat_delete_old_users(); + +/// Clean up the message + + $chat_message = addslashes(clean_text(stripslashes($chat_message), FORMAT_MOODLE)); // Strip bad tags + +/// Add the message to the database + + if (!empty($chat_message)) { + + $message->chatid = $chatuser->chatid; + $message->userid = $chatuser->userid; + $message->groupid = $chatuser->groupid; + $message->message = $chat_message; + $message->timestamp = time(); + + if (!insert_record('chat_messages', $message)) { + error('Could not insert a chat message!'); + } + + $chatuser->lastmessageping = time() - 2; + update_record('chat_users', $chatuser); + + if ($cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { + add_to_log($course->id, 'chat', 'talk', "view.php?id=$cm->id", $chat->id, $cm->id); + } + } + + if ($chatuser->version == 'header_js') { + /// force msg referesh ASAP + echo '<script type="text/javascript">parent.jsupdate.location.href = parent.jsupdate.document.anchors[0].href;</script>'; + } + + //redirect('empty.php'); +?> diff --git a/mod/chat/gui_header_js/jsupdate.php b/mod/chat/gui_header_js/jsupdate.php index c3c7c53298..57da1a5ece 100644 --- a/mod/chat/gui_header_js/jsupdate.php +++ b/mod/chat/gui_header_js/jsupdate.php @@ -1,73 +1,107 @@ -<?php +<?php // $Id$ -require("../../../config.php"); -require("../lib.php"); + $nomoodlecookie = true; // Session not needed! -$groupid = empty($_GET['groupid']) ? 0 : $_GET['groupid']; -$groupselect = $groupid ? " AND (groupid='$groupid' OR groupid='0') " : ""; + require('../../../config.php'); + require('../lib.php'); -if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) { - echo "Not logged in!"; - die; -} + $chat_sid = required_param('chat_sid', PARAM_ALPHANUM); + $chat_lasttime = optional_param('chat_lasttime', 0, PARAM_INT); -if (!$chat = get_record("chat", "id", $chatuser->chatid)) { - error("No chat found"); -} + if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { + error('Not logged in!'); + } -require_login($chat->course); + chat_force_language($chatuser->lang); -if ($message = chat_get_latest_message($chatuser->chatid, $groupid)) { - $chat_newlasttime = $message->timestamp; -} else { - $chat_newlasttime = 0; -} + // force deleting of timed out users if there is a silence in room or just entering + if ((time() - $chat_lasttime) > $CFG->chat_old_ping) { + // must be done before chat_get_latest_message!!! + chat_delete_old_users(); + } -if (empty($chat_lasttime)) { - $chat_lasttime = 0; -} + if ($message = chat_get_latest_message($chatuser->chatid, $chatuser->groupid)) { + $chat_newlasttime = $message->timestamp; + } else { + $chat_newlasttime = 0; + } + if ($chat_lasttime == 0) { //display some previous messages + $chat_lasttime = time() - $CFG->chat_old_ping; //TO DO - any better value?? + } -header("Expires: Sun, 28 Dec 1997 09:32:45 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); -header("Cache-Control: no-cache, must-revalidate"); -header("Pragma: no-cache"); -header("Content-Type: text/html"); -header("Refresh: $CFG->chat_refresh_room; url=jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&groupid=$groupid"); + $refreshurl = "jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime"; // no &amp; in url, does not work in header! + $timenow = time(); + + $groupselect = $chatuser->groupid ? " AND (groupid='".$chatuser->groupid."' OR groupid='0') " : ""; + + header('Expires: Sun, 28 Dec 1997 09:32:45 GMT'); + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); + header('Cache-Control: no-cache, must-revalidate'); + header('Pragma: no-cache'); + header('Content-Type: text/html'); + header("Refresh: $CFG->chat_refresh_room; url=$refreshurl"); ?> - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> - <html> - <head> - <script language="Javascript"> - <!-- -<?php - $beep = false; - - if ($chat_lasttime) { - if ($messages = get_records_select("chat_messages", - "chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime' $groupselect", - "timestamp ASC")) { - foreach ($messages as $message) { - $formatmessage = chat_format_message($message, $chat->course); - if ($formatmessage->beep) { - $beep = $formatmessage->beep; - } - echo "parent.msg.document.write('".addslashes($formatmessage->html)."\\n');"; +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<html> + <head> + <meta http-equiv="content-type" content="text/html; charset=<?php echo get_string('thischarset'); ?>" /> + <script type="text/javascript"> + <!-- + <?php + $beep = false; + $refreshusers = false; + $us = array (); + if (($chat_lasttime != $chat_newlasttime) + and $messages = get_records_select("chat_messages", + "chatid = '$chatuser->chatid' AND timestamp > '$chat_lasttime' $groupselect", + "timestamp ASC")) { + + if (!$currentuser = get_record('user', 'id', $chatuser->userid)) { + error('User does not exist!'); + } + $currentuser->description = ''; + + foreach ($messages as $message) { + $formatmessage = chat_format_message($message, $chatuser->course, $currentuser); + if ($formatmessage->beep) { + $beep = true; + } + if ($formatmessage->refreshusers) { + $refreshusers = true; + } + $us[$message->userid] = $timenow - $message->timestamp; + echo "parent.msg.document.write('".addslashes($formatmessage->html)."\\n');\n"; } - } - } - - $chatuser->lastping = time(); - update_record("chat_users", $chatuser); - ?> - parent.msg.scroll(1,5000000); - // --> - </script> - </head> - <body> - <?php if ($beep) { ?> - <embed src="../beep.wav" autostart="true" hidden="true" /> - <?php } ?> - </body> - </html> + } + + $chatuser->lastping = time(); + update_record('chat_users', $chatuser); + + if ($refreshusers) { + echo "parent.users.location.href = parent.users.document.anchors[0].href;\n"; + } else { + foreach($us as $uid=>$lastping) { + $min = (int) ($lastping/60); + $sec = $lastping - ($min*60); + $min = $min < 10 ? '0'.$min : $min; + $sec = $sec < 10 ? '0'.$sec : $sec; + $idle = $min.':'.$sec; + echo "parent.users.document.getElementById('uidle{$uid}').innerHTML = '$idle';"; + } + } + ?> + parent.msg.scroll(1,5000000); + // --> + </script> + </head> + <body> + <?php + if ($beep) { + echo '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />'; + } + ?> + <a href="<? echo $refreshurl ?>" name="refreshlink">Refresh link</a> + </body> +</html> diff --git a/mod/chat/gui_header_js/users.php b/mod/chat/gui_header_js/users.php new file mode 100644 index 0000000000..5b909be362 --- /dev/null +++ b/mod/chat/gui_header_js/users.php @@ -0,0 +1,116 @@ +<?php // $Id$ + + $nomoodlecookie = true; // Session not needed! + + include('../../../config.php'); + include('../lib.php'); + + $chat_sid = required_param('chat_sid', PARAM_ALPHANUM); + $beep = optional_param('beep', 0, PARAM_INT); // beep target + + if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { + error('Not logged in!'); + } + + chat_force_language($chatuser->lang); + + $courseid = $chatuser->course; + + if ($beep) { + $message->chatid = $chatuser->chatid; + $message->userid = $chatuser->userid; + $message->groupid = $chatuser->groupid; + $message->message = "beep $beep"; + $message->system = 0; + $message->timestamp = time(); + + if (!insert_record('chat_messages', $message)) { + error('Could not insert a chat message!'); + } + + $chatuser->lastmessageping = time(); // A beep is a ping ;-) + } + + $chatuser->lastping = time(); + update_record('chat_users', $chatuser); + + $refreshurl = "users.php?chat_sid=$chat_sid"; + + /// Get list of users + + if (!$chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid)) { + error(get_string('errornousers', 'chat')); + } + + ob_start(); + ?> + <script type="text/javascript"> + <!-- + var timer = null + var f = 1; //seconds + var uidles = new Array(<?php echo count($chatusers) ?>); + <?php + $i = 0; + foreach ($chatusers as $chatuser) { + echo "uidles[$i] = 'uidle{$chatuser->id}';\n"; + $i++; + } + ?> + + function stop() { + clearTimeout(timer) + } + + function start() { + timer = setTimeout("update()", f*1000); + } + + function update() { + for(i=0; i<uidles.length; i++) { + el = document.getElementById(uidles[i]); + parts = el.innerHTML.split(":"); + time = f + (parseInt(parts[0], 10)*60) + parseInt(parts[1], 10); + min = Math.floor(time/60); + sec = time % 60; + el.innerHTML = ((min < 10) ? "0" : "") + min + ":" + ((sec < 10) ? "0" : "") + sec; + } + timer = setTimeout("update()", f*1000); + } + // --> + </script> + <?php + + + /// Print headers + $meta = ob_get_clean(); + print_header('', '', '', '', $meta, false, '', '', false, 'onload="start()" onunload="stop()"'); + + + /// Print user panel body + $timenow = time(); + $stridle = get_string('idle', 'chat'); + $strbeep = get_string('beep', 'chat'); + + + echo '<div style="display: none"><a href="'.$refreshurl.'" name="refreshlink">Refresh link</a></div>'; + echo '<table width="100%">'; + foreach ($chatusers as $chatuser) { + $lastping = $timenow - $chatuser->lastmessageping; + $min = (int) ($lastping/60); + $sec = $lastping - ($min*60); + $min = $min < 10 ? '0'.$min : $min; + $sec = $sec < 10 ? '0'.$sec : $sec; + $idle = $min.':'.$sec; + echo '<tr><td width="35">'; + echo "<a target=\"_new\" onClick=\"return openpopup('$CFG->wwwroot/user/view.php?id=$chatuser->id&amp;course=$courseid','user$chatuser->id','');\" href=\"$CFG->wwwroot/user/view.php?id=$chatuser->id&amp;course=$courseid\">"; + print_user_picture($chatuser->id, 0, $chatuser->picture, false, false, false); + echo '</a></td><td valign="center">'; + echo '<p><font size="1">'; + echo fullname($chatuser).'<br />'; + echo "<span class=\"dimmed_text\">$stridle <span name=\"uidles\" id=\"uidle{$chatuser->id}\">$idle</span></span>"; + echo " <a href=\"users.php?chat_sid=$chat_sid&amp;beep=$chatuser->id\">$strbeep</a>"; + echo '</font></p>'; + echo '<td></tr>'; + } + echo '</table></body></html>'; +?> diff --git a/mod/chat/gui_java/MainFrameGui.java b/mod/chat/gui_java/MainFrameGui.java deleted file mode 100644 index 53c292b2e0..0000000000 --- a/mod/chat/gui_java/MainFrameGui.java +++ /dev/null @@ -1,177 +0,0 @@ -import java.awt.*; -import java.awt.event.*; - -public class MainFrameGui -extends Frame -{ - public static TextArea messages; - public static TextField eingabe; - public static List userliste; - public static Checkbox cb; - public static Button hilfebutton; - public static GridBagConstraints makegbc; - public static TextDialog hilfedialog; - public static MenuBar menu; - - public MainFrameGui() - { - super ("ARSC Really Simple Chat"); - setBackground(Color.lightGray); - addWindowListener(new WindowClosingAdapter(true)); - - //Menü - MenuBar menu = new MenuBar(); - Menu menuConnection = new Menu("Connection"); - menuConnection.add("Connect to server"); - menuConnection.add("Disconnect from server"); - menuConnection.add("Quit"); - Menu menuConfiguration = new Menu("Configuration"); - Menu menuHelp = new Menu("Help"); - MenuItem mi = new MenuItem("Show commands"); - mi.addActionListener(new hilfebuttonListener()); - menuHelp.add(mi); - menuHelp.add("About..."); - menu.add(menuConnection); - menu.add(menuConfiguration); - menu.add(menuHelp); - - setMenuBar(menu); - - //Layout setzen und Komponenten hinzufügen - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc; - setLayout(gbl); - - //TextArea hinzufügen - messages = new TextArea("", 20, 20, TextArea.SCROLLBARS_VERTICAL_ONLY); - gbc = makegbc(0, 0, 2, 2); - gbc.weightx = 100; - gbc.weighty = 100; - gbc.fill = GridBagConstraints.BOTH; - gbl.setConstraints(messages, gbc); - add(messages); - - //Userliste - userliste = new List(); - userliste.add("pgod"); - userliste.add("HanSolo"); - userliste.add("dArUdE"); - gbc = makegbc(2, 0, 2, 2); - gbc.fill = GridBagConstraints.BOTH; - gbl.setConstraints(userliste, gbc); - userliste.addActionListener(new userlisteListener()); - add(userliste); - - //Eingabefeld - eingabe = new TextField(); - gbc = makegbc(0, 2, 1, 1); - gbc.weightx = 100; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.SOUTH; - gbl.setConstraints(eingabe, gbc); - eingabe.addActionListener(new eingabeListener()); - add(eingabe); - - //Checkbox - cb = new Checkbox("Scrolling"); - cb.setState(true); - gbc = makegbc(1, 2, 1, 1); - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.SOUTH; - gbl.setConstraints(cb, gbc); - add(cb); - - //Hilfebutton - hilfebutton = new Button("Help"); - gbc = makegbc(2, 2, 1, 1); - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.WEST; - gbl.setConstraints(hilfebutton, gbc); - hilfebutton.addActionListener(new hilfebuttonListener()); - add(hilfebutton); - //Gib ihm - pack(); - hilfedialog = new TextDialog(this, "Hilfe", "Hilfe\nLala\nLulu...", "Schliessen", false, 200, 400); - } - - //Die Listener - public class eingabeListener - implements ActionListener - { - public void actionPerformed(ActionEvent event) - { - System.out.println("Event erhalten"); - TextField source = (TextField)event.getSource(); - messages.append("\n" + source.getText()); - source.selectAll(); - } - } - - public class userlisteListener - implements ActionListener - { - public void actionPerformed(ActionEvent event) - { - System.out.println("userliste Event erhalten"); - List source = (List)event.getSource(); - eingabe.setText("/msg " + source.getSelectedItem() + " "); - eingabe.setCaretPosition(99); - eingabe.requestFocus(); - } - } - - public class hilfebuttonListener - implements ActionListener - { - public void actionPerformed(ActionEvent event) - { - System.out.println("hilfebutton Event erhalten"); - if(getToolkit().getScreenSize().width - (getBounds().x + getBounds().width) >= hilfedialog.getSize().width) - { - hilfedialog.setLocation(getBounds().x + getBounds().width, getBounds().y); - } - else - { - hilfedialog.setLocation(getToolkit().getScreenSize().width - hilfedialog.getSize().width, getBounds().y); - } - hilfedialog.setVisible(true); - } - } - - public class WindowClosingAdapter - extends WindowAdapter - { - private boolean exitSystem; - - public WindowClosingAdapter(boolean exitSystem) - { - this.exitSystem = exitSystem; - } - - public WindowClosingAdapter() - { - this(true); - } - - public void windowClosing(WindowEvent event) - { - event.getWindow().setVisible(false); - event.getWindow().dispose(); - if (exitSystem) - { - System.exit(0); - } - } - } - - public static GridBagConstraints makegbc(int x, int y, int width, int height) - { - GridBagConstraints gbc = new GridBagConstraints(); - gbc.gridx = x; - gbc.gridy = y; - gbc.gridwidth = width; - gbc.gridheight = height; - gbc.insets = new Insets(1, 1, 1, 1); - return gbc; - } -} diff --git a/mod/chat/gui_java/TextDialog.java b/mod/chat/gui_java/TextDialog.java deleted file mode 100644 index 52e3a12021..0000000000 --- a/mod/chat/gui_java/TextDialog.java +++ /dev/null @@ -1,68 +0,0 @@ -import java.awt.*; -import java.awt.event.*; - -public class TextDialog -extends Dialog -implements ActionListener -{ - public TextDialog(Frame owner, String title, String textAreaText, String buttonText, boolean modal, int sizeX, int sizeY) - { - super(owner, title, modal); - setBackground(Color.lightGray); - setLocation(getToolkit().getScreenSize().width - sizeY, 0); - - //Layout setzen und Komponenten hinzufügen - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc; - setLayout(gbl); - - //TextArea hinzufügen - TextArea text = new TextArea(textAreaText, 1, 1, TextArea.SCROLLBARS_VERTICAL_ONLY); - gbc = MainFrameGui.makegbc(0, 0, 1, 1); - gbc.weightx = 100; - gbc.weighty = 100; - gbc.fill = GridBagConstraints.BOTH; - gbl.setConstraints(text, gbc); - add(text); - - //Button - Button button = new Button(buttonText); - gbc = MainFrameGui.makegbc(0, 1, 1, 1); - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.SOUTH; - gbl.setConstraints(button, gbc); - button.addActionListener(this); - add(button); - - pack(); - setSize(sizeX, sizeY); - } - - public void actionPerformed(ActionEvent event) - { - int i = getSize().height; - int j = i / 20; - int oldWidth = getSize().width; - int oldHeight = getSize().height; - - System.out.println(i + " - " + j); - - while(i > -1) - { - //System.out.println(i); - setSize(getSize().width, i); - try - { - Thread.sleep(5); - } - catch (InterruptedException e) - { - //nix - } - i = i - j; - } - setVisible(false); - setSize(oldWidth, oldHeight); - dispose(); - } -} diff --git a/mod/chat/gui_java/arsc.java b/mod/chat/gui_java/arsc.java deleted file mode 100644 index b45a6b4bc1..0000000000 --- a/mod/chat/gui_java/arsc.java +++ /dev/null @@ -1,90 +0,0 @@ -import java.awt.*; -import java.awt.event.*; -import java.net.*; -import java.io.*; -import java.sql.*; -import java.util.*; - -public class arsc -{ - static String DBUrl = "jdbc:mysql://194.231.30.146/arscdev?user=user&password=password"; - static String arsc_sid = "dhndewbz2798z23dzdewßdew"; - - public static void main(String[] args) - { - MainFrameGui gui = new MainFrameGui(); - gui.setSize(480,300); - gui.setVisible(true); - - try - { - try - { - Class.forName("org.gjt.mm.mysql.Driver").newInstance(); - } - catch (Exception e) - { - System.err.println(e.toString()); - } - - Connection conn = null; - Statement stmt = null; - PreparedStatement pStmt = null; - - conn = DriverManager.getConnection(DBUrl); - stmt = conn.createStatement(); - stmt.executeUpdate("INSERT INTO arsc_users (id, user, lastping, ip, room, language, version, level, sid, lastmessageping) VALUES ('', 'javapgod', '', '', 'lounge', 'german', 'sockets', '1', 'abcdefg', '') "); - } - catch (SQLException sqlEx) { System.err.println(sqlEx.toString()); } - - try - { - Thread.sleep(5000); - } - catch (InterruptedException e) - { - //nix - } - - try - { - Socket sock = new Socket("194.231.30.146", 12345); - BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream())); - OutputStream out = sock.getOutputStream(); - String line = "arsc_sid=abcdefg HTTP"; - out.write(line.getBytes()); - out.write('\r'); - out.write('\n'); - String blubb = new String(); - while ((blubb = in.readLine()) != null) - { - gui.messages.append(blubb); - } - in.close(); - out.close(); - sock.close(); - } - catch (IOException e) - { - System.err.println(e.toString()); - //System.exit; - } - - while (true) - { - try - { - Thread.sleep(500); - } - catch (InterruptedException e) - { - //nix - } - //gui.messages.append("blah...\n"); - if (gui.cb.getState() == true) - { - gui.messages.setCaretPosition(99999999); - } - } - } -} diff --git a/mod/chat/gui_push_js/chatinput.php b/mod/chat/gui_push_js/chatinput.php deleted file mode 100644 index 605a8e1179..0000000000 --- a/mod/chat/gui_push_js/chatinput.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -include("../config.inc.php"); -include("../functions.inc.php"); - -if ($arsc_my = arsc_getdatafromsid($arsc_sid)) -{ - include("../shared/language/".$arsc_my["language"].".inc.php"); - - if ($arsc_my["level"] >= 0) - { - echo $arsc_parameters["htmlhead_msginput_js"]; - ?> - <form action="../shared/chatins.php" method="GET" target="empty" name="f" OnSubmit="return empty_field_and_submit()"> - <input type="text" name="arsc_message" size="50" maxlength="<?php echo $arsc_parameters["input_maxsize"]; ?>" value="<?php echo $arsc_pretext; ?>" /> - </form> - <form action="../shared/chatins.php" method="GET" target="empty" name="fdummy" OnSubmit="return empty_field_and_submit()"> - <input type="hidden" name="arsc_sid" value="<?php echo $arsc_sid; ?>" /> - <input type="hidden" name="arsc_chatversion" value="header_js" /> - <input type="hidden" name="arsc_message" /> - </form> - </body> - </html> - <?php - } - else - { - echo $arsc_htmlhead_out; - } -} -else -{ - echo $arsc_htmlhead_out; -} -?> diff --git a/mod/chat/gui_push_js/chatmsg.php b/mod/chat/gui_push_js/chatmsg.php deleted file mode 100644 index 91dce60af1..0000000000 --- a/mod/chat/gui_push_js/chatmsg.php +++ /dev/null @@ -1,98 +0,0 @@ -<?php - -function arsc_shutdown() -{ - GLOBAL $arsc_sid, - $arsc_my; - if ($arsc_my["user"] <> "") - { - $arsc_user = $arsc_my["user"]; - $arsc_room = $arsc_my["room"]; - $arsc_nice_room = arsc_nice_room($arsc_room); - $arsc_timeid = arsc_microtime(); - $arsc_sendtime = date("H:i:s"); - mysql_query("DELETE from arsc_users WHERE sid = '$arsc_sid'"); - mysql_query("INSERT into arsc_room_$arsc_room (message, user, sendtime, timeid) VALUES ('arsc_user_quit~~$arsc_user~~$arsc_nice_room', 'System', '$arsc_sendtime', '$arsc_timeid')"); - } -} - -register_shutdown_function("arsc_shutdown"); - -include("../config.inc.php"); -include("../functions.inc.php"); -include("../filter.inc.php"); - -if ($arsc_my = arsc_getdatafromsid($arsc_sid)) -{ - include("../shared/language/".$arsc_my["language"].".inc.php"); - - $arsc_room = $arsc_my["room"]; - if ($arsc_lastid == "") - { - $arsc_result = mysql_query("SELECT * from arsc_room_$arsc_room ORDER BY timeid DESC"); - $arsc_b = mysql_fetch_array($arsc_result); - $arsc_lastid = $arsc_b["timeid"]; - } - - echo $arsc_parameters["htmlhead_js"]; - - set_magic_quotes_runtime(0); - @set_time_limit(0); - $arsc_sendtime = date("H:i:s"); - $arsc_timeid = arsc_microtime(); - $arsc_message = "/msg ".$arsc_my["user"]." ".$arsc_lang["welcome"]; - echo arsc_filter_posting("System", $arsc_sendtime, $arsc_message, $arsc_room, 0); - $i = 0; - while(!connection_aborted()) - { - $arsc_my = arsc_getdatafromsid($arsc_sid); - $arsc_room = $arsc_my["room"]; - if(!$arsc_result = mysql_query("SELECT * from arsc_room_$arsc_room ORDER BY timeid DESC")) - { - arsc_shutdown(); - die(); - } - $arsc_b = mysql_fetch_array($arsc_result); - if ($arsc_lastid == "") - { - $arsc_lastid = $arsc_b["timeid"]; - } - $arsc_lastid_save = $arsc_b["timeid"]; - if ($arsc_my["level"] < 0) - { - switch($arsc_my["level"]) - { - case "-1": echo arsc_filter_posting("System", date("H:i:s"), "<font size=\"4\"><b>".$arsc_lang["youwerekicked"]."</b></font>", $arsc_room, 0); - mysql_query("DELETE from arsc_users WHERE sid = '$arsc_sid'"); - break; - } - break; - } - - $i++; - $arsc_result = mysql_query("SELECT * from arsc_room_$arsc_room WHERE timeid > '$arsc_lastid' ORDER BY timeid ASC, id ASC"); - while ($arsc_a = mysql_fetch_array($arsc_result)) - { - $arsc_posting = arsc_filter_posting($arsc_a["user"], $arsc_a["sendtime"], $arsc_a["message"], $arsc_room, $arsc_a["flag_ripped"]); - echo "$arsc_posting"; - } - $arsc_lastid = $arsc_lastid_save; - $arsc_ping = time(); - $arsc_ip = getremoteaddr(); - mysql_query("UPDATE arsc_users SET lastping = '$arsc_ping', ip = '$arsc_ip' WHERE sid = '$arsc_sid'"); - echo " "; - flush(); - usleep($arsc_parameters["socketserver_refresh"]); - flush(); - flush(); - flush(); - flush(); - flush(); - // just to be sure :) - } -} -else -{ - echo $arsc_parameters["htmlhead_out"]; -} -?> diff --git a/mod/chat/gui_push_js/index.php b/mod/chat/gui_push_js/index.php deleted file mode 100644 index 6b1ff9c458..0000000000 --- a/mod/chat/gui_push_js/index.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php -include("../config.inc.php"); -include("../functions.inc.php"); -?> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> -<html> - <head> - <title> - ARSC - ARSC Really Simple Chat - </title> - </head> - <frameset cols="193,*,120" border="0" framespacing="no" frameborder="0" marginwidth="2" marginheight="1"> - <frame src="../shared/roomlist.php?arsc_sid=<?php echo $arsc_sid; ?>" name="roomlist" scrolling="auto" noresize marginwidth="0" marginheight="0"> - <frameset rows="1,*,40" border="1" framespacing="no" frameborder="0" marginwidth="2" marginheight="1"> - <frame src="../shared/empty.php" name="empty" scrolling="no" noresize marginwidth="0" marginheight="0"> - <frame src="chatmsg.php?arsc_sid=<?php echo $arsc_sid; ?>" name="msg" scrolling="auto" noresize marginwidth="2" marginheight="1"> - <frame src="chatinput.php?arsc_sid=<?php echo $arsc_sid; ?>" name="input" scrolling="no" noresize marginwidth="2" marginheight="1"> - </frameset> - <frame src="../shared/userlist.php?arsc_sid=<?php echo $arsc_sid; ?>&arsc_enter=true" name="users" scrolling="auto" noresize marginwidth="5" marginheight="5"> - </frameset> - <noframes> - Sorry, ARSC needs a browser that understands framesets. We have a Lynx friendly version too. - - diff --git a/mod/chat/gui_sockets/chatinput.php b/mod/chat/gui_sockets/chatinput.php index 1b896ca277..5183a84405 100644 --- a/mod/chat/gui_sockets/chatinput.php +++ b/mod/chat/gui_sockets/chatinput.php @@ -1,31 +1,31 @@ -chatid)) { - error("No chat found"); -} + if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) { + error('Not logged in!'); + } -require_login($chat->course); -optional_variable($chat_pretext, ''); + chat_force_language($chatuser->lang); ?> - + + Message Input -javascript"); ?> +javascript"); +?>