Location: PHPKode > projects > Insecticida > insecticida_wiki/main.php
<?
###################################################
#Copyright (C) 2001 Stuart Wigley (hide@address.com)
#
#main.php 19/04/2001
#
#This file is part of workbench.
#
#workbench is free software; you can 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.
#
#workbench 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 should have received a copy of the GNU General Public License
#along with workbench; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#####################################################
session_register("login");
session_register("group");
session_register("thisuserID");
require_once("config.php");
require_once("connect.php");
require_once("general.php");
include("header.php");

function prevMonday( $dayOfWeek, $mymon, $myday, $myyear, $num )
{
	return date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - ($num * 7), $myyear ) );
}
$profile = 0;
$time1 = getmicrotime();

if ( $login )
{
  session_register("login");
  # convert php $now into SQL date
  # echo $now . "<br>";
  $tok = strtok( $now, " " );
  $mydate = "";
  $thisMonday = "";
  for ( $i = 0; $tok; $i++ )
  {
       switch ( $i )
       {
       case 0: switch ( $tok )
       	       {
       		   case "Sun": $dayOfWeek = 6; break;
       		   case "Mon": $dayOfWeek = 0; break;
		   case "Tue": $dayOfWeek = 1; break;
		   case "Wed": $dayOfWeek = 2; break;
		   case "Thu": $dayOfWeek = 3; break;
		   case "Fri": $dayOfWeek = 4; break;
		   case "Sat": $dayOfWeek = 5; break;
	       }
       case 1: switch ( substr( $tok, 0, 3 ) )
       	       {
       		   case "Jan": $mymon = '01'; break;
       		   case "Feb": $mymon = '02'; break;
		   case "Mar": $mymon = '03'; break;
		   case "Apr": $mymon = '04'; break;
		   case "May": $mymon = '05'; break;
		   case "Jun": $mymon = '06'; break;
		   case "Jul": $mymon = '07'; break;
		   case "Aug": $mymon = '08'; break;
		   case "Sep": $mymon = '09'; break;
		   case "Oct": $mymon = '10'; break;
		   case "Nov": $mymon = '11'; break;
		   case "Dec": $mymon = '12'; break;
		   default:  $mymon = substr( $tok, 1, 3 );
       	       }
               break;
	   case 3: $myyear = $tok;
	       break;
	   case 2: $myday = $tok;
               break;
           default:
       }
       $tok = strtok( " " );
  }
  $mydate = $myyear . "-" . $mymon . "-" . $myday;
  $tomorrow = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday + 1, $myyear ) );
  $thisMonday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek, $myyear ) );
  $prevMonday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - 7, $myyear ) );
  $prev2Monday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - 14, $myyear ) );
  $prev3Monday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - 21, $myyear ) );
  $prev7Monday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - (7 * 7), $myyear ) );
  $prev11Monday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - (11 * 7), $myyear ) );
  $prev15Monday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - (15 * 7), $myyear ) );
  $prev19Monday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - (19 * 7), $myyear ) );
  $prev23Monday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - (23 * 7), $myyear ) );
  $prev27Monday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - (27 * 7), $myyear ) );
  $prev31Monday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - (31 * 7), $myyear ) );
  $prev35Monday = date( "Y-m-d", mktime( 0,0,0, $mymon, $myday - $dayOfWeek - (35 * 7), $myyear ) );
	# queries
	$query = mysql_query("select * from users where users.login='$login'") or die(mysql_error());
	$result = mysql_fetch_array($query);
	$query2 = mysql_query("select * from groups where grpID='$result[grpID]'") or die(mysql_error());
	$result2 = mysql_fetch_array($query2);
	$query3 = mysql_query("select * from bugs where assTo='$login' and statusID!='3'") or die(mysql_error());
	$queryInvestigating = mysql_query("select * from bugs where assTo='$login' and statusID = '11'") or die(mysql_error());
	$queryEstimated = mysql_query("select * from bugs where assTo='$login' and (estimate like '% Know' or estimateDatetime is null)") or die(mysql_error());
	$queryOverDue = mysql_query("select * from bugs where assTo='$login' and dueDate != '' and dueDate <= '" . $myyear . "/" . $mymon . "/" . $myday . "'") or die(mysql_error());
	$query4 = mysql_query("select email from users where userID='1'") or die(mysql_error());
	$result4 = mysql_fetch_array($query4);
	$query5 = mysql_query("select * from bugs where openedBy='$login' and statusID!='3'") or die(mysql_error());
	# update accessLog table
	$query7 = mysql_query("select * from accessLog where sessionID='".session_id()."'") or die(mysql_error());
	if (!mysql_num_rows($query7))
	{
		mysql_query("insert into accessLog (logID,sessionID,date,useragent,userID) values('','".session_id()."','$now','$HTTP_USER_AGENT','$result[userID]')") or die(mysql_error());
	}
?>
<table cellspacing="0" class="table3">
	<tr class="rowtitle">
		<td><h5>Hello <?=$result[fName]." ".$result[sName]?> (<?=$login?>) and welcome to <?=$theVersion?></h5></td>
	</tr>
	<tr>
    	<td><p>I am a <i> <?=$result2[grpName]?></i>. If this is inaccurate I will contact the <a class="nav2" href="mailto:<?=$result4[email]?>">Administrator</a>.</p></td>
	</tr>
   	<tr>
    	<td><p>Issues assigned to me: <a class="nav2" href="<?=$relative?>/bugtracking/viewbugs.php?assTo=<?=$login?>"><?=mysql_num_rows($query3)?></a>. 
<?
	if ($result[grpID] == '2' || $result[grpID] == '3')
	{
		echo( "I'm investigating <a class=\"nav2\" href=\"" . $relative . "/bugtracking/viewbugs.php?assTo=" . $login . "&status=11\">" );
		echo( mysql_num_rows( $queryInvestigating ) );
		echo( "</a> issues." );
		$estim = mysql_num_rows( $queryEstimated );
		if ( $estim > 0 )
		{
		   echo( " I have <strong>" );
		   echo( $estim );
		   echo( "</strong> issues not estimated." );
		}
		$overDue = mysql_num_rows( $queryOverDue );
		if ( $overDue > 0 )
		{
		   echo( " I have <strong>" );
		   echo( $overDue );
		   echo( "</strong> issues overdue." );
		}
	}
?></p>
	<p> Outstanding issues opened by me : <a class="nav2" href="<?=$relative?>/bugtracking/viewbugs.php?openBy=<?=$login?>"><?=mysql_num_rows($query5)?></a></p>
            <p>Project Statistics:</p>
	<ul>
	<div>
            <p>Project is 100% operational.</p>
<?
  $periodName[ 1 ] = "Today";
  	$dateFirst[ 1 ] = "$mydate"; $dateLast[ 1 ] = "$tomorrow";
  $periodName[ 2 ] = "This Week";
  	$dateFirst[ 2 ] = "$thisMonday"; $dateLast[ 2 ] = "$tomorrow";
  $periodName[ 3 ] = "Week - 1";
  	$dateFirst[ 3 ] = "$prevMonday"; $dateLast[ 3 ] = "$thisMonday";
  $periodName[ 4 ] = "Week - 2";
  	$dateFirst[ 4 ] = "$prev2Monday"; $dateLast[ 4 ] = "$prevMonday";
  $periodName[ 5 ] = "Week - 3";
  	$dateFirst[ 5 ] = "$prev3Monday"; $dateLast[ 5 ] = "$prev2Monday";
  $periodName[ 6 ] = "Month - 1";
  	$dateFirst[ 6 ] = "$prev7Monday"; $dateLast[ 6 ] = "$prev3Monday";
  $periodName[ 7 ] = "Month - 2";
  	$dateFirst[ 7 ] = "$prev11Monday"; $dateLast[ 7 ] = "$prev7Monday";
  $periodName[ 8 ] = "Month - 3";
  	$dateFirst[ 8 ] = "$prev15Monday"; $dateLast[ 8 ] = "$prev11Monday";
  $periodName[ 9 ] = "Month - 4";
  	$dateFirst[ 9 ] = "$prev19Monday"; $dateLast[ 9 ] = "$prev15Monday";
  $periodName[ 10 ] = "Month - 5";
  	$dateFirst[ 10 ] = "$prev23Monday"; $dateLast[ 10 ] = "$prev19Monday";
  $periodName[ 11 ] = "Month - 6";
  	$dateFirst[ 11 ] = "$prev27Monday"; $dateLast[ 11 ] = "$prev23Monday";
  $periodName[ 12 ] = "Month - 7";
  	$dateFirst[ 12 ] = "$prev31Monday"; $dateLast[ 12 ] = "$prev27Monday";
  $periodName[ 13 ] = "Month - 8";
  	$dateFirst[ 13 ] = "$prev35Monday"; $dateLast[ 13 ] = "$prev31Monday";

  # echo "today =", $mydate, "=", $dateFirst[1] . "<BR>";
  # echo "tomorrow =", $tomorrow, "=", $dateLast[1] . "<BR>";
  # echo $thisMonday . "<BR>";

?>
<table cellspacing="0" class="table5">
	<tr class="rowtitle">
		<td><h5>Period </h5> </td>
		<td align=right><h5>Opened </h5> </td>
		<td align=right><h5>Reopened </h5> </td>
		<td align=right><h5>Checked-in </h5> </td>
		<td align=right><h5>Closed </h5> </td>
	</tr>
<?
$time3 = getmicrotime();
if ( $profile == 1 ) echo "<p>Time elapsed: ", $time3 - $time1, " seconds";
$bgcolor = "#dddddd"; 
for ( $i = 1; $i <= 13; $i++ )
{
	$queryOpen = mysql_query( "select * from bugs where openDateTime >= '$dateFirst[$i]' and openDateTime < '$dateLast[$i]'" ) or die( mysql_error() );
	$queryReopen = mysql_query( "select * from bugs where reopenDateTime >= '$dateFirst[$i]' and reopenDateTime < '$dateLast[$i]'" ) or die( mysql_error() );
	$queryCheckIn = mysql_query( "select * from bugs where checkinDateTime >= '$dateFirst[$i]' and checkinDateTime < '$dateLast[$i]'" ) or die( mysql_error() );
	$queryClose = mysql_query( "select * from bugs where closeDateTime >= '$dateFirst[$i]' and closeDateTime < '$dateLast[$i]'" ) or die( mysql_error() );
	if ($bgcolor == "#dddddd")
        {
             $bgcolor = "#eeeeee";
        }
        elseif ($bgcolor == "#eeeeee")
        {
             $bgcolor = "#dddddd";
        } 
 	echo("<tr bgcolor=\"$bgcolor\">");
?>
            <td><?= $periodName[$i] ?></td>
	    <td align=right><strong> 
	<? 
	   $number = mysql_num_rows( $queryOpen );
	   if ( $number != 0 )
           {
		echo( $number );
	   }
	   else {
		echo( "&nbsp;" );
	   }
        ?> 
	    </strong></td>
	    <td align=right><strong> 
	<? 
	   $number = mysql_num_rows( $queryReopen );
	   if ( $number != 0 )
           {
		echo( $number );
	   }
	   else {
		echo( "&nbsp;" );
	   }
        ?> 
		</strong></td>
	    <td align=right><strong> 
	<? 
	   $number = mysql_num_rows( $queryCheckIn );
	   if ( $number != 0 )
           {
		echo( $number );
	   }
	   else {
		echo( "&nbsp;" );
	   }
        ?> 
		</strong></td>
	    <td align=right><strong> 
	<? 
	   $number = mysql_num_rows( $queryClose );
	   if ( $number != 0 )
           {
		echo( $number );
	   }
	   else {
		echo( "&nbsp;" );
	   }
        ?> 
		</strong></td>
	</tr>
<?
}
$time4 = getmicrotime();
if ( $profile == 1 ) echo "<p>Time elapsed: ", $time4 - $time3, " seconds";
?>
</tr>
</table>
	</div>
	</ul>
	</table>
<?
           
}
else {
	include("guest.php");
}
include("footer.php");

$time2 = getmicrotime();
if ( $profile == 1 ) echo "<p>Time elapsed: ", $time2 - $time1, " seconds";
?>
Return current item: Insecticida