function showChat($project_id)
{
    global $base_URL;
    $messages = false;
    $result = mysql_do("SELECT * FROM chat_log WHERE project_id='{$project_id}' ORDER BY created DESC LIMIT 50;");
    while ($query_data = mysql_fetch_array($result)) {
        $messages = true;
        $this_user = new User();
        $this_user->populateFromId($query_data['user_id']);
        $result_2 = mysql_do("SELECT * FROM users_active WHERE user_id='{$this_user->id}' LIMIT 1;");
        while ($query_data_2 = mysql_fetch_array($result_2)) {
            echo '<p><span class="date">' . $query_data['created'] . '</span> <span class="name"><a href="' . $base_URL . 'profile/' . $this_user->username . '" style="color: #' . $query_data_2['color'] . ';">' . $this_user->name . '</a></span>: <span class="message">' . $query_data['chat'] . '</span></p>';
        }
    }
    if (!$messages) {
        echo '<p><span class="none">No chat messages yet.</span></p>';
    }
}
    public function showComments($thread_id)
    {
        global $reply_depth;
        $this->comments = array();
        $this->getComments($thread_id);
        $to_return = FALSE;
        if (count($this->comments) > 0) {
            $to_return = TRUE;
            foreach ($this->comments as $comment_id) {
                $this_comment = new Comment();
                $this_comment->populateFromId($comment_id);
                $commenter = new User();
                $commenter->populateFromId($this_comment->user_id);
                ?>
			
		<div class="comment" style="margin-left: <?php 
                echo $reply_depth * 50;
                ?>
">
		
		<a name="comment_<?php 
                echo $this_comment->id;
                ?>
" />
		
		<p class="by"><a href="<?php 
                echo $base_URL;
                ?>
profile/<?php 
                echo $commenter->username;
                ?>
"><?php 
                echo $commenter->name;
                ?>
</a> <?php 
                if ($thread_id == 0) {
                    ?>
writes<?php 
                } else {
                    ?>
replies<?php 
                }
                ?>
:</p>
		
		<p class="comment"><?php 
                echo nl2br($this_comment->comment);
                ?>
</p>
		
		<p class="time"><b>Time:</b> <?php 
                echo $this_comment->created;
                ?>
</p>
		
		<p class="classification"><b>Classification:</b> <?php 
                echo $this_comment->classification;
                ?>
</p>
		
		<p class="caveat"><b>Caveat:</b> <?php 
                echo $this_comment->caveat;
                ?>
</p>
		
		
		
		<?php 
                $reply_id = rand(0, 10000000000);
                ?>
		
		<p class="replyTo"><a style="cursor: pointer;" onclick="new Effect.BlindDown(reply<?php 
                echo $reply_id;
                ?>
);">Reply</a></p>
		
		<div class="replyToThis" id="reply<?php 
                echo $reply_id;
                ?>
" style="display: none;">
		
		<form method="post" class="edit" action="add_comment_action.php">

		<input type="hidden" name="this_url" value="<?php 
                echo $_SERVER['REQUEST_URI'];
                ?>
" />
		
		<input type="hidden" name="user_id" value="<?php 
                echo $active_user->id;
                ?>
" />
		
		<input type="hidden" name="evidence_id" value="<?php 
                echo $this->id;
                ?>
" />
		
		<input type="hidden" name="project_id" value="<?php 
                echo $this->project_id;
                ?>
" />
		
		<input type="hidden" name="hypothesis_id" value="0" />
		
		<input type="hidden" name="reply_to_id" value="<?php 
                echo $this_comment->id;
                ?>
" />
		
		<p><textarea rows="8" name="comment" cols="60"></textarea></p>
		
		<p><b>Classification</b> <select name="classification">
			<option value="U">Unclassified</option>
			<option value="C">Confidential</option>
			<option value="S">Secret</option>
			<option value="TS">Top Secret</option>
		</select> <b style="padding-left: 15px;">Caveat</b> <select name="caveat">
			<option value="">(No caveat)</option>
			<option value="FOUO/AIUO">FOUO/AIUO</option>
			<option value="SI">SI</option>
			<option value="TK">TK</option>
			<option value="HCS">HCS</option>
			<option value="G">G</option>
		</select></p>
		
		<p class="submit"><input class="button" type="submit" value="Add Reply" /></p>
		
		</form>
		
		</div>


		
		</div>
			
			<?php 
                $reply_depth++;
                $this->showComments($this_comment->id);
                $reply_depth--;
            }
        }
        return $to_return;
    }
**
**    ACH 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 Open Source ACH. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////////////// */
?>

<?php 
$active_evidence = new Evidence();
$active_evidence->populateFromId($_REQUEST['evidence_id']);
$this_user = new User();
$this_user->populateFromId($active_evidence->user_id);
?>

<div id="nonEdit">
<p><a onClick="document.getElementById('edit').style.display='block'; document.getElementById('nonEdit').style.display='none';">Edit evidence information</a><?php 
if ($active_project->user_id == $active_user->id) {
    ?>
 |<a style="color: #FF0000; padding-left: 10px;" onclick="javascript:confirm_delete_evidence(<?php 
    echo $active_evidence->id;
    ?>
);">Delete evidence record</a><?php 
}
?>
</p>

 public function mailEveryone($subject, $message)
 {
     // Sends a message to everyone in the group.
     $this->getUsers();
     for ($i = 0; $i < count($this->users); $i++) {
         $this_user = new User();
         $this_user->populateFromId($this->users[$i]);
         sendMail($this_user->email, $subject, $message);
     }
 }
	
	
	
	<form style="margin: 0px;" method="post" class="edit" action="project_ratings_user_action.php">
	
	<input type="hidden" name="project_id" value="<?php 
            echo $active_project->id;
            ?>
">
	
	<p style="margin-bottom: 0px;">View others' personal matrices: <select name="ratings_user_id"><?php 
            $active_project->getUsers();
            for ($j = 0; $j < count($active_project->users); $j++) {
                if ($active_project->users[$j] != $active_user->id) {
                    $this_user = new User();
                    $this_user->populateFromId($active_project->users[$j]);
                    echo '<option value="' . $this_user->id . '">' . $this_user->name . '</a> ';
                }
            }
            ?>
</select> <input type="submit" value="View..." /></p>
	
	</form>
	
	<?php 
        }
        ?>
	
	
	
	</div>
                }
            }
            if (count($active_project->users) == 0) {
                echo "None.";
            }
            ?>
</p>
					
					<?php 
            if ($active_project->open == "n") {
                ?>
					
					<p class="otherMembers"><b>View-Only Members:</b> <?php 
                for ($j = 0; $j < count($active_project->users_view_only); $j++) {
                    $this_user = new User();
                    $this_user->populateFromId($active_project->users_view_only[$j]);
                    echo '<a href=' . $base_URL . '"/profile/' . $this_user->username . '">' . $this_user->name . '</a> ';
                }
                if (count($active_project->users_view_only) == 0) {
                    echo "None.";
                }
                ?>
 <span class="showHideInviteViewer" id="showHideInviteViewer"><a class="inviteViewer" onclick="showInviteViewer();">Invite</a></span></p>
					
					
					
					<div class="inviteViewer" id="inviteViewer" style="display: none;">
					
					<input type="hidden" name="project_id" value="<?php 
                echo $active_project->id;
                ?>
 public function displayInvitationNotices()
 {
     echo '<div class="invitationNotices">';
     $result = mysql_do("SELECT * FROM invitation_notices WHERE user_id='{$this->id}' AND displayed='n'");
     while ($query_data = mysql_fetch_array($result)) {
         $this_project = new Project();
         $this_project->populateFromId($query_data['project_id']);
         $by_user = new User();
         $by_user->populateFromId($query_data['by_user_id']);
         echo '<p class="' . $query_data['type'] . '">You have been ';
         if ($query_data['type'] == "approve") {
             echo 'approved';
         }
         if ($query_data['type'] == "deny") {
             echo 'denied';
         }
         echo ' access to project <a href="' . $base_URL . 'project/' . $this_project->id . '">' . $this_project->title . '</a> by <a href="' . $base_URL . 'profile/' . $by_user->username . '">' . $by_user->name . '</a>.';
     }
     echo '</div>';
     mysql_do("UPDATE invitation_notices SET displayed='y' WHERE user_id='{$this->id}';");
 }
                }
                ?>
</p>
			
			<?php 
                $this_project->getJoinRequests();
                if (count($this_project->join_requests) > 0 && in_array($this_project->id, $active_user->owner_of_projects)) {
                    ?>
			
			<p class="joinRequests"><b>Join Requests:</b></p>
			
			<ul class="joinRequests">
			<?php 
                    for ($j = 0; $j < count($this_project->join_requests); $j++) {
                        $this_user = new User();
                        $this_user->populateFromId($this_project->join_requests[$j]);
                        echo '<li><a href="' . $base_URL . 'profile/' . $this_user->username . '">' . $this_user->name . '</a> <a class="approve" href="' . $base_URL . 'joinrequest/' . $this_user->id . '/' . $this_project->id . '/approve">Approve</a> <a class="deny" href="' . $base_URL . 'joinrequest/' . $this_user->id . '/' . $this_project->id . '/deny">Deny</a></li>';
                    }
                    ?>
			</ul>
			
			<?php 
                }
                ?>
			
			</div>
			
			<?php 
            }
        }
        ?>
**
**    ACH 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 Open Source ACH. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////////////// */
?>

<?php 
$active_hypothesis = new Hypothesis();
$active_hypothesis->populateFromId($_REQUEST['hypothesis_id']);
$this_user = new User();
$this_user->populateFromId($active_hypothesis->user_id);
?>

<div id="nonEdit">

<?php 
if ($active_project->user_id == $active_user->id) {
    ?>
<p><a onClick="document.getElementById('edit').style.display='block'; document.getElementById('nonEdit').style.display='none';">Edit hypothesis information</a> | <?php 
}
if ($active_project->user_id == $active_user->id) {
    ?>
<a style="color: #FF0000;" onclick="javascript:confirm_delete_hypothesis(<?php 
    echo $active_hypothesis->id;
    ?>
);">Delete hypothesis</a></p><?php 
**
**    You should have received a copy of the GNU General Public License
**    along with Open Source ACH. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////////////// */
include "code/includes.php";
include "parts/includes.php";
$project_id = $_REQUEST['id'];
$this_project = new Project();
$this_project->populateFromId($project_id);
if ($this_project->open == "y") {
    $result = mysql_do("INSERT INTO users_in_projects (project_id, user_id) VALUES ('{$project_id}', '{$active_user->id}')");
    $this_project->mailEveryone("[ACH] New user in project '" . $this_project->title . "'", "Hello,\r\n\r\n" . $active_user->name . " has joined the project '" . $this_project->title . "':\r\n" . $base_URL . "project/" . $this_project->id . "\r\n\r\n - The ACH Bot");
} else {
    $result = mysql_do("INSERT INTO join_requests (user_id, project_id) VALUES ('{$active_user->id}', '{$project_id}')");
    $project_owner = new User();
    $project_owner->populateFromId($this_project->user_id);
    sendMail($project_owner->email, "[ACH] A user has requested to join your project", "Hello,\r\n\r\n" . $active_user->name . " has requested permission to join your project '" . $this_project->title . "'. To respond, please log into your ACH account here:\r\n" . $base_URL . "\r\n\r\nThanks!\r\n\r\n - The ACH Bot");
}
?>

<html>
<head>
	<title>Updating...</title>
	<meta http-equiv=Refresh content="0; url=project/<?php 
echo $project_id;
?>
">
</head>


**    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 Open Source ACH. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////////////// */
?>
<h3>Compare User Matrices</h3>

<?php 
$compare_user = new User();
$compare_user->populateFromId($_REQUEST['compare_user_id']);
$compare_user_2 = new User();
if ($_REQUEST['compare_user_id_2']) {
    $compare_user_2->populateFromId($_REQUEST['compare_user_id_2']);
    ?>
	<p>Comparing the ratings of <b><?php 
    echo $compare_user->name;
    ?>
</b> with <b><?php 
    echo $compare_user_2->name;
    ?>
</b>.</p>
	<?php 
} else {
    $compare_user_2->populateFromId($active_user->id);
    ?>
	<p>Comparing your ratings with <b><?php 
    echo $compare_user->name;
    ?>
if ($kind == "group") {
    $active_project->getDiagsGroup();
} else {
    if ($kind == "compare") {
        if (isset($_REQUEST['compare_user_id'])) {
            $compare_user = new User();
            $compare_user->populateFromId($_REQUEST['compare_user_id']);
            $compare_user_2 = new User();
            $compare_user_2->populateFromId($_REQUEST['compare_user_id_2']);
        }
        $active_project->getDiagsCompare($compare_user, $compare_user_2);
    } else {
        if ($kind == "user") {
            if (isset($_REQUEST['display_user_id'])) {
                $ratings_user = new User();
                $ratings_user->populateFromId($_REQUEST['display_user_id']);
            }
            $active_project->getDiagsUser($ratings_user);
        } else {
            $active_project->getDiags();
        }
    }
}
$evidence = array();
$evidence = $active_project->sortByFields($sort_field_1, $sort_field_1_dir, $sort_field_2, $sort_field_2_dir);
?>



<table cellspacing="0" cellpadding="0" border="0" class="groupMatrix" id="groupMatrix"><thead><tr><th onclick="sortGroupTable('name');" class="hypothesis cursorHand <?php 
echo $active_project->getSortArrow("name");
**    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 Open Source ACH. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////////////// */
include "code/includes.php";
include "parts/includes.php";
$user_id = $_REQUEST['user_id'];
$project_id = $_REQUEST['project_id'];
$action = $_REQUEST['action'];
$this_project = new Project();
$this_project->populateFromId($project_id);
$this_user = new User();
$this_user->populateFromId($user_id);
if ($active_user->id == $this_project->user_id) {
    if ($action == "approve") {
        $this_project->mailEveryone("[ACH] New user in project '" . $this_project->title . "'", "Hello,\r\n\r\n" . $this_user->name . " has joined the project '" . $this_project->title . "':\r\n " . $base_URL . "project/" . $this_project->id . "\r\n\r\n - The ACH Bot");
        $result = mysql_do("INSERT INTO users_in_projects (project_id, user_id) VALUES ('{$project_id}', '{$user_id}')");
        $result = mysql_do("INSERT INTO invitation_notices (user_id, by_user_id, project_Id, type, message) VALUES ('{$user_id}', '{$active_user->id}', '{$project_id}', 'approve', '');");
        sendMail($this_user->email, "[ACH] Project join request approved.", "Hello,\r\n\r\nYou have been approved to join project '" . $this_project->title . "':\r\n " . $base_URL . "project/" . $this_project->id . "\r\n\r\n - The ACH Bot");
    } else {
        if ($action == "deny") {
            $result = mysql_do("INSERT INTO invitation_notices (user_id, by_user_id, project_Id, type, message) VALUES ('{$user_id}', '{$active_user->id}', '{$project_id}', 'deny', '');");
            sendMail($this_user->email, "[ACH] Project join request denied.", "Hello,\r\n\r\nYou have been denied access to project '" . $this_project->title . "'.\r\n\r\n - The ACH Bot");
        }
    }
    mysql_do("DELETE FROM join_requests WHERE user_id='{$user_id}' AND project_id='{$project_id}'");
}
?>
**    it under the terms of the GNU General Public License as published by
**    the Free Software Foundation, either version 3 of the License, or
**    (at your option) any later version.
**
**    ACH 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 Open Source ACH. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////////////// */
include_once "code/includes.php";
$project_id = $_REQUEST['project_id'];
$active_users = getActiveUsers($project_id);
print_r($active_users);
if (empty($active_users)) {
    echo "No active users.";
}
?>

<ul>

<?php 
for ($i = 0; $i < count($active_users); $i++) {
    $this_user = new User();
    $this_user->populateFromId($active_users[$i]);
    echo "<li><p><a class='name' href='" . $base_URL . "profile/" . $this_user->username . "' style='color: #" . $this_user->color . ";'>" . $this_user->name . "</a><br />Viewing: <a href='" . $this_user->last_page . "'>" . $this_user->last_page . "</a></p></li>";
}
?>
</ul>
//THIS FILE IS CALLED WHEN COMMENTS ARE POSTED TO MESSAGE BOARDS
include "code/includes.php";
include "parts/includes.php";
$previous_page = $_REQUEST['this_url'];
$this_comment = new Comment();
foreach ($_REQUEST as $field => $value) {
    $this_comment->{$field} = addslashes($value);
}
$this_comment->user_id = $active_user->id;
$this_comment->insertNew();
setStatusMessage("Added!");
if ($_REQUEST['reply_to_id'] > 0) {
    $reply_comment = new Comment();
    $reply_comment->populateFromId($_REQUEST['reply_to_id']);
    $this_user = new User();
    $this_user->populateFromId($reply_comment->user_id);
    sendMail($this_user->email, "[ACH] Someone repied to your comment.", "Hello,\r\n\r\n" . $active_user->name . " has replied to your comment here:\r\n" . $base_URL . $previous_page . "#comment_" . $this_comment->id . "\r\n\r\n - The ACH Bot");
}
?>

<html>
<head>
	<title>Updating...</title>
	<meta http-equiv=Refresh content="0; url=<?php 
echo $previous_page;
?>
#comment_<?php 
echo $this_comment->id;
?>
">
</head>