Location: PHPKode > projects > ACollab > chat/index.php
<?php
/****************************************************************************************/
/* ACollab                                                                              */
/****************************************************************************************/
/* Copyright (c) 2002-2004  Adaptive Technology Resource Centre / University of Toronto */
/*                                                                                      */
/* http://atutor.ca/acollab                                                             */
/*                                                                                      */
/* This program is free software. You may redistribute it and/or                        */
/* modify it under the terms of the GNU General Public License                          */
/* as published by the Free Software Foundation; either version 2 of the License,       */
/* or (at your option) any later version.                                               */
/*                                                                                      */
/* This program 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 may access the GNU General Public License at:                                    */
/* http://www.opensource.org/licenses/gpl-license.php                                   */
/*                                                                                      */
/* You may contact the Adaptive Technology Resource Centre at                           */
/* Robarts Library, University of Toronto                                               */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5                              */
/* Further contact information is available at http://www.utoronto.ca/atrc/             */
/****************************************************************************************/
/* Programmer:                                                                          */
/* Joel Kronenberg - ATRC                                                               */
/****************************************************************************************/
// $Id: index.php 442 2005-03-07 21:22:00Z shozubq $

define('AC_INCLUDE_PATH', '../include/');

require(AC_INCLUDE_PATH.'vitals.inc.php');
authenticate(USER_CLIENT, USER_GROUP_ADMIN, USER_ADMIN);
require('include/functions.inc.php');

$_SECTION[0][0] = _AC('home');
$_SECTION[0][1] = 'home.php';
$_SECTION[1][0] = _AC('chat');
$_SECTION[1][1] = 'chat/';

require(AC_INCLUDE_PATH.'header.inc.php');

if ($_GET['f']) {
	print_feedback($_GET['f']);
}

print_popup_help('help_chat_transcript');


?>

<p align="center"><a href="chat/chat.php?firstLoginFlag=1" onfocus="this.className='highlight'" onblur="this.className=''"><b>ยป <?php echo _AC('enter_chat');  ?></b></a></p>

<!-- Check when chat was last accessed, if a chat session is ztill active then display list of users online -->
<?php
	if ($dir = @opendir('users/')) {
		echo '<h4>' . _AC('users_online') . ': </h4>';
		echo '<ul>';
		while (($file = readdir($dir)) !== false) {

			if (($file == '..') || ($file == '.')) {
				continue;
			}

			$chatName	= substr($file, 0, -strlen('.prefs'));
			if ($chatName == '') {
				continue;
			}

			$la	 = getLastAccessed($chatName);
			$now = time();

			if (getGroupID($chatName) != $_SESSION['group_id']) {
				continue;
			}
			
			if (($la == 0) || (!$la)) {
				$la = 0;
			} else if (($now - $la) < $admin['chatSessionLifeSpan']) {
				$colour	= getChatIDColour($chatName, $myPrefs['colours']);
				if ($chatName == $_SESSION['login']) {
					echo '<li><a href="chat/filterHistory.php?filterChatID='.$chatName.'" target="_top" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"><span style="color:'.$colour.'">'.$chatName.'</span></a> ('._AC('chat_you').')</li>';
				} else {
					echo '<li><a href="chat/filterHistory.php?filterChatID='.$chatName.'" target="_top" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'"><span style="color:'.$colour.'">'.$chatName.'</span></a></li>';
				}
				$active = true;
			} else {
				/**/
			}
		}
		if (!$active) {
			echo '<li>' . _AC('no_users_online') . '</li>';
		}
		echo '</ul>';
	}
	closedir($dir);


?>



<h4><?php echo _AC('transcripts');  ?></h4>
<?php

if ($_GET['col']) {
	$col = addslashes($_GET['col']);
} else {
	$col = 'date';
}

if ($_GET['order']) {
	$order = addslashes($_GET['order']);
} else {
	$order = 'desc';
}

${'highlight_'.$col} = ' u';


	$tran_files = array();

	if ($dir = @opendir('tran/'.$_SESSION['group_id'])) {
		while (($file = readdir($dir)) !== false) {
			if (substr($file, -strlen('.html')) == '.html') {
				$la	= stat('tran/'.$_SESSION['group_id'].'/'.$file);
				$file = str_replace('.html', '', $file);
				$tran_files[$file] = $la['ctime'];
			}
		}
	}

	if (count($tran_files) == 0) {
		echo '<p>'._AC('chat_none_found').'</p>';
	} else {
		echo '<table cellspacing="0" cellpadding="2" border="0" width="99%" align="center" bgcolor="white" summary="" class="box2">';
		echo '<tr>';
		echo '<th scope="col" class="box" align="left"><small><a href="'.$_SERVER['PHP_SELF'].'?col=name'.SEP.'order=asc" class="nav'.$highlight_name.'" title="'._AC('chat_sort_by_name').'" onfocus="this.className=\'highlight\'" onblur="this.className=\'nav'.$highlight_name.'\'">'._AC('chat_name').'</a> ';

		if (($col == 'name') && ($order == 'asc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=name'.SEP.'order=desc" title="'._AC('chat_name_descending').'"><img src="images/desc.gif" height="7" width="11" alt="'._AC('chat_name_descending').'" border="0" class="img4" /></a>';
		} else if (($col == 'name') && ($order == 'desc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=name'.SEP.'order=asc" title="'._AC('chat_name_ascending').'"><img src="images/asc.gif" height="7" width="11" alt="'._AC('chat_name_ascending').'" border="0"  class="img4" /></a>';
		} else {
			echo '<img src="images/clr.gif" height="7" width="11" alt="" />';
		}
		echo '</small></th>';
		echo '<th scope="col" class="box">&nbsp;</th>';
		echo '<th scope="col" class="box" align="right"><small><a href="'.$_SERVER['PHP_SELF'].'?col=date'.SEP.'order=desc" class="nav'.$highlight_date.'" title="'._AC('chat_sort_by_date').'" onfocus="this.className=\'highlight\'" onblur="this.className=\'nav'.$highlight_date.'\'">'._AC('chat_date').'</a> ';
		if (($col == 'date') && ($order == 'asc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=date'.SEP.'order=desc" title="'._AC('chat_date_descending').'"><img src="images/desc.gif" height="7" width="11" alt="'._AC('chat_date_descending').'" border="0"  class="img4" /></a>';
		} else if (($col == 'date') && ($order == 'desc')) {
			echo '<a href="'.$_SERVER['PHP_SELF'].'?col=date'.SEP.'order=asc" title="'._AC('chat_date_ascending').'"><img src="images/asc.gif" height="7" width="11" alt="'._AC('chat_date_ascending').'" border="0"  class="img4" /></a>';
		} else {
			echo '<img src="images/clr.gif" height="7" width="11" alt="" />';
		}
		echo '</small></th>';
		if (authenticate(USER_GROUP_ADMIN, USER_RETURN_CHECK)) {
			echo '<th scope="col" class="box">&nbsp;</th>';
		}

		echo '</tr>';

		if (($col == 'date') && ($order == 'asc')) {
			asort($tran_files);
		} else if (($col == 'date') && ($order == 'desc')) {
			arsort($tran_files);
		} else if (($col == 'name') && ($order == 'asc')) {
			ksort($tran_files);
		} else if (($col == 'name') && ($order == 'desc')) {
			krsort($tran_files);
		}
		reset ($tran_files);

		foreach ($tran_files as $file => $date) {
			$counter++;
			$col = ($counter-1)%2;

			echo '<tr>';
			echo '<td class="row'.$col.'"><small><a href="chat/tran.php?t='.$file.'" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">'.$file.'</a>';
			echo '</small></td>';
			echo '<td class="row'.$col.'"><small>';
			if (($file.'.html' == $admin['tranFile']) && ($admin['produceTran'])) {
				echo '<strong>'._AC('chat_currently_active').'</strong>';
			}
			echo '&nbsp;</small></td>';
				
			echo '<td class="row'.$col.'" align="right"><small>'.date('Y-m-d h:i:s', $date).'</small></td>';
			
			if (authenticate(USER_GROUP_ADMIN, USER_RETURN_CHECK)) {
				echo '<td class="row'.$col.'" align="right"><small>';
				if (($file.'.html' == $admin['tranFile']) && ($admin['produceTran'])) {
					echo '&nbsp;';
				} else {
					echo '<a href="chat/tran_delete.php?t='.$file.'" onfocus="this.className=\'highlight\'" onblur="this.className=\'\'">'._AC('chat_delete').'</a>';
				}
				
				echo '</small></td>';
			}

			echo '</tr>';
		}
		echo '</table>';
		echo '<p><small>'._AC('chat_use_headings_to_sort').'</small></p>';
	}

	require(AC_INCLUDE_PATH.'footer.inc.php');
?>
Return current item: ACollab