radical chat clean up, see forum for details

This commit is contained in:
skodak
2005-02-03 20:39:27 +00:00
parent 60ecca3a09
commit 516121bd0d
32 changed files with 668 additions and 1556 deletions
+3 -3
View File
@@ -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;
}
+5
View File
@@ -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;
}
+2
View File
@@ -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`),
+3 -1
View File
@@ -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);
+5 -1
View File
@@ -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;
}
?>
+2
View File
@@ -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)
);
-38
View File
@@ -1,38 +0,0 @@
<?php
include("../config.inc.php");
include("../functions.inc.php");
$arsc_result = mysql_query("SELECT COUNT(*) AS anzahl FROM arsc_users WHERE sid = '$arsc_sid'");
$arsc_a = mysql_fetch_array($arsc_result);
if ($arsc_a["anzahl"] == 1)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>
Abacho - Drawboard
</title>
</head>
<body bgcolor="#000000" topmargin="0" leftmargin="0" marginleft="0" margintop="0">
<applet code="drawboard/Main.class" width="<?php echo $arsc_parameters["drawboard_width"]; ?>" height="<?php echo $arsc_parameters["drawboard_height"]; ?>">
<param name="port" value="<?php echo $arsc_parameters["drawboard_port"]; ?>">
<param name="bgcolor" value="FFFFFF">
<param name="menubgcolor" value="FAE6A6">
<param name="emptythumbnailcolor" value="FDF0C6">
<param name="countercolor" value="000000">
<param name="pencolor" value="0000FF">
<param name="skindef" value="abacho/abacho.def">
Unfortunatelly, your browser doesn't support Java applets. You have to use another one.
</applet>
</body>
</html>
<?php
}
else
{
header("Location: ../shared/empty.php");
die();
}
?>
-33
View File
@@ -1,33 +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"];
?>
<form action="../shared/chatins.php" method="POST" name="f">
<input type="hidden" name="arsc_sid" value="<?php echo $arsc_sid; ?>" />
<input type="hidden" name="arsc_chatversion" value="header" />
<input type="text" name="arsc_message" size="50" maxlength="<?php echo $arsc_parameters["input_maxsize"]; ?>" value="<?php echo $arsc_pretext; ?>" />
<input type="submit" value="<?php echo $arsc_lang["sendmessage"]; ?>" />
</form>
</body>
</html>
<?php
}
else
{
echo $arsc_parameters["htmlhead_out"];
}
}
else
{
echo $arsc_parameters["htmlhead_out"];
}
?>
-74
View File
@@ -1,74 +0,0 @@
<?php
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_user = $arsc_my["user"];
$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"];
}
if ($arsc_my["level"] < 0)
{
switch($arsc_my["level"])
{
case "-1": $arsc_message = $arsc_lang["youwerekicked"];
mysql_query("DELETE from arsc_users WHERE sid = '$arsc_sid'");
break;
}
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");
echo $arsc_parameters["htmlhead"];
echo arsc_filter_posting("System", date("H:i:s"), "<font size=\"4\"><b>".$arsc_message."</b></font>", $arsc_room, 0);
?>
</body>
</html>
<?php
}
else
{
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: 4; url=chatmsg.php?arsc_sid=".$arsc_sid."&arsc_lastid=".$arsc_lastid."&dummy=".time()."#end");
echo $arsc_parameters["htmlhead"];
set_magic_quotes_runtime(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);
$arsc_result = mysql_query("SELECT * FROM arsc_room_$arsc_room WHERE timeid > '$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'");
?>
<a name="end"></a>
</body>
</html>
<?php
}
}
else
{
echo $arsc_parameters["htmlhead_out"];
}
?>
-23
View File
@@ -1,23 +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="*,40" border="1" framespacing="no" frameborder="0" marginwidth="2" marginheight="1">
<frame src="chatmsg.php?arsc_sid=<?php echo $arsc_sid; ?>#end" 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, this version of ARSC needs a browser that understands framesets. We have a Lynx friendly version too.
</noframes>
</html>
+41 -55
View File
@@ -1,64 +1,50 @@
<?php
<?php // $Id$
require("../../../config.php");
require("../lib.php");
$nomoodlecookie = true; // Session not needed!
require_variable($chat_sid);
optional_variable($groupid);
optional_variable($chat_pretext, '');
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);
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
error("No chat found");
}
require_login($chat->course);
if (!$chatuser = get_record('chat_users', 'sid', $chat_sid)) {
error('Not logged in!');
}
chat_force_language($chatuser->lang);
ob_start();
?>
<script type="text/javascript">
<!--
scroll_active = true;
function empty_field_and_submit() {
document.fdummy.chat_message.value=document.f.chat_message.value;
document.fdummy.submit();
document.f.chat_message.value='';
document.f.chat_message.focus();
return false;
}
// -->
</script>
<?php
$meta = ob_get_clean();
print_header('', '', '', 'f.chat_message', $meta, false);
?>
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">
<html>
<head>
<title>Message Input</title>
<?php include("$CFG->javascript"); ?>
<script language="Javascript">
<!--
scroll_active = true;
function empty_field_and_submit() {
document.fdummy.chat_message.value=document.f.chat_message.value;
document.fdummy.submit();
document.f.chat_message.value='';
document.f.chat_message.focus();
return false;
}
// -->
</script>
</head>
<body bgcolor="<?php echo $THEME->body ?>"
OnLoad="document.f.chat_message.focus();document.f.chat_message.select();">
<form action="../insert.php" method="GET" target="empty" name="f"
OnSubmit="return empty_field_and_submit()">
&gt;&gt;<input type="text" name="chat_message" size="60" value="<?php echo $chat_pretext; ?>" />
<?php helpbutton("chatting", get_string("helpchatting", "chat"), "chat", true, false); ?>
</form>
<form action="../insert.php" method="GET" target="empty" name="fdummy"
OnSubmit="return empty_field_and_submit()">
<input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
<input type="hidden" name="groupid" value="<?php echo $groupid ?>" />
<input type="hidden" name="chat_version" value="header_js" />
<input type="hidden" name="chat_message" />
</form>
<form action="insert.php" method="GET" target="empty" name="f"
OnSubmit="return empty_field_and_submit()">
&gt;&gt;<input type="text" name="chat_message" size="60" value="" />
<?php helpbutton('chatting', get_string('helpchatting', 'chat'), 'chat', true, false); ?>
</form>
<form action="insert.php" method="GET" target="empty" name="fdummy"
OnSubmit="return empty_field_and_submit()">
<input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
<input type="hidden" name="chat_message" />
</form>
</body>
</html>
</html>
+33 -31
View File
@@ -1,73 +1,75 @@
<?php
<?php // $Id$
require_once('../../../config.php');
require_once('../lib.php');
require_variable($id);
optional_variable($groupid, -1);
$id = required_param('id', PARAM_INT);
$groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
if (!$chat = get_record("chat", "id", $id)) {
error("Could not find that chat room!");
}
if (!$course = get_record("course", "id", $chat->course)) {
error("Could not find the course this belongs to!");
if (!$chat = get_record('chat', 'id', $id)) {
error('Could not find that chat room!');
}
if (!$cm = get_coursemodule_from_instance("chat", $chat->id, $course->id)) {
error("Course Module ID was incorrect");
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');
}
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&amp;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');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=<?php echo get_string('thischarset'); ?>" />
<title>
<?php echo "$strchat: $course->shortname: $chat->name$groupname" ?>
</title>
</head>
<frameset cols="*,200" border="5" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1">
<frameset rows="0,0,*,40" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
<frameset rows="0,0,*,50" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
<frame src="../empty.php" name="empty" scrolling="no" marginwidth="0" marginheight="0">
<frame src="jsupdate.php?<?php echo $params ?>" scrolling="no" marginwidth="0" marginheight="0">
<frame src="jsupdate.php?<?php echo $params ?>" name="jsupdate" scrolling="no" marginwidth="0" marginheight="0">
<frame src="chatmsg.php" name="msg" scrolling="auto" marginwidth="2" marginheight="1">
<frame src="chatinput.php?<?php echo $params ?>" name="input" scrolling="no" marginwidth="2" marginheight="1">
</frameset>
<frame src="../users.php?<?php echo $params ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5">
<frame src="users.php?<?php echo $params ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5">
</frameset>
<noframes>
Sorry, this version of Moodle Chat needs a browser that handles frames.
+65
View File
@@ -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');
?>
+93 -59
View File
@@ -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;
<!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 ($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');";
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>
+116
View File
@@ -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>';
?>
-177
View File
@@ -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;
}
}
-68
View File
@@ -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();
}
}
-90
View File
@@ -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);
}
}
}
}
-35
View File
@@ -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;
}
?>
-98
View File
@@ -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"];
}
?>
-24
View File
@@ -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.
</noframes>
</html>
+21 -26
View File
@@ -1,31 +1,31 @@
<?php
<?php // $Id$
require("../../../config.php");
require("../lib.php");
$nomoodlecookie = true; // Session not needed!
require_variable($chat_sid);
optional_variable($groupid);
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);
$groupid = optional_param('groupid', 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);
optional_variable($chat_pretext, '');
chat_force_language($chatuser->lang);
?>
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">
<!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'); ?>" />
<title>Message Input</title>
<?php include("$CFG->javascript"); ?>
<?php
$focus = '';
include("$CFG->javascript");
?>
<script type="text/javascript">
<!--
@@ -44,9 +44,9 @@ function empty_field_and_submit() {
function prepareusers() {
var frm = window.parent.frames;
for(i = 0; i < frm.length; ++i) {
if(frm(i).name == "users") {
window.userFrame = frm(i);
window.userHREF = frm(i).location.href;
if(frm[i]).name == "users") {
window.userFrame = frm[i];
window.userHREF = frm[i].location.href;
window.setTimeout("reloadusers();", <?php echo $CFG->chat_refresh_userlist; ?> * 1000);
}
}
@@ -63,17 +63,13 @@ function reloadusers() {
<body bgcolor="<?php echo $THEME->body ?>" onload="document.getElementById('inputform').chat_message.focus();document.getElementById('inputform').chat_message.select(); prepareusers();">
<!--
<form action="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport"; ?>" method="GET" target="empty" name="f" onsubmit="return empty_field_and_submit()">
-->
<form action="../insert.php" method="get" target="empty" id="inputform" onsubmit="return empty_field_and_submit();">
&gt;&gt; <input type="text" name="chat_message" size="60" value="<?php echo $chat_pretext; ?>" />
<form action="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport/"; ?>" method="get" target="empty" id="inputform" onsubmit="return empty_field_and_submit();">
&gt;&gt; <input type="text" name="chat_message" size="60" value="" />
<?php helpbutton("chatting", get_string("helpchatting", "chat"), "chat", true, false); ?>
</form>
<form action="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport/"; ?>" method="get" target="empty" id="sendform">
<input type="hidden" name="win" value="message" />
<input type="hidden" name="chat_version" value="sockets" />
<input type="hidden" name="chat_message" value="" />
<input type="hidden" name="chat_msgidnr" value="0" />
<input type="hidden" name="chat_sid" value="<?php echo $chat_sid ?>" />
@@ -82,4 +78,3 @@ function reloadusers() {
</body>
</html>
+21 -19
View File
@@ -1,9 +1,10 @@
<?php
<?php // $Id$
require_once('../../../config.php');
require_once('../lib.php');
require_variable($id);
optional_variable($groupid, -1);
$id = required_param('id', PARAM_INT);
$groupid = optional_param('groupid', 0, PARAM_INT); //only for teachers
if (!$chat = get_record('chat', 'id', $id)) {
error('Could not find that chat room!');
@@ -23,30 +24,34 @@
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, 'sockets', $currentgroup)) {
error("Could not log in to chat room!!");
chat_delete_old_users();
if (!$chat_sid = chat_login_user($chat->id, 'sockets', $groupid, $course)) {
error('Could not log in to chat room!!');
}
if ($currentgroup !== false) {
$params = "chat_enter=true&amp;chat_sid=$chat_sid&amp;groupid=$currentgroup";
} else {
$params = "chat_enter=true&amp;chat_sid=$chat_sid&amp;groupid=0";
}
$params = "chat_sid=$chat_sid&amp;groupid=$groupid";
$strchat = get_string("modulename", "chat");
@@ -61,15 +66,12 @@
</title>
</head>
<frameset cols="*,200" border="5" framespacing="no" frameborder="yes" marginwidth="2" marginheight="1">
<frameset rows="0,*,40" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
<frameset rows="0,*,50" border="0" framespacing="no" frameborder="no" marginwidth="2" marginheight="1">
<frame src="empty.php" name="empty" scrolling="auto" noresize marginwidth="2" marginheight="0">
<frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=chat&amp;$params"; ?>" name="msg" scrolling="auto" noresize marginwidth="2" marginheight="0">
<frame src="chatinput.php?<?php echo $params ?>" name="input" scrolling="no" marginwidth="2" marginheight="1">
</frameset>
<frame src="<?php echo "http://$CFG->chat_serverhost:$CFG->chat_serverport?win=users&amp;$params"; ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5">
<!--
<frame src="../users.php?<?php echo $params ?>" name="users" scrolling="auto" marginwidth="5" marginheight="5">
-->
</frameset>
<noframes>
Sorry, this version of Moodle Chat needs a browser that handles frames.
-122
View File
@@ -1,122 +0,0 @@
<?php
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_user = $arsc_my["user"];
$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"];
}
if ($arsc_my["level"] < 0)
{
switch($arsc_my["level"])
{
case "-1": $arsc_message = $arsc_lang["youwerekicked"];
mysql_query("DELETE from arsc_users WHERE sid = '$arsc_sid'");
break;
}
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");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<body>
<?php echo arsc_filter_posting("System", date("H:i:s"), "<font size=\"4\"><b>".$arsc_message."</b></font>", $arsc_room, 0); ?>
</body>
</html>
<?php
}
else
{
if ($arsc_enter == "true")
{
$arsc_sendtime = date("H:i:s");
$arsc_timeid = arsc_microtime();
$arsc_message = "arsc_user_enter~~".$arsc_my["user"]."~~".arsc_nice_room($arsc_room);
mysql_query("INSERT into arsc_room_$arsc_room (message, user, sendtime, timeid) VALUES ('$arsc_message', 'System', '$arsc_sendtime', '$arsc_timeid')");
}
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");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>
<?php echo $arsc_parameters["title"]; ?>
</title>
</head>
<body>
<form action="../shared/chatins.php" method="POST">
<a href="index.php?arsc_sid=<?php echo $arsc_sid; ?>&arsc_lastid=<?php echo $arsc_lastid; ?>"><?php echo $arsc_lang["refreshmessages"]; ?></a>
<input type="hidden" name="arsc_sid" value="<?php echo $arsc_sid; ?>" />
<input type="hidden" name="arsc_lastid" value="<?php echo $arsc_lastid; ?>" />
<input type="hidden" name="arsc_chatversion" value="text" />
<input type="text" name="arsc_message" size="30" maxlength="<?php echo $arsc_parameters["input_maxsize"]; ?>" value="<?php echo $arsc_pretext; ?>" />
<input type="submit" value="<?php echo $arsc_lang["sendmessage"]; ?>" />
&nbsp;&nbsp;&nbsp;<a href="../logout.php?arsc_sid=<?php echo $arsc_sid; ?>"><?php echo $arsc_lang["leave"]; ?></a>
</form>
<?php
set_magic_quotes_runtime(0);
echo $arsc_lang["usersinroom"]." ".arsc_nice_room($arsc_room).": ";
$arsc_result = mysql_query("SELECT user, level from arsc_users WHERE room = '$arsc_room' ORDER BY level DESC, user ASC");
while ($arsc_a = mysql_fetch_array($arsc_result))
{
$arsc_opstring = "";
if ($arsc_a["level"] == 1)
{
$arsc_opstring = "@";
}
if ($arsc_a["level"] == 2)
{
$arsc_opstring = "<b>@</b>";
}
if ($arsc_a["user"] == $arsc_my["user"])
{
echo "<i>".$arsc_opstring.$arsc_a["user"]."</i>\n";
}
else
{
echo "<a href=\"../version_".$arsc_my["version"]."/index.php?arsc_sid=".$arsc_my["sid"]."&arsc_lastid=".$arsc_lastid."&arsc_pretext=".urlencode("/msg ".$arsc_a["user"]." ")."\">".$arsc_opstring.$arsc_a["user"]."</a>\n";
}
}
echo "<br />";
$arsc_result = mysql_query("SELECT * from arsc_room_$arsc_room WHERE timeid > '$arsc_lastid' ORDER BY timeid DESC");
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_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);
$arsc_ping = time();
$arsc_ip = getremoteaddr();
mysql_query("UPDATE arsc_users SET lastping = '$arsc_ping', ip = '$arsc_ip' WHERE user = '$arsc_user'");
?>
</body>
</html>
<?php
}
}
else
{
echo $arsc_htmlhead_out;
}
?>
+26 -26
View File
@@ -1,55 +1,55 @@
<?php // $Id$
require_once("../../config.php");
require_once("lib.php");
require_once('../../config.php');
require_once('lib.php');
require_variable($id); // course
$id = required_param('id', PARAM_INT); // course
if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect");
if (! $course = get_record('course', 'id', $id)) {
error('Course ID is incorrect');
}
require_course_login($course);
add_to_log($course->id, "chat", "view all", "index.php?id=$course->id", "");
add_to_log($course->id, 'chat', 'view all', "index.php?id=$course->id", '');
/// Get all required strings
$strchats = get_string("modulenameplural", "chat");
$strchat = get_string("modulename", "chat");
$strchats = get_string('modulenameplural', 'chat');
$strchat = get_string('modulename', 'chat');
/// Print the header
print_header_simple($strchats, "", $strchats, "", "", true, "", navmenu($course));
print_header_simple($strchats, '', $strchats, '', '', true, '', navmenu($course));
/// Get all the appropriate data
if (! $chats = get_all_instances_in_course("chat", $course)) {
notice("There are no chats", "../../course/view.php?id=$course->id");
die;
if (! $chats = get_all_instances_in_course('chat', $course)) {
notice('There are no chats', "../../course/view.php?id=$course->id");
die();
}
/// Print the list of instances (your module will probably extend this)
$timenow = time();
$strname = get_string("name");
$strweek = get_string("week");
$strtopic = get_string("topic");
$timenow = time();
$strname = get_string('name');
$strweek = get_string('week');
$strtopic = get_string('topic');
if ($course->format == "weeks") {
if ($course->format == 'weeks') {
$table->head = array ($strweek, $strname);
$table->align = array ("center", "left");
} else if ($course->format == "topics") {
$table->align = array ('center', 'left');
} else if ($course->format == 'topics') {
$table->head = array ($strtopic, $strname);
$table->align = array ("center", "left", "left", "left");
$table->align = array ('center', 'left', 'left', 'left');
} else {
$table->head = array ($strname);
$table->align = array ("left", "left", "left");
$table->align = array ('left', 'left', 'left');
}
$currentsection = "";
$currentsection = '';
foreach ($chats as $chat) {
if (!$chat->visible) {
//Show dimmed if the mod is hidden
@@ -58,24 +58,24 @@
//Show normal if the mod is visible
$link = "<a href=\"view.php?id=$chat->coursemodule\">$chat->name</a>";
}
$printsection = "";
$printsection = '';
if ($chat->section !== $currentsection) {
if ($chat->section) {
$printsection = $chat->section;
}
if ($currentsection !== "") {
if ($currentsection !== '') {
$table->data[] = 'hr';
}
$currentsection = $chat->section;
}
if ($course->format == "weeks" or $course->format == "topics") {
if ($course->format == 'weeks' or $course->format == 'topics') {
$table->data[] = array ($printsection, $link);
} else {
$table->data[] = array ($link);
}
}
echo "<br />";
echo '<br />';
print_table($table);
-69
View File
@@ -1,69 +0,0 @@
<?php
include("../../config.php");
include("lib.php");
require_variable($chat_sid);
require_variable($chat_version);
require_variable($chat_message);
optional_variable($groupid);
if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
echo "Not logged in!";
die;
}
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
error("No chat found");
}
require_login($chat->course);
if ($groupid) {
if (!isteacheredit($chat->course) and !ismember($groupid)) {
error("You can't chat here!");
}
}
/// 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 = $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, $chat->course)) {
add_to_log($chat->course, "chat", "talk", "view.php?id=$cm->id", $chat->id, $cm->id);
}
}
/// Go back to the other page
if ($chat_version == "header" OR $chat_version == "box") {
redirect("../gui_$chat_version/chatinput.php?chat_sid=$chat_sid&amp;groupid=$groupid");
} else if ($chat_version == 'sockets') {
//redirect('./gui_sockets/chatinput.php?chat_sid='.$chat_sid.'&amp;groupid='.$groupid);
} else if ($chat_version == "text") {
redirect("../gui_$chat_version/index.php?chat_sid=$chat_sid&chat_lastid=$chat_lastid&amp;groupid=$groupid");
} else {
redirect("empty.php");
}
?>
+71 -202
View File
@@ -27,8 +27,6 @@ if (!isset($CFG->chat_servermax)) {
set_config("chat_servermax", 100);
}
define("CHAT_DRAWBOARD", false); // Look into this later
global $THEME;
// The HTML head for the message window to start with (<!-- nix --> is used to get some browsers starting with output
@@ -293,6 +291,20 @@ function chat_refresh_events($courseid = 0) {
return true;
}
function chat_force_language($lang) {
/// This function prepares moodle to operate in given language
/// usable when $nomoodlecookie = true;
/// BEWARE: there must be no $course, $USER or $SESSION
if(!empty($CFG->courselang)) {
uset($CFG->courselang);
}
if(!empty($CFG->locale)) {
uset($CFG->locale);
}
$CFG->lang = clean_filename($lang);
moodle_setlocale();
}
//////////////////////////////////////////////////////////////////////
/// Functions that require some SQL
@@ -343,20 +355,50 @@ function chat_get_latest_message($chatid, $groupid=0) {
//////////////////////////////////////////////////////////////////////
// login if not already logged in
function chat_login_user($chatid, $version="header_js", $groupid=0) {
function chat_login_user($chatid, $version, $groupid, $course) {
global $USER;
$chatuser->chatid = $chatid;
$chatuser->userid = $USER->id;
$chatuser->groupid = $groupid;
$chatuser->version = $version;
$chatuser->ip = $USER->lastIP;
$chatuser->lastping = $chatuser->firstping = $chatuser->lastmessageping = time();
$chatuser->sid = random_string(32);
if ($chatuser = get_record_select('chat_users', "chatid='$chatid' AND userid='$USER->id' AND groupid='$groupid' LIMIT 1")) {
$chatuser->version = $version;
$chatuser->ip = $USER->lastIP;
$chatuser->lastping = time();
$chatuser->lang = current_language();
if (!insert_record("chat_users", $chatuser)) {
return false;
if (($chatuser->course != $course->id)
or ($chatuser->userid != $USER->id)) {
return false;
}
if (!update_record('chat_users', $chatuser)) {
return false;
}
} else {
$chatuser->chatid = $chatid;
$chatuser->userid = $USER->id;
$chatuser->groupid = $groupid;
$chatuser->version = $version;
$chatuser->ip = $USER->lastIP;
$chatuser->lastping = $chatuser->firstping = $chatuser->lastmessageping = time();
$chatuser->sid = random_string(32);
$chatuser->course = $course->id; //caching only, but needed for current_language() to work properly!
$chatuser->lang = current_language();
if (!insert_record('chat_users', $chatuser)) {
return false;
}
$message->chatid = $chatuser->chatid;
$message->userid = $chatuser->userid;
$message->groupid = $groupid;
$message->message = 'enter';
$message->system = 1;
$message->timestamp = time();
if (!insert_record('chat_messages', $message)) {
error('Could not insert a chat message!');
}
}
return $chatuser->sid;
@@ -370,18 +412,18 @@ function chat_delete_old_users() {
$timeold = time() - $CFG->chat_old_ping;
$query = "lastping < '$timeold'";
if ($oldusers = get_records_select("chat_users", $query) ) {
delete_records_select("chat_users", $query);
if ($oldusers = get_records_select('chat_users', $query) ) {
delete_records_select('chat_users', $query);
foreach ($oldusers as $olduser) {
$message->chatid = $olduser->chatid;
$message->userid = $olduser->userid;
$message->groupid = $olduser->groupid;
$message->message = "exit";
$message->system = 1;
$message->chatid = $olduser->chatid;
$message->userid = $olduser->userid;
$message->groupid = $olduser->groupid;
$message->message = 'exit';
$message->system = 1;
$message->timestamp = time();
if (!insert_record("chat_messages", $message)) {
error("Could not insert a chat message!");
if (!insert_record('chat_messages', $message)) {
error('Could not insert a chat message!');
}
}
}
@@ -428,182 +470,6 @@ function chat_update_chat_times($chatid=0) {
}
function chat_browser_detect($HTTP_USER_AGENT) {
if(eregi("(opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}", $HTTP_USER_AGENT, $match)
|| eregi("(opera/)([0-9]{1,2}.[0-9]{1,3}){0,1}", $HTTP_USER_AGENT, $match))
{
$BName = "Opera"; $BVersion=$match[2];
}
elseif( eregi("(konqueror)/([0-9]{1,2}.[0-9]{1,3})", $HTTP_USER_AGENT, $match) )
{
$BName = "Konqueror"; $BVersion=$match[2];
}
elseif( eregi("(lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})", $HTTP_USER_AGENT, $match) )
{
$BName = "Lynx"; $BVersion=$match[2];
}
elseif( eregi("(links) \(([0-9]{1,2}.[0-9]{1,3})", $HTTP_USER_AGENT, $match) )
{
$BName = "Links"; $BVersion=$match[2];
}
elseif( eregi("(msie) ([0-9]{1,2}.[0-9]{1,3})", $HTTP_USER_AGENT, $match) )
{
$BName = "MSIE"; $BVersion=$match[2];
}
elseif( eregi("(netscape6)/(6.[0-9]{1,3})", $HTTP_USER_AGENT, $match) )
{
$BName = "Netscape"; $BVersion=$match[2];
}
elseif( eregi("mozilla/5", $HTTP_USER_AGENT) )
{
$BName = "Netscape"; $BVersion="Unknown";
}
elseif( eregi("(mozilla)/([0-9]{1,2}.[0-9]{1,3})", $HTTP_USER_AGENT, $match) )
{
$BName = "Netscape"; $BVersion=$match[2];
}
elseif( eregi("w3m", $HTTP_USER_AGENT) )
{
$BName = "w3m"; $BVersion="Unknown";
}
else
{
$BName = "Unknown"; $BVersion="Unknown";
}
if(eregi("linux", $HTTP_USER_AGENT))
{
$BPlatform = "Linux";
}
elseif( eregi("win32", $HTTP_USER_AGENT) )
{
$BPlatform = "Windows";
}
elseif( (eregi("(win)([0-9]{2})", $HTTP_USER_AGENT, $match) )
|| (eregi("(windows) ([0-9]{2})", $HTTP_USER_AGENT, $match) ))
{
$BPlatform = "Windows $match[2]";
}
elseif( eregi("(winnt)([0-9]{1,2}.[0-9]{1,2}){0,1}", $HTTP_USER_AGENT, $match) )
{
$BPlatform = "Windows NT $match[2]";
}
elseif( eregi("(windows nt)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1}", $HTTP_USER_AGENT, $match) )
{
$BPlatform = "Windows NT $match[3]";
}
elseif( eregi("mac", $HTTP_USER_AGENT) )
{
$BPlatform = "Macintosh";
}
elseif( eregi("(sunos) ([0-9]{1,2}.[0-9]{1,2}){0,1}", $HTTP_USER_AGENT, $match) )
{
$BPlatform = "SunOS $match[2]";
}
elseif( eregi("(beos) r([0-9]{1,2}.[0-9]{1,2}){0,1}", $HTTP_USER_AGENT, $match) )
{
$BPlatform = "BeOS $match[2]";
}
elseif( eregi("freebsd", $HTTP_USER_AGENT) )
{
$BPlatform = "FreeBSD";
}
elseif( eregi("openbsd", $HTTP_USER_AGENT) )
{
$BPlatform = "OpenBSD";
}
elseif( eregi("irix", $HTTP_USER_AGENT) )
{
$BPlatform = "IRIX";
}
elseif( eregi("os/2", $HTTP_USER_AGENT) )
{
$BPlatform = "OS/2";
}
elseif( eregi("plan9", $HTTP_USER_AGENT) )
{
$BPlatform = "Plan9";
}
elseif( eregi("unix", $HTTP_USER_AGENT)
|| eregi("hp-ux", $HTTP_USER_AGENT) )
{
$BPlatform = "Unix";
}
elseif( eregi("osf", $HTTP_USER_AGENT) )
{
$BPlatform = "OSF";
}
else
{
$BPlatform = "Unknown";
}
$return["name"] = $BName;
$return["version"] = $BVersion;
$return["platform"] = $BPlatform;
return $return;
}
function chat_display_version($version, $browser)
{
GLOBAL $CFG;
$checked = "";
if (($version == "sockets") OR ($version == "push_js"))
{
$checked = "checked";
}
if (($version == "sockets" OR $version == "push_js")
AND
($browser["name"] == "Lynx"
OR
$browser["name"] == "Links"
OR
$browser["name"] == "w3m"
OR
$browser["name"] == "Konqueror"
OR
($browser["name"] == "Netscape" AND substr($browser["version"], 0, 1) == "2")))
{
$checked = "";
}
if (($version == "text")
AND
($browser["name"] == "Lynx"
OR
$browser["name"] == "Links"
OR
$browser["name"] == "w3m"))
{
$checked = "checked";
}
if (($version == "header")
AND
($browser["name"] == "Konqueror"))
{
$checked = "checked";
}
if (($version == "header_js")
AND
($browser["name"] == "Netscape" AND substr($browser["version"], 0, 1) == "2"))
{
$checked = "checked";
}
?>
<tr>
<td valign="top">
<input type="radio" name="chat_chatversion" value="<?php echo $version; ?>"<?php echo $checked; ?> />
</td>
<td valign="top" align="left">
<font face="Arial" size="2">
<?php echo $chat_lang["gui_".$version]; ?>
</font>
</td>
</tr>
<?php
}
function chat_language_override($language) {
// Override the highest-ranking language variable from current_language()
@@ -629,7 +495,8 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
global $CFG;
$output = New stdClass;
$output->beep = false; // by default
$output->beep = false; // by default
$output->refreshusers = false; // by default
if(empty($language)) {
$language = current_language();
@@ -656,6 +523,10 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
$output->html = '<table><tr><td style="vertical-align: top;">'.$message->picture.'</td><td>';
$output->html .= '<font size="2" color="#ccaaaa">'.$output->text.'</font></td></tr></table>';
if($message->message == 'exit' or $message->message == 'enter') {
$output->refreshusers = true; //force user panel refresh ASAP
}
// Don't forget to reset the language before returning!!!
if(!empty($oldcfglang)) {
$CFG->courselang = $oldcfglang;
@@ -728,18 +599,16 @@ function chat_format_message_manually($message, $courseid, $sender, $currentuser
return $output;
}
function chat_format_message($message, $courseid=0) {
function chat_format_message($message, $courseid, $currentuser) {
/// Given a message object full of information, this function
/// formats it appropriately into text and html, then
/// returns the formatted data.
global $CFG, $USER;
if (!$user = get_record("user", "id", $message->userid)) {
return "Error finding user id = $message->userid";
}
return chat_format_message_manually($message, $courseid, $user, $USER);
return chat_format_message_manually($message, $courseid, $user, $currentuser);
}
+43 -43
View File
@@ -1,9 +1,9 @@
<?php
<?php // $Id$
if (!isset($form->name)) {
$form->name = "";
$form->name = '';
}
if (!isset($form->intro)) {
$form->intro = "";
$form->intro = '';
}
if (!isset($form->keepdays)) {
$form->keepdays = 30;
@@ -21,75 +21,75 @@
<form name="form" method="post" action="mod.php">
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string("chatname", "chat")?>:</b></td>
<td align="right"><b><?php print_string('chatname', 'chat')?>:</b></td>
<td>
<input type="text" name="name" size="30" value="<?php p($form->name) ?>" alt="<?php print_string('chatname', 'chat') ?>" />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("chatintro", "chat")?>:</b><br /><br />
<td align="right"><b><?php print_string('chatintro', 'chat')?>:</b><br /><br />
<?php
helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
echo "<br />";
helpbutton("questions", get_string("helpquestions"), "moodle", true, true);
echo "<br />";
emoticonhelpbutton("form", "intro");
echo "<br />";
helpbutton('writing', get_string('helpwriting'), 'moodle', true, true);
echo '<br />';
helpbutton('questions', get_string('helpquestions'), 'moodle', true, true);
echo '<br />';
emoticonhelpbutton('form', 'intro');
echo '<br />';
?>
</td>
<td>
<?php print_textarea($usehtmleditor, 20, 50, 680, 400, "intro", $form->intro); ?>
<?php print_textarea($usehtmleditor, 20, 50, 680, 400, 'intro', $form->intro); ?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("chattime", "chat") ?>:</b></td>
<td align="right"><b><?php print_string('chattime', 'chat') ?>:</b></td>
<td><?php
print_date_selector("chatday", "chatmonth", "chatyear", $form->chattime);
echo "&nbsp;-&nbsp;";
print_time_selector("chathour", "chatminute", $form->chattime);
print_date_selector('chatday', 'chatmonth', 'chatyear', $form->chattime);
echo '&nbsp;-&nbsp;';
print_time_selector('chathour', 'chatminute', $form->chattime);
?></td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("repeattimes", "chat") ?>:</b></td>
<td align="right"><b><?php print_string('repeattimes', 'chat') ?>:</b></td>
<td><?php
unset($options);
$options[0] = get_string("donotusechattime", "chat");
$options[1] = get_string("repeatnone", "chat");
$options[2] = get_string("repeatdaily", "chat");
$options[3] = get_string("repeatweekly", "chat");
choose_from_menu ($options, "schedule", $form->schedule, "", "", "");
$options[0] = get_string('donotusechattime', 'chat');
$options[1] = get_string('repeatnone', 'chat');
$options[2] = get_string('repeatdaily', 'chat');
$options[3] = get_string('repeatweekly', 'chat');
choose_from_menu ($options, 'schedule', $form->schedule, '', '', '');
?></td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("savemessages", "chat")?>:</b></td>
<td align="right"><b><?php print_string('savemessages', 'chat')?>:</b></td>
<td>
<?php
unset($options);
$options[0] = get_string("neverdeletemessages", "chat");
$options[365] = get_string("numdays", "", 365);
$options[180] = get_string("numdays", "", 180);
$options[150] = get_string("numdays", "", 150);
$options[120] = get_string("numdays", "", 120);
$options[90] = get_string("numdays", "", 90);
$options[60] = get_string("numdays", "", 60);
$options[30] = get_string("numdays", "", 30);
$options[21] = get_string("numdays", "", 21);
$options[14] = get_string("numdays", "", 14);
$options[7] = get_string("numdays", "", 7);
$options[2] = get_string("numdays", "", 2);
$options[0] = get_string('neverdeletemessages', 'chat');
$options[365] = get_string('numdays', '', 365);
$options[180] = get_string('numdays', '', 180);
$options[150] = get_string('numdays', '', 150);
$options[120] = get_string('numdays', '', 120);
$options[90] = get_string('numdays', '', 90);
$options[60] = get_string('numdays', '', 60);
$options[30] = get_string('numdays', '', 30);
$options[21] = get_string('numdays', '', 21);
$options[14] = get_string('numdays', '', 14);
$options[7] = get_string('numdays', '', 7);
$options[2] = get_string('numdays', '', 2);
choose_from_menu ($options, "keepdays", $form->keepdays, "", "", "");
choose_from_menu ($options, 'keepdays', $form->keepdays, '', '', '');
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("studentseereports", "chat")?>:</b></td>
<td align="right"><b><?php print_string('studentseereports', 'chat')?>:</b></td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "studentlogs", $form->studentlogs, "", "", "");
$options[0] = get_string('no');
$options[1] = get_string('yes');
choose_from_menu ($options, 'studentlogs', $form->studentlogs, '', '', '');
?>
</td>
</tr>
@@ -104,7 +104,7 @@
<input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
<input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
<input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
<input type="submit" value="<?php print_string('savechanges') ?>" />
<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
</center>
</form>
</form>
+66 -64
View File
@@ -2,82 +2,86 @@
/// This page prints reports and info about chats
require_once("../../config.php");
require_once("lib.php");
require_once('../../config.php');
require_once('lib.php');
require_variable($id); // Course module ID
optional_variable($groupid, ""); // Group
optional_variable($start, ""); // Start of period
optional_variable($end, ""); // End of period
optional_variable($deletesession, ""); // Delete a session
optional_variable($confirmdelete, ""); // End of period
$id = required_param('id', PARAM_INT);
$start = optional_param('start', 0, PARAM_INT); // Start of period
$end = optional_param('end', 0, PARAM_INT); // End of period
$deletesession = optional_param('deletesession', 0, PARAM_BOOL);
$confirmdelete = optional_param('confirmdelete', 0, PARAM_BOOL);
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
if (! $cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID was incorrect');
}
if (! $chat = get_record("chat", "id", $cm->instance)) {
error("Course module is incorrect");
if (! $chat = get_record('chat', 'id', $cm->instance)) {
error('Course module is incorrect');
}
if (! $course = get_record("course", "id", $chat->course)) {
error("Course is misconfigured");
if (! $course = get_record('course', 'id', $chat->course)) {
error('Course is misconfigured');
}
require_login($course->id);
$isteacher = isteacher($course->id);
$isteacher = isteacher($course->id);
$isteacheredit = isteacheredit($course->id);
if (isguest() or (!$isteacher and !$chat->studentlogs)) {
error("You can not view these chat reports");
error('You can not view these chat reports');
}
add_to_log($course->id, "chat", "report", "report.php?id=$cm->id", "$chat->id", "$cm->id");
add_to_log($course->id, 'chat', 'report', "report.php?id=$cm->id", $chat->id, $cm->id);
$strchats = get_string("modulenameplural", "chat");
$strchat = get_string("modulename", "chat");
$strchatreport = get_string("chatreport", "chat");
$strseesession = get_string("seesession", "chat");
$strdeletesession = get_string("deletesession", "chat");
$strchats = get_string('modulenameplural', 'chat');
$strchat = get_string('modulename', 'chat');
$strchatreport = get_string('chatreport', 'chat');
$strseesession = get_string('seesession', 'chat');
$strdeletesession = get_string('deletesession', 'chat');
/// Print a session if one has been specified
if ($start and $end and !$confirmdelete) { // Show a full transcript
if (!empty($groupid)) {
$groupselect = " AND groupid = '$currentgroup'";
$groupparam = "&amp;groupid=$currentgroup";
print_header_simple("$chat->name: $strchatreport", '',
"<a href=\"index.php?id=$course->id\">$strchats</a> ->
<a href=\"view.php?id=$cm->id\">$chat->name</a> ->
<a href=\"report.php?id=$cm->id\">$strchatreport</a>",
'', '', true, '', navmenu($course, $cm));
/// Check to see if groups are being used here
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
$currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id=$cm->id");
} else {
$groupselect = "";
$groupparam = "";
$currentgroup = false;
}
print_header_simple("$chat->name: $strchatreport", "",
"<a href=\"index.php?id=$course->id\">$strchats</a> ->
<a href=\"view.php?id=$cm->id\">$chat->name</a> ->
<a href=\"report.php?id=$cm->id\">$strchatreport</a>",
"", "", true, "", navmenu($course, $cm));
if (!empty($currentgroup)) {
$groupselect = " AND groupid = '$currentgroup'";
} else {
$groupselect = "";
}
if ($deletesession and $isteacheredit) {
notice_yesno(get_string("deletesessionsure", "chat"),
"report.php?id=$cm->id&amp;deletesession=1&amp;confirmdelete=1&amp;start=$start&amp;end=$end$groupparam",
notice_yesno(get_string('deletesessionsure', 'chat'),
"report.php?id=$cm->id&amp;deletesession=1&amp;confirmdelete=1&amp;start=$start&amp;end=$end&amp;sesskey=$USER->sesskey",
"report.php?id=$cm->id");
}
if (!$messages = get_records_select("chat_messages", "chatid = $chat->id AND
timestamp >= '$start' AND
if (!$messages = get_records_select('chat_messages', "chatid = $chat->id AND
timestamp >= '$start' AND
timestamp <= '$end' $groupselect", "timestamp ASC")) {
print_heading(get_string("nomessages", "chat"));
print_heading(get_string('nomessages', 'chat'));
} else {
echo "<p align=\"center\">".userdate($start)." --> ". userdate($end)."</p>";
echo '<p align="center">'.userdate($start).' --> '. userdate($end).'</p>';
print_simple_box_start("center");
print_simple_box_start('center');
foreach ($messages as $message) { // We are walking FORWARDS through messages
$formatmessage = chat_format_message($message, $course->id);
$formatmessage = chat_format_message($message, $course->id, $USER);
echo $formatmessage->html;
}
print_simple_box_end("center");
print_simple_box_end('center');
}
if (!$deletesession or !$isteacheredit) {
@@ -91,12 +95,12 @@
/// Print the Sessions display
print_header_simple("$chat->name: $strchatreport", "",
"<a href=\"index.php?id=$course->id\">$strchats</a> ->
<a href=\"view.php?id=$cm->id\">$chat->name</a> -> $strchatreport",
"", "", true, "", navmenu($course, $cm));
print_header_simple("$chat->name: $strchatreport", '',
"<a href=\"index.php?id=$course->id\">$strchats</a> ->
<a href=\"view.php?id=$cm->id\">$chat->name</a> -> $strchatreport",
'', '', true, '', navmenu($course, $cm));
print_heading($chat->name.": ".get_string("sessions", "chat"));
print_heading($chat->name.': '.get_string('sessions', 'chat'));
/// Check to see if groups are being used here
@@ -108,20 +112,18 @@
if (!empty($currentgroup)) {
$groupselect = " AND groupid = '$currentgroup'";
$groupparam = "&amp;groupid=$currentgroup";
} else {
$groupselect = "";
$groupparam = "";
}
/// Delete a session if one has been specified
if ($deletesession and $isteacheredit and $confirmdelete and $start and $end) {
delete_records_select("chat_messages", "chatid = $chat->id AND
timestamp >= '$start' AND
if ($deletesession and $isteacheredit and $confirmdelete and $start and $end and confirm_sesskey()) {
delete_records_select('chat_messages', "chatid = $chat->id AND
timestamp >= '$start' AND
timestamp <= '$end' $groupselect");
$strdeleted = get_string("deleted");
notify("$strdeleted: ".userdate($start)." --> ". userdate($end));
$strdeleted = get_string('deleted');
notify("$strdeleted: ".userdate($start).' --> '. userdate($end));
unset($deletesession);
}
@@ -129,8 +131,8 @@
/// Get the messages
if (empty($messages)) { /// May have already got them above
if (!$messages = get_records_select("chat_messages", "chatid = '$chat->id' $groupselect", "timestamp DESC")) {
print_heading(get_string("nomessages", "chat"));
if (!$messages = get_records_select('chat_messages', "chatid = '$chat->id' $groupselect", "timestamp DESC")) {
print_heading(get_string('nomessages', 'chat'));
print_footer($course);
exit;
}
@@ -164,30 +166,30 @@
$sessionusers[$message->userid] ++;
}
}
} else {
} else {
$sessionstart = $lasttime;
if ($sessionend - $sessionstart > 60 and count($sessionusers) > 1) {
echo "<p align=\"center\">".userdate($sessionstart)." --> ". userdate($sessionend)."</p>";
echo '<p align="center">'.userdate($sessionstart).' --> '. userdate($sessionend).'</p>';
print_simple_box_start("center");
print_simple_box_start('center');
arsort($sessionusers);
foreach ($sessionusers as $sessionuser => $usermessagecount) {
if ($user = get_record("user", "id", $sessionuser)) {
if ($user = get_record('user', 'id', $sessionuser)) {
print_user_picture($user->id, $course->id, $user->picture);
echo "&nbsp;".fullname($user, $isteacher);
echo '&nbsp;'.fullname($user, $isteacher);
echo "&nbsp;($usermessagecount)<br />";
}
}
echo "<p align=\"right\">";
echo "<a href=\"report.php?id=$cm->id&amp;start=$sessionstart&amp;end=$sessionend$groupparam\">$strseesession</a>";
echo '<p align="right">';
echo "<a href=\"report.php?id=$cm->id&amp;start=$sessionstart&amp;end=$sessionend\">$strseesession</a>";
if ($isteacheredit) {
echo "<br /><a href=\"report.php?id=$cm->id&amp;start=$sessionstart&amp;end=$sessionend&amp;deletesession=1$groupparam\">$strdeletesession</a>";
echo "<br /><a href=\"report.php?id=$cm->id&amp;start=$sessionstart&amp;end=$sessionend&amp;deletesession=1\">$strdeletesession</a>";
}
echo "</p>";
echo '</p>';
print_simple_box_end();
}
-110
View File
@@ -1,110 +0,0 @@
<?php
include("../../config.php");
include("lib.php");
require_variable($chat_sid);
optional_variable($groupid, 0);
if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
echo "Not logged in!";
die;
}
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
error("No chat found");
}
require_login($chat->course);
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
error("Could not find chat! id = $chatuser->chatid");
}
if (isset($_GET['chat_enter'])) {
$message->chatid = $chatuser->chatid;
$message->userid = $chatuser->userid;
$message->groupid = $groupid;
$message->message = "enter";
$message->system = 1;
$message->timestamp = time();
if (!insert_record("chat_messages", $message)) {
error("Could not insert a chat message!");
}
}
if (isset($_GET['beep'])) {
$message->chatid = $chatuser->chatid;
$message->userid = $chatuser->userid;
$message->groupid = $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 ;-)
update_record("chat_users", $chatuser);
}
$chatuser->lastping = time();
update_record("chat_users", $chatuser);
/// Delete users who are using text version and are old
chat_delete_old_users();
/// Print headers
header("Expires: Wed, 4 Oct 1978 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_userlist; url=users.php?chat_sid=$chat_sid&groupid=$groupid");
print_header();
$timenow = time();
$stridle = get_string("idle", "chat");
$strbeep = get_string("beep", "chat");
$str->day = get_string("day");
$str->days = get_string("days");
$str->hour = get_string("hour");
$str->hours = get_string("hours");
$str->min = get_string("min");
$str->mins = get_string("mins");
$str->sec = get_string("sec");
$str->secs = get_string("secs");
/// Get list of users
if (!$chatusers = chat_get_users($chatuser->chatid, $groupid)) {
print_string("errornousers", "chat");
exit;
}
echo "<table width=\"100%\">";
foreach ($chatusers as $chatuser) {
$lastping = $timenow - $chatuser->lastmessageping;
echo "<tr><td width=\"35\">";
echo "<a target=\"_new\" onClick=\"return openpopup('/user/view.php?id=$chatuser->id&amp;course=$chat->course','user$chatuser->id','');\" href=\"$CFG->wwwroot/user/view.php?id=$chatuser->id&amp;course=$chat->course\">";
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 "<font color=\"#888888\">$stridle: ".format_time($lastping, $str)."</font>";
echo " <a href=\"users.php?chat_sid=$chat_sid&amp;beep=$chatuser->id&amp;groupid=$groupid\">$strbeep</a>";
echo "</font></p>";
echo "<td></tr>";
}
echo "</table>";
?>
+1 -1
View File
@@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
$module->version = 2004111200; // The (date) version of this module
$module->version = 2005020300; // The (date) version of this module
$module->requires = 2004052505; // Requires this Moodle version
$module->cron = 300; // How often should cron check this module (seconds)?
+51 -64
View File
@@ -2,62 +2,67 @@
/// This page prints a particular instance of chat
require_once("../../config.php");
require_once("lib.php");
require_once('../../config.php');
require_once('lib.php');
optional_variable($id); // Course Module ID, or
optional_variable($c); // chat ID
$id = optional_param('id', 0, PARAM_INT);
$c = optional_param('c', 0, PARAM_INT);
if ($id) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
if (! $cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID was incorrect');
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
if (! $course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
chat_update_chat_times($cm->instance);
if (! $chat = get_record("chat", "id", $cm->instance)) {
error("Course module is incorrect");
if (! $chat = get_record('chat', 'id', $cm->instance)) {
error('Course module is incorrect');
}
} else {
chat_update_chat_times($c);
if (! $chat = get_record("chat", "id", $c)) {
error("Course module is incorrect");
if (! $chat = get_record('chat', 'id', $c)) {
error('Course module is incorrect');
}
if (! $course = get_record("course", "id", $chat->course)) {
error("Course is misconfigured");
if (! $course = get_record('course', 'id', $chat->course)) {
error('Course is misconfigured');
}
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_course_login($course);
add_to_log($course->id, "chat", "view", "view.php?id=$cm->id", $chat->id, $cm->id);
if (!$cm->visible and !isteacher($course->id)) {
print_header();
notice(get_string("activityiscurrentlyhidden"));
}
add_to_log($course->id, 'chat', 'view', "view.php?id=$cm->id", $chat->id, $cm->id);
/// Print the page header
$strchats = get_string("modulenameplural", "chat");
$strchat = get_string("modulename", "chat");
$strenterchat = get_string("enterchat", "chat");
$stridle = get_string("idle", "chat");
$strcurrentusers = get_string("currentusers", "chat");
$strnextsession = get_string("nextsession", "chat");
$strchats = get_string('modulenameplural', 'chat');
$strchat = get_string('modulename', 'chat');
$strenterchat = get_string('enterchat', 'chat');
$stridle = get_string('idle', 'chat');
$strcurrentusers = get_string('currentusers', 'chat');
$strnextsession = get_string('nextsession', 'chat');
print_header_simple("$chat->name", "",
"<a href=\"index.php?id=$course->id\">$strchats</a> -> $chat->name",
"", "", true, update_module_button($cm->id, $course->id, $strchat),
print_header_simple($chat->name, '',
"<a href=\"index.php?id=$course->id\">$strchats</a> -> $chat->name",
'', '', true, update_module_button($cm->id, $course->id, $strchat),
navmenu($course, $cm));
if (($chat->studentlogs or isteacher($course->id)) and !isguest()) {
echo "<p align=\"right\"><a href=\"report.php?id=$cm->id\">".
get_string("viewreport", "chat")."</a></p>";
get_string('viewreport', 'chat').'</a></p>';
}
print_heading($chat->name);
@@ -66,7 +71,7 @@
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
$currentgroup = setup_and_print_groups($course, $groupmode, "view.php?id=$cm->id");
} else {
$currentgroup = false;
$currentgroup = 0;
}
if ($currentgroup) {
@@ -79,27 +84,9 @@
/// Print the main part of the page
// Do the browser-detection etc later on.
// $chatversion = "header_js";
// $browser = chat_browser_detect($HTTP_USER_AGENT);
// print_object($browser);
//if ($CFG->chatsocketserver == true) {
// chat_display_version("sockets", $browser);
//} else {
// chat_display_version("push_js", $browser);
// }
// chat_display_version("header_js", $browser);
// chat_display_version("header", $browser);
// chat_display_version("box", $browser);
// chat_display_version("text", $browser);
if (!isguest()) {
print_simple_box_start("center");
link_to_popup_window ("/mod/chat/gui_$CFG->chat_method/index.php?id=$chat->id$groupparam",
print_simple_box_start('center');
link_to_popup_window ("/mod/chat/gui_$CFG->chat_method/index.php?id=$chat->id$groupparam",
"chat$course->id$chat->id$groupparam", "$strenterchat", 500, 700, $strchat);
print_simple_box_end();
} else {
@@ -109,42 +96,42 @@
if ($chat->chattime and $chat->schedule) { // A chat is scheduled
if (abs($USER->timezone) > 13) {
$timezone = get_string("serverlocaltime");
$timezone = get_string('serverlocaltime');
} else if ($USER->timezone < 0) {
$timezone = "GMT".$USER->timezone;
$timezone = 'GMT'.$USER->timezone;
} else {
$timezone = "GMT+".$USER->timezone;
$timezone = 'GMT+'.$USER->timezone;
}
echo "<p align=\"center\">$strnextsession: ".userdate($chat->chattime)." ($timezone)</p>";
} else {
echo "<br />";
echo '<br />';
}
if ($chat->intro) {
print_simple_box( format_text($chat->intro) , "center");
echo "<br />";
print_simple_box( format_text($chat->intro) , 'center');
echo '<br />';
}
chat_delete_old_users();
if ($chatusers = chat_get_users($chat->id, $currentgroup)) {
$timenow = time();
print_simple_box_start("center");
print_simple_box_start('center');
print_heading($strcurrentusers);
echo "<table width=\"100%\">";
echo '<table width="100%">';
foreach ($chatusers as $chatuser) {
$lastping = $timenow - $chatuser->lastmessageping;
echo "<tr><td width=\"35\">";
echo '<tr><td width="35">';
echo "<a href=\"$CFG->wwwroot/user/view.php?id=$chatuser->id&amp;course=$chat->course\">";
print_user_picture($chatuser->id, 0, $chatuser->picture, false, false, false);
echo "</a></td><td valign=\"center\">";
echo "<p><font size=\"1\">";
echo '</a></td><td valign="center">';
echo '<p><font size="1">';
echo fullname($chatuser).'<br />';
echo "<font color=\"#888888\">$stridle: ".format_time($lastping)."</font>";
echo "</font></p>";
echo "<td></tr>";
echo '</font></p>';
echo '<td></tr>';
}
echo "</table>";
echo '</table>';
print_simple_box_end();
}