���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home3/cpr76684/public_html/gui_header_js.tar
���ѧ٧ѧ�
users.php 0000644 00000012264 15152036143 0006423 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. define('NO_MOODLE_COOKIES', true); // Session not used here. require_once('../../../config.php'); require_once($CFG->dirroot.'/mod/chat/lib.php'); $chatsid = required_param('chat_sid', PARAM_ALPHANUM); $beep = optional_param('beep', 0, PARAM_INT); // Beep target. $PAGE->set_url('/mod/chat/gui_header_js/users.php', array('chat_sid' => $chatsid)); $PAGE->set_popup_notification_allowed(false); if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) { throw new \moodle_exception('notlogged', 'chat'); } // Get the minimal course. if (!$course = $DB->get_record('course', array('id' => $chatuser->course))) { throw new \moodle_exception('invalidcourseid'); } // Get the user theme and enough info to be used in chat_format_message() which passes it along to. // No optimisation here, it would break again in future! if (!$user = $DB->get_record('user', array('id' => $chatuser->userid, 'deleted' => 0, 'suspended' => 0))) { throw new \moodle_exception('invaliduser'); } \core\session\manager::set_user($user); $PAGE->set_pagelayout('embedded'); // Setup course, lang and theme. $PAGE->set_course($course); $courseid = $chatuser->course; if (!$cm = get_coursemodule_from_instance('chat', $chatuser->chatid, $courseid)) { throw new \moodle_exception('invalidcoursemodule'); } if ($beep) { chat_send_chatmessage($chatuser, "beep $beep", 0, $cm); $chatuser->lastmessageping = time(); // A beep is a ping. } $chatuser->lastping = time(); $DB->set_field('chat_users', 'lastping', $chatuser->lastping, array('id' => $chatuser->id)); $refreshurl = "users.php?chat_sid=$chatsid"; // Get list of users. if (!$chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid)) { throw new \moodle_exception('errornousers', 'chat'); } $uidles = Array(); foreach ($chatusers as $chatuser) { $uidles[] = $chatuser->id; } $module = array( 'name' => 'mod_chat_header', 'fullpath' => '/mod/chat/gui_header_js/module.js', 'requires' => array('node') ); $PAGE->requires->js_init_call('M.mod_chat_header.init_users', array($uidles), false, $module); // Print user panel body. $timenow = time(); $stridle = get_string('idle', 'chat'); $strbeep = get_string('beep', 'chat'); $table = new html_table(); $table->width = '100%'; $table->data = array(); 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; $row = array(); $row[0] = $OUTPUT->user_picture($chatuser, array('courseid' => $courseid, 'popup' => true)); $row[1] = html_writer::start_tag('p'); $row[1] .= html_writer::start_tag('font', array('size' => '1')); $row[1] .= fullname($chatuser).'<br />'; $row[1] .= html_writer::tag('span', $stridle . html_writer::tag('span', $idle, array('name' => 'uidles', 'id' => 'uidle'.$chatuser->id)), array('class' => 'dimmed_text')) . ' '; $row[1] .= html_writer::tag('a', $strbeep, array('href' => new moodle_url('/mod/chat/gui_header_js/users.php', array('chat_sid' => $chatsid, 'beep' => $chatuser->id)))); $row[1] .= html_writer::end_tag('font'); $row[1] .= html_writer::end_tag('p'); $table->data[] = $row; } ob_start(); echo $OUTPUT->header(); echo html_writer::tag('div', html_writer::tag('a', get_string('refresh'), array('href' => $refreshurl, 'id' => 'refreshLink')), array('style' => 'display:none')); echo html_writer::table($table); echo $OUTPUT->footer(); // Support HTTP Keep-Alive by printing Content-Length // // If the user pane is refreshing often, using keepalives // is lighter on the server and faster for most clients. // // Apache is normally configured to have a 15s timeout on // keepalives, so let's observe that. Unfortunately, we cannot // autodetect the keepalive timeout. // // Using keepalives when the refresh is longer than the timeout // wastes server resources keeping an apache child around on a // connection that will timeout. So we don't. if ($CFG->chat_refresh_userlist < 15) { header("Content-Length: " . ob_get_length() ); ob_end_flush(); } exit; // No further output. jsupdate.php 0000644 00000015604 15152036143 0007102 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. define('NO_MOODLE_COOKIES', true); // Session not used here. require('../../../config.php'); require_once('../lib.php'); $chatsid = required_param('chat_sid', PARAM_ALPHANUM); $chatlasttime = optional_param('chat_lasttime', 0, PARAM_INT); $chatlastrow = optional_param('chat_lastrow', 1, PARAM_INT); $url = new moodle_url('/mod/chat/gui_header_js/jsupdate.php', array('chat_sid' => $chatsid)); if ($chatlasttime !== 0) { $url->param('chat_lasttime', $chatlasttime); } if ($chatlastrow !== 1) { $url->param('chat_lastrow', $chatlastrow); } $PAGE->set_url($url); if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) { throw new \moodle_exception('notlogged', 'chat'); } // Get the minimal course. if (!$course = $DB->get_record('course', array('id' => $chatuser->course))) { throw new \moodle_exception('invalidcourseid'); } // Get the user theme and enough info to be used in chat_format_message() which passes it along to. // No optimisation here, it would break again in future! if (!$user = $DB->get_record('user', array('id' => $chatuser->userid, 'deleted' => 0, 'suspended' => 0))) { throw new \moodle_exception('invaliduser'); } \core\session\manager::set_user($user); // Setup course, lang and theme. $PAGE->set_course($course); // Force deleting of timed out users if there is a silence in room or just entering. if ((time() - $chatlasttime) > $CFG->chat_old_ping) { // Must be done before chat_get_latest_message! chat_delete_old_users(); } if ($message = chat_get_latest_message($chatuser->chatid, $chatuser->groupid)) { $chatnewlasttime = $message->timestamp; } else { $chatnewlasttime = 0; } if ($chatlasttime == 0) { // Display some previous messages. $chatlasttime = time() - $CFG->chat_old_ping; // TO DO - any better value? } $timenow = time(); $params = array('groupid' => $chatuser->groupid, 'chatid' => $chatuser->chatid, 'lasttime' => $chatlasttime); $groupselect = $chatuser->groupid ? " AND (groupid=:groupid OR groupid=0) " : ""; $messages = $DB->get_records_select("chat_messages_current", "chatid = :chatid AND timestamp > :lasttime $groupselect", $params, "timestamp ASC"); if ($messages) { $num = count($messages); } else { $num = 0; } $chatnewrow = ($chatlastrow + $num) % 2; // No & in url, does not work in header! $baseurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?"; $refreshurl = $baseurl . "chat_sid=$chatsid&chat_lasttime=$chatnewlasttime&chat_lastrow=$chatnewrow"; $refreshurlamp = $baseurl . "chat_sid=$chatsid&chat_lasttime=$chatnewlasttime&chat_lastrow=$chatnewrow"; 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; charset=utf-8'); header("Refresh: $CFG->chat_refresh_room; url=$refreshurl"); // Use ob to be able to send Content-Length headers. // Needed for Keep-Alive to work. ob_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript"> //<![CDATA[ if (parent.msg && parent.msg.document.getElementById("msgStarted") == null) { parent.msg.document.close(); parent.msg.document.open("text/html","replace"); parent.msg.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); parent.msg.document.write("<html><head>"); parent.msg.document.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"); parent.msg.document.write("<base target=\"_blank\" />"); parent.msg.document.write("<\/head><body class=\"mod-chat-gui_header_js course-<?php echo $chatuser->course ?>\" id=\"mod-chat-gui_header_js-jsupdate\"><div style=\"display: none\" id=\"msgStarted\"> <\/div>"); } <?php $beep = false; $refreshusers = false; $us = array (); if (($chatlasttime != $chatnewlasttime) and $messages) { foreach ($messages as $message) { $chatlastrow = ($chatlastrow + 1) % 2; $formatmessage = chat_format_message($message, $chatuser->course, $USER, $chatlastrow); if ($formatmessage->beep) { $beep = true; } if ($formatmessage->refreshusers) { $refreshusers = true; } $us[$message->userid] = $timenow - $message->timestamp; echo "if(parent.msg)"; echo "parent.msg.document.write('".addslashes_js($formatmessage->html)."\\n');\n"; } } $chatuser->lastping = time(); $DB->set_field('chat_users', 'lastping', $chatuser->lastping, array('id' => $chatuser->id)); if ($refreshusers) { ?> var link = parent.users.document.getElementById('refreshLink'); if (link != null) { parent.users.location.href = link.href; } <?php } 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 "if (parent.users && parent.users.document.getElementById('uidle{$uid}') != null) {". "parent.users.document.getElementById('uidle{$uid}').innerHTML = '$idle';}\n"; } } ?> if (parent.input) { var autoscroll = parent.input.document.getElementById('auto'); if (parent.msg && autoscroll && autoscroll.checked) { parent.msg.scroll(1,5000000); } } //]]> </script> </head> <body> <?php if ($beep) { echo '<script> (function() {'; echo 'var audioElement = document.createElement("audio");'; echo 'audioElement.setAttribute("src", "../beep.mp3");'; echo 'audioElement.play(); })();'; echo '</script>'; } ?> <a href="<?php echo $refreshurlamp ?>" name="refreshLink">Refresh link</a> </body> </html> <?php // Support HTTP Keep-Alive. header("Content-Length: " . ob_get_length() ); ob_end_flush(); exit; module.js 0000644 00000007505 15152036143 0006376 0 ustar 00 /* * NOTE: the /mod/chat/gui_header_js/ is not a real plugin, * ideally this code should be in /mod/chat/module.js */ /** * @namespace M.mod_chat_header */ M.mod_chat_header = M.mod_chat_ajax || {}; /** * Init header based Chat UI - frame input * * @namespace M.mod_chat_header * @function * @param {YUI} Y * @param {Boolean} forcerefreshasap refresh users frame asap */ M.mod_chat_header.init_insert = function(Y, forcerefreshasap) { if (forcerefreshasap) { parent.jsupdate.location.href = parent.jsupdate.document.anchors[0].href; } parent.input.enableForm(); }; /** * Init header based Chat UI - frame input * * @namespace M.mod_chat_header * @function * @param {YUI} Y */ M.mod_chat_header.init_input = function(Y) { var inputframe = { waitflag : false, // True when a submission is in progress /** * Initialises the input frame * * @function */ init : function() { Y.one('#inputForm').on('submit', this.submit, this); }, /** * Enables the input form * @this {M.mod_chat.js} */ enable_form : function() { var el = Y.one('#input_chat_message'); this.waitflag = false; el.set('className', ''); el.focus(); }, /** * Submits the entered message * @param {Event} e */ submit : function(e) { e.halt(); if (this.waitflag) { return false; } this.waitflag = true; var inputchatmessage = Y.one('#input_chat_message'); Y.one('#insert_chat_message').set('value', inputchatmessage.get('value')); inputchatmessage.set('value', ''); inputchatmessage.addClass('wait'); Y.one('#sendForm').submit(); this.enable_form(); return false; } }; inputframe.init(); }; /** * Init header based Chat UI - frame users * * @namespace M.mod_chat_header * @function * @param {YUI} Y * @param {Array} users */ M.mod_chat_header.init_users = function(Y, users) { var usersframe = { timer : null, // Stores the timer object timeout : 1, // The seconds between updates users : [], // An array of users /** * Initialises the frame with list of users * * @function * @this * @param {Array|null} users */ init : function(users) { this.users = users; this.start(); Y.one(document.body).on('unload', this.stop, this); }, /** * Starts the update timeout * * @function * @this */ start : function() { this.timer = setTimeout(function(self) { self.update(); }, this.timeout * 1000, this); }, /** * Stops the update timeout * @function * @this */ stop : function() { clearTimeout(this.timer); }, /** * Updates the user information * * @function * @this */ update : function() { for (var i in this.users) { var el = Y.one('#uidle' + this.users[i]); if (el) { var parts = el.get('innerHTML').split(':'); var time = this.timeout + (parseInt(parts[0], 10) * 60) + parseInt(parts[1], 10); var min = Math.floor(time / 60); var sec = time % 60; el.set('innerHTML', ((min < 10) ? "0" : "") + min + ":" + ((sec < 10) ? "0" : "") + sec); } } this.start(); } }; usersframe.init(users); }; chatinput.php 0000644 00000007003 15152036143 0007254 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. define('NO_MOODLE_COOKIES', true); // Session not used here. require_once('../../../config.php'); require_once($CFG->dirroot.'/mod/chat/lib.php'); $chatsid = required_param('chat_sid', PARAM_ALPHANUM); $chatid = required_param('chat_id', PARAM_INT); if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) { throw new \moodle_exception('notlogged', 'chat'); } if (!$chat = $DB->get_record('chat', array('id' => $chatid))) { throw new \moodle_exception('invalidid', 'chat'); } if (!$course = $DB->get_record('course', array('id' => $chat->course))) { throw new \moodle_exception('invalidcourseid'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { throw new \moodle_exception('invalidcoursemodule'); } $PAGE->set_url('/mod/chat/gui_header_js/chatinput.php', array('chat_sid' => $chatsid, 'chat_id' => $chatid)); $PAGE->set_popup_notification_allowed(false); // Get the user theme. $USER = $DB->get_record('user', array('id' => $chatuser->userid)); $module = array( 'name' => 'mod_chat_header', 'fullpath' => '/mod/chat/gui_header_js/module.js', 'requires' => array('node') ); $PAGE->requires->js_init_call('M.mod_chat_header.init_input', array(false), false, $module); // Setup course, lang and theme. $PAGE->set_course($course); $PAGE->set_pagelayout('embedded'); $PAGE->set_focuscontrol('input_chat_message'); $PAGE->set_cacheable(false); echo $OUTPUT->header(); echo html_writer::start_tag('form', array('action' => '../empty.php', 'method' => 'post', 'target' => 'empty', 'id' => 'inputForm', 'style' => 'margin:0')); echo html_writer::label(get_string('entermessage', 'chat'), 'input_chat_message', false, array('class' => 'accesshide')); echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'input_chat_message', 'name' => 'chat_message', 'size' => '50', 'value' => '')); echo html_writer::empty_tag('input', array('type' => 'checkbox', 'id' => 'auto', 'checked' => 'checked', 'value' => '')); echo html_writer::tag('label', get_string('autoscroll', 'chat'), array('for' => 'auto')); echo html_writer::end_tag('form'); echo html_writer::start_tag('form', array('action' => 'insert.php', 'method' => 'post', 'target' => 'empty', 'id' => 'sendForm')); echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'chat_sid', 'value' => $chatsid)); echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'chat_message', 'id' => 'insert_chat_message')); echo html_writer::end_tag('form'); echo $OUTPUT->footer(); jsupdated.php 0000644 00000022063 15152036143 0007243 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** jsupdated.php - notes by Martin Langhoff <martin@catalyst.net.nz> ** ** This is an alternative version of jsupdate.php that acts ** as a long-running daemon. It will feed/stall/feed JS updates ** to the client. From the module configuration select "Stream" ** updates. ** ** The client connection is not forever though. Once we reach ** CHAT_MAX_CLIENT_UPDATES, it will force the client to re-fetch it. ** ** This buys us all the benefits that chatd has, minus the setup, ** as we are using apache to do the daemon handling. ** **/ define('CHAT_MAX_CLIENT_UPDATES', 1000); define('NO_MOODLE_COOKIES', true); // Session not used here. define('NO_OUTPUT_BUFFERING', true); require('../../../config.php'); require_once('../lib.php'); // We are going to run for a long time. // Avoid being terminated by php. core_php_time_limit::raise(); $chatsid = required_param('chat_sid', PARAM_ALPHANUM); $chatlasttime = optional_param('chat_lasttime', 0, PARAM_INT); $chatlastrow = optional_param('chat_lastrow', 1, PARAM_INT); $chatlastid = optional_param('chat_lastid', 0, PARAM_INT); $url = new moodle_url('/mod/chat/gui_header_js/jsupdated.php', array('chat_sid' => $chatsid)); if ($chatlasttime !== 0) { $url->param('chat_lasttime', $chatlasttime); } if ($chatlastrow !== 1) { $url->param('chat_lastrow', $chatlastrow); } if ($chatlastid !== 1) { $url->param('chat_lastid', $chatlastid); } $PAGE->set_url($url); if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) { throw new \moodle_exception('notlogged', 'chat'); } // Get the minimal course. if (!$course = $DB->get_record('course', array('id' => $chatuser->course))) { throw new \moodle_exception('invalidcourseid'); } // Get the user theme and enough info to be used in chat_format_message() which passes it along to // chat_format_message_manually() -- and only id and timezone are used. // No optimisation here, it would break again in future! if (!$user = $DB->get_record('user', array('id' => $chatuser->userid, 'deleted' => 0, 'suspended' => 0))) { throw new \moodle_exception('invaliduser'); } \core\session\manager::set_user($user); // Setup course, lang and theme. $PAGE->set_course($course); // Force deleting of timed out users if there is a silence in room or just entering. if ((time() - $chatlasttime) > $CFG->chat_old_ping) { // Must be done before chat_get_latest_message! chat_delete_old_users(); } // Time to send headers, and lay out the basic JS updater page. 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; charset=utf-8'); $refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdated.php?". "chat_sid=$chatsid&chat_lasttime=$chatlasttime&chat_lastrow=$chatnewrow&chat_lastid=$chatlastid"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript"> //<![CDATA[ if (parent.msg.document.getElementById("msgStarted") == null) { parent.msg.document.close(); parent.msg.document.open("text/html","replace"); parent.msg.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); parent.msg.document.write("<html><head>"); parent.msg.document.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"); parent.msg.document.write("<base target=\"_blank\" />"); parent.msg.document.write("</head><body class=\"mod-chat-gui_header_js course-<?php echo $chatuser->course ?>\" id=\"mod-chat-gui_header_js-jsupdate\"><div style=\"display: none\" id=\"msgStarted\"> </div>"); } //]]> </script> </head> <body> <?php // Ensure the HTML head makes it out there. echo $CHAT_DUMMY_DATA; for ($n = 0; $n <= CHAT_MAX_CLIENT_UPDATES; $n++) { // Ping first so we can later shortcut as needed. $chatuser->lastping = time(); $DB->set_field('chat_users', 'lastping', $chatuser->lastping, array('id' => $chatuser->id)); if ($message = chat_get_latest_message($chatuser->chatid, $chatuser->groupid)) { $chatnewlasttime = $message->timestamp; $chatnewlastid = $message->id; } else { $chatnewlasttime = 0; $chatnewlastid = 0; print " \n"; print $CHAT_DUMMY_DATA; sleep($CFG->chat_refresh_room); continue; } $timenow = time(); $params = array('groupid' => $chatuser->groupid, 'lastid' => $chatlastid, 'lasttime' => $chatlasttime, 'chatid' => $chatuser->chatid); $groupselect = $chatuser->groupid ? " AND (groupid=:groupid OR groupid=0) " : ""; $newcriteria = ''; if ($chatlastid > 0) { $newcriteria = "id > :lastid"; } else { if ($chatlasttime == 0) { // Display some previous messages. $chatlasttime = $timenow - $CFG->chat_old_ping; // TO DO - any better value? } $newcriteria = "timestamp > :lasttime"; } $messages = $DB->get_records_select("chat_messages_current", "chatid = :chatid AND $newcriteria $groupselect", $params, "timestamp ASC"); if ($messages) { $num = count($messages); } else { print " \n"; print $CHAT_DUMMY_DATA; sleep($CFG->chat_refresh_room); continue; } print '<script type="text/javascript">' . "\n"; print "//<![CDATA[\n\n"; $chatnewrow = ($chatlastrow + $num) % 2; $refreshusers = false; $us = array (); if (($chatlasttime != $chatnewlasttime) and $messages) { $beep = false; $refreshusers = false; foreach ($messages as $message) { $chatlastrow = ($chatlastrow + 1) % 2; $formatmessage = chat_format_message($message, $chatuser->course, $USER, $chatlastrow); if ($formatmessage->beep) { $beep = true; } if ($formatmessage->refreshusers) { $refreshusers = true; } $us[$message->userid] = $timenow - $message->timestamp; echo "parent.msg.document.write('".addslashes_js($formatmessage->html )."\\n');\n"; } // From the last message printed. // A strange case where lack of closures is useful! $chatlasttime = $message->timestamp; $chatlastid = $message->id; } if ($refreshusers) { echo "if (parent.users.document.anchors[0] != null) {" . "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 "if (parent.users.document.getElementById('uidle{$uid}') != null) {". "parent.users.document.getElementById('uidle{$uid}').innerHTML = '$idle';}\n"; } } print <<<EOD if(parent.input){ var autoscroll = parent.input.document.getElementById('auto'); if(parent.msg && autoscroll && autoscroll.checked){ parent.msg.scroll(1,5000000); } } EOD; print "//]]>\n"; print '</script>' . "\n\n"; if ($beep) { print '<script> (function() {'; print 'var audioElement = document.createElement("audio");'; print 'audioElement.setAttribute("src", "../beep.mp3");'; print 'audioElement.play(); })();'; print '</script>'; } print $CHAT_DUMMY_DATA; sleep($CFG->chat_refresh_room); } // Here ends the for() loop. // Here & should be written & :-D. $refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdated.php?"; $refreshurl .= "chat_sid=$chatsid&chat_lasttime=$chatlasttime&chat_lastrow=$chatnewrow&chat_lastid=$chatlastid"; print '<script type="text/javascript">' . "\n"; print "//<![CDATA[ \n\n"; print "location.href = '$refreshurl';\n"; print "//]]>\n"; print '</script>' . "\n\n"; ?> </body> </html> insert.php 0000644 00000004630 15152036143 0006564 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. require_once('../../../config.php'); require_once('../lib.php'); $chatsid = required_param('chat_sid', PARAM_ALPHANUM); $chatmessage = required_param('chat_message', PARAM_RAW); $PAGE->set_url('/mod/chat/gui_header_js/insert.php', array('chat_sid' => $chatsid, 'chat_message' => $chatmessage)); if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) { throw new \moodle_exception('notlogged', 'chat'); } if (!$chat = $DB->get_record('chat', array('id' => $chatuser->chatid))) { throw new \moodle_exception('nochat', 'chat'); } if (!$course = $DB->get_record('course', array('id' => $chat->course))) { throw new \moodle_exception('invalidcourseid'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { throw new \moodle_exception('invalidcoursemodule'); } require_login($course, false, $cm); if (isguestuser()) { throw new \moodle_exception('noguests'); } \core\session\manager::write_close(); // Delete old users now. chat_delete_old_users(); // Clean up the message. $chatmessage = clean_text($chatmessage, FORMAT_MOODLE); // Strip bad tags. // Add the message to the database. if (!empty($chatmessage)) { chat_send_chatmessage($chatuser, $chatmessage, 0, $cm); $chatuser->lastmessageping = time() - 2; $DB->update_record('chat_users', $chatuser); } if ($chatuser->version == 'header_js') { $forcerefreshasap = ($CFG->chat_normal_updatemode != 'jsupdated'); // See bug MDL-6791. $module = array( 'name' => 'mod_chat_header', 'fullpath' => '/mod/chat/gui_header_js/module.js' ); $PAGE->requires->js_init_call('M.mod_chat_header.init_insert_nojsupdated', array($forcerefreshasap), true, $module); } redirect('../empty.php'); index.php 0000644 00000007517 15152036143 0006376 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. require_once('../../../config.php'); require_once('../lib.php'); $id = required_param('id', PARAM_INT); $groupid = optional_param('groupid', 0, PARAM_INT); // Only for teachers. $url = new moodle_url('/mod/chat/gui_header_js/index.php', array('id' => $id)); if ($groupid !== 0) { $url->param('groupid', $groupid); } $PAGE->set_url($url); if (!$chat = $DB->get_record('chat', array('id' => $id))) { throw new \moodle_exception('invalidid', 'chat'); } if (!$course = $DB->get_record('course', array('id' => $chat->course))) { throw new \moodle_exception('invalidcourseid'); } if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { throw new \moodle_exception('invalidcoursemodule'); } $context = context_module::instance($cm->id); require_login($course, false, $cm); require_capability('mod/chat:chat', $context); // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used. if ($groupid = groups_get_activity_group($cm)) { if (!$group = groups_get_group($groupid)) { throw new \moodle_exception('invalidgroupid'); } $groupname = ': '.$group->name; } else { $groupname = ': '.get_string('allparticipants'); } } else { $groupid = 0; $groupname = ''; } $strchat = get_string('modulename', 'chat'); // Must be before current_language() in chat_login_user() to force course language! if (!$chatsid = chat_login_user($chat->id, 'header_js', $groupid, $course)) { throw new \moodle_exception('cantlogin', 'chat'); } $params = "chat_id=$id&chat_sid={$chatsid}"; // Fallback to the old jsupdate, but allow other update modes. $updatemode = 'jsupdate'; if (!empty($CFG->chat_normal_updatemode)) { $updatemode = $CFG->chat_normal_updatemode; } $courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id))); ?> <!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=utf-8" /> <title> <?php echo "$strchat: " . $courseshortname . ": ". format_string($chat->name, true, array('context' => $context)) . "$groupname" ?> </title> </head> <frameset cols="*,200" border="5" framespacing="no" frameborder="yes" 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="<?php echo $updatemode ?>.php?<?php echo $params ?>" name="jsupdate" scrolling="no" marginwidth="0" marginheight="0"> <frame src="chatmsg.php?<?php echo $params ?>" 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"> </frameset> <noframes> Sorry, this version of Moodle Chat needs a browser that handles frames. </noframes> </html> chatmsg.php 0000644 00000000274 15152036143 0006706 0 ustar 00 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Dummy</title> </head> <body> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�