Hacked By AnonymousFox
chat_chat.php 0000644 00000013473 15200302165 0007175 0 ustar 00 <?php
/* For licensing terms, see /license.txt */
/**
* Chat frame that shows the message list
*
* @author Olivier Brouckaert
* @package chamilo.chat
*/
/**
* Code
*/
define('FRAME', 'chat');
$language_file = array('chat');
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$course = $_GET['cidReq'];
$session_id = intval($_SESSION['id_session']);
$group_id = intval($_SESSION['_gid']);
// if we have the session set up
if (!empty($course)) {
$reset = (bool)$_GET['reset'];
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$query = "SELECT username FROM $tbl_user WHERE user_id='".intval($_user['user_id'])."'";
$result = Database::query($query);
list($pseudo_user) = Database::fetch_row($result);
$isAllowed = !(empty($pseudo_user) || !$_cid);
$isMaster = (bool)$is_courseAdmin;
$date_now = date('Y-m-d');
$basepath_chat = '';
$document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
if (!empty($group_id)) {
$group_info = GroupManager :: get_group_properties($group_id);
$basepath_chat = $group_info['directory'].'/chat_files';
} else {
$basepath_chat = '/chat_files';
}
$chat_path = $document_path.$basepath_chat.'/';
$TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = api_get_course_int_id();
if (!is_dir($chat_path)) {
if (is_file($chat_path)) {
@unlink($chat_path);
}
if (!api_is_anonymous()) {
@mkdir($chat_path, api_get_permissions_for_new_directories());
// Save chat files document for group into item property
if (!empty($group_id)) {
$doc_id = add_document($_course, $basepath_chat, 'folder', 0, 'chat_files');
$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, 'document',1,NOW(),NOW(),$doc_id,'FolderCreated',1,$group_id,NULL,0)";
Database::query($sql);
}
}
}
$filename_chat = '';
if (!empty($group_id)) {
$filename_chat = 'messages-'.$date_now.'_gid-'.$group_id.'.log.html';
} else if (!empty($session_id)) {
$filename_chat = 'messages-'.$date_now.'_sid-'.$session_id.'.log.html';
} else {
$filename_chat = 'messages-'.$date_now.'.log.html';
}
if (!file_exists($chat_path.$filename_chat)) {
@fclose(fopen($chat_path.$filename_chat, 'w'));
if (!api_is_anonymous()) {
$doc_id = add_document($_course, $basepath_chat.'/'.$filename_chat, 'file', 0, $filename_chat);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $group_id, null, null, null, $session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'], $group_id, null, null, null, $session_id);
item_property_update_on_folder($_course, $basepath_chat, $_user['user_id']);
}
}
$basename_chat = '';
if (!empty($group_id)) {
$basename_chat = 'messages-'.$date_now.'_gid-'.$group_id;
} else if (!empty($session_id)) {
$basename_chat = 'messages-'.$date_now.'_sid-'.$session_id;
} else {
$basename_chat = 'messages-'.$date_now;
}
if ($reset && $isMaster) {
$i = 1;
while (file_exists($chat_path.$basename_chat.'-'.$i.'.log.html')) {
$i++;
}
@rename($chat_path.$basename_chat.'.log.html', $chat_path.$basename_chat.'-'.$i.'.log.html');
@fclose(fopen($chat_path.$basename_chat.'.log.html', 'w'));
$doc_id = add_document($_course, $basepath_chat.'/'.$basename_chat.'-'.$i.'.log.html', 'file', filesize($chat_path.$basename_chat.'-'.$i.'.log.html'), $basename_chat.'-'.$i.'.log.html');
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $group_id, null, null, null, $session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'], $group_id, null, null, null, $session_id);
item_property_update_on_folder($_course,$basepath_chat, $_user['user_id']);
$doc_id = DocumentManager::get_document_id($_course, $basepath_chat.'/'.$basename_chat.'.log.html');
update_existing_document($_course, $doc_id, 0);
}
$remove = 0;
$content = array();
if (file_exists($chat_path.$basename_chat.'.log.html')) {
$content = file($chat_path.$basename_chat.'.log.html');
$nbr_lines = sizeof($content);
$remove = $nbr_lines - 100;
}
if ($remove < 0) {
$remove = 0;
}
array_splice($content, 0, $remove);
require 'header_frame.inc.php';
if ($_GET['origin'] == 'whoisonline') { //the caller
$content[0] = get_lang('CallSent').'<br />'.$content[0];
}
if ($_GET['origin'] == 'whoisonlinejoin') { //the joiner (we have to delete the chat request to him when he joins the chat)
$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "UPDATE $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='' WHERE (user_id = ".$_user['user_id'].")";
$result = Database::query($sql);
}
echo '<div style="margin-left: 5px;">';
foreach ($content as & $this_line) {
echo strip_tags(api_html_entity_decode($this_line), '<br> <span> <b> <i> <img> <font>');
}
echo '</div>';
?>
<a name="bottom" style="text-decoration:none;"> </a>
<?php
if ($isMaster || $is_courseCoach) {
$rand = mt_rand(1, 1000);
echo '<div style="margin-left: 5px;">';
echo '<a href="'.api_get_self().'?rand='.$rand.'&reset=1&cidReq='.$_GET['cidReq'].'#bottom" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmReset'), ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.gif', get_lang('ClearList')).' '.get_lang('ClearList').'</a>';
echo '</div>';
}
} else {
require 'header_frame.inc.php';
$message = get_lang('CloseOtherSession');
Display :: display_error_message($message);
}
require 'footer_frame.inc.php';
chat.php 0000644 00000007364 15200302165 0006200 0 ustar 00 <?php
/* For licensing terms, see /license.txt */
/**
* Chat tool
* @package chamilo.chat
*/
/**
* Code
*/
$language_file = array('chat');
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_CHAT;
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$this_section = SECTION_COURSES;
$nameTools = get_lang('ToolChat');
if ($_GET["origin"] != 'whoisonline') {
api_protect_course_script(true);
} else {
$origin = $_SESSION['origin'];
$target = $_SESSION['target'];
$_SESSION['origin']=$_GET["origin"];
$_SESSION['target']=$_GET["target"];
}
/* TRACKING */
event_access_tool(TOOL_CHAT);
header('Content-Type: text/html; charset='.api_get_system_encoding());
/*
* Choose CSS style (platform's, user's, or course's)
*/
$my_style = api_get_visual_theme();
$mycourseid = api_get_course_id();
if (!empty($mycourseid) && $mycourseid != -1) {
$open_chat_window = api_get_course_setting('allow_open_chat_window');
}
$cidreq = Security::remove_XSS($_GET['cidReq']);
$toolgroup = Security::remove_XSS($_GET['toolgroup']); //fix when change by vertical or horizontal menu from a chat group to chat course.
if (empty($toolgroup) && empty($open_chat_window)){
unset($_SESSION['_gid']);
}
?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo api_get_language_isocode(); ?>" lang="<?php echo api_get_language_isocode(); ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
<?php
echo'<title>'.get_lang('Chat').' - '.$mycourseid.' - '.api_get_setting('siteName').'</title>';
// If it is a group chat then the breadcrumbs.
if ($_SESSION['_gid'] OR $_GET['group_id']) {
if (isset($_SESSION['_gid'])) {
$_clean['group_id'] = (int)$_SESSION['_gid'];
}
if (isset($_GET['group_id'])) {
$_clean['group_id'] = (int)Database::escape_string($_GET['group_id']);
}
$group_properties = GroupManager :: get_group_properties($_clean['group_id']);
$interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$_SESSION['_gid'], 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
$noPHP_SELF = true;
$shortBanner = false;
$add_group_to_title = ' ('.$group_properties['name'].')';
$groupfilter = 'group_id="'.$_clean['group_id'].'"';
// Ensure this tool in groups whe it's private or deactivated
/*if ($group_properties['chat_state'] == 0) {
echo api_not_allowed();
} elseif ($group_properties['chat_state'] == 2) {
if (!api_is_allowed_to_edit(false,true) and !GroupManager :: is_user_in_group($_user['user_id'], $_SESSION['_gid'])) {
echo api_not_allowed();
}
}*/
} else {
$groupfilter = 'group_id=0';
}
//$is_allowed_to_edit = api_is_allowed_to_edit(false, true);
if (empty($open_chat_window)) {
Display::display_header($tool_name, 'Chat');
}
echo '<iframe src="chat_whoisonline.php?cidReq='.$cidreq.'" name="chat_whoisonline" scrolling="auto" style="height:320px; width:19%; border: 0px none; float:left"></iframe>';
echo '<iframe src="chat_chat.php?origin='.Security::remove_XSS($_GET['origin']).'&target='.Security::remove_XSS($_GET['target']).'&cidReq='.$cidreq.'" name="chat_chat" scrolling="auto" height="240" style="width:80%; border: 0px none; float:right"></iframe>';
echo '<iframe src="chat_message.php?cidReq='.$cidreq.'" name="chat_message" scrolling="no" height="80" style="width:80%; border: 0px none; float:right"></iframe>';
echo '<iframe src="chat_hidden.php?cidReq='.$cidreq.'" name="chat_hidden" height="0" style="border: 0px none"></iframe>';
if (empty($open_chat_window)) {
Display::display_footer();
}
echo '</html>';
chat_functions.lib.php 0000644 00000010070 15200302165 0011021 0 ustar 00 <?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.chat
*/
/**
* @author isaac flores paz
* @param integer the user id
* @param string the database name
* @return boolean
* @todo this function need more parameters seems not to be use anymore
* @deprecated fix this function or create another
*/
function user_connected_in_chat ($user_id) {
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
$user_id = intval($user_id);
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$course_id = api_get_course_int_id();
$extra_condition = '';
if (!empty($group_id)) {
$extra_condition = " AND to_group_id = '$group_id'";
} else {
$extra_condition = api_get_session_condition($session_id);
}
$sql = 'SELECT COUNT(*) AS count FROM '.$tbl_chat_connected .' c WHERE c_id = '.$course_id.' AND user_id='.$user_id.$extra_condition;
$result = Database::query($sql);
$count = Database::fetch_array($result,'ASSOC');
return $count['count'] == 1;
}
/**
* @param integer
* @return void
*/
function exit_of_chat($user_id) {
$user_id = intval($user_id);
$list_course = CourseManager::get_courses_list_by_user_id($user_id);
/*$session_id = api_get_session_id();
$group_id = api_get_group_id();
$extra_condition = '';
if (!empty($group_id)) {
$extra_condition = " AND to_group_id = '$group_id'";
} else {
$extra_condition = api_get_session_condition($session_id);
}
$extra_condition.= " AND course_id = $course_id";*/
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
foreach ($list_course as $course) {
$response = user_connected_in_chat($user_id);
//if ($response === true) {
$sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE c_id = '.$course['real_id'].' AND user_id = '.$user_id;
Database::query($sql);
//}
}
}
/**
* @param string $database_name (optional)
* @return void
*/
function disconnect_user_of_chat() {
$list_info_user_in_chat = array();
$course_id = api_get_course_int_id();
$list_info_user_in_chat = users_list_in_chat();
$course_id = api_get_course_int_id();
$cd_date = date('Y-m-d',time());
$cdate_h = date('H',time());
$cdate_m = date('i',time());
$cdate_s = date('s',time());
$cd_count_time_seconds = $cdate_h*3600 + $cdate_m*60 + $cdate_s;
if (is_array($list_info_user_in_chat) && count($list_info_user_in_chat) > 0 ) {
foreach ($list_info_user_in_chat as $list_info_user) {
$date_db_date = date('Y-m-d', strtotime($list_info_user['last_connection']));
$date_db_h = date('H', strtotime($list_info_user['last_connection']));
$date_db_m = date('i', strtotime($list_info_user['last_connection']));
$date_db_s = date('s', strtotime($list_info_user['last_connection']));
$date_count_time_seconds=$date_db_h*3600 + $date_db_m*60 + $date_db_s;
if ($cd_date == $date_db_date) {
if (($cd_count_time_seconds - $date_count_time_seconds) > 5) {
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
$sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE c_id = '.$course_id.' AND user_id ='.$list_info_user['user_id'];
Database::query($sql);
}
}
}
}
}
/**
* @param string $database_name (optional)
* @return array user list in chat
*/
function users_list_in_chat() {
$list_users_in_chat = array();
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$extra_condition = '';
if (!empty($group_id)) {
$extra_condition = " WHERE to_group_id = '$group_id'";
} else{
$extra_condition = api_get_session_condition($session_id, false);
}
$extra_condition.= " AND c_id = $course_id ";
$sql = 'SELECT user_id, last_connection FROM '.$tbl_chat_connected.$extra_condition;
$result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) {
$list_users_in_chat[] = $row;
}
return $list_users_in_chat;
} chat_hidden.php 0000644 00000007772 15200302165 0007516 0 ustar 00 <?php
/* For licensing terms, see /license.txt */
/**
* Hidden frame that refreshes the visible frames when a modification occurs
*
* @author Olivier Brouckaert
* @package chamilo.chat
*/
/**
* Code
*/
define('FRAME', 'hidden');
$language_file = array('chat');
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
require_once 'chat_functions.lib.php';
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
$course_id = api_get_course_int_id();
$query = "SELECT username FROM $tbl_user WHERE user_id='".$_user['user_id']."'";
$result = Database::query($query);
list($pseudo_user) = Database::fetch_row($result);
$isAllowed = !(empty($pseudo_user) || !$_cid);
$isMaster = (bool)$is_courseAdmin;
$date_now = date('Y-m-d');
$group_id = intval($_SESSION['_gid']);
$session_id = intval($_SESSION['id_session']);
$session_condition = api_get_session_condition($session_id);
$group_condition = " AND to_group_id = '$group_id'";
$extra_condition = '';
if (!empty($group_id)) {
$extra_condition = $group_condition;
} else {
$extra_condition = $session_condition;
}
$extra_condition.= " AND c_id = $course_id";
// get chat path
$chat_path = '';
$document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
if (!empty($group_id)) {
$group_info = GroupManager :: get_group_properties($group_id);
$chat_path = $document_path.$group_info['directory'].'/chat_files/';
} else {
$chat_path = $document_path.'/chat_files/';
}
// get chat file
$basename_chat = '';
if (!empty($group_id)) {
$basename_chat = 'messages-'.$date_now.'_gid-'.$group_id;
} elseif (!empty($session_id)) {
$basename_chat = 'messages-'.$date_now.'_sid-'.$session_id;
} else {
$basename_chat = 'messages-'.$date_now;
}
$chat_size_old = intval($_POST['chat_size_old']);
$file = $chat_path.$basename_chat.'.log.html';
$chat_size_new = 0;
if (file_exists($file)) {
$chat_size_new = filesize($file);
}
$sql = "SELECT user_id FROM $tbl_chat_connected WHERE user_id='".$_user['user_id']."' $extra_condition";
$result = Database::query($sql);
// The user_id exists so we must do an UPDATE and not a INSERT
$current_time = date('Y-m-d H:i:s');
if (Database::num_rows($result) == 0) {
$query = "INSERT INTO $tbl_chat_connected(c_id, user_id,last_connection,session_id,to_group_id) VALUES($course_id, '".$_user['user_id']."','$current_time','$session_id','$group_id')";
} else {
$query = "UPDATE $tbl_chat_connected set last_connection='".$current_time."' WHERE c_id = $course_id AND user_id='".$_user['user_id']."' AND session_id='$session_id' AND to_group_id='$group_id'";
}
Database::query($query);
$query = "SELECT COUNT(user_id) FROM $tbl_chat_connected WHERE last_connection>'".date('Y-m-d H:i:s',time()-60*5)."' $extra_condition";
$result = Database::query($query);
$connected_old = intval($_POST['connected_old']);
list($connected_new) = Database::fetch_row($result);
/*disconnected user of chat*/
disconnect_user_of_chat ();
require 'header_frame.inc.php';
?>
<form name="formHidden" method="post" action="<?php echo api_get_self().'?cidReq='.$_GET['cidReq']; ?>">
<input type="hidden" name="chat_size_old" value="<?php echo $chat_size_new; ?>">
<input type="hidden" name="connected_old" value="<?php echo $connected_new; ?>">
</form>
<?php
if ($_SESSION["origin"] == 'whoisonline') { //check if our target has denied our request or not
$talk_to = $_SESSION["target"];
$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "select chatcall_text from $track_user_table where ( user_id = $talk_to )";
$result = Database::query($sql);
$row = Database::fetch_array($result);
if ($row['chatcall_text'] == 'DENIED') {
echo "<script language=\"javascript\" type=\"text/javascript\"> alert('".get_lang('ChatDenied')."'); </script>";
$sql = "update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='' WHERE (user_id = $talk_to)";
$result = Database::query($sql);
}
}
require 'footer_frame.inc.php'; chat_message.php 0000644 00000035134 15200302165 0007700 0 ustar 00 <?php
/* For licensing terms, see /license.txt */
/**
* Allows to type the messages that will be displayed on chat_chat.php
*
* @author Olivier Brouckaert
* @package chamilo.chat
*/
/**
* Code
*/
/* INIT SECTION */
define('FRAME', 'message');
$language_file = array('chat');
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$course = api_get_course_id();
$session_id = intval($_SESSION['id_session']);
$group_id = intval($_SESSION['_gid']);
// Juan Carlos RaƱa inserted smileys and self-closing window.
?>
<script type="text/javascript">
function insert_smile(text) {
if (text.createTextRange) {
text.smile = document.selection.createRange().duplicate();
}
}
function insert(text) {
var chat = document.formMessage.message;
if (chat.createTextRange && chat.smile) {
var smile = chat.smile;
smile.text = smile.text.charAt(smile.text.length - 1) == ' ' ? text + ' ' : text;
}
else chat.value += text;
chat.focus(smile)
}
function close_chat_window() {
var chat_window = top.window.self;
chat_window.opener = top.window.self;
chat_window.top.close();
}
</script>
<?php
// Mode open in a new window: close the window when there isn't an user login
if (empty($_user['user_id'])) {
echo '<script languaje="javascript" type="text/javascript"> close_chat_window(); </script>';
} else {
api_protect_course_script();
}
// if we have the session set up
if (!empty($course) && !empty($_user['user_id'])) {
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
/* Constants and variables */
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$sent = $_REQUEST['sent'];
/* MAIN CODE */
$query = "SELECT lastname, firstname, username FROM $tbl_user WHERE user_id='".intval($_user['user_id'])."'";
$result = Database::query($query);
list($pseudo_user) = Database::fetch_row($result);
$isAllowed = !(empty($pseudo_user) || !$_cid);
$isMaster = (bool)$is_courseAdmin;
$firstname = Database::result($result, 0, 'firstname');
$lastname = Database::result($result, 0, 'lastname');
$date_now = date('Y-m-d');
$basepath_chat = '';
$document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
if (!empty($group_id)) {
$group_info = GroupManager :: get_group_properties($group_id);
$basepath_chat = $group_info['directory'].'/chat_files';
} else {
$basepath_chat = '/chat_files';
}
$chat_path = $document_path.$basepath_chat.'/';
$TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = api_get_course_int_id();
if (!is_dir($chat_path)) {
if (is_file($chat_path)) {
@unlink($chat_path);
}
if (!api_is_anonymous()) {
@mkdir($chat_path, api_get_permissions_for_new_directories());
// save chat files document for group into item property
if (!empty($group_id)) {
$doc_id = add_document($_course,$basepath_chat, 'folder', 0, 'chat_files');
$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, 'document',1,NOW(),NOW(),$doc_id,'FolderCreated',1,$group_id,NULL,0)";
Database::query($sql);
}
}
}
require 'header_frame.inc.php';
$chat_size = 0;
// Define emoticons
$emoticon_text1 = ':-)';
$emoticon_img1 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_smile.gif" alt="'.get_lang('Smile').'" title="'.get_lang('Smile').'" />';
$emoticon_text2 = ':-D';
$emoticon_img2 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_biggrin.gif" alt="'.get_lang('BigGrin').'" title="'.get_lang('BigGrin').'" />';
$emoticon_text3 = ';-)';
$emoticon_img3 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_wink.gif" alt="'.get_lang('Wink').'" title="'.get_lang('Wink').'" />';
$emoticon_text4 = ':-P';
$emoticon_img4 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_razz.gif" alt="'.get_lang('Avid').'" title="'.get_lang('Avid').'" />';
$emoticon_text5 = '8-)';
$emoticon_img5 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_cool.gif" alt="'.get_lang('Cool').'" title="'.get_lang('Cool').'" />';
$emoticon_text6 = ':-o)';
$emoticon_img6 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_surprised.gif" alt="'.get_lang('Surprised').'" title="'.get_lang('Surprised').'" />';
$emoticon_text7 = '=;';
$emoticon_img7 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_hand.gif" alt="'.get_lang('Hand').'" title="'.get_lang('Hand').'" />';
$emoticon_text8 = '=8-o';
$emoticon_img8 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_eek.gif" alt="'.get_lang('Amazing').'" title="'.get_lang('Amazing').'" />';
$emoticon_text9 = ':-|)';
$emoticon_img9 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_neutral.gif" alt="'.get_lang('Neutral').'" title="'.get_lang('Neutral').'" />';
$emoticon_text8 = ':-k';
$emoticon_img8 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_think.gif" alt="'.get_lang('Think').'" title="'.get_lang('Think').'" />';
$emoticon_text11 = ':-?';
$emoticon_img11 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_confused.gif" alt="'.get_lang('Confused').'" title="'.get_lang('Confused').'" />';
$emoticon_text12 = ':-8';
$emoticon_img12 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_redface.gif" alt="'.get_lang('Redface').'" title="'.get_lang('Redface').'" />';
$emoticon_text13 = ':- = ';
$emoticon_img13 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_shhh.gif" alt="'.get_lang('Silence').'" title="'.get_lang('Silence').'" />';
$emoticon_text14 = ':-#)';
$emoticon_img14 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_silenced.gif" alt="'.get_lang('Silenced').'" title="'.get_lang('Silenced').'" />';
$emoticon_text15 = ':-(';
$emoticon_img15 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_sad.gif" alt="'.get_lang('Sad').'" title="'.get_lang('Sad').'" />';
$emoticon_text16 = ':-[8';
$emoticon_img16 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_angry.gif" alt="'.get_lang('Angry').'" title="'.get_lang('Angry').'" />';
$emoticon_text17 = '--)';
$emoticon_img17 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_arrow.gif" alt="'.get_lang('Arrow').'" title="'.get_lang('Arrow').'" />';
$emoticon_text18 = ':!:';
$emoticon_img18 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_exclaim.gif" alt="'.get_lang('Exclamation').'" title="'.get_lang('Exclamation').'" />';
$emoticon_text19 = ':?:';
$emoticon_img19 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_question.gif" alt="'.get_lang('Question').'" title="'.get_lang('Question').'" />';
$emoticon_text20 = '0-';
$emoticon_img20 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/icon_idea.gif" alt="'.get_lang('Idea').'" title="'.get_lang('Idea').'" />';
//
$emoticon_text201 = '*';
$emoticon_img201 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/waiting.gif" alt="'.get_lang('AskPermissionSpeak').'" title="'.get_lang('AskPermissionSpeak').'" />';
$emoticon_text202 = ':speak:';
$emoticon_img202 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/flag_green_small.gif" alt="'.get_lang('GiveTheFloorTo').'" title="'.get_lang('GiveTheFloorTo').'" />';
$emoticon_text203 = ':pause:';
$emoticon_img203 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/flag_yellow_small.gif" alt="'.get_lang('Pause').'" title="'.get_lang('Pause').'" />';
$emoticon_text204 = ':stop:';
$emoticon_img204 = '<img src="'.api_get_path(WEB_IMG_PATH).'smileys/flag_red_small.gif" alt="'.get_lang('Stop').'" title="'.get_lang('Stop').'" />';
if ($sent) {
$message = trim(htmlspecialchars(stripslashes($_POST['message']), ENT_QUOTES, $charset));
$message = str_replace($emoticon_text1, $emoticon_img1, $message);
$message = str_replace($emoticon_text2, $emoticon_img2, $message);
$message = str_replace($emoticon_text3, $emoticon_img3, $message);
$message = str_replace($emoticon_text4, $emoticon_img4, $message);
$message = str_replace($emoticon_text5, $emoticon_img5, $message);
$message = str_replace($emoticon_text6, $emoticon_img6, $message);
$message = str_replace($emoticon_text7, $emoticon_img7, $message);
$message = str_replace($emoticon_text8, $emoticon_img8, $message);
$message = str_replace($emoticon_text9, $emoticon_img9, $message);
$message = str_replace($emoticon_text10, $emoticon_img10, $message);
$message = str_replace($emoticon_text11, $emoticon_img11, $message);
$message = str_replace($emoticon_text12, $emoticon_img12, $message);
$message = str_replace($emoticon_text13, $emoticon_img13, $message);
$message = str_replace($emoticon_text14, $emoticon_img14, $message);
$message = str_replace($emoticon_text15, $emoticon_img15, $message);
$message = str_replace($emoticon_text16, $emoticon_img16, $message);
$message = str_replace($emoticon_text17, $emoticon_img17, $message);
$message = str_replace($emoticon_text18, $emoticon_img18, $message);
$message = str_replace($emoticon_text19, $emoticon_img19, $message);
$message = str_replace($emoticon_text20, $emoticon_img20, $message);
//
$message = str_replace($emoticon_text201, $emoticon_img201, $message);
$message = str_replace($emoticon_text202, $emoticon_img202, $message);
$message = str_replace($emoticon_text203, $emoticon_img203, $message);
$message = str_replace($emoticon_text204, $emoticon_img204, $message);
$timeNow = date('d/m/y H:i:s');
$basename_chat = '';
if (!empty($group_id)) {
$basename_chat = 'messages-'.$date_now.'_gid-'.$group_id;
} elseif (!empty($session_id)) {
$basename_chat = 'messages-'.$date_now.'_sid-'.$session_id;
} else {
$basename_chat = 'messages-'.$date_now;
}
if (!api_is_anonymous()) {
if (!empty($message)) {
$message = make_clickable($message);
if (!file_exists($chat_path.$basename_chat.'.log.html')) {
$doc_id = add_document($_course, $basepath_chat.'/'.$basename_chat.'.log.html', 'file', 0, $basename_chat.'.log.html');
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $group_id, null, null, null, $session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'], $group_id, null, null, null, $session_id);
item_property_update_on_folder($_course, $basepath_chat, $_user['user_id']);
} else {
$doc_id = DocumentManager::get_document_id($_course, $basepath_chat.'/'.$basename_chat.'.log.html');
}
$fp = fopen($chat_path.$basename_chat.'.log.html', 'a');
if ($isMaster) {
$photo = '<img src="'.api_get_path(WEB_IMG_PATH).'teachers.gif" alt="'.get_lang('Teacher').'" width="11" height="11" align="top" title="'.get_lang('Teacher').'" />';
fputs($fp, '<span style="color:#999; font-size: smaller;">['.$timeNow.']</span>'.$photo.' <span id="chat_login_name"><b>'.api_get_person_name($firstname, $lastname).'</b></span> : <i>'.$message.'</i><br />'."\n");
} else {
$photo = '<img src="'.api_get_path(WEB_IMG_PATH).'students.gif" alt="'.get_lang('Student').'" width="11" height="11" align="top" title="'.get_lang('Student').'" />';
fputs($fp, '<span style="color:#999; font-size: smaller;">['.$timeNow.']</span>'.$photo.' <b>'.api_get_person_name($firstname, $lastname).'</b> : <i>'.$message.'</i><br />'."\n");
}
fclose($fp);
$chat_size = filesize($chat_path.$basename_chat.'.log.html');
update_existing_document($_course, $doc_id, $chat_size);
item_property_update_on_folder($_course, $basepath_chat, $_user['user_id']);
}
}
}
?>
<form name="formMessage" method="post" action="<?php echo api_get_self().'?'.api_get_cidreq(); ?>" onsubmit="javascript: if(document.formMessage.message.value == '') { alert('<?php echo addslashes(api_htmlentities(get_lang('TypeMessage'), ENT_QUOTES)); ?>'); document.formMessage.message.focus(); return false; }" autocomplete="off">
<input type="hidden" name="sent" value="1">
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td width="320" valign="middle">
<?php $talkboxsize=(api_get_course_setting('allow_open_chat_window')) ? 'width: 350px; height: 35px' : 'width: 450px; height: 35px'; ?>
<textarea name="message" style=" <?php echo $talkboxsize; ?>" onkeydown="send_message(event);" onclick="javascript: insert_smile(this);"></textarea>
</td>
<td>
<button type="submit" value="<?php echo get_lang('Send'); ?>" class="background_submit"><?php echo get_lang('Send'); ?></button>
</td>
</tr>
<tr>
<td>
<?php
echo "<a href=\"javascript:insert('".$emoticon_text1."')\">".$emoticon_img1."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text2."')\">".$emoticon_img2."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text3."')\">".$emoticon_img3."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text4."')\">".$emoticon_img4."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text5."')\">".$emoticon_img5."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text6."')\">".$emoticon_img6."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text7."')\">".$emoticon_img7."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text8."')\">".$emoticon_img8."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text9."')\">".$emoticon_img9."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text10."')\">".$emoticon_img10."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text11."')\">".$emoticon_img11."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text12."')\">".$emoticon_img12."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text13."')\">".$emoticon_img13."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text14."')\">".$emoticon_img14."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text15."')\">".$emoticon_img15."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text16."')\">".$emoticon_img16."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text17."')\">".$emoticon_img17."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text18."')\">".$emoticon_img18."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text19."')\">".$emoticon_img19."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text20."')\">".$emoticon_img20."</a>";
?>
</td>
<td>
<?php
echo "<a href=\"javascript:insert('".$emoticon_text201."')\">".$emoticon_img201."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text202."')\">".$emoticon_img202."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text203."')\">".$emoticon_img203."</a>";
echo "<a href=\"javascript:insert('".$emoticon_text204."')\">".$emoticon_img204."</a>";
?>
</td>
</tr>
</table>
</form>
<?php
}
require 'footer_frame.inc.php';
chat_whoisonline.php 0000644 00000012755 15200302165 0010616 0 ustar 00 <?php
/* For licensing terms, see /license.txt */
/**
* Shows the list of connected users
*
* @author Olivier Brouckaert
* @package chamilo.chat
*/
/**
* Code
*/
define('FRAME', 'online');
$language_file = array('chat');
require_once '../inc/global.inc.php';
$course = api_get_course_id();
$group_id = intval($_SESSION['_gid']);
$session_id = intval($_SESSION['id_session']);
$session_condition = api_get_session_condition($session_id);
$group_condition = " AND to_group_id = '$group_id'";
$extra_condition = '';
if (!empty($group_id)) {
$extra_condition = $group_condition;
} else {
$extra_condition = $session_condition;
}
$user_id = api_get_user_id();
if (!empty($course)) {
$showPic = intval($_GET['showPic']);
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED);
$query = "SELECT username FROM $tbl_user WHERE user_id='".$user_id."'";
$result = Database::query($query);
list($pseudo_user) = Database::fetch_array($result);
$isAllowed = !(empty($pseudo_user) || !$_cid);
$isMaster = (bool)$is_courseAdmin;
$date_inter = date('Y-m-d H:i:s', time() - 120);
$users = array();
$course_id = api_get_course_int_id();
if (empty($session_id)) {
$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri,t3.status
FROM $tbl_user t1, $tbl_chat_connected t2, $tbl_course_user t3
WHERE t2.c_id = $course_id AND
t1.user_id=t2.user_id AND
t3.user_id=t2.user_id AND
t3.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND
t3.course_code = '".$_course['sysCode']."' AND
t2.last_connection>'".$date_inter."' $extra_condition
ORDER BY username";
$result = Database::query($query);
$users = Database::store_result($result);
} else {
// select learners
$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri FROM $tbl_user t1, $tbl_chat_connected t2, $tbl_session_course_user t3
WHERE
t2.c_id = $course_id AND
t1.user_id=t2.user_id AND t3.id_user=t2.user_id AND
t3.id_session = '".$session_id."' AND
t3.course_code = '".$_course['sysCode']."' AND t2.last_connection>'".$date_inter."' $extra_condition ORDER BY username";
$result = Database::query($query);
while ($learner = Database::fetch_array($result)) {
$users[$learner['user_id']] = $learner;
}
// select session coach
$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri FROM $tbl_user t1,$tbl_chat_connected t2,$tbl_session t3
WHERE t2.c_id = $course_id AND
t1.user_id=t2.user_id AND t3.id_coach=t2.user_id AND t3.id = '".$session_id."' AND t2.last_connection>'".$date_inter."' $extra_condition ORDER BY username";
$result = Database::query($query);
if ($coach = Database::fetch_array($result)) {
$users[$coach['user_id']] = $coach;
}
// select session course coach
$query = "SELECT DISTINCT t1.user_id,username,firstname,lastname,picture_uri
FROM $tbl_user t1,$tbl_chat_connected t2,$tbl_session_course_user t3
WHERE
t2.c_id = $course_id AND
t1.user_id=t2.user_id
AND t3.id_user=t2.user_id AND t3.status=2
AND t3.id_session = '".$session_id."'
AND t3.course_code = '".$_course['sysCode']."'
AND t2.last_connection>'".$date_inter."' $extra_condition ORDER BY username";
$result = Database::query($query);
$course_coaches = array();
while ($coaches = Database::fetch_array($result)) {
//$course_coaches[] = $coaches['user_id'];
$users[$coaches['user_id']] = $coaches;
}
//if ($coach = Database::fetch_array($result))
// $users[$coach['user_id']] = $coach;
}
$user_id = $enreg['user_id'];
require 'header_frame.inc.php';
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="data_table">
<tr><th colspan="2"><?php echo get_lang('Connected'); ?></th></tr>
<?php
foreach ($users as & $user) {
if (empty($session_id)) {
$status = $user['status'];
} else {
$status = CourseManager::is_course_teacher($user['user_id'], $_SESSION['_course']['id']) ? 1 : 5;
}
$user_image = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);
$file_url = $user_image['dir'].$user_image['file'];
?>
<tr>
<td width="1%" valign="top"><img src="<?php echo $file_url;?>" border="0" width="22" alt="" /></td>
<td width="99%"><?php if ($status == 1) echo Display::return_icon('teachers.gif', get_lang('Teacher'), array('height' => '11')).' '; else echo Display::return_icon('students.gif', get_lang('Student'), array('height' => '11')); ?><a <?php if ($status == 1) echo 'class="master"'; ?> name="user_<?php echo $user['user_id']; ?>" href="<?php echo api_get_self(); ?>?<?php echo api_get_cidreq(); ?>&showPic=<?php if ($showPic == $user['user_id']) echo '0'; else echo $user['user_id']; ?>#user_<?php echo $user['user_id']; ?>"><?php echo api_get_person_name($user['firstname'], $user['lastname']); ?></a></td>
</tr>
<?php
if ($showPic == $user['user_id']) { ?>
<tr>
<td colspan="2" align="center"><img src="<?php echo $file_url; ?>" border="0" width="100" alt="" /></td>
</tr>
<?php
}
}
unset($users);
?>
</table>
<?php
}
require 'footer_frame.inc.php'; footer_frame.inc.php 0000644 00000000261 15200302165 0010466 0 ustar 00 <?php
/* For licensing terms, see /license.txt */
/**
* Footer of each frame of the Chat tool
*
* @author Olivier Brouckaert
* @package chamilo.chat
*/
?>
</body>
</html>