[RC5] Script page for team summary?

Bjoern Martin boris59 at gmx.net
Sat Jul 14 13:06:02 EDT 2001


>I'll take a closer look, as I wanted this page in the first place.
>May take some time though, as I actually don't know a bit about
>PHP...

OK, here it is. I sent it to some admins, but maybe someone here in the 
list can review my changes and optimize it (I actually didn't remove any 
calculations, as I don't know anything about php, but some calculations are 
obsolete).

Bye,

Boris59

-- 
boris59 at gmx.net -> PGP mails welcome, public key on request
Member of RC5-64 effort by www.distributed.net - team #6941
-------------- next part --------------
<!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_raw.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;
}

// Set raw low number to first member
$low = 0;

// Set raw limit number far away (will be fixed during sanity test)
$limit = 99999;

$lim = $limit;

// Print header
 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"
        \"http://www.w3.org/TR/REC-html40/loose.dtd\">
<html>
<head>
<title>Raw Team Members for ID $tm</title>
</head>
<body>
<pre>
NOTE: Please make your scripts tolerant of additional values
in this report.  Future improvements may be implemented which
result in additional fields added to each line.
";

// 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";

	print "Hey, you ain't supposed to be here!
This team does not want to list it's members, so you might as well
quit asking for them!
</pre>
</body> 
</html>
";
	exit;
}

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

		if ($pass == "") {
			print "Password required
Not so fast!  You need a password to view this page!
";
		} else {
			print "Invalid password
Sorry, but the password you entered doesn't match the one I'm
looking for... please try again.
";
		}
		print "</pre>
</body> 
</html>
";
		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;
}

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

include "etc/project.inc";
 print "---BEGIN HEADER---
TEAM=$team
MEMBERS=$rows
---BEGIN DATA---
P_RANK,P_ID,FIRST_DATE,LAST_DATE,YESTERDAY_BLOCKS,TOTAL_BLOCKS
";
// Generate the listing here.
for ($i = $low; $i < $low + $limit; $i++)
{
	sybase_data_seek($result, $i);
	$member = sybase_fetch_object($result);
	if (($i/2) == round($i/2)){
		$fmt_bar_color = "$bar_color_a";
	} else {
		$fmt_bar_color = "$bar_color_b";
	}
	$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,$linkid,$first,$last,$yesterday,$blocks
        ";
}
// Print footer
print "---END DATA---
</pre>
</body> 
</html>
";

?>


More information about the rc5 mailing list