Page 1 of 1

Admin Ticket Activity

Posted: Tue Dec 30, 2008 9:56 pm
by azWRX06
/*************************************
Title: Admin Ticket Activity
Version: 1.0
Author: Aaron Lee
Demo: NA
Download: NA
Website: NA

Short description: Displays the activity of the
ticket within a given time. Original Source:
http://fundisom.com/phparadise/php/info ... ine#code13
*************************************/

As usual, I modified someone else's code.

Place the following in you admin_ticket.php file.

Between;

Code: Select all

<!-- HR -->
<p>&nbsp;</p>
AND

Code: Select all

<?php
require_once('inc/footer.inc.php');
Paste in the following.

Code: Select all

<div align="center">
<?php

function counter_write($filename, $filecontent, $mode='w')
{ 
	if($fp = @fopen($filename,$mode))
	{ 
		fwrite($fp, stripslashes($filecontent)); 
		fclose($fp);
		return true; 
	}else{ 
		return false; 
	} 
} 

function counter_count($filename, $ip, $timeframe=600)
{
	$counterstr = time().'|'.$ip.'|'."\n";
	$counter = array($ip=>1);
	$hits = 1;
	$counterdata = file($filename);
	$number = count($counterdata);
	for($i = 0; $i < $number; $i++)
	{
		$userdata = explode('|',$counterdata[$i]);
		if($userdata[0] > time()-$timeframe)
		{
			$counter[$userdata[1]]++;
			$hits++;
			$counterstr .= $counterdata[$i];
		}
	}
	counter_write($filename, $counterstr);
	return $hits.' hit'.($hits > 1 ? 's' : '').' by '.count($counter).' user'.(count($counter) > 1 ? 's' : '').' in the last '.($timeframe/60).' minutes.';
}

echo "Ticket Activity: ";
echo counter_count('counter'.$trackingID.'.txt', $_SERVER['REMOTE_ADDR']);

?>
</div>
The result places the individual ticket's activity for a given period of time at the bottom of the admin detail of the ticket.

It may help you to know if another admin has viewed the ticket within the last ?? mins.