[RC5] Script page for team summary?

Richard Farmbrough Richard.Farmbrough at imminus.co.uk
Wed Jul 11 11:22:43 EDT 2001


Will this do?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
	"http://www.w3.org/TR/REC-html40/loose.dtd"> <?
// $Id: tmember.php3,v 1.12 2000/11/25 19:01:13 decibel Exp $

// Variables Passed in url:
//  team == team id to display
//  low == ID to start at, assume 0 if not specified
//  limit == Number of records to display at once - default 100
//  pass == Password for viewing member listing
//  source == y for yesterday's contributors only

$myname = "tmember.php3";

include "../etc/config.inc";
include "../etc/modules.inc";

debug_text("<!-- team: $team, low: $low, limit: $limit, source: $source,
pass: $pass. -->\n",$debug);

if ($team == ""){
	$tm = 1;
} else {
	$tm = 0+$team;
}

if ($low == ""){
	$low = 0;
} else {
	// Make external interface 1 based, internal 0 based
	$low = $low - 1;
	if ($low < 0){
		$low = 0;
	}
}

if ($limit == "") {
	$limit = 100;
}
$lim = $limit;

// Connect to server
sybase_pconnect($interface, $username, $password);

// Query server for basic team information
$qs = "select name, showpassword, showmembers
	from STATS_team
	where team = $tm";
$result = sybase_query($qs);
$info = sybase_fetch_object($result);


$rows = sybase_num_rows($result);
$rows = 0+$rows;

// Verify the team exists
$title = "Team Members Listing - Team #".$tm;

// Do the password checking
if ($info->showmembers == "NO") {
	
	include "etc/project.inc";
	include "etc/lastupdate.inc";
	include "templates/header.inc";

	print "<h1>Hey, you ain't supposed to be here!</h1> <p>This team
does not want to list it's members, so you might as well
		quit asking for them!</p>";
	include "templates/footer.inc";
	exit;
}

if ($info->showmembers == "PAS") {
	if ($pass != $info->showpassword ) {
	
		include "etc/project.inc";
		include "etc/lastupdate.inc";
		include "templates/header.inc";

		if ($pass == "") {
			print "	<h1>Password required</h1> <p>Not so fast!
You need a password to view this page!</p>";
		} else {
			print "	<h1>Invalid password</h1> <p>Sorry, but the
password you entered doesn't match the one I'm
				looking for... please try again.</p>";
		}
		print "	<form action=\"$myname\" method=\"get\"> Password:
<input type=\"password\" length=\"16\" name=\"pass\"> <input type=\"hidden\"
name=\"team\" value=\"$tm\"> <input type=\"hidden\" name=\"source\"
value=\"$source\"> <input type=\"submit\" value=\"Go\"> </form>";
		include "templates/footer.inc";
		exit;
	}
}

// Check when this info was last updated
$qs = "p_lastupdate t, rc5_64, o";
$result = sybase_query($qs);
if(!$result) {
	$qs = "p_lastupdate t, rc5_64, y";
	$result = sybase_query($qs);
}
if($result) {
	$par = sybase_fetch_object($result);
	$lastupdate = sybase_date_format_long($par->lastupdate);
} else {
	$lastupdate = "some day, not too long ago";
}

// See what the last date in the master table is
$qs = "p_lastupdate m, rc5_64";
$result = sybase_query($qs);
$par = sybase_fetch_object($result);
$DT_yesterday = substr($par->lastupdate,0,11);

// See how many blocks this team did
$qs = "	SELECT	rank.blocks as oblocks, yrank.blocks as yblocks
	FROM	statproc.CACHE_tm_RANK rank,
		statproc.CACHE_tm_YRANK yrank
	WHERE	rank.team = $tm and yrank.team = $tm";
$result = sybase_query("set rowcount 0");
$result = sybase_query($qs);
if ($result == "") {
	$totblocks = FALSE;
} else {
	$totblocks = TRUE;
	$blocksresult = sybase_fetch_object($result);
	$oblocks = $blocksresult->oblocks;
	$yblocks = $blocksresult->yblocks;
	if ( $yblocks == 0 ) $yblocks = 1;
}

// Query server for member listing
if ($source == y) {		// $qs_source is an easy way around re-doing
$qs based on $source
	$qs_source = "";
} else {
	$qs_source = "*";
}
$qs = "	SELECT	tmember.blocks, tmember.first, tmember.last,
		part.id, part.listmode, part.contact_name, part.email,
part.team, emyrank.blocks AS yblocks
	FROM	statproc.CACHE_tm_MEMBERS tmember,
		STATS_participant part,
		statproc.CACHE_em_yrank emyrank
	WHERE	tmember.team = $tm
		and part.id = tmember.id
		and emyrank.id =" . $qs_source . " tmember.id 
		and emyrank.id =" . $qs_source . " part.id 
		and part.listmode < 10 ";
if ($source == y) $qs = $qs . "and tmember.last = '$DT_yesterday'
	ORDER BY emyrank.blocks desc";
 else $qs = $qs . "ORDER BY tmember.blocks desc";

$result = sybase_query("set rowcount 0");
$result = sybase_query($qs);
$rows = sybase_num_rows($result);
$rows = 0+$rows;

if ($debug == "yes") echo "<!-- Query: \"$qs\" Rows: \"$rows\" -->";

// Sanity check $low and $limit
if ($low > $rows) {
	$low = $rows - 1;
	$limit = 1;
}

if ($low + $limit > $rows)
{
	$limit = $rows - $low;
	if ($limit > $rows) $limit = $rows;
	$low = $rows - $limit;
}
// Richard's first hack
$lo=0
$limit=$rows
// </hack>

$hi = $low + $limit;
$lo = $low + 1;
$title = "$info->name Members ";
if ($source == y) $title = $title . "Yesterday ";
    else $title = $title . "Overall ";
$title = $title . "$lo - $hi";


// Generate the listing here.
for ($i = $low; $i < $low + $limit; $i++)
{
	sybase_data_seek($result, $i);
	$member = sybase_fetch_object($result);
	$rnk = number_style_convert($i+1);
	if ( substr($member->last,0,11) == $DT_yesterday ) $n_yesterday =
0+$member->yblocks;
	   else $n_yesterday = 0;
	$yesterday = number_style_convert($n_yesterday);
	$blocks = number_style_convert(0+$member->blocks);
	$first = sybase_date_format_long($member->first);
	$last = sybase_date_format_long($member->last);
	$linkid = 0+$member->id;
	$fmtid = number_style_convert($linkid);

	$listas = participant_listas($member->listmode, $member->email,
$member->id, $member->contact_name);
	if ($debug == "yes") echo "
<!--- last: " . substr($member->last,0,11) . " DT: $DT_yesterday
y:$n_yesterday o:$member->blocks yt:$yblocks ot:$oblocks
y%:$n_yesterday/$yblocks --->";

	print " $rnk , $listas , $first , $last , $yesterday ,";
	if ($totblocks) print
number_style_convert($n_yesterday/$yblocks*100 ,2) 
	print " , $blocks , ";
	if ($totblocks) print
number_style_convert($member->blocks/$oblocks*100, 2) ;
	print "
";
}


?> 


               Rgds,
 
                          Richard Farmbrough.
--
ECommerce Manager
Business Solutions Group
Telewest Communications PLC
Tel +44 (0) 1733 392122
Mob +44 (0) 7711 895 397 




-----Original Message-----
From: David McNett [mailto:nugget at slacker.com]
Sent: 10 July 2001 16:42
To: rc5 at lists.distributed.net
Subject: Re: [RC5] Script page for team summary?


On 10-Jul-2001, Jim C. Nasby wrote:
> No such page exists.  (raw data stats pages)

However, the source to the stats php is available for review at 
http://cvs.distributed.net/ and if anyone feels motivated enough to
hack "raw" support in, we'll gladly put that code into production.

-- 
 ________________________________________________________________________
|David McNett          |To ensure privacy and data integrity this message|
|nugget at distributed.net|has been encrypted by using dual rounds of ROT-13|
|Austin, TX USA        |finger nugget at distributed.net for my news and pgp|

------------------------------------------------------------------------------
Live Life in Broadband
www.telewest.co.uk


The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material.
Statements and opinions expressed in this e-mail may not represent those of the company. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender immediately and delete the material from any computer.


==============================================================================

--
To unsubscribe, send 'unsubscribe rc5' to majordomo at lists.distributed.net
rc5-digest subscribers replace rc5 with rc5-digest



More information about the rc5 mailing list