diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/config_defaults_inc.php /cygdrive/D/mantis/config_defaults_inc.php
--- /cygdrive/D/mantis-0.18.0rc1/config_defaults_inc.php	2003-08-24 07:14:08.000000000 -0300
+++ /cygdrive/D/mantis/config_defaults_inc.php	2003-09-03 13:24:19.000000000 -0300
@@ -9,7 +9,7 @@
 	# $Id: config_defaults_inc.php,v 1.128 2003/08/24 10:14:07 vboctor Exp $
 	# --------------------------------------------------------
 
-	
+
 	###########################################################################
 	# CONFIGURATION VARIABLES
 	###########################################################################
@@ -679,7 +679,7 @@
 	# --- login method ----------------
 	# CRYPT or PLAIN or MD5 or LDAP or BASIC_AUTH
 	# You can simply change this at will. Mantis will try to figure out how the passwords were encrypted.
-	$g_login_method				= MD5;
+	$g_login_method				= CRYPT;
 
 	# --- limit reporters -------------
 	# Set to ON if you wish to limit reporters to only viewing bugs that they report.
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/config_inc.php /cygdrive/D/mantis/config_inc.php
--- /cygdrive/D/mantis-0.18.0rc1/config_inc.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/config_inc.php	2003-09-03 13:42:33.000000000 -0300
@@ -0,0 +1,118 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000, 2001  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the files README and LICENSE for details
+
+	# This sample file contains the essential files that you MUST
+	# configure to your specific settings.  You may override settings
+	# from default/config_inc1.php by assigning new values in this file
+
+	# Rename this file to config_inc.php after configuration.
+	###########################################################################
+	# CONFIGURATION VARIABLES
+	###########################################################################
+
+	# In general a value of 0 means the feature is disabled and 1 means the
+	# feature is enabled.  Any other cases will have an explanation.
+
+	# Look in configuration.html or default/config_inc1.php for more
+	# detailed comments.
+
+	$g_phpcollab_path = "http://localhost/phpcollab/";
+
+	$g_login_method 		= CRYPT;
+	$g_absolute_path		= "D:\\mantis\\"; // PUT YOUR OWN CONFIG
+	$g_path 				= "http://colaborativa.dnsalias.com/mantis/"; // PUT YOUR OWN CONFIG
+	$g_use_iis 				= ON; // PUT YOUR OWN CONFIG
+	$g_show_version   		= OFF;
+
+	# --- database variables ---------
+
+	# set these values to match your setup
+	$g_hostname      = "localhost";
+	$g_port          = 3306;         # 3306 is default
+	$g_db_username   = "root";
+	$g_db_password   = "";
+	$g_database_name = "mantis";
+
+	##################################
+	# Mantis Default Preferences
+	##################################
+
+	$g_validate_email            = OFF;
+	$g_check_mx_record           = OFF;
+
+	# experimental
+	$g_register_globals          = OFF;
+
+	# --- signup default ---------------
+	# look in constant_inc.php for values
+	$g_default_new_account_access_level = REPORTER;
+
+	# --- viewing defaults ------------
+	# site defaults for viewing preferences
+	$g_default_limit_view         = 50;
+	$g_default_show_changed       = 6;
+	$g_hide_closed_default        = ON;
+
+	# make sure people aren't refreshing too often
+	$g_min_refresh_delay          = 10;    # in minutes
+
+	# --- account pref defaults -------
+	# BOTH, SIMPLE_ONLY, ADVANCED_ONLY
+	$g_default_advanced_report    = BOTH;
+	$g_default_advanced_view      = BOTH;
+	$g_default_advanced_update    = BOTH;
+	$g_default_refresh_delay      = 30;    # in minutes
+	$g_default_redirect_delay     = 2;     # in seconds
+	$g_default_email_on_new       = ON;
+	$g_default_email_on_assigned  = ON;
+	$g_default_email_on_feedback  = ON;
+	$g_default_email_on_resolved  = ON;
+	$g_default_email_on_closed    = ON;
+	$g_default_email_on_reopened  = ON;
+	$g_default_email_on_bugnote   = ON;
+	$g_default_email_on_status    = 0; # @@@ Unused
+	$g_default_email_on_priority  = 0; # @@@ Unused
+	# default_language - is set to site language
+
+	#######################################
+	# Mantis Database Table Variables
+	#######################################
+
+	# --- table prefix ----------------
+	# if you change this remember to reflect the changes in the database
+	$g_db_table_prefix = "mantis";
+
+	# --- table names -----------------
+	$g_mantis_bug_file_table          = $g_db_table_prefix."_bug_file_table";
+	$g_mantis_bug_table               = $g_db_table_prefix."_bug_table";
+	$g_mantis_bug_text_table          = $g_db_table_prefix."_bug_text_table";
+	$g_mantis_bugnote_table           = $g_db_table_prefix."_bugnote_table";
+	$g_mantis_bugnote_text_table      = $g_db_table_prefix."_bugnote_text_table";
+	$g_mantis_news_table              = $g_db_table_prefix."_news_table";
+	$g_mantis_project_category_table  = $g_db_table_prefix."_project_category_table";
+	$g_mantis_project_file_table      = $g_db_table_prefix."_project_file_table";
+	$g_mantis_project_table           = $g_db_table_prefix."_project_table";
+	$g_mantis_project_user_list_table = $g_db_table_prefix."_project_user_list_table";
+	$g_mantis_project_version_table   = $g_db_table_prefix."_project_version_table";
+	$g_mantis_user_table              = $g_db_table_prefix."_user_table";
+	$g_mantis_user_profile_table      = $g_db_table_prefix."_user_profile_table";
+	$g_mantis_user_pref_table         = $g_db_table_prefix."_user_pref_table";
+	$g_mantis_bug_monitor_table       = $g_db_table_prefix."_bug_monitor_table";
+
+	# Upload destination: specify actual location in project settings
+	# DISK or DATABASE
+	$g_file_upload_method   = DATABASE;
+
+	# ---- Customise variable for phpCollab -----
+	// specify files upload directory if $g_file_upload_method = DISK, make sure it has correct permission
+	$g_file_path = "d:/wwwroot/localhost/mantis/files/"; // add slash at end
+	$client_user_level = 25; // Reporter
+	$team_user_level = 55; // Developer
+
+
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/config_inc.php.sample /cygdrive/D/mantis/config_inc.php.sample
--- /cygdrive/D/mantis-0.18.0rc1/config_inc.php.sample	2003-08-17 19:29:52.000000000 -0300
+++ /cygdrive/D/mantis/config_inc.php.sample	1969-12-31 21:00:00.000000000 -0300
@@ -1,67 +0,0 @@
-<?php
-	# Mantis - a php based bugtracking system
-	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
-	# Copyright (C) 2002 - 2003  Mantis Team   - mantisbt-dev@lists.sourceforge.net
-	# This program is distributed under the terms and conditions of the GPL
-	# See the README and LICENSE files for details
-
-	# --------------------------------------------------------
-	# $Id: config_inc.php.sample,v 1.10 2003/08/17 22:29:52 vboctor Exp $
-	# --------------------------------------------------------
-	
-	# This sample file contains the essential files that you MUST
-	# configure to your specific settings.  You may override settings
-	# from config_defaults_inc.php by assigning new values in this file
-
-	# Rename this file to config_inc.php after configuration.
-
-	###########################################################################
-	# CONFIGURATION VARIABLES
-	###########################################################################
-
-	# In general the value OFF means the feature is disabled and ON means the
-	# feature is enabled.  Any other cases will have an explanation.
-
-	# Look in http://mantisbt.sourceforge.net/manual or config_defaults_inc.php for more
-	# detailed comments.
-
-	# --- database variables ---------
-
-	# set these values to match your setup
-	$g_hostname      = "localhost";
-	$g_port          = 3306;         # 3306 is default
-	$g_db_username   = "root";
-	$g_db_password   = "";
-	$g_database_name = "bugtracker";
-
-	# --- email variables -------------
-	$g_administrator_email  = 'administrator@example.com';
-	$g_webmaster_email      = 'webmaster@example.com';
-
-	# the "From: " field in emails
-	$g_from_email           = 'noreply@example.com';
-
-	# the "To: " address all emails are sent.  This can be a mailing list or archive address.
-	# Actual users are emailed via the bcc: fields
-	$g_to_email             = 'nobody@example.com';
-
-	# the return address for bounced mail
-	$g_return_path_email    = 'admin@example.com';
-
-	# --- login method ----------------
-	# CRYPT or PLAIN or MD5 or LDAP or BASIC_AUTH
-	$g_login_method = MD5;
-
-	# --- email vars ------------------
-	# set to OFF to disable email check
-	# These should be OFF for Windows installations
-	$g_validate_email            = OFF;
-	$g_check_mx_record           = OFF;
-
-	# --- file upload settings --------
-	# This is the master setting to disable *all* file uploading functionality
-	#
-	# The default value is ON but you must make sure file uploading is enabled
-	#  in PHP as well.  You may need to add "file_uploads = TRUE" to your php.ini.
-	$g_allow_file_upload	= ON;
-?>
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/constant_inc.php /cygdrive/D/mantis/constant_inc.php
--- /cygdrive/D/mantis-0.18.0rc1/constant_inc.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/constant_inc.php	2002-12-05 16:17:40.000000000 -0300
@@ -0,0 +1,125 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the files README and LICENSE for details
+
+	###########################################################################
+	# CONFIGURATION VARIABLES
+	###########################################################################
+
+	########################
+	# Mantis Constants
+	########################
+
+	# --- constants -------------------
+
+	# magic numbers
+	define( "ON",       1 );
+	define( "OFF",      0 );
+
+	#define( "SUCCESS", 1 );
+	#define( "NOERROR", 1 );
+	#define( "ERROR",   0 );
+
+	# access levels
+	define( "VIEWER",         10 );
+	define( "REPORTER",       25 );
+	define( "UPDATER",        40 );
+	define( "DEVELOPER",      55 );
+	define( "MANAGER",        70 );
+	define( "ADMINISTRATOR",  90 );
+
+	# status
+	define( "NEW_",          10 );   # NEW seems to be a reserved keyword
+	define( "FEEDBACK",      20 );
+	define( "ACKNOWLEDGED",  30 );
+	define( "CONFIRMED",     40 );
+	define( "ASSIGNED",      50 );
+	define( "RESOLVED",      80 );
+	define( "CLOSED",        90 );
+
+	# resolution
+	define( "OPEN",                 10 );
+	define( "FIXED",                20 );
+	define( "REOPENED",             30 );
+	define( "UNABLE_TO_DUPLICATE",  40 );
+	define( "NOT_FIXABLE",          50 );
+	define( "DUPLICATE",            60 );
+	define( "NOT_A_BUG",            70 );
+	define( "SUSPENDED",            80 );
+	define( "WONT_FIX",             90 );
+
+	# priority
+	define( "NONE",       10 );
+	define( "LOW",        20 );
+	define( "NORMAL",     30 );
+	define( "HIGH",       40 );
+	define( "URGENT",     50 );
+	define( "IMMEDIATE",  60 );
+
+	# severity
+	define( "FEATURE",  10 );
+	define( "TRIVIAL",  20 );
+	define( "TEXT",     30 );
+	define( "TWEAK",    40 );
+	define( "MINOR",    50 );
+	define( "MAJOR",    60 );
+	define( "CRASH",    70 );
+	define( "BLOCK",    80 );
+
+	# project view_state
+	define( "PUBLIC",     10 );
+	define( "PRIVATE",    50 );
+
+	# direction
+	define( "ASC",    101 );
+	define( "DESC",   102 );
+
+	# unread status
+	define( "READ",     201 );
+	define( "UNREAD",   202 );
+
+	# login methods
+	define( "PLAIN",	       0 );
+	define( "CRYPT",	       1 );
+	define( "CRYPT_FULL_SALT", 2 );
+	define( "MD5",		       3 );
+	define( "LDAP",		       4 );
+	define( "BASIC_AUTH",      5 );
+
+	# file upload methods
+	define( "DISK",       1 );
+	define( "DATABASE",   2 );
+
+	# show variable values
+	define( "BOTH",             0 );
+	define( "SIMPLE_ONLY",      1 );
+	define( "ADVANCED_ONLY",    2 );
+
+	# news values
+	define( "BY_LIMIT",     0 );
+	define( "BY_DATE",      1 );
+
+	# show email limits
+	#define( "NONE",         0 );
+	define( "ALL",          1 );
+	define( "NO_ANONYMOUS", 2 );
+	define( "ADMIN_ONLY",   3 );
+
+	# error messages
+	define( "ERROR_GENERIC",              0 );
+	define( "ERROR_SQL",                  1 );
+	define( "ERROR_LOGIN",                2 );
+	define( "ERROR_REPORT",               3 );
+	define( "ERROR_NO_FILE_SPECIFIED",    4 );
+	define( "ERROR_FILE_DISALLOWED",      5 );
+	define( "ERROR_NO_DIRECTORY",         6 );
+	define( "ERROR_DUPLICATE_CATEGORY",   7 );
+	define( "ERROR_DUPLICATE_VERSION",    8 );
+	define( "ERROR_DUPLICATE_FILE",       9 );
+	define( "ERROR_EMPTY_FIELD",         10 );
+	define( "ERROR_PROTECTED_ACCOUNT",   11 );
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/core/authentication_api.php /cygdrive/D/mantis/core/authentication_api.php
--- /cygdrive/D/mantis-0.18.0rc1/core/authentication_api.php	2003-07-13 07:27:00.000000000 -0300
+++ /cygdrive/D/mantis/core/authentication_api.php	2003-09-03 14:37:09.000000000 -0300
@@ -125,6 +125,19 @@
 	}
 
 	# --------------------
+	# Wrapper for PhpCollab integration
+	function auth_attempt_login_phpcollab( $p_username, $p_password, $p_perm_login=false, $url ) {
+		if (auth_attempt_login( $p_username, $p_password, $p_perm_login=false)) {
+			# set the cookies
+			auth_set_cookie_phpcollab( $url );
+			return true;
+		} else {
+			return false;
+		}
+
+	}
+
+	# --------------------
 	# Logout the current user and remove any remaining cookies from their browser
 	# Returns true on success, false otherwise
 	function auth_logout() {
@@ -148,26 +161,36 @@
 		if ( LDAP == $t_configured_login_method ) {
 			return ldap_authenticate( $p_user_id, $p_test_password );
 		}
-		
+
 		$t_password = user_get_field( $p_user_id, 'password' );
-		
+
 		$t_login_methods = Array(MD5, CRYPT, PLAIN);
-		
+
 		foreach ( $t_login_methods as $t_login_method ) {
-			
+
+			#
+			# The passwords need to be with 2 char salt, as for PhpCollab integration
+			#
+			$p_salt = substr( $p_test_password, 0, 2 );
+
 			# pass the stored password in as the salt
-			if ( auth_process_plain_password( $p_test_password, $t_password, $t_login_method ) == $t_password ) {
-				# Check for migration to another login method and test whether the password was encrypted
-				# with our previously insecure implemention of the CRYPT method
-				if ( $t_login_method != $t_configured_login_method 
+			# if ( auth_process_plain_password( $p_test_password, $p_salt, $t_login_method ) == $t_password ) {
+
+			if ( auth_process_plain_password( $p_test_password, $p_salt, $t_login_method ) == $t_password ) {
+
+			# Check for migration to another login method and test whether the password was encrypted
+			# with our previously insecure implemention of the CRYPT method
+				/** THIS IS DISABLED for PhpCollab integration
+				if ( $t_login_method != $t_configured_login_method
 					|| ( CRYPT == $t_configured_login_method && substr( $t_password, 0, 2 ) == substr( $p_test_password, 0, 2 ) ) ) {
 					user_set_password( $p_user_id, $p_test_password, true );
 				}
-				
+				*/
+
 				return true;
 			}
 		}
-		
+
 		return false;
 	}
 
@@ -185,6 +208,10 @@
 			$t_login_method = $p_method;
 		}
 
+		if ($p_salt == null) {
+			$p_salt = substr($p_password, 0, 2);
+		}
+
 		switch ( $t_login_method ) {
 			case CRYPT:
 				# a null salt is the same as no salt, which causes a salt to be generated
@@ -221,6 +248,13 @@
 	#===================================
 
 	# --------------------
+	# Set cookies for PhpCollab integration
+	function auth_set_cookie_phpcollab( $url ) {
+			gpc_set_cookie( 'phpcollab_url_cookie', $url, true );
+			gpc_set_cookie( 'phpcollab_url_cookie', $url, false );
+	}
+
+	# --------------------
 	# Set login cookies for the user
 	#  If $p_perm_login is true, a long-term cookie is created
 	function auth_set_cookies( $p_user_id, $p_perm_login=false ) {
@@ -244,6 +278,7 @@
 		$t_cookie_path = config_get( 'cookie_path' );
 
 		gpc_clear_cookie( $t_cookie_name, $t_cookie_path );
+		gpc_clear_cookie( 'phpcollab_url_cookie', $t_cookie_path );
 	}
 
 	# --------------------
@@ -286,7 +321,7 @@
 		} else {
 			return true;
 		}
-	}	
+	}
 
 	# --------------------
 	# Return the current user login cookie string, or '' if none exists
@@ -317,7 +352,7 @@
 		$t_user_table = config_get( 'mantis_user_table' );
 
 		$t_cookie_string = auth_get_current_user_cookie();
-		
+
 		# @@@ error with an error saying they aren't logged in?
 		#     Or redirect to the login page maybe?
 
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/core/user_api.php /cygdrive/D/mantis/core/user_api.php
--- /cygdrive/D/mantis-0.18.0rc1/core/user_api.php	2003-05-23 08:52:28.000000000 -0300
+++ /cygdrive/D/mantis/core/user_api.php	2003-09-03 13:59:09.000000000 -0300
@@ -655,17 +655,21 @@
 	function user_set_default_project( $p_user_id, $p_project_id ) {
 		return user_pref_set_pref( $p_user_id, 'default_project', (int)$p_project_id );
 	}
-	
+
 	# --------------------
 	# Set the user's password to the given string, encoded as appropriate
 	function user_set_password( $p_user_id, $p_password, $p_allow_protected=false ) {
 		$c_user_id = db_prepare_int( $p_user_id );
-		
+
 		if ( !$p_allow_protected ) {
 			user_ensure_unprotected( $p_user_id );
 		}
 
-		$t_password = auth_process_plain_password( $p_password );
+		#
+		# salt with the two first chars as for PhpCollab integration
+		#
+		$salt = substr( $p_password, 0, 2 );
+		$t_password = auth_process_plain_password( $p_password, $salt);
 
 		$t_user_table	= config_get( 'mantis_user_table' );
 
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/core_API.php /cygdrive/D/mantis/core_API.php
--- /cygdrive/D/mantis-0.18.0rc1/core_API.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/core_API.php	2002-12-05 16:17:42.000000000 -0300
@@ -0,0 +1,18 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the files README and LICENSE for details
+
+  	require( "../mantis/constant_inc.php" );
+	require( "../mantis/config_inc.php" );
+	require( "../mantis/core_database_API.php" );
+	require( "../mantis/core_user_API.php" );
+	require( "../mantis/core_print_API.php" );
+	require( "../mantis/core_helper_API.php" );
+	require( "../mantis/core_proj_user_API.php" );
+	
+	# --------------------
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/core_database_API.php /cygdrive/D/mantis/core_database_API.php
--- /cygdrive/D/mantis-0.18.0rc1/core_database_API.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/core_database_API.php	2002-12-05 16:17:44.000000000 -0300
@@ -0,0 +1,144 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the files README and LICENSE for details
+
+	###########################################################################
+	# Database
+	###########################################################################
+
+	# This in the general interface for all database calls.
+	# The actual SQL queries are found in the pages.
+	# Use this as a starting point to port to other databases
+
+	# --------------------
+	# connect to database and select database
+	function db_connect($p_hostname="", $p_username="",
+						$p_password="", $p_database="",
+						$p_port="" ) {
+
+		global $g_hostname, $g_db_username, $g_db_password, $g_database_name, $g_port;
+
+		if ( empty( $p_hostname ) ) {
+			$p_hostname = $g_hostname;
+		}
+		if ( empty( $p_username ) ) {
+			$p_username = $g_db_username;
+		}
+		if ( empty( $p_password ) ) {
+			$p_password = $g_db_password;
+		}
+		if ( empty( $p_database ) ) {
+			$p_database = $g_database_name;
+		}
+		if ( empty( $p_port ) ) {
+			$p_port = $g_port;
+		}
+
+		$t_result = mysql_connect(  $p_hostname.":".$p_port,
+									$p_username, $p_password );
+
+		if ( !$t_result ) {
+			echo "ERROR: FAILED CONNECTION TO DATABASE: ";
+			echo db_error();
+			exit;
+		}
+
+		$t_result = db_select_db( $p_database );
+
+		if ( !$t_result ) {
+			echo "ERROR: FAILED DATABASE SELECTION: ";
+			echo db_error();
+			exit;
+		}
+	}
+	# --------------------
+	# persistent connect to database and select database
+	function db_pconnect($p_hostname="localhost", $p_username="root",
+						$p_password="", $p_database="mantis",
+						$p_port=3306 ) {
+
+		$t_result = mysql_pconnect(  $p_hostname.":".$p_port,
+									$p_username, $p_password );
+
+		if ( !$t_result ) {
+			echo "ERROR: FAILED CONNECTION TO DATABASE: ";
+			echo db_error();
+			exit;
+		}
+
+		$t_result = db_select_db( $p_database );
+
+		if ( !$t_result ) {
+			echo "ERROR: FAILED DATABASE SELECTION: ";
+			echo db_error();
+			exit;
+		}
+	}
+	# --------------------
+	# execute query, requires connection to be opened,
+	function db_query( $p_query ) {
+
+		$t_result = mysql_query( $p_query );
+
+		if ( !$t_result ) {
+			echo "ERROR: FAILED QUERY: ".$p_query." : ";
+			echo db_error();
+			exit;
+		} else {
+			return $t_result;
+		}
+	}
+	# --------------------
+	function db_select_db( $p_db_name ) {
+		return mysql_select_db( $p_db_name );
+	}
+	# --------------------
+	function db_num_rows( $p_result ) {
+		return mysql_num_rows( $p_result );
+	}
+	# --------------------
+	function db_fetch_array( $p_result ) {
+		return mysql_fetch_array( $p_result );
+	}
+	# --------------------
+	function db_result( $p_result, $p_index1=0, $p_index2=0 ) {
+		if ( $p_result && ( db_num_rows( $p_result ) > 0 ) ) {
+			return mysql_result( $p_result, $p_index1, $p_index2 );
+		} else {
+			return false;
+		}
+	}
+	# --------------------
+	# return the last inserted id
+	# For MS SQL use: SELECT @@IDENTITY AS 'id'
+	function db_insert_id() {
+		$query = "SELECT LAST_INSERT_ID()";
+		$t_result = db_query( $query );
+		return db_result( $t_result, 0, 0 );
+	}
+	# --------------------
+	function db_error_num() {
+		return mysql_errno();
+	}
+	# --------------------
+	function db_error_msg() {
+		return mysql_error();
+	}
+	# --------------------
+	# display both the error num and error msg
+	function db_error() {
+		return "<p>".db_error_num().": ".db_error_msg()."<p>";
+	}
+	# --------------------
+	# close the connection.
+	# Not really necessary most of the time since a connection is
+	# automatically closed when a page finishes loading.
+	function db_close() {
+		$t_result = mysql_close();
+	}
+	# --------------------
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/core_helper_API.php /cygdrive/D/mantis/core_helper_API.php
--- /cygdrive/D/mantis-0.18.0rc1/core_helper_API.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/core_helper_API.php	2002-12-05 16:17:46.000000000 -0300
@@ -0,0 +1,500 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the files README and LICENSE for details
+
+	###########################################################################
+	# Helper API
+	###########################################################################
+
+	# These are miscellaneous functions to help the package
+
+	# --------------------
+	# updates the last_updated field
+	function bug_date_update( $p_bug_id ) {
+		global $g_mantis_bug_table;
+
+		$query = "UPDATE $g_mantis_bug_table
+				SET last_updated=NOW()
+				WHERE id='$p_bug_id'";
+		return db_query( $query );
+	}
+	# --------------------
+	# updates the last_modified field
+	function bugnote_date_update( $p_bugnote_id ) {
+		global $g_mantis_bugnote_table;
+
+		$query = "UPDATE $g_mantis_bugnote_table
+				SET last_modified=NOW()
+				WHERE id='$p_bugnote_id'";
+		$result = db_query( $query );
+	}
+	# --------------------
+	# Returns the specified field value of the specified bug
+	function get_bug_field( $p_bug_id, $p_field_name ) {
+		global 	$g_string_cookie_val,
+				$g_mantis_bug_table;
+
+		# get info
+		$query = "SELECT $p_field_name
+				FROM $g_mantis_bug_table
+				WHERE id='$p_bug_id'";
+		$result = db_query( $query );
+		return db_result( $result, 0 );
+	}
+	# --------------------
+	# Returns the specified field value of the specified bug text
+	function get_bug_text_field( $p_bug_id, $p_field_name ) {
+		global 	$g_string_cookie_val,
+				$g_mantis_bug_text_table;
+
+		$t_bug_text_id = get_bug_field( $p_bug_id, "bug_text_id" );
+		# get info
+		$query = "SELECT $p_field_name
+				FROM $g_mantis_bug_text_table
+				WHERE id='$t_bug_text_id'";
+		$result = db_query( $query );
+		return db_result( $result, 0 );
+	}
+	# --------------------
+	# converts a 1 value to X
+	# converts a 0 value to a space
+	function trans_bool( $p_num ) {
+		if ( 0 == $p_num ) {
+			return "&nbsp;";
+		} else {
+			return "X";
+		}
+	}
+	# --------------------
+	# check to see if bug exists
+	# if it doesn't exist then redirect to the main page
+	# otherwise let execution continue undisturbed
+	function check_bug_exists( $p_bug_id ) {
+		global $g_mantis_bug_table, $g_main_page;
+
+		$query = "SELECT *
+				FROM $g_mantis_bug_table
+				WHERE id='$p_bug_id'";
+		$result = db_query( $query );
+		if ( 0 == db_num_rows( $result ) ) {
+			print_header_redirect( $g_main_page );
+		}
+	}
+	# --------------------
+	# check to see if bugnote exists
+	# if it doesn't exist then redirect to the main page
+	# otherwise let execution continue undisturbed
+	function check_bugnote_exists( $p_bugnote_id ) {
+		global $g_mantis_bugnote_table, $g_main_page;
+
+		$query = "SELECT *
+				FROM $g_mantis_bugnote_table
+				WHERE id='$p_bugnote_id'";
+		$result = db_query( $query );
+		if ( 0 == db_num_rows( $result ) ) {
+			print_header_redirect( $g_main_page );
+		}
+	}
+	# --------------------
+	# check to see if user exists
+	# if it doesn't exist then redirect to the main page
+	# otherwise let execution continue undisturbed
+	function check_user_exists( $p_user_id ) {
+		global $g_mantis_user_table, $g_main_page;
+
+		$query = "SELECT *
+				FROM $g_mantis_user_table
+				WHERE id='$p_user_id'";
+		$result = db_query( $query );
+		if ( 0 == db_num_rows( $result ) ) {
+			print_header_redirect( $g_main_page );
+		}
+	}
+	# --------------------
+	# check to see if project exists by id
+	# if it doesn't exist then redirect to the main page
+	# otherwise let execution continue undisturbed
+	function check_project_exists( $p_project_id ) {
+		global $g_mantis_project_table, $g_main_page;
+
+		$query = "SELECT COUNT(*)
+				FROM $g_mantis_project_table
+				WHERE id='$p_project_id'";
+		$result = db_query( $query );
+		if ( 0 == db_result( $result, 0, 0 ) ) {
+			print_header_redirect( $g_main_page );
+		}
+	}
+	# --------------------
+	# check to see if project exists by name
+	# if it doesn't exist then redirect to the main page
+	# otherwise let execution continue undisturbed
+	function is_duplicate_project( $p_name ) {
+		global $g_mantis_project_table;
+
+		$query = "SELECT COUNT(*)
+				FROM $g_mantis_project_table
+				WHERE name='$p_name'";
+		$result = db_query( $query );
+		if ( 0 == db_result( $result, 0, 0 ) ) {
+			return false;
+		} else {
+			return true;
+		}
+	}
+	# --------------------
+	# retrieve the number of open assigned bugs to a user in a project
+	function get_assigned_open_bug_count( $p_project_id, $p_cookie_str ) {
+		global $g_mantis_bug_table, $g_mantis_user_table, $g_project_cookie_val;
+
+		$query = "SELECT id
+				FROM $g_mantis_user_table
+				WHERE cookie_string='$p_cookie_str'";
+		$result = db_query( $query );
+		$t_id = db_result( $result );
+
+		if ( "0000000" == $g_project_cookie_val ) $t_where_prj ="1=1";
+		else $t_where_prj = "project_id='$p_project_id'";
+		$t_res = RESOLVED;
+		$t_clo = CLOSED;
+		$query = "SELECT COUNT(*)
+				FROM $g_mantis_bug_table
+				WHERE $t_where_prj AND
+						status<>'$t_res' AND status<>'$t_clo' AND
+						handler_id='$t_id'";
+		$result = db_query( $query );
+		return db_result( $result, 0, 0 );
+	}
+	# --------------------
+	# retrieve the number of open reported bugs by a user in a project
+	function get_reported_open_bug_count( $p_project_id, $p_cookie_str ) {
+		global $g_mantis_bug_table, $g_mantis_user_table, $g_project_cookie_val;
+
+		$query = "SELECT id
+				FROM $g_mantis_user_table
+				WHERE cookie_string='$p_cookie_str'";
+		$result = db_query( $query );
+		$t_id = db_result( $result );
+
+		if ( "0000000" == $g_project_cookie_val ) $t_where_prj ="1=1";
+		else $t_where_prj = "project_id='$p_project_id'";
+		$t_res = RESOLVED;
+		$t_clo = CLOSED;
+		$query = "SELECT COUNT(*)
+				FROM $g_mantis_bug_table
+				WHERE $t_where_prj AND
+						status<>'$t_res' AND status<>'$t_clo' AND
+						reporter_id='$t_id'";
+		$result = db_query( $query );
+		return db_result( $result, 0, 0 );
+	}
+	### --------------------
+	# process the $p_string and convert filenames in the format
+	# cvs:filename.ext or cvs:filename.ext:n.nn to a html link
+	function process_cvs_link( $p_string ) {
+		global $g_cvs_web;
+
+		return preg_replace( '/cvs:([^\.\s:,\?!]+(\.[^\.\s:,\?!]+)*)(:)?(\d\.[\d\.]+)?([\W\s])?/i',
+							 '[CVS] <a href="'.$g_cvs_web.'\\1?rev=\\4" target="_new">\\1</a>\\5',
+							 $p_string );
+	}
+	### --------------------
+	# process the $p_string and convert filenames in the format
+	# cvs:filename.ext or cvs:filename.ext:n.nn to a html link
+	function process_cvs_link_email( $p_string ) {
+		global $g_cvs_web;
+
+		return preg_replace( '/cvs:([^\.\s:,\?!]+(\.[^\.\s:,\?!]+)*)(:)?(\d\.[\d\.]+)?([\W\s])?/i',
+							 '[CVS] '.$g_cvs_web.'\\1?rev=\\4\\5',
+							 $p_string );
+	}
+	# --------------------
+	# process the $p_string and create links to bugs if warranted
+	# Uses the $g_bug_link_tag variable to determine the bug link tag
+	# eg. #45  or  bug:76
+	# default is the # symbol.  You may substitue any pattern you want.
+	function process_bug_link( $p_string ) {
+		global $g_bug_link_tag, $g_view_bug_page, $g_view_bug_advanced_page;
+
+		if ( ON == get_current_user_pref_field( "advanced_view" ) ) {
+			return preg_replace("/$g_bug_link_tag([0-9]+)/",
+								"<a href=\"$g_view_bug_advanced_page?f_id=\\1\">#\\1</a>",
+								$p_string);
+		} else {
+			return preg_replace("/$g_bug_link_tag([0-9]+)/",
+								"<a href=\"$g_view_bug_page?f_id=\\1\">#\\1</a>",
+								$p_string);
+		}
+	}
+	# --------------------
+	# process the $p_string and convert bugs in this format #123 to a plain text link
+	function process_bug_link_email( $p_string ) {
+		global	$g_view_bug_page, $g_view_bug_advanced_page,
+				$g_bug_link_tag;
+
+		if ( ON == get_current_user_pref_field( "advanced_view" ) ) {
+			return preg_replace("/$g_bug_link_tag([0-9]+)/",
+								"$g_view_bug_advanced_page?f_id=\\1",
+								$p_string);
+		} else {
+			return preg_replace("/$g_bug_link_tag([0-9]+)/",
+								"$g_view_bug_page?f_id=\\1",
+								$p_string);
+		}
+	}
+	# --------------------
+	# alternate color function
+	function alternate_colors( $p_num, $p_color1="", $p_color2="" ) {
+		global $g_primary_color1, $g_primary_color2;
+
+		if ( empty( $p_color1 ) ) {
+			$p_color1 = $g_primary_color1;
+		}
+		if ( empty( $p_color2 ) ) {
+			$p_color2 = $g_primary_color2;
+		}
+
+		if ( 1 == $p_num % 2 ) {
+			return $p_color1;
+		} else {
+			return $p_color2;
+		}
+	}
+	# --------------------
+	# get the color string for the given status
+	function get_status_color( $p_status ) {
+		global $g_status_enum_string;
+
+		# This code creates the appropriate variable name
+		# then references that color variable
+		# You could replace this with a bunch of if... then... else
+		# statements
+		$t_color_str = "closed";
+		$t_arr = explode_enum_string( $g_status_enum_string );
+		$t_arr_count = count( $t_arr );
+		for ( $i=0;$i<$t_arr_count;$i++ ) {
+			$elem_arr = explode_enum_arr( $t_arr[$i] );
+			if ( $elem_arr[0] == $p_status ) {
+				# now get the appropriate translation
+				$t_color_str = $elem_arr[1];
+				break;
+			}
+		}
+
+		$t_color_variable_name = "g_".$t_color_str."_color";
+		global $$t_color_variable_name;
+		return $$t_color_variable_name;
+	}
+	# --------------------
+	# get a bgcolor="" string for the given status or "" if the status is CLOSED
+	function get_status_bgcolor( $p_status ){
+		if ( !( CLOSED == $p_status ) ) {
+			return "bgcolor=\"".get_status_color( $p_status )."\"";
+		} else {
+			return "";
+		}
+	}
+	# --------------------
+	# Get the default project of a user
+	function get_default_project( $p_user_id ) {
+		global $g_mantis_user_pref_table;
+
+		$query = "SELECT default_project
+				FROM $g_mantis_user_pref_table
+				WHERE user_id='$p_user_id'";
+		$result = db_query( $query );
+		return db_result( $result, 0, 0 );
+	}
+	# --------------------
+	# Get the string associated with the $p_enum value
+	function get_enum_to_string( $p_enum_string, $p_num ) {
+		$t_arr = explode_enum_string( $p_enum_string );
+		$enum_count = count( $t_arr );
+		for ($i=0;$i<$enum_count;$i++) {
+			$t_s = explode_enum_arr( $t_arr[$i] );
+			if ( $t_s[0] == $p_num ) {
+				return $t_s[1];
+			}
+		}
+		return "@null@";
+	}
+	# --------------------
+	# Breaks up an enum string into num:value elements
+	function explode_enum_string( $p_enum_string ) {
+		return explode( ",", $p_enum_string );
+	}
+	# --------------------
+	# Given one num:value pair it will return both in an array
+	# num will be first (element 0) value second (element 1)
+	function explode_enum_arr( $p_enum_elem ) {
+		return explode( ":", $p_enum_elem );
+	}
+	# --------------------
+	# Given a enum string and num, return the appropriate string
+	function get_enum_element( $p_enum_name, $p_val ) {
+		$g_var = "g_".$p_enum_name."_enum_string";
+		$s_var = "s_".$p_enum_name."_enum_string";
+		global $$g_var, $$s_var;
+
+		# use the global enum string to search
+		$t_arr = explode_enum_string( $$g_var );
+		$t_arr_count = count( $t_arr );
+		for ( $i=0;$i<$t_arr_count;$i++ ) {
+			$elem_arr = explode_enum_arr( $t_arr[$i] );
+			if ( $elem_arr[0] == $p_val ) {
+				# now get the appropriate translation
+				return get_enum_to_string( $$s_var, $p_val );
+			}
+		}
+		return "@null@";
+	}
+	# --------------------
+	# Returns the number of bugntoes for the given bug_id
+	function get_bugnote_count( $p_id ) {
+		global $g_mantis_bugnote_table;
+
+		$query = "SELECT COUNT(*)
+					FROM $g_mantis_bugnote_table
+					WHERE bug_id ='$p_id'";
+		$result = db_query( $query );
+		return db_result( $result, 0 );
+	}
+	# --------------------
+	# Returns the number of bugntoes for the given bug_id
+	function get_bugnote_field( $p_bugnote_id, $p_field_name ) {
+		global $g_mantis_bugnote_table;
+
+		$query = "SELECT $p_field_name
+					FROM $g_mantis_bugnote_table
+					WHERE id ='$p_bugnote_id'";
+		$result = db_query( $query );
+		return db_result( $result, 0 );
+	}
+	# --------------------
+	# Returns the specified field of the project
+	function get_current_project_field( $p_field_name ) {
+		global $g_mantis_project_table, $g_project_cookie_val;
+
+		$query = "SELECT $p_field_name
+				FROM $g_mantis_project_table
+				WHERE id='$g_project_cookie_val'";
+		$result = db_query( $query );
+		return db_result( $result, 0, 0 );
+	}
+	# --------------------
+	# Returns the specified field of the project
+	function get_project_field( $p_project_id, $p_field_name ) {
+		global $g_mantis_project_table;
+
+		$query = "SELECT $p_field_name
+				FROM $g_mantis_project_table
+				WHERE id='$p_project_id'";
+		$result = db_query( $query );
+		return db_result( $result, 0, 0 );
+	}
+	# --------------------
+	# Some proxies strip out HTTP_REFERER.
+	# This function helps determine which pages to redirect to
+	# based on site and user preference.
+	function get_view_redirect_url( $p_bug_id, $p_no_referer=0 ) {
+		global $HTTP_REFERER, $g_show_view, $g_view_bug_page, $g_view_bug_advanced_page;
+
+		if ( ( !isset( $HTTP_REFERER ) ) ||
+			 ( empty( $HTTP_REFERER ) ) ||
+			 ( 1 == $p_no_referer ) ) {
+			switch ( $g_show_view ) {
+				case BOTH:
+						if ( ON == get_current_user_pref_field( "advanced_view" ) ) {
+							return $g_view_bug_advanced_page."?f_id=".$p_bug_id;
+						} else {
+							return $g_view_bug_page."?f_id=".$p_bug_id;
+						}
+				case SIMPLE_ONLY:
+						return $g_view_bug_page."?f_id=".$p_bug_id;
+				case ADVANCED_ONLY:
+						return $g_view_bug_advanced_page."?f_id=".$p_bug_id;
+				default:return $g_view_bug_page."?f_id=".$p_bug_id;
+			}
+		} else {
+			return $HTTP_REFERER;
+		}
+	}
+	# --------------------
+	# Some proxies strip out HTTP_REFERER.
+	# This function helps determine which pages to redirect to
+	# based on site and user preference.
+	function get_report_redirect_url( $p_no_referer=0 ) {
+		global $HTTP_REFERER, $g_show_report, $g_report_bug_page, $g_report_bug_advanced_page;
+
+		if ( ( !isset( $HTTP_REFERER ) ) ||
+			 ( empty( $HTTP_REFERER ) ) ||
+			 ( 1 == $p_no_referer ) ) {
+			switch( $g_show_report ) {
+				case BOTH:
+						if ( ON == get_current_user_pref_field( "advanced_report" ) ) {
+							return $g_report_bug_advanced_page;
+		 				} else {
+							return $g_report_bug_page;
+						}
+				case SIMPLE_ONLY:
+						return $g_report_bug_page;
+				case ADVANCED_ONLY:
+						return $g_report_bug_advanced_page;
+				default:return $g_report_bug_page;
+			}
+		} else {
+			return $HTTP_REFERER;
+		}
+	}
+	# --------------------
+	# Contributed by Peter Palmreuther
+	function mime_encode( $p_string="" ) {
+		$output = "";
+		for ( $i=0; $i<strlen( $p_string ); $i++ ) {
+			if (( ord( $p_string[$i] ) < 33 ) ||
+				( ord( $p_string[$i] ) > 127 ) ||
+				( eregi( "[\%\[\]\{\}\(\)]", $p_string[$i] ) )) {
+				$output .= sprintf( "%%%02X", ord( $p_string[$i] ) );
+			} else {
+				$output .= $p_string[$i];
+			}
+		}
+		return( $output );
+	}
+	# --------------------
+	# File type check
+	function file_type_check( $p_file_name ) {
+		global $g_allowed_files, $g_disallowed_files;
+
+		# grab extension
+		$t_ext_array = explode( ".", $p_file_name );
+		$last_position = count( $t_ext_array )-1;
+		$t_extension = $t_ext_array[$last_position];
+
+		# check against disallowed files
+		$t_disallowed_arr =  explode_enum_string( $g_disallowed_files );
+		foreach ( $t_disallowed_arr as $t_val ) {
+		    if ( $t_val == $t_extension ) {
+		    	return false;
+		    }
+		}
+
+		# check against allowed files
+		$t_allowed_arr = explode_enum_string( $g_allowed_files );
+		# if the allowed list is populated then the file must be in the list.
+		if ( empty( $g_allowed_files ) ) {
+			return true;
+		}
+		foreach ( $t_allowed_arr as $t_val ) {
+		    if ( $t_val == $t_extension ) {
+				return true;
+		    }
+		}
+		return false;
+	}
+	# --------------------
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/core_html_API.php /cygdrive/D/mantis/core_html_API.php
--- /cygdrive/D/mantis-0.18.0rc1/core_html_API.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/core_html_API.php	2002-10-08 16:46:58.000000000 -0300
@@ -0,0 +1,538 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the files README and LICENSE for details
+
+	###########################################################################
+	# Core HTML API
+	###########################################################################
+
+	# These functions control the display of each page
+	# I've numbered the functions in the order they should appear
+
+	# --------------------
+	# first part of the html followed by meta tags then the second part
+	function print_page_top1() {
+		global $g_window_title, $g_css_include_file, $g_meta_include_file;
+
+		print_html_top();
+		print_head_top();
+		print_title( $g_window_title );
+		print_css( $g_css_include_file );
+		include( $g_meta_include_file );
+	}
+	# --------------------
+	# second part of the html, comes after the meta tags
+	function print_page_top2() {
+		global $g_page_title, $g_top_include_page;
+
+		print_head_bottom();
+		print_body_top();
+		print_header( $g_page_title );
+		print_top_page( $g_top_include_page );
+		print_login_info();
+		print_menu();
+	}
+	# --------------------
+	# second part of the html, comes after the meta tags
+	function print_page_top2a() {
+		global $g_page_title, $g_top_include_page;
+
+		print_head_bottom();
+		print_body_top();
+		print_header( $g_page_title );
+		print_top_page( $g_top_include_page );
+	}
+	# --------------------
+	# comes at the bottom of the html
+	# $p_file should always be the __FILE__ variable. This is passed to show source.
+	function print_page_bot1( $p_file ) {
+		global $g_bottom_include_page;
+
+		print_bottom_page( $g_bottom_include_page );
+		print_footer( $p_file );
+		print_body_bottom();
+		print_html_bottom();
+	}
+	# --------------------
+	# (1) this is the first text sent by the page
+	function print_html_top() {
+		PRINT "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
+		PRINT "<html>";
+	}
+	# --------------------
+	# (2)
+	function print_head_top() {
+	   PRINT "<head>";
+	}
+	# --------------------
+	# (3)
+	function print_title( $p_title ) {
+		global 	$g_show_project_in_title,
+				$g_project_cookie_val;
+
+		if ( 1 == $g_show_project_in_title ) {
+			$t_project_name = get_project_field( $g_project_cookie_val, "name" );
+			if ( empty( $t_project_name ) ) {
+				PRINT "<title>$p_title</title>";
+			} else {
+				PRINT "<title>$p_title - $t_project_name</title>";
+			}
+		} else if ( 2 == $g_show_project_in_title ) {
+			$t_project_name = get_project_field( $g_project_cookie_val, "name" );
+
+			PRINT "<title>$t_project_name</title>";
+		} else {
+			PRINT "<title>$p_title</title>";
+		}
+	}
+	# --------------------
+	# (4) the css include file to use, is likely to be either empty or css_inc.php
+	function print_css( $p_css="" ) {
+		if ( !empty($p_css )) {
+			include( "$p_css" );
+		}
+	}
+	# --------------------
+	# (5) OPTIONAL: for pages that require a redirect
+	# The time field is the number of seconds to wait before redirecting
+	function print_meta_redirect( $p_url, $p_time="" ) {
+		global $g_wait_time;
+
+		if ( empty( $p_time ) ) {
+			$p_time = $g_wait_time;
+		}
+
+		PRINT "<meta http-equiv=\"Refresh\" content=\"$p_time;URL=$p_url\">";
+	}
+	# --------------------
+	# (6)
+	function print_head_bottom() {
+	   PRINT "</head>";
+	}
+	# --------------------
+	# (7)
+	function print_body_top() {
+		PRINT "<body>";
+	}
+	# --------------------
+	# (8) This prints the title that is visible in the main panel of the browser
+	# We use a temporary vairable to create the title then print it.
+	function print_header( $p_title="Mantis" ) {
+		global 	$g_show_project_in_title,
+				$g_project_cookie_val;
+
+		$t_title = "";
+		switch ( $g_show_project_in_title ) {
+			case 1:	$t_project_name = get_project_field( $g_project_cookie_val, "name" );
+					if ( empty( $t_project_name ) ) {
+						$t_title = $p_title;
+					} else {
+						$t_title = $p_title." - ".$t_project_name;
+					}
+					break;
+			case 2:	$t_title = get_project_field( $g_project_cookie_val, "name" );
+					break;
+			default:$t_title = $p_title;
+					break;
+		}
+
+		PRINT "<div align=\"center\"><span class=\"pagetitle\">$t_title</span></div>";
+	}
+	# --------------------
+	# (9) $p_page is included.  This allows for the admin to have a nice baner or
+	# graphic at the top of every page
+	function print_top_page( $p_page ) {
+		if (( !empty( $p_page ) )&&( file_exists( $p_page ) )&&( !is_dir( $p_page ) )) {
+			include( $p_page );
+		}
+	}
+	# --------------------
+	# (10) $p_page is included.  This allows for the admin to have a nice baner or
+	# graphic at the bottom of every page
+	function print_bottom_page( $p_page ) {
+		if (( !empty( $p_page ) )&&( file_exists( $p_page ) )&&( !is_dir( $p_page ) )) {
+			include( $p_page );
+		}
+	}
+	# --------------------
+	# (11) Prints the bottom of page information
+	function print_footer( $p_file ) {
+		global 	$g_string_cookie_val, $g_webmaster_email,
+				$g_menu_include_file, $g_show_footer_menu,
+				$g_mantis_version, $g_show_version,
+				$g_timer, $g_show_timer;
+
+		# @@@
+		if (isset($g_string_cookie_val)&&!empty($g_string_cookie_val)) {
+			if ( $g_show_footer_menu ) {
+				PRINT "<p>";
+				print_menu();
+			}
+		}
+
+		print_source_link( $p_file );
+
+		PRINT "<p>";
+		PRINT "<hr size=\"1\">";
+		if ( ON == $g_show_version ) {
+			PRINT "<span class=\"timer\"><a href=\"http://mantisbt.sourceforge.net/\">Mantis $g_mantis_version</a></span>";
+		}
+		PRINT "<address>Copyright (C) 2000 - 2002</address>";
+		PRINT "<address><a href=\"mailto:$g_webmaster_email\">$g_webmaster_email</a></address>";
+		if ( ON == $g_show_timer ) {
+			$g_timer->end_time();
+			PRINT "<span class=\"italic\">Time: ".$g_timer->elapsed_time()." seconds</span><br />";
+		}
+	}
+	# --------------------
+	# (12)
+	function print_body_bottom() {
+		PRINT "</body>";
+	}
+	# --------------------
+	# (13)  The very last text that is sent in a html page
+	function print_html_bottom() {
+		PRINT "</html>";
+	}
+	# --------------------
+	###########################################################################
+	# HTML Appearance Helper API
+	###########################################################################
+	# --------------------
+	# prints the user that is logged in and the date/time
+	# it also creates the form where users can switch projects
+	function print_login_info() {
+		global 	$g_mantis_user_table,
+				$g_string_cookie_val, $g_project_cookie_val,
+				$g_complete_date_format, $g_set_project,
+				$s_switch, $s_logged_in_as, $s_all_projects,
+				$s_access_levels_enum_string;
+
+		$t_username = get_current_user_field( "username" );
+		$t_access_level = get_enum_element( "access_levels", get_current_user_access_level() );
+		$t_now = date( $g_complete_date_format );
+
+		PRINT "<table class=\"hide\">";
+		PRINT "<form method=\"post\" action=\"$g_set_project\">";
+		PRINT "<tr>";
+			PRINT "<td class=\"login-info-left\">";
+				PRINT "$s_logged_in_as: <span class=\"login-username\">$t_username</span> <span class=\"small\">($t_access_level)</span>";
+			PRINT "</td>";
+			PRINT "<td class=\"login-info-middle\">";
+				PRINT "<span class=\"login-time\">$t_now</span>";
+			PRINT "</td>";
+			PRINT "<td class=\"login-info-right\">";
+				PRINT "<select name=\"f_project_id\" class=\"small\">";
+					PRINT "<option value=\"0000000\">$s_all_projects</option>";
+					print_project_option_list( $g_project_cookie_val );
+				PRINT "</select>";
+				PRINT "<input type=\"submit\" value=\"$s_switch\" class=\"small\">";
+			PRINT "</td>";
+		PRINT "</tr>";
+		PRINT "</form>";
+		PRINT "</table>";
+	}
+	# --------------------
+	# This prints the little [?] link for user help
+	# The $p_a_name is a link into the documentation.html file
+	function print_documentation_link( $p_a_name="" ) {
+		global $g_documentation_html;
+
+		PRINT "<a href=\"$g_documentation_html#$p_a_name\" target=_info>[?]</a>";
+	}
+	# --------------------
+	# checks to see whether we need to be displaying the source link
+	# WARNING: displaying source (and the ability to do so) can be a security risk
+	# used in print_footer()
+	function print_source_link( $p_file ) {
+		global $g_show_source, $g_show_source_page, $g_string_cookie_val;
+
+		if (!isset($g_string_cookie_val)) {
+			return;
+		}
+
+		if (( ON == $g_show_source )&&
+			( access_level_check_greater_or_equal( ADMINISTRATOR ) )) {
+				PRINT "<p>";
+				PRINT "<div align=\"center\">";
+				PRINT "<a href=\"$g_show_source_page?f_url=$p_file\">Show Source</a>";
+				PRINT "</div>";
+		}
+	}
+ 	# --------------------
+	# print the hr
+	function print_hr( $p_hr_size, $p_hr_width ) {
+		PRINT "<hr size=\"$p_hr_size\" width=\"$p_hr_width%\">";
+	}
+	# --------------------
+	###########################################################################
+	# HTML Menu API
+	###########################################################################
+	# --------------------
+	# print the standard command menu at the top of the pages
+	# also prints the login info, time, and project select form
+	function print_menu() {
+		global	$g_string_cookie_val, $g_project_cookie_val,
+
+				$g_show_report,
+
+				$g_main_page, $g_view_all_bug_page,
+				$g_report_bug_page, $g_report_bug_advanced_page,
+				$g_summary_page, $g_account_page, $g_proj_doc_page, $g_manage_page,
+				$g_news_menu_page, $g_usage_doc_page, $g_logout_page,
+				$g_proj_user_menu_page, $g_login_select_proj_page,
+
+				$s_main_link, $s_view_bugs_link, $s_report_bug_link,
+				$s_summary_link, $s_account_link, $g_manage_project_menu_page,
+				$s_manage_link, $s_users_link, $s_edit_news_link, $s_docs_link,
+				$s_jump, $g_jump_to_bug,
+
+				$s_logout_link;
+
+		if ( isset( $g_string_cookie_val ) ) {
+		    $t_protected = get_current_user_field( "protected" );
+			PRINT "<table class=\"width100\" cellspacing=\"0\">";
+			PRINT "<tr>";
+				PRINT "<td class=\"menu\">";
+				PRINT "<a href=\"$g_main_page\">$s_main_link</a> | ";
+				PRINT "<a href=\"$g_view_all_bug_page\">$s_view_bugs_link</a> | ";
+				$t_project_status = get_project_field( $g_project_cookie_val, "status" );
+				if ( access_level_check_greater_or_equal( REPORTER ) ) {
+					if ( "0000000" != $g_project_cookie_val ) {
+						$t_report_url = get_report_redirect_url( 1 );
+						PRINT "<a href=\"$t_report_url\">$s_report_bug_link</a> | ";
+					} else {
+						PRINT "<a href=\"$g_login_select_proj_page?f_ref=".get_report_redirect_url( 1 )."\">$s_report_bug_link</a> | ";
+					}
+				}
+
+				PRINT "<a href=\"$g_summary_page\">$s_summary_link</a> | ";
+
+				# only show accounts that are NOT protected
+				if ( OFF == $t_protected ) {
+					PRINT "<a href=\"$g_account_page\">$s_account_link</a> | ";
+				}
+
+				if ( access_level_check_greater_or_equal( MANAGER ) ) {
+					if ( "0000000" != $g_project_cookie_val ) {
+						PRINT "<a href=\"$g_proj_user_menu_page\">$s_users_link</a> | ";
+					} else {
+						PRINT "<a href=\"$g_login_select_proj_page\">$s_users_link</a> | ";
+					}
+				}
+
+				if ( access_level_check_greater_or_equal( ADMINISTRATOR ) ) {
+					PRINT "<a href=\"$g_manage_page\">$s_manage_link</a> | ";
+				}
+				if ( access_level_check_greater_or_equal( MANAGER ) ) {
+					if ( "0000000" != $g_project_cookie_val ) {
+					PRINT "<a href=\"$g_news_menu_page\">$s_edit_news_link</a> | ";
+					} else {
+						PRINT "<a href=\"$g_login_select_proj_page\">$s_edit_news_link</a> | ";
+					}
+				}
+
+				PRINT "<a href=\"$g_proj_doc_page\">$s_docs_link</a> | ";
+				PRINT "<a href=\"$g_logout_page\">$s_logout_link</a>";
+				PRINT "</td>";
+				PRINT "<form method=\"post\" action=\"$g_jump_to_bug\">";
+				PRINT "<td nowrap class=\"right\">";
+				PRINT "<input type=\"text\" name=\"f_id\" size=\"10\" class=\"small\">&nbsp;";
+				PRINT "<input type=\"submit\" value=\"$s_jump\" class=\"small\">&nbsp;";
+				PRINT "</td>";
+				PRINT "</form>";
+			PRINT "</tr>";
+			PRINT "</table>";
+		}
+	}
+	# --------------------
+	# prints the manage menu
+	# if the $p_page matches a url then don't make that a link
+	function print_manage_menu( $p_page="" ) {
+		global 	$g_manage_page,
+				$s_manage_users_link, $s_manage_projects_link,
+				$g_manage_create_user_page, $s_create_new_account_link,
+				$g_manage_project_menu_page, $s_projects,
+				$g_documentation_page, $s_documentation_link;
+
+		$t_manage_page 				= $g_manage_page;
+		$t_manage_project_menu_page = $g_manage_project_menu_page;
+		$t_manage_create_user_page 	= $g_manage_create_user_page;
+		$t_documentation_page 		= $g_documentation_page;
+
+		switch ( $p_page ) {
+			case $t_manage_page				: $t_manage_page 				= ""; break;
+			case $t_manage_project_menu_page: $t_manage_project_menu_page 	= ""; break;
+			case $t_manage_create_user_page	: $t_manage_create_user_page 	= ""; break;
+			case $t_documentation_page		: $t_documentation_page 		= ""; break;
+		}
+
+		PRINT "<p><div align=\"center\">";
+			print_bracket_link( $t_manage_page, $s_manage_users_link );
+			print_bracket_link( $t_manage_project_menu_page, $s_manage_projects_link );
+			print_bracket_link( $t_manage_create_user_page, $s_create_new_account_link );
+			print_bracket_link( $t_documentation_page, $s_documentation_link );
+		PRINT "</div>";
+	}
+	# --------------------
+	# prints the account menu
+	# if the $p_page matches a url then don't make that a link
+	function print_account_menu( $p_page="" ) {
+		global 	$g_account_page, $s_account_link,
+				$g_account_profile_menu_page, $s_manage_profiles_link,
+				$g_account_prefs_page, $s_change_preferences_link;
+
+		$t_account_page 				= $g_account_page;
+		$t_account_prefs_page 			= $g_account_prefs_page;
+		$t_account_profile_menu_page 	= $g_account_profile_menu_page;
+
+		switch ( $p_page ) {
+			case $t_account_page				: $t_account_page 				= ""; break;
+			case $t_account_prefs_page			: $t_account_prefs_page 		= ""; break;
+			case $t_account_profile_menu_page	: $t_account_profile_menu_page 	= ""; break;
+		}
+		// changes made for phpcollab, so user cannot modify usernam/password from mantis
+		#print_bracket_link( $t_account_page, $s_account_link );
+		print_bracket_link( $t_account_prefs_page, $s_change_preferences_link );
+		print_bracket_link( $t_account_profile_menu_page, $s_manage_profiles_link );
+	}
+	# --------------------
+	# prints the doc menu
+	# if the $p_page matches a url then don't make that a link
+	function print_doc_menu( $p_page="" ) {
+		global	$g_documentation_html, $s_user_documentation,
+				$g_proj_doc_page, $s_project_documentation,
+				$g_proj_doc_add_page, $s_add_file,
+				$g_allow_file_upload;
+
+		$t_documentation_html 	= $g_documentation_html;
+		$t_proj_doc_page 		= $g_proj_doc_page;
+		$t_proj_doc_add_page 	= $g_proj_doc_add_page;
+
+		switch ( $p_page ) {
+			case $t_documentation_html	: $t_documentation_html	= ""; break;
+			case $t_proj_doc_page		: $t_proj_doc_page		= ""; break;
+			case $t_proj_doc_add_page	: $t_proj_doc_add_page	= ""; break;
+		}
+
+		print_bracket_link( $t_documentation_html, $s_user_documentation );
+		print_bracket_link( $t_proj_doc_page, $s_project_documentation );
+		if ( ( ON == $g_allow_file_upload )&&( access_level_check_greater_or_equal( MANAGER ) ) ) {
+			print_bracket_link( $t_proj_doc_add_page, $s_add_file );
+		}
+	}
+	# --------------------
+	# prints the manage doc menu
+	# if the $p_page matches a url then don't make that a link
+	function print_manage_doc_menu( $p_page="" ) {
+		global	$g_documentation_page, $s_system_info_link, $g_path;
+
+		$g_path = $g_path."doc/";
+		$t_documentation_page = $g_documentation_page;
+
+		switch ( $p_page ) {
+			case $t_documentation_page: $t_documentation_page = ""; break;
+		}
+
+		PRINT "<p><div align=\"center\">";
+			print_bracket_link( $t_documentation_page, $s_system_info_link );
+			print_bracket_link( $g_path."ChangeLog", "ChangeLog" );
+			print_bracket_link( $g_path."README", "README" );
+			print_bracket_link( $g_path."INSTALL", "INSTALL" );
+			print_bracket_link( $g_path."UPGRADING", "UPGRADING" );
+			print_bracket_link( $g_path."CUSTOMIZATION", "CUSTOMIZATION" );
+		PRINT "</div>";
+	}
+	# --------------------
+	# prints the summary menu
+	function print_summary_menu( $p_page="" ) {
+		global	$g_summary_page, $s_summary_link,
+				$g_use_jpgraph, $s_summary_jpgraph_link,
+				$g_print_all_bug_page, $s_print_all_bug_page_link,
+				$g_summary_jpgraph_page, $s_print_reports;
+
+		PRINT "<p><div align=\"center\">";
+		print_bracket_link( $g_print_all_bug_page, $s_print_all_bug_page_link );
+
+        if ( $g_use_jpgraph != 0 ) {
+			$t_summary_page 		= $g_summary_page;
+			$t_summary_jpgraph_page = $g_summary_jpgraph_page;
+
+			switch ( $p_page ) {
+				case $t_summary_page		: $t_summary_page			= ""; break;
+				case $t_summary_jpgraph_page: $t_summary_jpgraph_page	= ""; break;
+			}
+
+			print_bracket_link( $t_summary_page, $s_summary_link );
+			print_bracket_link( $t_summary_jpgraph_page, $s_summary_jpgraph_link );
+		}
+		PRINT "</div>";
+	}
+	# --------------------
+	# prints the signup link
+	function print_signup_link() {
+		global $g_allow_signup, $g_signup_page, $s_signup_link;
+
+		if ( $g_allow_signup != 0 ) {
+			PRINT "<p><div align=\"center\">";
+			print_bracket_link( $g_signup_page, $s_signup_link );
+			PRINT "</div>";
+		}
+	}
+	# --------------------
+	function print_proceed( $p_result, $p_query, $p_link ) {
+		global $s_operation_successful, $s_proceed;
+
+		PRINT "<p>";
+		PRINT "<div align=\"center\">";
+		if ( $p_result ) {						# SUCCESS
+			PRINT "$s_operation_successful<p>";
+		} else {								# FAILURE
+			print_sql_error( $p_query );
+		}
+		print_bracket_link( $p_link, $s_proceed );
+		PRINT "</div>";
+	}
+	# --------------------
+	# This is our generic error printing function
+	# Errors should terminate the script immediately
+	function print_mantis_error( $p_error_num=0 ) {
+		global $MANTIS_ERROR;
+
+		PRINT "<html><head></head><body>";
+		PRINT $MANTIS_ERROR[$p_error_num];
+		PRINT "</body></html>";
+		exit;
+	}
+	# --------------------
+	# Print the color legend for the colors
+	function print_status_colors() {
+		global	$g_status_enum_string,
+				$g_new_color, $g_feedback_color,
+				$g_acknowledged_color, $g_confirmed_color,
+				$g_assigned_color, $g_resolved_color,
+				$g_closed_color;
+
+		PRINT "<p>";
+		PRINT "<table class=\"width100\" cellspacing=\"1\">";
+		PRINT "<tr>";
+		$t_arr  = explode_enum_string( $g_status_enum_string );
+		$enum_count = count( $t_arr );
+		for ($i=0;$i<$enum_count;$i++) {
+			$t_s = explode_enum_arr( $t_arr[$i] );
+			$t_val = get_enum_element( "status", $t_s[0] );
+
+			$t_color = "#ffffff";
+			$t_color_variable_name = "g_".$t_s[1]."_color";
+			if ( isset( $$t_color_variable_name ) ) {
+				$t_color = $$t_color_variable_name;
+			}
+			PRINT "<td class=\"small-caption\" bgcolor=\"$t_color\">$t_val</td>";
+		}
+		PRINT "</tr>";
+		PRINT "</table>";
+	}
+	# --------------------
+?>
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/core_print_API.php /cygdrive/D/mantis/core_print_API.php
--- /cygdrive/D/mantis-0.18.0rc1/core_print_API.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/core_print_API.php	2002-12-05 16:17:48.000000000 -0300
@@ -0,0 +1,1262 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the files README and LICENSE for details
+
+	###########################################################################
+	# Basic Print API
+	###########################################################################
+
+	# this file handles printing and string manipulation functions
+
+	# --------------------
+	function print_header_redirect( $p_url ) {
+		global $g_use_iis;
+
+		if ( OFF == $g_use_iis ) {
+			header( "Status: 302" );
+		}
+		header( "Content-Type: text/html" );
+		header( "Pragma: no-cache" );
+		header( "Expires: Fri, 01 Jan 1999 00:00:00 GMT" );
+		header( "Cache-control: no-cache, no-cache=\"Set-Cookie\", private" );
+		if ( ON == $g_use_iis ) {
+			header( "Refresh: 0;url=$p_url" );
+		} else {
+			header( "Location: $p_url" );
+		}
+		die; # additional output can cause problems so let's just stop output here
+	}
+	# --------------------
+	# prints the name of the user given the id.  also makes it an email link.
+	function print_user( $p_user_id ) {
+		global $g_mantis_user_table, $s_user_no_longer_exists;
+
+		# invalid user
+		if ( "0000000" == $p_user_id ) {
+			return;
+		}
+	    $query = "SELECT username, email
+	    		FROM $g_mantis_user_table
+	    		WHERE id='$p_user_id'";
+	    $result = db_query( $query );
+	    if ( db_num_rows( $result ) > 0 ) {
+			$t_username	= db_result( $result, 0, 0 );
+			$t_email	= db_result( $result, 0, 1 );
+
+			print_email_link( $t_email, $t_username );
+		} else {
+			PRINT $s_user_no_longer_exists;
+		}
+	}
+	# --------------------
+	# same as print_user() but fills in the subject with the bug summary
+	function print_user_with_subject( $p_user_id, $p_bug_id ) {
+		global $g_mantis_user_table, $s_user_no_longer_exists;
+
+		if ( "0000000" == $p_user_id ) {
+			return;
+		}
+	    $query = "SELECT username, email
+	    		FROM $g_mantis_user_table
+	    		WHERE id='$p_user_id'";
+	    $result = db_query( $query );
+	    if ( db_num_rows( $result ) > 0 ) {
+			$t_username	= db_result( $result, 0, 0 );
+			$t_email	= db_result( $result, 0, 1 );
+
+			print_email_link_with_subject( $t_email, $t_username, $p_bug_id );
+		} else {
+			PRINT $s_user_no_longer_exists;
+		}
+	}
+	# --------------------
+	# returns username if account
+	function get_user( $p_user_id ) {
+		global $g_mantis_user_table, $s_user_no_longer_exists;
+
+		if ( "0000000" == $p_user_id ) {
+			return "";
+		}
+		$query = "SELECT username
+				FROM $g_mantis_user_table
+				WHERE id='$p_user_id'";
+		$result = db_query( $query );
+		if ( db_num_rows( $result )>0 ) {
+			return db_result( $result, 0, 0 );
+		} else {
+			return $s_user_no_longer_exists;
+		}
+	}
+	# --------------------
+	function print_duplicate_id( $p_duplicate_id ) {
+		global 	$g_view_bug_page, $g_view_bug_advanced_page;
+
+		if ( $p_duplicate_id!="0000000" ) {
+			if ( ON == get_current_user_pref_field( "advanced_view" ) ) {
+				PRINT "<a href=\"$g_view_bug_advanced_page?f_id=$p_duplicate_id\">".$p_duplicate_id."</a>";
+			} else {
+				PRINT "<a href=\"$g_view_bug_page?f_id=$p_duplicate_id\">".$p_duplicate_id."</a>";
+			}
+		}
+	}
+	# --------------------
+	###########################################################################
+	# Option List Printing API
+	###########################################################################
+	# --------------------
+	# sorts the array by the first element of the array element
+	# @@@ might not be used
+	function cmp( $p_var1, $p_var2 ) {
+		if ( $p_var1[0][0] == $p_var2[0][0] ) {
+			return 0;
+		}
+		if ( $p_var1[0][0] < $p_var2[0][0] ) {
+			return -1;
+		} else {
+			return 1;
+		}
+	}
+	# --------------------
+	# ugly functions  need to be refactored
+	# This populates the reporter option list with the appropriate users
+	function print_reporter_option_list( $p_user_id ) {
+		global	$g_mantis_user_table, $g_mantis_project_user_list_table,
+				$g_mantis_project_table, $g_project_cookie_val;
+
+		$t_adm = ADMINISTRATOR;
+		$t_rep = REPORTER;
+		$t_pub = PUBLIC;
+		$t_prv = PRIVATE;
+		$user_arr = array();
+
+		# checking if it's per project or all projects
+		# 0 is all projects
+		if ( '0000000' == $g_project_cookie_val ) {
+			$query = "SELECT DISTINCT u.id, u.username, u.email
+					FROM 	$g_mantis_user_table u,
+							$g_mantis_project_user_list_table l,
+							$g_mantis_project_table p
+					WHERE	(p.view_state='$t_pub' AND
+							u.access_level>='$t_rep') OR
+							(l.access_level>='$t_rep' AND
+							l.user_id=u.id) OR
+							u.access_level>='$t_adm'
+					ORDER BY u.username";
+			$result = db_query( $query );
+			$user_count = db_num_rows( $result );
+			for ($i=0;$i<$user_count;$i++) {
+				$row = db_fetch_array( $result );
+				extract( $row, EXTR_PREFIX_ALL, "v" );
+				$user_arr[$v_username] = array( $v_username, $v_id );
+			}
+		} else {
+			$temp_arr = array();
+			# grab the administrators
+			$query = "SELECT id, username
+					FROM $g_mantis_user_table
+					ORDER BY username";
+			$result = db_query( $query );
+			$user_count = db_num_rows( $result );
+			for ($i=0;$i<$user_count;$i++) {
+				$row = db_fetch_array( $result );
+				extract( $row, EXTR_PREFIX_ALL, "v" );
+				$temp_arr[$v_username] = array( $v_username, $v_id );
+			}
+
+			foreach ( $temp_arr as $key => $val ) {
+				$v_id = $val[1];
+				$v_username = $val[0];
+
+				# always add all administrators
+				$t_access_level = get_user_field( $v_id, "access_level" );
+				if ( ADMINISTRATOR == $t_access_level ) {
+					$user_arr[$v_username] = array( $v_username, $v_id );
+					continue;
+				}
+
+				# see if users belong
+				$t_project_view_state = get_project_field( $g_project_cookie_val, "view_state" );
+				if ( PUBLIC == $t_project_view_state ) {
+					$query = "SELECT l.access_level
+							FROM	$g_mantis_project_user_list_table l,
+									$g_mantis_project_table p
+							WHERE	l.project_id='$g_project_cookie_val' AND
+									p.id=l.project_id AND
+									l.user_id='$v_id'";
+					$result = db_query( $query );
+					$count = db_num_rows( $result );
+					if ( $count > 0 ){
+						$t_access_level = db_result( $result );
+					}
+					if ( $t_access_level >= REPORTER ) {
+						$user_arr[$v_username] = array( $v_username, $v_id );
+					}
+
+				} else {
+					$query = "SELECT COUNT(*)
+							FROM	$g_mantis_project_user_list_table l,
+									$g_mantis_project_table p
+							WHERE	l.project_id='$g_project_cookie_val' AND
+									p.id=l.project_id AND
+									l.user_id='$v_id' AND
+									l.access_level>='$t_rep'";
+					$result = db_query( $query );
+					$count = db_result( $result, 0, 0 );
+					if ( $count > 0 ) {
+						$user_arr[$v_username] = array( $v_username, $v_id );
+						continue;
+					}
+				}
+			}
+		}
+
+		asort( $user_arr );
+		foreach ( $user_arr as $key => $val ) {
+			$v_id = $val[1];
+			$v_username = $val[0];
+			if ( $v_id == $p_user_id ) {
+				PRINT "<option value=\"$v_id\" SELECTED>$v_username</option>";
+			} else {
+				PRINT "<option value=\"$v_id\">$v_username</option>";
+			}
+		} # end foreach
+	}
+	# --------------------
+	function print_duplicate_id_option_list() {
+		global $g_mantis_bug_table;
+
+	    $query = "SELECT id
+	    		FROM $g_mantis_bug_table
+	    		ORDER BY id ASC";
+	    $result = db_query( $query );
+	    $duplicate_id_count = db_num_rows( $result );
+	    PRINT "<option value=\"0000000\"></option>";
+
+	    for ($i=0;$i<$duplicate_id_count;$i++) {
+	    	$row = db_fetch_array( $result );
+	    	$t_duplicate_id	= $row["id"];
+
+			PRINT "<option value=\"$t_duplicate_id\">".$t_duplicate_id."</option>";
+		}
+	}
+	# --------------------
+	# Get current headlines and id  prefix with v_
+	function print_news_item_option_list() {
+		global $g_mantis_news_table, $g_project_cookie_val;
+
+		if ( access_level_check_greater_or_equal( ADMINISTRATOR ) ) {
+			$query = "SELECT id, headline
+				FROM $g_mantis_news_table
+				ORDER BY date_posted DESC";
+		} else {
+			$query = "SELECT id, headline
+				FROM $g_mantis_news_table
+				WHERE project_id='$g_project_cookie_val'
+				ORDER BY date_posted DESC";
+		}
+	    $result = db_query( $query );
+	    $news_count = db_num_rows( $result );
+
+		for ($i=0;$i<$news_count;$i++) {
+			$row = db_fetch_array( $result );
+			extract( $row, EXTR_PREFIX_ALL, "v" );
+			$v_headline = string_display( $v_headline );
+
+			PRINT "<option value=\"$v_id\">$v_headline</option>";
+		}
+	}
+	# --------------------
+	# Used for update pages
+	function print_field_option_list( $p_list, $p_item="" ) {
+		global $g_mantis_bug_table;
+
+		$t_category_string = get_enum_string( $g_mantis_bug_table, $p_list );
+	    $t_arr = explode_enum_string( $t_category_string );
+		$entry_count = count( $t_arr );
+		for ($i=0;$i<$entry_count;$i++) {
+			$t_s = str_replace( "'", "", $t_arr[$i] );
+			if ( $p_item == $t_s ) {
+				PRINT "<option value=\"$t_s\" SELECTED>$t_s</option>";
+			}
+			else {
+				PRINT "<option value=\"$t_s\">$t_s</option>";
+			}
+		} # end for
+	}
+	# --------------------
+	function print_assign_to_option_list( $p_id="" ) {
+		global $g_mantis_user_table, $g_mantis_project_table,
+				$g_mantis_project_user_list_table, $g_project_cookie_val;
+
+		$t_adm = ADMINISTRATOR;
+		$t_dev = DEVELOPER;
+		$t_pub = PUBLIC;
+		$t_prv = PRIVATE;
+		$user_arr = array();
+
+		# checking if it's per project or all projects
+		# 0 is all projects
+		if ( '0000000' == $g_project_cookie_val ) {
+			$query = "SELECT DISTINCT u.id, u.username, u.email
+					FROM 	$g_mantis_user_table u,
+							$g_mantis_project_user_list_table l,
+							$g_mantis_project_table p
+					WHERE	(p.view_state='$t_pub' AND
+							u.access_level>='$t_dev') OR
+							(l.access_level>='$t_dev' AND
+							l.user_id=u.id) OR
+							u.access_level>='$t_adm'
+					ORDER BY u.username";
+			$result = db_query( $query );
+			$user_count = db_num_rows( $result );
+			for ($i=0;$i<$user_count;$i++) {
+				$row = db_fetch_array( $result );
+				extract( $row, EXTR_PREFIX_ALL, "v" );
+				$user_arr[$v_username] = array( $v_username, $v_id );
+			}
+		} else {
+			$temp_arr = array();
+			# grab the administrators
+			$query = "SELECT id, username
+					FROM $g_mantis_user_table
+					ORDER BY username";
+			$result = db_query( $query );
+			$user_count = db_num_rows( $result );
+			for ($i=0;$i<$user_count;$i++) {
+				$row = db_fetch_array( $result );
+				extract( $row, EXTR_PREFIX_ALL, "v" );
+				$temp_arr[$v_username] = array( $v_username, $v_id );
+			}
+
+			foreach ( $temp_arr as $key => $val ) {
+				$v_id = $val[1];
+				$v_username = $val[0];
+
+				# always add all administrators
+				$t_access_level = get_user_field( $v_id, "access_level" );
+				if ( ADMINISTRATOR == $t_access_level ) {
+					$user_arr[$v_username] = array( $v_username, $v_id );
+					continue;
+				}
+
+				# see if users belong
+				$t_project_view_state = get_project_field( $g_project_cookie_val, "view_state" );
+				if ( PUBLIC == $t_project_view_state ) {
+					$query = "SELECT l.access_level
+							FROM	$g_mantis_project_user_list_table l,
+									$g_mantis_project_table p
+							WHERE	l.project_id='$g_project_cookie_val' AND
+									p.id=l.project_id AND
+									l.user_id='$v_id'";
+					$result = db_query( $query );
+					$count = db_num_rows( $result );
+					if ( $count > 0 ){
+						$t_access_level = db_result( $result );
+					}
+					if ( $t_access_level >= DEVELOPER ) {
+						$user_arr[$v_username] = array( $v_username, $v_id );
+					}
+
+				} else {
+					$query = "SELECT COUNT(*)
+							FROM	$g_mantis_project_user_list_table l,
+									$g_mantis_project_table p
+							WHERE	l.project_id='$g_project_cookie_val' AND
+									p.id=l.project_id AND
+									l.user_id='$v_id' AND
+									l.access_level>='$t_dev'";
+					$result = db_query( $query );
+					$count = db_result( $result, 0, 0 );
+					if ( $count > 0 ) {
+						$user_arr[$v_username] = array( $v_username, $v_id );
+						continue;
+					}
+				}
+			}
+		}
+
+		asort( $user_arr );
+		foreach ( $user_arr as $key => $val ) {
+			$v_id = $val[1];
+			$v_username = $val[0];
+			if ( $v_id == $p_user_id ) {
+				PRINT "<option value=\"$v_id\" SELECTED>$v_username</option>";
+			} else {
+				PRINT "<option value=\"$v_id\">$v_username</option>";
+			}
+		} # end foreach
+	}
+	# --------------------
+	# List projects that the current user has access to
+	function print_project_option_list( $p_project_id="" ) {
+		global $g_mantis_project_table, $g_mantis_project_user_list_table,
+				$g_project_cookie_val;
+
+		$t_user_id = get_current_user_field( "id" );
+		$t_access_level = get_current_user_field( "access_level" );
+
+		$t_pub = PUBLIC;
+		$t_prv = PRIVATE;
+
+		if ( ADMINISTRATOR == $t_access_level ) {
+			$query = "SELECT DISTINCT( p.id ), p.name
+						FROM $g_mantis_project_table p
+						WHERE p.enabled=1
+						ORDER BY p.name";
+		} else {
+			$query = "SELECT DISTINCT( p.id ), p.name
+						FROM $g_mantis_project_table p
+						LEFT JOIN $g_mantis_project_user_list_table u
+						ON p.id=u.project_id
+						WHERE p.enabled=1 AND
+						((p.view_state=$t_pub) OR
+						 (p.view_state=$t_prv AND u.user_id=$t_user_id))
+						ORDER BY p.name";
+		}
+
+		$result = db_query( $query );
+		$project_count = db_num_rows( $result );
+
+		for ($i=0;$i<$project_count;$i++) {
+			$row = db_fetch_array( $result );
+			extract( $row, EXTR_PREFIX_ALL, "v" );
+			if ( $p_project_id == $v_id ) {
+				PRINT "<option value=\"$v_id\" SELECTED>$v_name</option>";
+			} else {
+				PRINT "<option value=\"$v_id\">$v_name</option>";
+			}
+		}
+	}
+	# --------------------
+	# prints the profiles given the user id
+	function print_profile_option_list( $p_id, $p_select_id="" ) {
+		global $g_mantis_user_profile_table, $g_mantis_user_pref_table;
+
+		$query = "SELECT default_profile
+			FROM $g_mantis_user_pref_table
+			WHERE user_id='$p_id'";
+	    $result = db_query( $query );
+	    $v_default_profile = db_result( $result, 0, 0 );
+
+		# Get profiles
+		$query = "SELECT id, platform, os, os_build
+			FROM $g_mantis_user_profile_table
+			WHERE user_id='$p_id'
+			ORDER BY id";
+	    $result = db_query( $query );
+	    $profile_count = db_num_rows( $result );
+
+		PRINT "<option value=\"\"></option>";
+		for ($i=0;$i<$profile_count;$i++) {
+			# prefix data with v_
+			$row = db_fetch_array( $result );
+			extract( $row, EXTR_PREFIX_ALL, "v" );
+			$v_platform	= string_display( $v_platform );
+			$v_os		= string_display( $v_os );
+			$v_os_build	= string_display( $v_os_build );
+
+			if ( $v_id == $v_default_profile ) {
+				PRINT "<option value=\"$v_id\" SELECTED>$v_platform $v_os $v_os_build</option>";
+			} else {
+				PRINT "<option value=\"$v_id\">$v_platform $v_os $v_os_build</option>";
+			}
+		}
+	}
+	# --------------------
+	function print_news_project_option_list( $p_id ) {
+		global 	$g_mantis_project_table, $g_mantis_project_user_list_table,
+				$g_project_cookie;
+
+		if ( access_level_check_greater_or_equal( ADMINISTRATOR ) ) {
+			$query = "SELECT *
+					FROM $g_mantis_project_table
+					ORDER BY name";
+		} else {
+			$t_user_id = get_current_user_field( "id" );
+			$query = "SELECT p.id, p.name
+					FROM $g_mantis_project_table p, $g_mantis_project_user_list_table m
+					WHERE 	p.id=m.project_id AND
+							m.user_id='$t_user_id' AND
+							p.enabled='1'";
+		}
+		$result = db_query( $query );
+		$project_count = db_num_rows( $result );
+		for ($i=0;$i<$project_count;$i++) {
+			$row = db_fetch_array( $result );
+			extract( $row, EXTR_PREFIX_ALL, "v" );
+
+			if ( $v_id == $p_id ) {
+				PRINT "<option value=\"$v_id\" SELECTED>$v_name</option>";
+			} else {
+				PRINT "<option value=\"$v_id\">$v_name</option>";
+			}
+		} # end for
+	}
+	# --------------------
+	# Since categories can be orphaned we need to grab all unique instances of category
+	# We check in the project category table and in the bug table
+	# We put them all in one array and make sure the entries are unique
+	function print_category_option_list( $p_category="" ) {
+		global $g_mantis_bug_table, $g_mantis_project_category_table, $g_project_cookie_val;
+
+		# grab all categories in the project category table
+		$cat_arr = array();
+		$query = "SELECT DISTINCT( category ) as category
+				FROM $g_mantis_project_category_table
+				WHERE project_id='$g_project_cookie_val'
+				ORDER BY category";
+		$result = db_query( $query );
+		$category_count = db_num_rows( $result );
+		for ($i=0;$i<$category_count;$i++) {
+			$row = db_fetch_array( $result );
+			$cat_arr[] = $row["category"];
+		}
+		sort( $cat_arr );
+		$cat_arr = array_unique( $cat_arr );
+
+		foreach( $cat_arr as $t_category ) {
+			if ( $t_category == $p_category ) {
+				PRINT "<option value=\"$t_category\" SELECTED>$t_category</option>";
+			} else {
+				PRINT "<option value=\"$t_category\">$t_category</option>";
+			}
+		}
+	}
+	# --------------------
+	# Since categories can be orphaned we need to grab all unique instances of category
+	# We check in the project category table and in the bug table
+	# We put them all in one array and make sure the entries are unique
+	function print_category_complete_option_list( $p_category="" ) {
+		global $g_mantis_bug_table, $g_mantis_project_category_table, $g_project_cookie_val;
+
+		# grab all categories in the project category table
+		$cat_arr = array();
+		$query = "SELECT DISTINCT( category ) as category
+				FROM $g_mantis_project_category_table
+				WHERE project_id='$g_project_cookie_val'
+				ORDER BY category";
+		$result = db_query( $query );
+		$category_count = db_num_rows( $result );
+		for ($i=0;$i<$category_count;$i++) {
+			$row = db_fetch_array( $result );
+			$cat_arr[] = $row["category"];
+		}
+
+		# grab all categories in the bug table
+		$query = "SELECT DISTINCT( category ) as category
+				FROM $g_mantis_bug_table
+				WHERE project_id='$g_project_cookie_val'
+				ORDER BY category";
+		$result = db_query( $query );
+		$category_count = db_num_rows( $result );
+
+		for ($i=0;$i<$category_count;$i++) {
+			$row = db_fetch_array( $result );
+			$cat_arr[] = $row["category"];
+		}
+		sort( $cat_arr );
+		$cat_arr = array_unique( $cat_arr );
+
+		foreach( $cat_arr as $t_category ) {
+			if ( $t_category == $p_category ) {
+				PRINT "<option value=\"$t_category\" SELECTED>$t_category</option>";
+			} else {
+				PRINT "<option value=\"$t_category\">$t_category</option>";
+			}
+		}
+	}
+	# --------------------
+	function print_category_option_listOLD( $p_category="" ) {
+		global $g_mantis_project_category_table, $g_project_cookie_val;
+
+		# @@@ not implemented yet
+		if ( '0000000' == $g_project_cookie_val ) {
+			$query = "SELECT category
+					FROM $g_mantis_project_category_table
+					WHERE project_id='$g_project_cookie_val'
+					ORDER BY category";
+
+		} else {
+			$query = "SELECT category
+					FROM $g_mantis_project_category_table
+					WHERE project_id='$g_project_cookie_val'
+					ORDER BY category";
+		}
+
+		$result = db_query( $query );
+		$category_count = db_num_rows( $result );
+		for ($i=0;$i<$category_count;$i++) {
+			$row = db_fetch_array( $result );
+			$t_category = $row["category"];
+			if ( $t_category == $p_category ) {
+				PRINT "<option value=\"$t_category\" SELECTED>$t_category</option>";
+			} else {
+				PRINT "<option value=\"$t_category\">$t_category</option>";
+			}
+		}
+	}
+	# --------------------
+	function print_version_option_list( $p_version="" ) {
+		global $g_mantis_project_version_table, $g_project_cookie_val;
+
+		$query = "SELECT *
+				FROM $g_mantis_project_version_table
+				WHERE project_id='$g_project_cookie_val'
+				ORDER BY date_order DESC";
+		$result = db_query( $query );
+		$version_count = db_num_rows( $result );
+		for ($i=0;$i<$version_count;$i++) {
+			$row = db_fetch_array( $result );
+			$t_version = $row["version"];
+			if ( $t_version == $p_version ) {
+				PRINT "<option value=\"$t_version\" SELECTED>$t_version</option>";
+			} else {
+				PRINT "<option value=\"$t_version\">$t_version</option>";
+			}
+		}
+	}
+	# --------------------
+	# select the proper enum values based on the input parameter
+	# we use variable variables in order to achieve this
+	function print_enum_string_option_list( $p_enum_name, $p_val=0 ) {
+		$g_var = "g_".$p_enum_name."_enum_string";
+		global $$g_var;
+
+		$t_arr  = explode_enum_string( $$g_var );
+		$enum_count = count( $t_arr );
+		for ($i=0;$i<$enum_count;$i++) {
+			$t_elem  = explode_enum_arr( $t_arr[$i] );
+			$t_elem2 = get_enum_element( $p_enum_name, $t_elem[0] );
+			if ( $t_elem[0] == $p_val ) {
+				PRINT "<option value=\"$t_elem[0]\" SELECTED>$t_elem2</option>";
+			} else {
+				PRINT "<option value=\"$t_elem[0]\">$t_elem2</option>";
+			}
+		} # end for
+	}
+	# --------------------
+	# prints the list of access levels exluding ADMINISTRATOR
+	# this is used when adding users to projects
+	function print_project_user_option_list( $p_val ) {
+		global $g_mantis_project_table, $g_access_levels_enum_string;
+
+		$t_arr = explode_enum_string( $g_access_levels_enum_string );
+		$enum_count = count( $t_arr );
+		for ($i=0;$i<$enum_count;$i++) {
+			$t_elem = explode_enum_arr( $t_arr[$i] );
+
+			if ( $t_elem[0] >= ADMINISTRATOR ) {
+				continue;
+			}
+
+			$t_access_level = get_enum_element( "access_levels", $t_elem[0] );
+			if ( $p_val == $t_elem[0] ) {
+				PRINT "<option value=\"$t_elem[0]\" SELECTED>$t_access_level</option>";
+			} else {
+				PRINT "<option value=\"$t_elem[0]\">$t_access_level</option>";
+			}
+		} # end for
+	}
+	# --------------------
+	function print_language_option_list( $p_language ) {
+		global $g_language_choices_arr;
+
+		$t_arr = $g_language_choices_arr;
+		$enum_count = count( $t_arr );
+		for ($i=0;$i<$enum_count;$i++) {
+			if ( $t_arr[$i] == $p_language ) {
+				PRINT "<option value=\"$t_arr[$i]\" SELECTED>$t_arr[$i]</option>";
+			} else {
+				PRINT "<option value=\"$t_arr[$i]\">$t_arr[$i]</option>";
+			}
+		} # end for
+	}
+	# --------------------
+	# @@@ preliminary support for multiple bug actions.
+	function print_all_bug_action_option_list() {
+		$zook_arr[0] = "Move Bugs";
+		$zook_arr[1] = "Assign";
+		$zook_arr[3] = "Resolve";
+		$zook_arr[4] = "Update Priority";
+		$zook_arr[4] = "Update Status";
+
+		$t_count = count( $zook_arr );
+		for ($i=0;$i<$t_count;$i++) {
+			PRINT "<option value=\""."\">".$zook_arr[$i]."</option>";
+		}
+	}
+	# --------------------
+	# list of users that are NOT in the specified project
+	# if no project is specified use the current project
+	function print_project_user_list_option_list( $p_project_id=0 ) {
+		global	$g_mantis_project_user_list_table, $g_mantis_user_table,
+				$g_project_cookie_val;
+
+		if ( 0 == $p_project_id ) {
+			$p_project_id = $g_project_cookie_val;
+		}
+		$t_adm = ADMINISTRATOR;
+		$query = "SELECT DISTINCT u.id, u.username
+				FROM $g_mantis_user_table u
+				LEFT JOIN $g_mantis_project_user_list_table p
+				ON p.user_id=u.id AND p.project_id='$p_project_id'
+				WHERE u.access_level<$t_adm AND
+					p.user_id IS NULL AND
+					u.access_level<'$t_adm'
+				ORDER BY u.username";
+		$result = db_query( $query );
+		$category_count = db_num_rows( $result );
+		for ($i=0;$i<$category_count;$i++) {
+			$row = db_fetch_array( $result );
+			$t_username = $row["username"];
+			$t_id = $row["id"];
+			PRINT "<option value=\"$t_id\">$t_username</option>";
+		}
+	}
+	# --------------------
+	# list of projects that a user is NOT in
+	function print_project_user_list_option_list2( $p_user_id ) {
+		global	$g_mantis_project_user_list_table, $g_mantis_project_table;
+
+		$t_prv = PRIVATE;
+		$query = "SELECT DISTINCT p.id, p.name
+				FROM $g_mantis_project_table p
+				LEFT JOIN $g_mantis_project_user_list_table u
+				ON p.id=u.project_id AND u.user_id='$p_user_id'
+				WHERE p.enabled=1 AND
+					p.view_state='$t_prv' AND
+					u.user_id IS NULL
+				ORDER BY p.name";
+		$result = db_query( $query );
+		$category_count = db_num_rows( $result );
+		for ($i=0;$i<$category_count;$i++) {
+			$row = db_fetch_array( $result );
+			$t_project_name = $row["name"];
+			$t_id = $row["id"];
+			PRINT "<option value=\"$t_id\">$t_project_name</option>";
+		}
+	}
+	# --------------------
+	# list of projects that a user is NOT in
+	function print_project_user_list( $p_user_id ) {
+		global	$g_mantis_project_user_list_table, $g_mantis_project_table,
+				$s_remove_link, $g_manage_user_proj_delete;
+
+		$query = "SELECT DISTINCT p.id, p.name, p.view_state, u.access_level
+				FROM $g_mantis_project_table p
+				LEFT JOIN $g_mantis_project_user_list_table u
+				ON p.id=u.project_id
+				WHERE p.enabled=1 AND
+					u.user_id='$p_user_id'
+				ORDER BY p.name";
+		$result = db_query( $query );
+		$category_count = db_num_rows( $result );
+		for ($i=0;$i<$category_count;$i++) {
+			$row = db_fetch_array( $result );
+			$t_project_id = $row["id"];
+			$t_project_name = $row["name"];
+			$t_view_state = $row["view_state"];
+			$t_access_level = $row["access_level"];
+			$t_access_level = get_enum_element( "access_levels", $t_access_level );
+			$t_view_state = get_enum_element( "project_view_state", $t_view_state );
+			PRINT "$t_project_name [$t_access_level] ($t_view_state) [<a class=\"small\" href=\"$g_manage_user_proj_delete?f_project_id=$t_project_id&f_user_id=$p_user_id\">$s_remove_link</a>]<br />";
+		}
+	}
+	# --------------------
+	###########################################################################
+	# String printing API
+	###########################################################################
+	# --------------------
+	# prints a link to a bug given an ID
+	# it accounts for the user preference and site override
+	function print_bug_link( $p_id ) {
+		global 	$g_view_bug_page, $g_view_bug_advanced_page, $g_show_view;
+
+		switch ( $g_show_view ) {
+		case BOTH:
+			if ( ON == get_current_user_pref_field( "advanced_view" ) ) {
+				PRINT "<a href=\"$g_view_bug_advanced_page?f_id=$p_id\">$p_id</a>";
+			} else {
+				PRINT "<a href=\"$g_view_bug_page?f_id=$p_id\">$p_id</a>";
+			}
+			break;
+		case SIMPLE_ONLY:
+			PRINT "<a href=\"$g_view_bug_page?f_id=$p_id\">$p_id</a>";
+			break;
+		case ADVANCED_ONLY:
+			PRINT "<a href=\"$g_view_bug_advanced_page?f_id=$p_id\">$p_id</a>";
+			break;
+		}
+	}
+	# --------------------
+	# prints a link to the update page given an ID
+	# it accounts for the user preference and site override
+	function get_bug_update_page() {
+		global 	$g_bug_update_page, $g_bug_update_advanced_page, $g_show_update;
+
+		switch ( $g_show_update ) {
+		case BOTH:
+			if ( ON == get_current_user_pref_field( "advanced_update" ) ) {
+				return $g_bug_update_advanced_page;
+			} else {
+				return $g_bug_update_page;
+			}
+			break;
+		case SIMPLE_ONLY:
+				return $g_bug_update_page;
+			break;
+		case ADVANCED_ONLY:
+				return $g_bug_update_advanced_page;
+			break;
+		}
+	}
+	# --------------------
+	# returns a href link to a bug given an ID
+	# it accounts for the user preference and site override
+	function get_bug_link( $p_id ) {
+		global 	$g_view_bug_page, $g_view_bug_advanced_page, $g_show_view;
+
+		switch ( $g_show_view ) {
+		case BOTH:
+			if ( ON == get_current_user_pref_field( "advanced_view" ) ) {
+				return "<a href=\"$g_view_bug_advanced_page?f_id=$p_id\">$p_id</a>";
+			} else {
+				return "<a href=\"$g_view_bug_page?f_id=$p_id\">$p_id</a>";
+			}
+			break;
+		case SIMPLE_ONLY:
+			return "<a href=\"$g_view_bug_page?f_id=$p_id\">$p_id</a>";
+			break;
+		case ADVANCED_ONLY:
+			return "<a href=\"$g_view_bug_advanced_page?f_id=$p_id\">$p_id</a>";
+			break;
+		}
+	}
+	# --------------------
+	# returns a href link to a bug given an ID
+	# it accounts for the user preference and site override
+	function get_bug_link_plain( $p_id ) {
+		global 	$g_view_bug_page, $g_view_bug_advanced_page, $g_show_view;
+
+		switch ( $g_show_view ) {
+		case BOTH:
+			if ( ON == get_current_user_pref_field( "advanced_view" ) ) {
+				return "$g_view_bug_advanced_page?f_id=$p_id";
+			} else {
+				return "$g_view_bug_page?f_id=$p_id";
+			}
+			break;
+		case SIMPLE_ONLY:
+			return "$g_view_bug_page?f_id=$p_id";
+			break;
+		case ADVANCED_ONLY:
+			return "$g_view_bug_advanced_page?f_id=$p_id";
+			break;
+		}
+	}
+	# --------------------
+	# formats the severity given the status
+	# shows the severity in BOLD if the bug is NOT closed and is of significant severity
+	function print_formatted_severity_string( $p_status, $p_severity ) {
+		$t_sev_str = get_enum_element( "severity", $p_severity );
+		if ( ( ( MAJOR == $p_severity ) ||
+			   ( CRASH == $p_severity ) ||
+			   ( BLOCK == $p_severity ) ) &&
+			 ( CLOSED != $p_status ) ) {
+			PRINT "<span class=\"bold\">$t_sev_str</span>";
+		} else {
+			PRINT "$t_sev_str";
+		}
+	}
+	# --------------------
+	function print_project_category_string( $p_project_id ) {
+		global $g_mantis_project_category_table, $g_mantis_project_table;
+
+		$query = "SELECT category
+				FROM $g_mantis_project_category_table
+				WHERE project_id='$p_project_id'
+				ORDER BY category";
+		$result = db_query( $query );
+		$category_count = db_num_rows( $result );
+		$t_string = "";
+
+		for ($i=0;$i<$category_count;$i++) {
+			$row = db_fetch_array( $result );
+			$t_category = $row["category"];
+
+			if ( $i+1 < $category_count ) {
+				$t_string .= $t_category.", ";
+			} else {
+				$t_string .= $t_category;
+			}
+		}
+
+		return $t_string;
+	}
+	# --------------------
+	function print_project_version_string( $p_project_id ) {
+		global $g_mantis_project_version_table, $g_mantis_project_table;
+
+		$query = "SELECT version
+				FROM $g_mantis_project_version_table
+				WHERE project_id='$p_project_id'";
+		$result = db_query( $query );
+		$version_count = db_num_rows( $result );
+		$t_string = "";
+
+		for ($i=0;$i<$version_count;$i++) {
+			$row = db_fetch_array( $result );
+			$t_version = $row["version"];
+
+			if ( $i+1 < $version_count ) {
+				$t_string .= $t_version.", ";
+			} else {
+				$t_string .= $t_version;
+			}
+		}
+
+		return $t_string;
+	}
+	# --------------------
+	###########################################################################
+	# Link Printing API
+	###########################################################################
+	# --------------------
+	function print_view_bug_sort_link( $p_string, $p_sort_field, $p_sort, $p_dir ) {
+		global $g_view_all_set;
+
+		if ( $p_sort_field == $p_sort ) {
+			# we toggle between ASC and DESC if the user clicks the same sort order
+			if ( "ASC" == $p_dir ) {
+				$p_dir = "DESC";
+			} else {
+				$p_dir = "ASC";
+			}
+
+			PRINT "<a href=\"$g_view_all_set?f_sort=$p_sort_field&f_dir=$p_dir&f_type=2\">$p_string</a>";
+		} else {
+			PRINT "<a href=\"$g_view_all_set?f_sort=$p_sort_field&f_dir=$p_dir&f_type=2\">$p_string</a>";
+		}
+	}
+	# --------------------
+	function print_view_bug_sort_link2( $p_string, $p_sort_field, $p_sort, $p_dir ) {
+		global $g_view_all_set;
+
+		if ( $p_sort_field == $p_sort ) {
+			# we toggle between ASC and DESC if the user clicks the same sort order
+			if ( "ASC" == $p_dir ) {
+				$p_dir = "DESC";
+			} else {
+				$p_dir = "ASC";
+			}
+
+			PRINT "<a href=\"$g_view_all_set?f_sort=$p_sort_field&f_dir=$p_dir&f_type=2&f_print=1\">$p_string</a>";
+		} else {
+			PRINT "<a href=\"$g_view_all_set?f_sort=$p_sort_field&f_dir=$p_dir&f_type=2&f_print=1\">$p_string</a>";
+		}
+	}
+	# --------------------
+	function print_manage_user_sort_link(  $p_page, $p_string, $p_sort_field, $p_dir, $p_hide=0 ) {
+		PRINT "<a href=\"$p_page?f_sort=$p_sort_field&f_dir=$p_dir&f_save=1&f_hide=$p_hide\">$p_string</a>";
+	}
+	# --------------------
+	function print_manage_project_sort_link(  $p_page, $p_string, $p_sort_field, $p_dir ) {
+		PRINT "<a href=\"$p_page?f_sort=$p_sort_field&f_dir=$p_dir\">$p_string</a>";
+	}
+	# --------------------
+	# print the bracketed links used near the top
+	# if the $p_link is blank then the text is printed but no link is created
+	function print_bracket_link( $p_link, $p_url_text ) {
+		if (empty( $p_link )) {
+			PRINT "[ $p_url_text ]";
+		} else {
+			PRINT "[ <a href=\"$p_link\">$p_url_text</a> ]";
+		}
+	}
+	# --------------------
+	# print a mailto: href link
+	function print_email_link( $p_email, $p_text ) {
+		PRINT get_email_link($p_email,$p_text);
+	}
+	# --------------------
+	# return the mailto: href string link instead of printing it
+	function get_email_link( $p_email, $p_text ) {
+		global $g_show_user_email, $g_anonymous_account;
+
+		switch ( $g_show_user_email ) {
+			case NONE:	return "$p_text";
+			case ALL:	return "<a href=\"mailto:$p_email\">$p_text</a>";
+			case NO_ANONYMOUS:	if ( get_current_user_field( "username" ) != $g_anonymous_account ) {
+									return "<a href=\"mailto:$p_email\">$p_text</a>";
+								} else {
+									return "$p_text";
+								}
+			case ADMIN_ONLY:	if ( ADMINISTRATOR == get_current_user_field( "access_level" ) ) {
+									return "<a href=\"mailto:$p_email\">$p_text</a>";
+								} else {
+									return "$p_text";
+								}
+			default:	return "$p_text";
+		}
+	}
+	# --------------------
+	# print a mailto: href link with subject
+	function print_email_link_with_subject( $p_email, $p_text, $p_bug_id ) {
+		global $g_mantis_bug_table;
+
+		$t_subject = email_build_subject( $p_bug_id );
+		PRINT get_email_link_with_subject( $p_email, $p_text, $t_subject );
+	}
+	# --------------------
+	# return the mailto: href string link instead of printing it
+	# add subject line
+	function get_email_link_with_subject( $p_email, $p_text, $p_summary ) {
+		global $g_show_user_email, $g_anonymous_account;
+
+		switch ( $g_show_user_email ) {
+			case NONE:	return "$p_text";
+			case ALL:	return "<a href=\"mailto:$p_email?subject=$p_summary\">$p_text</a>";
+			case NO_ANONYMOUS:	if ( get_current_user_field( "username" ) != $g_anonymous_account ) {
+									return "<a href=\"mailto:$p_email?subject=$p_summary\">$p_text</a>";
+								} else {
+									return "$p_text";
+								}
+			case ADMIN_ONLY:	if ( ADMINISTRATOR == get_current_user_field( "access_level" ) ) {
+									return "<a href=\"mailto:$p_email?subject=$p_summary\">$p_text</a>";
+								} else {
+									return "$p_text";
+								}
+			default:	return "$p_text";
+		}
+	}
+	# --------------------
+	# print our standard mysql query error
+	# this function should rarely (if ever) be reached.  instead the db_()
+	# functions should trap (altough inelegantly).
+	function print_sql_error( $p_query ) {
+		global $MANTIS_ERROR, $g_administrator_email, $s_administrator;
+
+		PRINT $MANTIS_ERROR[ERROR_SQL];
+		print_email_link( $g_administrator_email, $s_administrator );
+		PRINT "<p>$p_query;<p>";
+	}
+	# --------------------
+	###########################################################################
+	# Filter API
+	###########################################################################
+	# --------------------
+	# make http and mailto link urls
+	function filter_href_tags( $p_string ) {
+    	$p_string = eregi_replace( "([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])",
+    							"<a href=\"\\1://\\2\\3\">\\1://\\2\\3</a>",
+    							$p_string);
+        $p_string = eregi_replace( "(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))",
+        						"<a href=\"mailto:\\1\" target=\"_new\">\\1</a>",
+        						$p_string);
+		return $p_string;
+	}
+	# --------------------
+	# undo http and mailto link urls for editing purposes
+	function unfilter_href_tags( $p_string ) {
+    	$p_string = eregi_replace( "<a href=\"([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])\">([^[:space:]]*)([[:alnum:]#?/&=])</a>",
+    							"\\1://\\2\\3",
+    							$p_string);
+        $p_string = eregi_replace( "<a href=\"mailto:(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))\" target=\"_new\">(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))</a>",
+        						"\\1",
+        						$p_string);
+		return $p_string;
+	}
+	# --------------------
+	# @@@ currently does nothing
+	function filter_img_tags( $p_string ) {
+		return $p_string;
+	}
+	# --------------------
+	# process $g_html_tags to be treated as html
+	function filter_html_tags( $p_string ) {
+		global $g_html_tags;
+
+		$t_filter_from 	= @array( "/\//", "/</", "/>/" );
+		$t_filter_to 	= @array( "\/", "", "" );
+		//$t_filter_from 	= @array( "\/", "<", ">" );
+		//$t_filter_to 	= @array( "\/", "", "" );
+
+		$t_tag_count = count( $g_html_tags );
+		for ($i=0;$i<$t_tag_count;$i++) {
+			$tag = preg_replace( $t_filter_from, $t_filter_to, $g_html_tags[$i] );
+
+			$p_string = preg_replace( "/&lt;($tag)&gt;/i", "<\\1>", $p_string );
+		}
+
+		return $p_string;
+	}
+	# --------------------
+	###########################################################################
+	# String Processing API
+	###########################################################################
+	# --------------------
+	# every string that comes form a textarea should be processed through this
+	# function *before* insertion into the database.
+	function string_prepare_textarea( $p_string ) {
+		global $g_allow_href_tags, $g_allow_html_tags;
+
+		$p_string = htmlspecialchars( $p_string );
+
+		if ( ON == $g_allow_html_tags ) {
+			$p_string = filter_html_tags( $p_string );
+		}
+
+		if ( ON == $g_allow_href_tags ) {
+			$p_string = filter_href_tags( $p_string );
+		}
+
+		$p_string = filter_img_tags( $p_string );
+		$p_string = addslashes( $p_string );
+		return $p_string;
+	}
+	# --------------------
+	# every string that comes form a text field should be processed through this
+	# function *before* insertion into the database.
+	function string_prepare_text( $p_string ) {
+		global $g_allow_href_tags, $g_allow_html_tags;
+		# the " breaks a text box when you go back to edit so we will convert
+		# it here
+		$p_string = str_replace( "\"", "'", $p_string );
+		$p_string = htmlspecialchars( $p_string );
+
+		if ( ON == $g_allow_html_tags ) {
+			$p_string = filter_html_tags( $p_string );
+		}
+
+		if ( ON == $g_allow_href_tags ) {
+			$p_string = filter_href_tags( $p_string );
+		}
+
+		$p_string = filter_img_tags( $p_string );
+		$p_string = addslashes( $p_string );
+		return $p_string;
+	}
+	# --------------------
+	# Use this to prepare a string for display to HTML
+	function string_display( $p_string ) {
+		$p_string = stripslashes( $p_string );
+		$p_string = process_bug_link( $p_string );
+		$p_string = process_cvs_link( $p_string );
+		$p_string = nl2br( $p_string );
+		return $p_string;
+	}
+	# --------------------
+	# Prepare a string for plain text display in email
+	function string_email( $p_string ) {
+		$p_string = stripslashes( $p_string );
+		$p_string = unfilter_href_tags( $p_string );
+		$p_string = process_bug_link_email( $p_string );
+		$p_string = process_cvs_link_email( $p_string );
+		$p_string = str_replace( "&lt;", "<",  $p_string );
+		$p_string = str_replace( "&gt;", ">",  $p_string );
+		$p_string = str_replace( "&quot;", "\"",  $p_string );
+		$p_string = str_replace( "&amp;", "&",  $p_string );
+
+		return $p_string;
+	}
+	# --------------------
+	# Process a string for display in a textarea box
+	function string_edit_textarea( $p_string ) {
+		$p_string = stripslashes( $p_string );
+		$p_string = str_replace( "<br>", "",  $p_string );
+		$p_string = unfilter_href_tags( $p_string );
+		$p_string = str_replace( "<br />", "\n",  $p_string );
+		$p_string = str_replace( "&lt;", "<",  $p_string );
+		$p_string = str_replace( "&gt;", ">",  $p_string );
+		$p_string = str_replace( "&quot;", "\"",  $p_string );
+		return $p_string;
+	}
+	# --------------------
+	# Process a string for display in a text box
+	function string_edit_text( $p_string ) {
+		$p_string = stripslashes( $p_string );
+		$p_string = str_replace( "<br>", "",  $p_string );
+		$p_string = unfilter_href_tags( $p_string );
+		$p_string = str_replace( "&lt;", "<",  $p_string );
+		$p_string = str_replace( "&gt;", ">",  $p_string );
+		$p_string = str_replace( "&quot;", "'",  $p_string );
+		return $p_string;
+	}
+	# --------------------
+	###########################################################################
+	# Miscellaneous String Functions API
+	###########################################################################
+	# --------------------
+	# duplicates str_pad() from PHP4
+	# left pad $p_string with $p_pad until we reach $p_length
+	function str_pd( $p_string, $p_pad, $p_length, $p_dir=STR_PAD_RIGHT ) {
+		$t_num = $p_length - strlen( $p_string );
+		for ($i=0;$i<$t_num;$i++) {
+			switch ( $p_dir ) {
+				case STR_PAD_LEFT: $p_string = $p_pad.$p_string;
+									break;
+				case STR_PAD_RIGHT: $p_string = $p_string.$p_pad;
+									break;
+			}
+		}
+		return $p_string;
+	}
+	# --------------------
+	/* wordwrap($string, $cols, $prefix)
+	 *
+	 * Takes $string, and wraps it on a per-word boundary (does not clip
+	 * words UNLESS the word is more than $cols long), no more than $cols per
+	 * line. Allows for optional prefix string for each line. (Was written to
+	 * easily format replies to e-mails, prefixing each line with "> ".
+	 *
+	 * Copyright 1999 Dominic J. Eidson, use as you wish, but give credit
+	 * where credit due.
+	 */
+	if ( !function_exists( "wordwrap" ) ) {
+		function wordwrap ($string, $cols = 72, $prefix = "") {
+
+			$t_lines = split( "\n", $string);
+			$outlines = "";
+
+			while(list(, $thisline) = each($t_lines)) {
+				if(strlen($thisline) > $cols) {
+
+					$newline = "";
+					$t_l_lines = split(" ", $thisline);
+
+					while(list(, $thisword) = each($t_l_lines)) {
+						while((strlen($thisword) + strlen($prefix)) > $cols) {
+							$cur_pos = 0;
+							$outlines .= $prefix;
+
+							for($num=0; $num < $cols-1; $num++) {
+							    $outlines .= $thisword[$num];
+							    $cur_pos++;
+							} # end for
+
+							$outlines .= "\n";
+							$thisword = substr($thisword, $cur_pos, (strlen($thisword)-$cur_pos));
+						} # end innermost while
+
+						if((strlen($newline) + strlen($thisword)) > $cols) {
+							$outlines .= $prefix.$newline."\n";
+							$newline = $thisword." ";
+						} else {
+							$newline .= $thisword." ";
+						}
+					}  # end while
+
+					$outlines .= $prefix.$newline."\n";
+			    } else {
+					$outlines .= $prefix.$thisline."\n";
+				}
+			} # end outermost while
+			return $outlines;
+		}
+	}
+	# --------------------
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/core_proj_user_API.php /cygdrive/D/mantis/core_proj_user_API.php
--- /cygdrive/D/mantis-0.18.0rc1/core_proj_user_API.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/core_proj_user_API.php	2002-12-05 16:17:48.000000000 -0300
@@ -0,0 +1,103 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the files README and LICENSE for details
+
+	###########################################################################
+	# Project User API
+	###########################################################################
+	# --------------------
+	# checks to see if the user/project combo already exists
+	# returns true is duplicate is found, otherwise false
+	function proj_user_is_duplicate( $p_project_id, $p_user_id ) {
+		global $g_mantis_project_user_list_table;
+
+		$query = "SELECT COUNT(*)
+				FROM $g_mantis_project_user_list_table
+				WHERE 	project_id='$p_project_id' AND
+						user_id='$p_user_id'";
+		$result = db_query( $query );
+		$count = db_result( $result, 0, 0 );
+		if ( 0 == $count ) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+	# --------------------
+	# add user with the specified access level to a project
+	function proj_user_add( $p_project_id, $p_user_id, $p_access_level ) {
+		global $g_mantis_project_user_list_table;
+
+		$query = "INSERT
+				INTO $g_mantis_project_user_list_table
+				( project_id, user_id, access_level )
+				VALUES
+				( '$p_project_id', '$p_user_id', '$p_access_level')";
+		return db_query( $query );
+	}
+	# --------------------
+	# update entry
+	# must make sure entry exists beforehand
+	function proj_user_update( $p_project_id, $p_user_id, $p_access_level ) {
+		global $g_mantis_project_user_list_table;
+
+		$query = "UPDATE $g_mantis_project_user_list_table
+				SET		access_level='$p_access_level'
+				WHERE	project_id='$p_project_id' AND
+						user_id='$p_user_id'";
+		return db_query( $query );
+	}
+	# --------------------
+	# remove user from project
+	function proj_user_delete( $p_project_id, $p_user_id ) {
+		global $g_mantis_project_user_list_table;
+
+		$query = "DELETE FROM $g_mantis_project_user_list_table
+				WHERE	project_id='$p_project_id' AND
+						user_id='$p_user_id'";
+		return db_query( $query );
+	}
+	# --------------------
+	# delete all users from the project user list for a given project
+	# this is useful when deleting or closing a project
+	function proj_user_delete_all_users( $p_project_id ) {
+		global $g_mantis_project_user_list_table;
+
+		$query = "DELETE FROM $g_mantis_project_user_list_table
+				WHERE project_id='$p_project_id'";
+		return db_query( $query );
+	}
+	# --------------------
+	# returns the descriptor holding all the info from the project user list
+	# for the specified project
+	function proj_user_get_all_users( $p_project_id ) {
+		global $g_mantis_project_user_list_table;
+
+		$query = "SELECT *
+				FROM $g_mantis_project_user_list_table
+				WHERE project_id='$p_project_id'";
+		return db_query( $query );
+	}
+	# --------------------
+	# returns true if the user exists in the project user list.
+	function is_removable_proj_user( $p_user_id ) {
+		global $g_mantis_project_user_list_table, $g_project_cookie_val;
+
+		$query = "SELECT COUNT(*)
+				FROM $g_mantis_project_user_list_table p
+				WHERE	p.project_id='$g_project_cookie_val' AND
+						p.user_id='$p_user_id'";
+		$result = db_query( $query );
+		$count = db_result( $result, 0, 0 );
+		if ( $count>0 ) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+	# --------------------
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/core_user_API.php /cygdrive/D/mantis/core_user_API.php
--- /cygdrive/D/mantis-0.18.0rc1/core_user_API.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/core_user_API.php	2002-12-05 16:17:20.000000000 -0300
@@ -0,0 +1,787 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the files README and LICENSE for details
+
+	###########################################################################
+	# Cookie API
+	###########################################################################
+	# --------------------
+	# checks to see that a user is logged in
+	# if the user is and the account is enabled then let them pass
+	# otherwise redirect them to the login page
+	# if $p_redirect_url is specifed then redirect them to that page
+	function login_cookie_check( $p_redirect_url="" ) {
+		global 	$g_string_cookie_val, $g_project_cookie_val,
+				$g_login_page, $g_logout_page, $g_login_select_proj_page,
+				$g_hostname, $g_db_username, $g_db_password, $g_database_name,
+				$g_mantis_user_table;
+
+		# if logged in
+		//echo "Jumanji.....$g_string_cookie_val";
+		if ( !empty( $g_string_cookie_val ) ) {
+			db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+
+			# get user info
+			$t_enabled = get_current_user_field( "enabled" );
+			# check for acess enabled
+			if ( OFF == $t_enabled ) {
+				print_header_redirect( $g_logout_page );
+			}
+
+			# update last_visit date
+			login_update_last_visit( $g_string_cookie_val );
+			db_close();
+			# if no project is selected then go to the project selection page
+			if ( empty( $g_project_cookie_val ) ) {
+				print_header_redirect( $g_login_select_proj_page );
+				exit;
+			}
+
+			# go to redirect if set
+			if ( !empty( $p_redirect_url ) ) {
+				print_header_redirect( $p_redirect_url );
+				exit;
+			} else {			# continue with current page
+				return;
+			}
+		} else {				# not logged in
+			print_header_redirect( $g_login_page );
+			exit;
+		}
+	}
+	# --------------------
+	# checks to see if a returning user is valid
+	# also sets the last time they visited
+	# otherwise redirects to the login page
+	function index_login_cookie_check( $p_redirect_url="" ) {
+		global 	$g_string_cookie_val, $g_project_cookie_val,
+				$g_login_page, $g_logout_page, $g_login_select_proj_page,
+				$g_hostname, $g_db_username, $g_db_password, $g_database_name,
+				$g_mantis_user_table;
+
+		# if logged in
+		if ( !empty( $g_string_cookie_val ) ) {
+			if ( empty( $g_project_cookie_val ) ) {
+				print_header_redirect( $g_login_select_proj_page );
+				exit;
+			}
+
+			# set last visit cookie
+
+			db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+
+			# get user info
+			$t_enabled = get_current_user_field( "enabled" );
+
+			# check for acess enabled
+			if ( OFF == $t_enabled ) {
+				print_header_redirect( $g_login_page );
+			}
+
+			# update last_visit date
+			login_update_last_visit( $g_string_cookie_val );
+			db_close();
+
+			# go to redirect
+			if ( !empty( $p_redirect_url ) ) {
+				print_header_redirect( $p_redirect_url );
+				exit;
+			} else {			# continue with current page
+				return;
+			}
+		} else {				# not logged in
+			print_header_redirect( $g_login_page );
+			exit;
+		}
+	}
+	# --------------------
+	# Only check to see if the user is logged in
+	# redirect to logout_page if fail
+	function login_user_check_only() {
+		global 	$g_string_cookie_val, $g_project_cookie_val,
+				$g_login_page, $g_logout_page, $g_login_select_proj_page,
+				$g_hostname, $g_db_username, $g_db_password, $g_database_name,
+				$g_mantis_user_table;
+
+		# if logged in
+		if ( !empty( $g_string_cookie_val ) ) {
+			db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+
+			# get user info
+			$t_enabled = get_current_user_field( "enabled" );
+			# check for acess enabled
+			if ( OFF == $t_enabled ) {
+				print_header_redirect( $g_logout_page );
+			}
+			db_close();
+		} else {				# not logged in
+			print_header_redirect( $g_login_page );
+			exit;
+		}
+	}
+	# --------------------
+	###########################################################################
+	# Authentication API
+	###########################################################################
+	# --------------------
+	# Checks for password match using the globally specified login method
+	/** Disable for phpcollab for duplication function declaration
+	function is_password_match( $f_username, $p_test_password, $p_password ) {
+		global $g_login_method, $g_allow_anonymous_login, $g_anonymous_account;
+		global $PHP_AUTH_PW;
+
+
+		# allow anonymous logins
+		if ( $g_anonymous_account == $f_username ) {
+			if ( ON == $g_allow_anonymous_login ) {
+				return true;
+			}
+		}
+
+		switch ( $g_login_method ) {
+			case CRYPT:	$salt = substr( $p_password, 0, 2 );
+						if ( crypt( $p_test_password, $salt ) == $p_password ) {
+							return true;
+						} else {
+							return false;
+						}
+			case CRYPT_FULL_SALT:
+						$salt = $p_password;
+						if ( crypt( $p_test_password, $salt ) == $p_password ) {
+							return true;
+						} else {
+							return false;
+						}
+			case PLAIN:	if ( $p_test_password == $p_password ) {
+							return true;
+						} else {
+							return false;
+						}
+			case MD5:	if ( md5( $p_test_password ) == $p_password ) {
+							return true;
+						} else {
+							return false;
+						}
+			case LDAP:	if ( ldap_uid_pass( $f_username, $p_test_password ) ) {
+							return true;
+						} else {
+							return false;
+						}
+			case BASIC_AUTH:
+					return ( isset( $PHP_AUTH_PW ) && ( $p_test_password == $PHP_AUTH_PW ) );
+
+		}
+		return false;
+	}*/
+	# --------------------
+	# This function is only called from the login.php3 script
+	function increment_login_count( $p_id ) {
+		global $g_mantis_user_table;
+
+		$query = "UPDATE $g_mantis_user_table
+				SET login_count=login_count+1
+				WHERE id='$p_id'";
+		$result = db_query( $query );
+	}
+	# --------------------
+	#
+	function process_plain_password( $p_password ) {
+		global $g_login_method;
+
+		$t_processed_password = $p_password;
+		switch ( $g_login_method ) {
+			case CRYPT:	$salt = substr( $p_password, 0, 2 );
+						$t_processed_password= crypt( $p_password, $salt );
+						break;
+			case CRYPT_FULL_SALT:
+						$salt = $p_password;
+						$t_processed_password = crypt( $p_password, $salt );
+						break;
+			case PLAIN:	$t_processed_password = $p_password;
+						break;
+			case MD5:	$t_processed_password = md5( $p_password );
+						break;
+			default:	$t_processed_password = $p_password;
+						break;
+		}
+		# cut this off to 32 cahracters which the largest possible string in the database
+		return substr( $t_processed_password, 0, 32 );
+	}
+	# --------------------
+	###########################################################################
+	# User Management API
+	###########################################################################
+	# --------------------
+	# creates a random 12 character password
+	# p_email is unused
+	function create_random_password( $p_email ) {
+		$t_val = mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() );
+		$t_val = md5( $t_val );
+
+		return substr( $t_val, 0, 12 );
+	}
+	# --------------------
+	# This string is used to use as the login identified for the web cookie
+	# It is not guarranteed to be unique and should be checked
+	# The string returned should be 64 characters in length
+	function generate_cookie_string() {
+		$t_val = mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() );
+		$t_val = md5( $t_val ).md5( time() );
+		return substr( $t_val, 0, 64 );
+	}
+	# --------------------
+	# The string returned should be 64 characters in length
+	function create_cookie_string() {
+		$t_cookie_string = generate_cookie_string();
+		while ( check_cookie_string_duplicate( $t_cookie_string ) ) {
+			$t_cookie_string = generate_cookie_string();
+		}
+		return $t_cookie_string;
+	}
+	# --------------------
+	# Check to see that the unique identifier is really unique
+	function check_cookie_string_duplicate( $p_cookie_string ) {
+		global $g_mantis_user_table;
+
+		$query = "SELECT COUNT(*)
+				FROM $g_mantis_user_table
+				WHERE cookie_string='$p_cookie_string'";
+		$result = db_query( $query );
+		$t_count = db_result( $result, 0, 0 );
+		if ( $t_count > 0 ) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+	# --------------------
+	# Create a user.
+	# If $g_use_ldap_email then tries to find email using ldap
+	# $p_email may be empty, but the user wont get any emails.
+	# returns false if error, the generated cookie string if ok
+	function signup_user( $p_username, $p_email=false ) {
+		global $g_use_ldap_email,
+		$g_mantis_user_table,
+		$g_default_new_account_access_level,
+		$g_mantis_user_pref_table,
+		$g_default_advanced_report,
+		$g_default_advanced_view, $g_default_advanced_update,
+		$g_default_refresh_delay, $g_default_redirect_delay,
+		$g_default_email_on_new, $g_default_email_on_assigned,
+		$g_default_email_on_feedback, $g_default_email_on_resolved,
+		$g_default_email_on_closed, $g_default_email_on_reopened,
+		$g_default_email_on_bugnote, $g_default_email_on_status,
+		$g_default_email_on_priority, $g_default_language;
+
+		if ( ( false == $p_email ) && ( ON == $g_use_ldap_email ) ) {
+			$p_email = get_user_info( "$p_username","email" );
+		}
+
+		$t_seed = $p_email ? $p_email : $p_username;
+		# Create random password
+		$t_password = create_random_password( $t_seed );
+		# Use a default access level
+		# create the almost unique string for each user then insert into the table
+		$t_cookie_string = create_cookie_string( $t_seed );
+		$t_password2 = process_plain_password( $t_password );
+		$query = "INSERT INTO $g_mantis_user_table
+				( id, username, email, password, date_created, last_visit,
+				enabled, protected, access_level, login_count, cookie_string )
+				VALUES
+				( null, '$p_username', '$p_email', '$t_password2', NOW(), NOW(),
+				1, 0, $g_default_new_account_access_level, 0, '$t_cookie_string')";
+		$result = db_query( $query );
+
+		if ( !$result ) {
+			return false;
+		}
+
+		# Create preferences for the user
+		$t_user_id = db_insert_id();
+		$query = "INSERT INTO $g_mantis_user_pref_table
+				(id, user_id, advanced_report, advanced_view, advanced_update,
+				refresh_delay, redirect_delay,
+				email_on_new, email_on_assigned,
+				email_on_feedback, email_on_resolved,
+				email_on_closed, email_on_reopened,
+				email_on_bugnote, email_on_status,
+				email_on_priority, language)
+				VALUES
+				(null, '$t_user_id', '$g_default_advanced_report',
+				'$g_default_advanced_view', '$g_default_advanced_update',
+				'$g_default_refresh_delay', '$g_default_redirect_delay',
+				'$g_default_email_on_new', '$g_default_email_on_assigned',
+				'$g_default_email_on_feedback', '$g_default_email_on_resolved',
+				'$g_default_email_on_closed', '$g_default_email_on_reopened',
+				'$g_default_email_on_bugnote', '$g_default_email_on_status',
+				'$g_default_email_on_priority', '$g_default_language')";
+		$result = db_query($query);
+
+		if ( !$result ) {
+			return false;
+		}
+
+		# Send notification email
+		if ( $p_email ) {
+			email_signup( $t_user_id, $t_password );
+		}
+
+		return $t_cookie_string;
+	}
+	# --------------------
+	###########################################################################
+	# Access Control API
+	###########################################################################
+	# --------------------
+	# check to see if the access level is strictly equal
+	function access_level_check_equal( $p_access_level, $p_project_id=0 ) {
+		global $g_string_cookie_val;
+
+		if ( !isset( $g_string_cookie_val ) ) {
+			return false;
+		}
+
+		$t_access_level = get_current_user_field( "access_level" );
+		$t_access_level2 = get_project_access_level( $p_project_id );
+
+		if ( $t_access_level2 == $p_access_level ) {
+			return true;
+		} else if ( ( $t_access_level == $p_access_level ) &&
+					( -1 == $t_access_level2 ) ) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+	# --------------------
+	# check to see if the access level is equal or greater
+	# this checks to see if the user has a higher access level for the current project
+	function access_level_check_greater_or_equal( $p_access_level, $p_project_id=0 ) {
+		global $g_string_cookie_val;
+
+		# user isn't logged in
+		if (( !isset( $g_string_cookie_val ) )||( empty( $g_string_cookie_val ) )) {
+			return false;
+		}
+
+		# Administrators ALWAYS pass.
+		if ( get_current_user_field( "access_level" ) >= ADMINISTRATOR ) {
+			return true;
+		}
+
+		$t_access_level = get_current_user_field( "access_level" );
+		$t_access_level2 = get_project_access_level( $p_project_id );
+
+		# use the project level access level instead of the global access level
+		# if the project level is not specified then use the global access level
+		if ( -1 != $t_access_level2 ) {
+			#echo $t_access_level."=".$t_access_level2." ";
+			#echo $t_access_level."=".$t_access_level2." ";
+			$t_access_level = $t_access_level2;
+			#echo $t_access_level."=".$t_access_level2." ";
+		}
+
+		if ( $t_access_level >= $p_access_level ) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+	# --------------------
+	# check to see if the access level is strictly equal
+	function absolute_access_level_check_equal( $p_access_level ) {
+		global $g_string_cookie_val;
+
+		if ( !isset( $g_string_cookie_val ) ) {
+			return false;
+		}
+
+		$t_access_level = get_current_user_field( "access_level" );
+		if ( $t_access_level == $p_access_level ) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+	# --------------------
+	# check to see if the access level is equal or greater
+	# this checks to see if the user has a higher access level for the current project
+	function absolute_access_level_check_greater_or_equal( $p_access_level ) {
+		global $g_string_cookie_val;
+
+		# user isn't logged in
+		if (( !isset( $g_string_cookie_val ) ) ||
+			( empty( $g_string_cookie_val ) )) {
+			return false;
+		}
+
+		$t_access_level = get_current_user_field( "access_level" );
+
+		if ( $t_access_level >= $p_access_level ) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+	# --------------------
+	# Checks to see if the user should be here.  If not then log the user out.
+	function check_access( $p_access_level ) {
+		global $g_logout_page;
+
+		# Administrators ALWAYS pass.
+		if ( get_current_user_field( "access_level" ) >= ADMINISTRATOR ) {
+			return;
+		}
+		if ( !access_level_check_greater_or_equal( $p_access_level ) ) {
+			# need to replace with access error page
+			print_header_redirect( $g_logout_page );
+			exit;
+		}
+	}
+	# --------------------
+	# Checks to see if the user has access to this project
+	# If not then log the user out
+	# If not logged into the project it attempts to log you into that project
+	function project_access_check( $p_bug_id, $p_project_id="0" ) {
+		global	$g_logout_page, $g_mantis_project_user_list_table,
+				$g_mantis_project_table, $g_mantis_bug_table,
+				$g_login_select_proj_page,
+				$g_project_cookie_val;
+
+		project_check( $p_bug_id );
+
+		# Administrators ALWAYS pass.
+		if ( get_current_user_field( "access_level" ) >= ADMINISTRATOR ) {
+			return;
+		}
+
+		# access_level check
+		$t_project_id = get_bug_field( $p_bug_id, "project_id" );
+		$t_project_view_state = get_project_field( $t_project_id, "view_state" );
+
+		# public project accept all users
+		if ( PUBLIC == $t_project_view_state ) {
+			return;
+		} else {
+			# private projects require users to be assigned
+			$t_project_access_level = get_project_access_level( $t_project_id );
+			if ( -1 == $t_project_access_level ) {
+				print_header_redirect( $g_login_select_proj_page );
+			} else {
+				return;
+			}
+		}
+	}
+	# --------------------
+	# Check to see if the currently logged in project and bug project id match
+	# If there is no match then the project cookie will be set to the bug project id
+	# No access check is done.  It is expected to be checked afterwards.
+	function project_check( $p_bug_id ) {
+		global	$g_project_cookie, $g_project_cookie_val, $g_view_all_cookie,
+				$g_cookie_time_length, $g_cookie_path;
+
+		$t_project_id = get_bug_field( $p_bug_id, "project_id" );
+		if ( $t_project_id != $g_project_cookie_val ) {
+			setcookie( $g_project_cookie, $t_project_id, time()+$g_cookie_time_length, $g_cookie_path );
+			setcookie( $g_view_all_cookie, '' );
+
+			$t_redirect_url = get_view_redirect_url( $p_bug_id, 1 );
+			print_header_redirect( $t_redirect_url );
+		}
+	}
+	# --------------------
+	# Check to see if the current user has access on the specified project
+	function check_access_to_project( $p_project_id ) {
+		$t_project_view_state = get_project_field( $p_project_id, 'view_state' );
+
+		# Administrators ALWAYS pass.
+		if ( get_current_user_field( 'access_level' ) >= ADMINISTRATOR ) {
+			return;
+		}
+
+		# public project accept all users
+		if ( PUBLIC == $t_project_view_state ) {
+			return;
+		} else {
+			# private projects require users to be assigned
+			$t_project_access_level = get_project_access_level( $p_project_id );
+			# -1 means not assigned, kick them out to the project selection screen
+			if ( -1 == $t_project_access_level ) {
+				print_header_redirect( 'login_select_proj_page.php' );
+			} else { # passed
+				return;
+			}
+		}
+	}
+	# --------------------
+	# return the project access level for the current user/project key pair.
+	# use the project_id if supplied.
+	function get_project_access_level( $p_project_id=0 ) {
+		global	$g_mantis_project_user_list_table,
+				$g_project_cookie_val;
+
+		$t_user_id = get_current_user_field( "id" );
+		if ( 0 == $p_project_id ) {
+			$query = "SELECT access_level
+					FROM $g_mantis_project_user_list_table
+					WHERE user_id='$t_user_id' AND project_id='$g_project_cookie_val'";
+		} else {
+			$query = "SELECT access_level
+					FROM $g_mantis_project_user_list_table
+					WHERE user_id='$t_user_id' AND project_id='$p_project_id'";
+		}
+		$result = db_query( $query );
+		if ( db_num_rows( $result ) > 0 ) {
+			return db_result( $result, 0, 0 );
+		} else {
+			return -1;
+		}
+	}
+	# --------------------
+	# Return the project user list access level for the current user/project key pair if it exists.
+	# Otherwise return the default user access level.
+	function get_effective_access_level( $p_user_id=0, $p_project_id=-1 ) {
+		global	$g_mantis_project_user_list_table,
+				$g_project_cookie_val;
+
+		# use the current user unless otherwise specified
+		if ( 0 == $p_user_id ) {
+			$t_user_id = get_current_user_field( "id" );
+		} else {
+			$t_user_id = $p_user_id;
+		}
+
+		# all projects
+		if ( -1 == $p_project_id ) {
+			$query = "SELECT access_level
+					FROM $g_mantis_project_user_list_table
+					WHERE user_id='$t_user_id' AND project_id='$g_project_cookie_val'";
+		} else if ( 0 == $p_project_id ) {
+			$g_project_cookie_val = p_project_id;
+			$query = "SELECT access_level
+					FROM $g_mantis_project_user_list_table
+					WHERE user_id='$t_user_id'";
+		} else {
+			$query = "SELECT access_level
+					FROM $g_mantis_project_user_list_table
+					WHERE user_id='$t_user_id' AND project_id='$p_project_id'";
+		}
+
+		$result = db_query( $query );
+		$count = db_num_rows( $result, 0, 0 );
+		if ( $count>0 ) {
+			return db_result( $result, 0, 0 );
+		} else {
+			return get_user_field( $t_user_id, "access_level" );
+		}
+	}
+	# --------------------
+	###########################################################################
+	# User Information API
+	###########################################################################
+	# --------------------
+	# Returns the specified field of the currently logged in user, otherwise 0
+	function get_current_user_field( $p_field_name ) {
+		global 	$g_string_cookie_val, $g_mantis_user_table;
+
+		# if logged in
+		if ( isset( $g_string_cookie_val ) ) {
+			# get user info
+			$query = "SELECT $p_field_name
+					FROM $g_mantis_user_table
+					WHERE cookie_string='$g_string_cookie_val'";
+			$result = db_query( $query );
+			return db_result( $result, 0 );
+		} else {
+			return 0;
+		}
+	}
+	# --------------------
+	# Returns the specified field of the currently logged in user, otherwise 0
+	function get_current_user_pref_field( $p_field_name ) {
+		global 	$g_string_cookie_val, $g_mantis_user_pref_table;
+
+		# if logged in
+		if ( isset( $g_string_cookie_val ) ) {
+
+			$t_id = get_current_user_field( "id" );
+			# get user info
+			$query = "SELECT $p_field_name
+					FROM $g_mantis_user_pref_table
+					WHERE user_id='$t_id'";
+			$result = db_query( $query );
+			return db_result( $result, 0 );
+		} else {
+			return 0;
+		}
+	}
+	# --------------------
+	# return all data associated with a particular user id
+	function get_user_info_by_id_arr( $p_user_id ) {
+		global $g_mantis_user_table;
+
+	    $query = "SELECT *
+	    		FROM $g_mantis_user_table
+	    		WHERE id='$p_user_id'";
+	    $result =  db_query( $query );
+	    return db_fetch_array( $result );
+	}
+	# --------------------
+	# return all data associated with a particular user name
+	function get_user_info_by_name_arr( $p_username ) {
+		global $g_mantis_user_table;
+
+	    $query = "SELECT *
+	    		FROM $g_mantis_user_table
+	    		WHERE username='$p_username'";
+	    $result =  db_query( $query );
+	    return db_fetch_array( $result );
+	}
+	# --------------------
+	# return the specified preference field for the user id
+	function get_user_pref_info( $p_user_id, $p_field ) {
+		global $g_mantis_user_pref_table;
+
+	    $query = "SELECT $p_field
+	    		FROM $g_mantis_user_pref_table
+	    		WHERE user_id='$p_user_id'";
+	    $result =  db_query( $query );
+	    if ( $result ) {
+	    	return db_result( $result, 0, 0 );
+	    } else {
+	    	return 0;
+	    }
+	}
+	# --------------------
+	# return the specified user field for the user id
+	# exception for LDAP email
+	function get_user_info( $p_user_id, $p_field ) {
+		global $g_mantis_user_table,$g_use_ldap_email,$g_login_method;
+		if ( ( ON == $g_use_ldap_email ) && ( "email" == $p_field  ) ) {
+		    # Find out what username belongs to the p_user_id and ask ldap
+		    return ldap_emailaddy("$p_user_id");
+		}
+
+		$query = "SELECT $p_field
+				FROM $g_mantis_user_table
+				WHERE id='$p_user_id'";
+
+
+		$result =  db_query( $query );
+		return db_result( $result, 0, 0 );
+
+	}
+	# --------------------
+	# return whether user is monitoring bug for the user id and bug id
+	function check_bug_monitoring( $p_user_id, $p_bug_id ) {
+		global $g_mantis_bug_monitor_table;
+
+		$query = "SELECT user_id
+				FROM $g_mantis_bug_monitor_table
+				WHERE user_id='$p_user_id' AND bug_id='$p_bug_id'";
+
+
+		$result =  db_query( $query );
+		return db_result( $result, 0, 0 );
+
+	}
+	# --------------------
+	# return the specified user field for the user id
+	# exception for LDAP email
+	function get_user_field( $p_user_id, $p_field ) {
+		global $g_mantis_user_table,$g_use_ldap_email,$g_login_method;
+		if ( ( ON == $g_use_ldap_email ) && ( "email" == $p_field  ) ) {
+		    # Find out what username belongs to the p_user_id and ask ldap
+		    return ldap_emailaddy("$p_user_id");
+		}
+
+		$query = "SELECT $p_field
+				FROM $g_mantis_user_table
+				WHERE id='$p_user_id'";
+
+
+		$result =  db_query( $query );
+		return db_result( $result, 0, 0 );
+
+	}
+	# --------------------
+	###########################################################################
+	# Miscellaneous User API
+	###########################################################################
+	# --------------------
+	# Update the last_visited field to be NOW()
+	function login_update_last_visit( $p_string_cookie_val ) {
+		global $g_mantis_user_table;
+
+		$query = "UPDATE $g_mantis_user_table
+				SET last_visit=NOW()
+				WHERE cookie_string='$p_string_cookie_val'";
+		$result = db_query( $query );
+	}
+	# --------------------
+	function check_user_pref_exists( $p_project_id ) {
+		global $g_mantis_user_pref_table;
+
+		$t_user_id = get_current_user_field( "id" );
+	    $query = "SELECT COUNT(*)
+	    		FROM $g_mantis_user_pref_table
+	    		WHERE user_id='$t_user_id' AND project_id='$p_project_id'";
+	    $result = db_query($query);
+		$t_count =  db_result( $result, 0, 0 );
+		if ( $t_count > 0 ) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+	# --------------------
+	function create_project_user_prefs( $p_project_id ) {
+		global $g_mantis_user_pref_table;
+
+		$t_user_id = get_current_user_field( "id" );
+	    $query = "INSERT
+	    		INTO $g_mantis_user_pref_table
+	    		(id, user_id, project_id,
+	    		advanced_report, advanced_view, advanced_update,
+	    		refresh_delay, redirect_delay,
+	    		email_on_new, email_on_assigned,
+	    		email_on_feedback, email_on_resolved,
+	    		email_on_closed, email_on_reopened,
+	    		email_on_bugnote, email_on_status,
+	    		email_on_priority, language)
+	    		VALUES
+	    		(null, '$t_user_id', '$p_project_id',
+	    		'$g_default_advanced_report', '$g_default_advanced_view', '$g_default_advanced_update',
+	    		'$g_default_refresh_delay', '$g_default_redirect_delay',
+	    		'$g_default_email_on_new', '$g_default_email_on_assigned',
+	    		'$g_default_email_on_feedback', '$g_default_email_on_resolved',
+	    		'$g_default_email_on_closed', '$g_default_email_on_reopened',
+	    		'$g_default_email_on_bugnote', '$g_default_email_on_status',
+	    		'$g_default_email_on_priority', '$g_default_language')";
+	    $result = db_query($query);
+	}
+	# --------------------
+	# grabs the access level of the current user
+	# this function accounts for private project and the project user lists
+	function get_current_user_access_level() {
+		global $g_string_cookie_val;
+
+		$t_access_level = get_current_user_field( "access_level" );
+		$t_access_level2 = get_project_access_level();
+
+		if ( $t_access_level >= ADMINISTRATOR ) {
+			return $t_access_level;
+		}
+
+		if ( -1 == $t_access_level2 ) {
+			return $t_access_level;
+		} else {
+			return $t_access_level2;
+		}
+	}
+	# --------------------
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/create_new_user.php /cygdrive/D/mantis/create_new_user.php
--- /cygdrive/D/mantis-0.18.0rc1/create_new_user.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/create_new_user.php	2002-12-05 16:17:24.000000000 -0300
@@ -0,0 +1,57 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+?>
+<?php include( "../mantis/core_API.php" ) ?>
+<?php
+	db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+	//check_access( ADMINISTRATOR );
+
+	# get all form values from phpcollab
+	$f_username = trim($un);
+	$f_password = trim($pw);
+	$f_email = trim($em);
+	$f_protected = 0;  // default value
+	$f_enabled = 1;	// default value
+
+	# create the almost unique string for each user then insert into the table
+	$t_cookie_string = create_cookie_string();
+    $query = "INSERT
+    		INTO $g_mantis_user_table
+    		( id, username, email, password, date_created, last_visit,
+    		access_level, enabled, protected, cookie_string )
+			VALUES
+			( $num, '$f_username', '$f_email', '$f_password', NOW(), NOW(),
+			'$f_access_level', '$f_enabled', '$f_protected', '$t_cookie_string')";
+    $result = db_query( $query );
+
+   	# Use this for MS SQL: SELECT @@IDENTITY AS 'id'
+	$t_user_id = $num;
+
+	# Create preferences
+
+    $query = "INSERT
+    		INTO $g_mantis_user_pref_table
+    		(id, user_id, project_id,
+    		advanced_report, advanced_view, advanced_update,
+    		refresh_delay, redirect_delay,
+    		email_on_new, email_on_assigned,
+    		email_on_feedback, email_on_resolved,
+    		email_on_closed, email_on_reopened,
+    		email_on_bugnote, email_on_status,
+    		email_on_priority, language)
+    		VALUES
+    		(null, '$t_user_id', '0000000',
+    		'$g_default_advanced_report', '$g_default_advanced_view', '$g_default_advanced_update',
+    		'$g_default_refresh_delay', '$g_default_redirect_delay',
+    		'$g_default_email_on_new', '$g_default_email_on_assigned',
+    		'$g_default_email_on_feedback', '$g_default_email_on_resolved',
+    		'$g_default_email_on_closed', '$g_default_email_on_reopened',
+    		'$g_default_email_on_bugnote', '$g_default_email_on_status',
+    		'$g_default_email_on_priority', '$g_default_language')";
+    $result = db_query($query);
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/default/config_inc2.php /cygdrive/D/mantis/default/config_inc2.php
--- /cygdrive/D/mantis-0.18.0rc1/default/config_inc2.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/default/config_inc2.php	2003-09-03 11:24:47.000000000 -0300
@@ -0,0 +1,276 @@
+<?php
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000, 2001  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the files README and LICENSE for details
+
+	###########################################################################
+	# CONFIGURATION VARIABLES
+	###########################################################################
+
+	# default/config_inc2.php
+
+	#----------------------------------
+	# specifiy your top/bottom include file (logos, banners, etc)
+	$g_bottom_include_page            = $g_absolute_path."";
+	$g_top_include_page               = $g_absolute_path."";
+	# css
+	$g_css_include_file               = $g_absolute_path."css_inc".$g_php;
+	# meta tags
+	$g_meta_include_file              = $g_absolute_path."meta_inc".$g_php;
+	#----------------------------------
+	# core file variables
+	$g_core_API_file                  = $g_absolute_path."core_API".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# misc
+	$g_index                          = $g_path."index".$g_php;
+	$g_main_page                      = $g_path."main_page".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# account
+	// change for phpcollab any user related admin work should be done from phpcollab
+#	$g_account_page                   = $g_path."account_prof_menu_page".$g_php;
+	$g_account_page                   = $g_path."account_page".$g_php;
+
+	$g_account_update                 = $g_path."account_update".$g_php;
+	$g_account_delete_page            = $g_path."account_delete_page".$g_php;
+	$g_account_delete                 = $g_path."account_delete".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# account profiles
+	$g_account_profile_menu_page      = $g_path."account_prof_menu_page".$g_php;
+	$g_account_profile_add            = $g_path."account_prof_add".$g_php;
+	$g_account_profile_edit_page      = $g_path."account_prof_edit_page".$g_php;
+	$g_account_profile_update         = $g_path."account_prof_update".$g_php;
+	$g_account_profile_delete         = $g_path."account_prof_delete".$g_php;
+	$g_account_profile_make_default   = $g_path."account_prof_make_default".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# account prefs
+	$g_account_prefs_page             = $g_path."account_prefs_page".$g_php;
+	$g_account_prefs_update           = $g_path."account_prefs_update".$g_php;
+	$g_account_prefs_reset            = $g_path."account_prefs_reset".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# bug
+	$g_bug_assign                     = $g_path."bug_assign".$g_php;
+
+	$g_bug_file_add                   = $g_path."bug_file_add".$g_php;
+
+	$g_bug_delete_page                = $g_path."bug_delete_page".$g_php;
+	$g_bug_delete                     = $g_path."bug_delete".$g_php;
+	$g_bug_update_page                = $g_path."bug_update_page".$g_php;
+	$g_bug_update_advanced_page       = $g_path."bug_update_advanced_page".$g_php;
+	$g_bug_update                     = $g_path."bug_update".$g_php;
+
+	$g_bug_reopen_page                = $g_path."bug_reopen_page".$g_php;
+	$g_bug_reopen                     = $g_path."bug_reopen".$g_php;
+
+	$g_bug_close_page                 = $g_path."bug_close_page".$g_php;
+	$g_bug_close                      = $g_path."bug_close".$g_php;
+
+	$g_bug_resolve                    = $g_path."bug_resolve".$g_php;
+	$g_bug_resolve_page               = $g_path."bug_resolve_page".$g_php;
+	$g_bug_vote_add                   = $g_path."bug_vote_add".$g_php;
+
+	$g_bug_monitor                    = $g_path."bug_monitor".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# bugnote
+	$g_bugnote_add                    = $g_path."bugnote_add".$g_php;
+	$g_bugnote_delete                 = $g_path."bugnote_delete".$g_php;
+	$g_bugnote_edit_page              = $g_path."bugnote_edit_page".$g_php;
+	$g_bugnote_update                 = $g_path."bugnote_update".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# bugnote includes
+	$g_bugnote_include_file           = $g_absolute_path."bugnote_inc.php";
+	#----------------------------------
+
+	#----------------------------------
+	# login
+	$g_login                          = $g_path."login".$g_php;
+	$g_login_anon                     = $g_path."login_anon".$g_php;
+#	$g_login_page                     = $g_path."login_page".$g_php;
+	$g_login_page                     = $g_phpcollab_path."login".$g_php;
+	$g_login_error_page               = $g_path."login_error_page".$g_php;
+	$g_login_success_page             = $g_path."index".$g_php;
+	$g_login_select_proj_page         = $g_path."login_select_proj_page".$g_php;
+	$g_logout_page                    = $g_path."logout_page".$g_php;
+#	$g_logout_redirect_page           = $g_path."login_page".$g_php;
+	$g_logout_redirect_page           = $phpcollab_url_cookie;
+	#----------------------------------
+
+	# documentation
+	$g_documentation_html             = $g_path."doc/documentation.html";
+
+	#----------------------------------
+	# site management
+	$g_manage_page                    = $g_path."manage_page".$g_php;
+	$g_manage_create_new_user         = $g_path."manage_create_new_user".$g_php;
+	$g_manage_create_user_page        = $g_path."manage_create_user_page".$g_php;
+	#----------------------------------
+
+	$g_manage_prune                   = $g_path."manage_prune".$g_php;
+
+	#----------------------------------
+	$g_manage_user_page               = $g_path."manage_user_page".$g_php;
+	$g_manage_user_update             = $g_path."manage_user_update".$g_php;
+	$g_manage_user_reset              = $g_path."manage_user_reset".$g_php;
+	$g_manage_user_delete_page        = $g_path."manage_user_delete_page".$g_php;
+	$g_manage_user_delete             = $g_path."manage_user_delete".$g_php;
+	$g_manage_user_proj_delete        = $g_path."manage_user_proj_delete".$g_php;
+	$g_manage_user_proj_add           = $g_path."manage_user_proj_add".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# userland documentation
+	$g_documentation_page             = $g_path."documentation_page".$g_php;
+	$g_usage_doc_page                 = $g_path."documentation.html";
+	#----------------------------------
+
+	#----------------------------------
+	$g_set_project                    = $g_path."set_project".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# multiple projects
+	$g_proj_doc_add_page              = $g_path."proj_doc_add_page".$g_php;
+	$g_proj_doc_add                   = $g_path."proj_doc_add".$g_php;
+	$g_proj_doc_delete_page           = $g_path."proj_doc_delete_page".$g_php;
+	$g_proj_doc_edit_page             = $g_path."proj_doc_edit_page".$g_php;
+	$g_proj_doc_page                  = $g_path."proj_doc_page".$g_php;
+	$g_proj_doc_update                = $g_path."proj_doc_update".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# multiple projects
+	$g_manage_project_menu_page       = $g_path."manage_proj_menu_page".$g_php;
+	$g_manage_project_add             = $g_path."manage_proj_add".$g_php;
+	$g_manage_project_edit_page       = $g_path."manage_proj_edit_page".$g_php;
+	$g_manage_project_update          = $g_path."manage_proj_update".$g_php;
+	$g_manage_project_delete          = $g_path."manage_proj_delete".$g_php;
+	$g_manage_project_delete_page     = $g_path."manage_proj_delete_page".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# project versions
+	$g_manage_project_version_add         = $g_path."manage_proj_ver_add".$g_php;
+	$g_manage_project_version_delete      = $g_path."manage_proj_ver_delete".$g_php;
+	$g_manage_project_version_delete_page = $g_path."manage_proj_ver_del_page".$g_php;
+	$g_manage_project_version_edit_page   = $g_path."manage_proj_ver_edit_page".$g_php;
+	$g_manage_project_version_update      = $g_path."manage_proj_ver_update".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# project category
+	$g_manage_project_category_add         = $g_path."manage_proj_cat_add".$g_php;
+	$g_manage_project_category_copy        = $g_path."manage_proj_cat_copy".$g_php;
+	$g_manage_project_category_delete      = $g_path."manage_proj_cat_delete".$g_php;
+	$g_manage_project_category_delete_page = $g_path."manage_proj_cat_del_page".$g_php;
+	$g_manage_project_category_edit_page   = $g_path."manage_proj_cat_edit_page".$g_php;
+	$g_manage_project_category_update      = $g_path."manage_proj_cat_update".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# news
+	$g_news_menu_page                 = $g_path."news_menu_page".$g_php;
+	$g_news_edit_page                 = $g_path."news_edit_page".$g_php;
+	$g_news_add                       = $g_path."news_add".$g_php;
+	$g_news_update                    = $g_path."news_update".$g_php;
+	$g_news_delete_page               = $g_path."news_delete_page".$g_php;
+	$g_news_delete                    = $g_path."news_delete".$g_php;
+
+	$g_news_list_page                 = $g_path."news_list_page".$g_php;
+	$g_news_view_page                 = $g_path."news_view_page".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# project documents
+	$g_proj_doc_add                   = $g_path."proj_doc_add".$g_php;
+	$g_proj_doc_add_page              = $g_path."proj_doc_add_page".$g_php;
+	$g_proj_doc_delete                = $g_path."proj_doc_delete".$g_php;
+	$g_proj_doc_delete_page           = $g_path."proj_doc_delete_page".$g_php;
+	$g_proj_doc_edit_page             = $g_path."proj_doc_edit_page".$g_php;
+	$g_proj_doc_page                  = $g_path."proj_doc_page".$g_php;
+	$g_proj_doc_update                = $g_path."proj_doc_update".$g_php;
+	$g_proj_doc_view_page             = $g_path."proj_doc_view_page".$g_php;
+	#----------------------------------
+
+	$g_proj_user_add                  = $g_path."proj_user_add".$g_php;
+	$g_proj_user_copy                 = $g_path."proj_user_copy".$g_php;
+	$g_proj_user_delete               = $g_path."proj_user_delete".$g_php;
+	$g_proj_user_update               = $g_path."proj_user_update".$g_php;
+	$g_proj_user_menu_page            = $g_path."proj_user_menu_page".$g_php;
+
+	#----------------------------------
+	# report bug
+	$g_report_bug_page                = $g_path."report_bug_page".$g_php;
+	$g_report_bug_advanced_page       = $g_path."report_bug_advanced_page".$g_php;
+	$g_report_add                     = $g_path."report_add".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# debug only
+	$g_show_source_page               = $g_path."show_source_page".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	#signup
+	$g_signup_page                    = $g_path."signup_page".$g_php;
+	$g_signup                         = $g_path."signup".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# summary
+	$g_summary_page                       = $g_path."summary_page".$g_php;
+	$g_summary_jpgraph_function           = $g_absolute_path."summary_graph_functions".$g_php;
+	$g_summary_jpgraph_page               = $g_path."summary_jpgraph_page".$g_php;
+	$g_summary_jpgraph_cumulative_bydate  = $g_path."summary_graph_cumulative_bydate".$g_php;
+	$g_summary_jpgraph_bydeveloper        = $g_path."summary_graph_bydeveloper".$g_php;
+	$g_summary_jpgraph_byreporter         = $g_path."summary_graph_byreporter".$g_php;
+	$g_summary_jpgraph_byseverity         = $g_path."summary_graph_byseverity".$g_php;
+	$g_summary_jpgraph_bystatus           = $g_path."summary_graph_bystatus".$g_php;
+	$g_summary_jpgraph_byresolution       = $g_path."summary_graph_byresolution".$g_php;
+	$g_summary_jpgraph_bycategory         = $g_path."summary_graph_bycategory".$g_php;
+	$g_summary_jpgraph_bypriority         = $g_path."summary_graph_bypriority".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# bug view/update
+	$g_view_all_bug_page              = $g_path."view_all_bug_page".$g_php;
+	$g_view_all_include_file          = $g_absolute_path."view_all_inc".$g_php;
+
+	$g_view_all_set                   = $g_path."view_all_set".$g_php;
+
+	$g_view_bug_advanced_page         = $g_path."view_bug_advanced_page".$g_php;
+	$g_view_bug_page                  = $g_path."view_bug_page".$g_php;
+	$g_view_bug_inc                   = $g_absolute_path."view_bug_inc".$g_php;
+	$g_bug_file_upload_inc            = $g_absolute_path."bug_file_upload_inc".$g_php;
+
+	$g_file_download                  = $g_path."file_download".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# printing
+	$g_print_all_bug_page             = $g_path."print_all_bug_page".$g_php;
+	$g_print_bug_page                 = $g_path."print_bug_page".$g_php;
+	$g_print_bugnote_include_file     = $g_absolute_path."print_bugnote_inc".$g_php;
+	#----------------------------------
+
+	#----------------------------------
+	# New files
+	$g_bug_file_delete                = $g_path."bug_file_delete".$g_php;
+	$g_csv_export_inc                 = $g_path."view_csv_export_inc".$g_php;
+	$g_view_all_bug_update            = $g_path."view_all_bug_update".$g_php;
+	$g_jump_to_bug                    = $g_path."jump_to_bug".$g_php;
+	#----------------------------------
+?>
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/lang/strings_english.txt /cygdrive/D/mantis/lang/strings_english.txt
--- /cygdrive/D/mantis-0.18.0rc1/lang/strings_english.txt	2003-08-23 23:59:58.000000000 -0300
+++ /cygdrive/D/mantis/lang/strings_english.txt	2003-09-03 11:23:48.000000000 -0300
@@ -633,7 +633,7 @@
 $s_manage_link = 'Manage';
 $s_edit_news_link = 'Edit News';
 $s_docs_link = 'Docs';
-$s_logout_link = 'Logout';
+$s_logout_link = 'PhpCollab';
 
 # meta_inc.php
 
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/lang/strings_spanish.txt /cygdrive/D/mantis/lang/strings_spanish.txt
--- /cygdrive/D/mantis-0.18.0rc1/lang/strings_spanish.txt	2003-08-24 07:02:34.000000000 -0300
+++ /cygdrive/D/mantis/lang/strings_spanish.txt	2003-09-03 11:24:12.000000000 -0300
@@ -633,7 +633,7 @@
 $s_manage_link = 'Administracion';
 $s_edit_news_link = 'Noticias';
 $s_docs_link = 'Documentos';
-$s_logout_link = 'Desconectarse';
+$s_logout_link = 'PhpCollab';
 
 # meta_inc.php
 
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/login.php /cygdrive/D/mantis/login.php
--- /cygdrive/D/mantis-0.18.0rc1/login.php	2003-01-17 23:14:12.000000000 -0300
+++ /cygdrive/D/mantis/login.php	2003-09-03 11:30:38.000000000 -0300
@@ -14,18 +14,25 @@
 ?>
 <?php require_once( 'core.php' ) ?>
 <?php
+
+#
+# For integration with phpCollab: id is passed as the parameter for the phpcollab proj
+#
+	$id = gpc_get_string( 'id', '-1' );
+	$url = gpc_get_string( 'url', 'http://localhost/phpcollab' );
+
 	$f_username		= gpc_get_string( 'username', '' );
 	$f_password		= gpc_get_string( 'password', '' );
 	$f_perm_login	= gpc_get_bool( 'perm_login' );
-	$f_return		= gpc_get_string( 'return', 'main_page.php' );
+	$f_return		= gpc_get_string( 'return', 'main_page.php?' );
 
 	if ( BASIC_AUTH == config_get( 'login_method' ) ) {
 		$f_username = $_SERVER['REMOTE_USER'];
 		$f_password = $_SERVER['PHP_AUTH_PW'];
  	}
 
-	if ( auth_attempt_login( $f_username, $f_password, $f_perm_login ) ) {
-		$t_redirect_url = 'login_cookie_test.php?return=' . $f_return;
+	if ( auth_attempt_login_phpcollab( $f_username, $f_password, $f_perm_login, $url ) ) {
+		$t_redirect_url = 'login_cookie_test.php?return=' . $f_return . '&id=' . $id . '&url=' . $url;
 	} else {
 		$t_redirect_url = 'login_page.php?error=1';
 	}
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/login_cookie_test.php /cygdrive/D/mantis/login_cookie_test.php
--- /cygdrive/D/mantis-0.18.0rc1/login_cookie_test.php	2003-01-17 23:14:12.000000000 -0300
+++ /cygdrive/D/mantis/login_cookie_test.php	2003-09-03 11:29:47.000000000 -0300
@@ -14,10 +14,16 @@
 ?>
 <?php require_once( 'core.php' ) ?>
 <?php
-	$f_return = gpc_get_string( 'return', 'main_page.php' );
+	$f_return = gpc_get_string( 'return', 'main_page.php?' );
+
+#
+# For integration with phpCollab: id is passed as the parameter for the phpcollab proj
+#
+	$id = gpc_get_string( 'id', '-1' );
+	$url = gpc_get_string( 'url', 'http://localhost/phpcollab' );
 
 	if ( auth_is_user_authenticated() ) {
-		$t_redirect_url = $f_return;
+		$t_redirect_url = $f_return . '&id=' . $id . '&url=' . $url;
 	} else {
 		$t_redirect_url = 'login_page.php?cookie_error=1';
 	}
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/logout_page.php /cygdrive/D/mantis/logout_page.php
--- /cygdrive/D/mantis-0.18.0rc1/logout_page.php	2003-02-27 05:14:56.000000000 -0300
+++ /cygdrive/D/mantis/logout_page.php	2003-09-03 12:10:11.000000000 -0300
@@ -16,6 +16,7 @@
 <?php require_once( 'core.php' ); ?>
 <?php
 	auth_logout();
-
-	print_header_redirect( config_get( 'logout_redirect_page' ) );
+	$redir_url = config_get( 'logout_redirect_page' );
+#	echo $redir_url;
+ 	print_header_redirect( $redir_url );
 ?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/main_page.php /cygdrive/D/mantis/main_page.php
--- /cygdrive/D/mantis-0.18.0rc1/main_page.php	2003-07-24 13:08:44.000000000 -0300
+++ /cygdrive/D/mantis/main_page.php	2003-09-03 10:20:52.000000000 -0300
@@ -15,9 +15,9 @@
 ?>
 <?php
 	require_once( 'core.php' );
-	
+
 	$t_core_path = config_get( 'core_path' );
-	
+
 	require_once( $t_core_path.'current_user_api.php' );
 	require_once( $t_core_path.'news_api.php' );
 	require_once( $t_core_path.'date_api.php' );
@@ -56,7 +56,13 @@
 <?php
 	$c_offset = db_prepare_int( $f_offset );
 
-	$t_project_id = helper_get_current_project();
+#
+#	$t_project_id = helper_get_current_project();
+#
+#	For phpcollab integration: id is a GET parameter (see login_cookie_test.php)
+#
+	if ($id != -1)
+		$t_project_id = $id;
 
 	# get news count (project plus sitewide posts)
     $total_news_count = news_get_count( $t_project_id );
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/proj_add.php /cygdrive/D/mantis/proj_add.php
--- /cygdrive/D/mantis-0.18.0rc1/proj_add.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/proj_add.php	2002-12-05 16:17:26.000000000 -0300
@@ -0,0 +1,54 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+?>
+<?php include( "../mantis/core_API.php" ) ?>
+<?php //login_cookie_check() ?>
+<?php
+	db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+	//check_access( MANAGER );
+
+	$f_project_id	= $num; // project Id from phpcollab
+	$f_name 		= string_prepare_textarea( $pn );
+	$f_description 	= string_prepare_textarea( $d );
+	$f_status		= 10; // development default phase
+	$f_view_state	= 10;  // private =50 or public =10 
+	$f_user_id		= $pown;
+	$f_access_level	= $team_user_level; // default developer
+	$f_file_path	= "";
+	
+	# dump file content to the connection.
+	if ( DISK == $g_file_upload_method ) {
+		$f_file_path	= $g_file_path.$f_name;
+		@mkdir("$f_file_path",0755);
+		@chmod("$f_file_path",0777);
+	}
+	
+	# Make sure file path has trailing slash
+	if ( $f_file_path[strlen($f_file_path)-1] != "/" ) {
+		$f_file_path = $f_file_path."/";
+	}
+
+	$result = 0;
+	$duplicate = is_duplicate_project( $f_name );
+
+	if ( !empty( $f_name ) && !$duplicate ) {
+		# Add item
+		$query = "INSERT
+				INTO $g_mantis_project_table
+				( id, name, status, enabled, view_state, file_path, description )
+				VALUES
+				( '$f_project_id', '$f_name', '$f_status', '1', '$f_view_state', '$f_file_path', '$f_description' )";
+	    $result = db_query( $query );
+	}
+
+// add current user(i.e creator of this project) to this project to synchronize with phpcollab
+	
+	# Add a user to project(s)
+	$result = 0;
+	$result = proj_user_add( $f_project_id, $f_user_id, $f_access_level );
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/proj_delete.php /cygdrive/D/mantis/proj_delete.php
--- /cygdrive/D/mantis-0.18.0rc1/proj_delete.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/proj_delete.php	2002-12-05 16:17:26.000000000 -0300
@@ -0,0 +1,94 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+?>
+<?php include( "../mantis/core_API.php" ) ?>
+<?php //login_cookie_check() ?>
+<?php
+	db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+	//check_access( MANAGER );
+
+	$f_project_id = "$id";
+
+	# Delete the bugs, bug text, bugnotes, and bugnote text
+	# first select the bug ids
+	$query = "SELECT id, bug_text_id
+			FROM $g_mantis_bug_table
+    		WHERE project_id IN($f_project_id)";
+    $result = db_query( $query );
+    $bug_count = db_num_rows( $result );
+
+	for ($i=0;$i<$bug_count;$i++) {
+		$row = db_fetch_array( $result );
+		$t_bug_id = $row["id"];
+		$t_bug_text_id = $row["bug_text_id"];
+
+		# Delete the bug texts
+		$query2 = "DELETE
+				FROM $g_mantis_bug_text_table
+	    		WHERE id ='$t_bug_text_id'";
+	    $result2 = db_query( $query2 );
+
+		# select bugnotes to delete
+		$query3 = "SELECT id, bugnote_text_id
+				FROM $g_mantis_bugnote_table
+	    		WHERE bug_id='$t_bug_id'";
+	    $result3 = db_query( $query3 );
+	    $bugnote_count = db_num_rows( $result3 );
+
+		for ($j=0;$j<$bugnote_count;$j++) {
+			$row2 = db_fetch_array( $result3 );
+			$t_bugnote_id = $row2["id"];
+			$t_bugnote_text_id = $row2["bugnote_text_id"];
+
+			# Delete the bugnotes
+			$query = "DELETE
+					FROM $g_mantis_bugnote_table
+		    		WHERE id='$t_bugnote_id'";
+		    $result = db_query( $query );
+
+			# Delete the bugnote texts
+			$query4 = "DELETE
+					FROM $g_mantis_bugnote_text_table
+		    		WHERE id='$t_bugnote_text_id'";
+		    $result4 = db_query( $query4 );
+		}
+	}
+
+	# now finally remove all bugs that are part of the project
+	$query = "DELETE
+			FROM $g_mantis_bug_table
+    		WHERE project_id IN($f_project_id)";
+    $result = db_query( $query );
+
+	# Delete the project entry
+	$query = "DELETE
+			FROM $g_mantis_project_table
+    		WHERE id IN($f_project_id)";
+    $result = db_query( $query );
+
+	# Delete the project categories
+	$query = "DELETE
+			FROM $g_mantis_project_category_table
+    		WHERE project_id IN($f_project_id)";
+    $result = db_query( $query );
+
+	# Delete the project versions
+	$query = "DELETE
+			FROM $g_mantis_project_version_table
+    		WHERE project_id IN($f_project_id)";
+    $result = db_query( $query );
+
+// bug in mantis when project is removed 
+    	# Delete user list for this project 
+	# All user should unassign from that project.
+	$query = "DELETE
+    			FROM $g_mantis_project_user_list_table
+    		WHERE project_id IN($f_project_id)";
+	    $result = db_query( $query );
+
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/proj_update.php /cygdrive/D/mantis/proj_update.php
--- /cygdrive/D/mantis-0.18.0rc1/proj_update.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/proj_update.php	2002-12-05 16:17:28.000000000 -0300
@@ -0,0 +1,46 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+?>
+<?php include( "../mantis/core_API.php" ) ?>
+<?php //login_cookie_check() ?>
+<?php
+	db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+	//check_access( MANAGER );
+
+	$f_project_id	= $id;
+	$f_enabled = 1;
+	$f_name 		= string_prepare_textarea( $pn );
+	$f_description 	= string_prepare_textarea( $d );
+	$f_status		= 10; // development default phase
+	$f_view_state	= 10;  // private =50 or public =10 
+	$f_file_path	= "";
+	
+	# dump file content to the connection.
+	if ( DISK == $g_file_upload_method ) {
+		$f_file_path	= $g_file_path.$f_name;
+		@mkdir("$f_file_path",0755);
+		@chmod("$f_file_path",0777);
+	}
+
+	# Make sure file path has trailing slash
+	if ( $f_file_path[strlen($f_file_path)-1] != "/" ) {
+		$f_file_path = $f_file_path."/";
+	}
+
+	# Update entry
+	$query = "UPDATE $g_mantis_project_table
+			SET name='$f_name',
+				status='$f_status',
+				enabled='$f_enabled',
+				view_state='$f_view_state',
+				file_path='$f_file_path',
+				description='$f_description'
+    		WHERE id='$f_project_id'";
+    $result = db_query( $query );
+
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/sql/db_generate.sql /cygdrive/D/mantis/sql/db_generate.sql
--- /cygdrive/D/mantis-0.18.0rc1/sql/db_generate.sql	2003-03-22 07:53:26.000000000 -0300
+++ /cygdrive/D/mantis/sql/db_generate.sql	2003-09-03 14:16:16.000000000 -0300
@@ -702,5 +702,5 @@
 # Dumping data for table 'mantis_user_table'
 #
 
-INSERT INTO mantis_user_table VALUES (1,'administrator','admin','63a9f0ea7bb98050796b649e85481845','2003-02-16 02:03:48','2003-02-16 02:36:38',1,1,90,3,'MN91uSF/JIhos8bcda8acc2ead8d60749ad019e56b54fadkPGTyoBgNBQf91563');
+INSERT INTO mantis_user_table VALUES (1,'administrator','admin@yourdomain.com','MNYm8SfoJlvIY','2003-02-16 02:03:48','2003-02-16 02:36:38',1,1,90,3,'MN91uSF/JIhos8bcda8acc2ead8d60749ad019e56b54fadkPGTyoBgNBQf91563');
 
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/user_delete.php /cygdrive/D/mantis/user_delete.php
--- /cygdrive/D/mantis-0.18.0rc1/user_delete.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/user_delete.php	2002-12-05 16:17:30.000000000 -0300
@@ -0,0 +1,41 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+?>
+<?php include( "../mantis/core_API.php" ) ?>
+<?php //login_cookie_check() ?>
+<?php
+	db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+	//check_access( ADMINISTRATOR );
+
+	# delete account
+    if ( $f_protected!="on" ) {
+	    # Remove aaccount
+    	$query = "DELETE
+    			FROM $g_mantis_user_table
+    			WHERE id IN($id)";
+	    $result = db_query( $query );
+
+	    # Remove associated profiles
+	    $query = "DELETE
+	    		FROM $g_mantis_user_profile_table
+	    		WHERE user_id IN($id)";
+	    $result = db_query( $query );
+
+		# Remove associated preferences
+    	$query = "DELETE
+    			FROM $g_mantis_user_pref_table
+    			WHERE user_id IN($id)";
+    	$result = db_query( $query );
+
+    	$query = "DELETE
+    			FROM $g_mantis_project_user_list_table
+	    		WHERE user_id IN($id)";
+	    $result = db_query( $query );
+    }
+
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/user_profile.php /cygdrive/D/mantis/user_profile.php
--- /cygdrive/D/mantis-0.18.0rc1/user_profile.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/user_profile.php	2002-12-05 16:17:32.000000000 -0300
@@ -0,0 +1,33 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+?>
+<?php include( "../mantis/core_API.php" ) ?>
+<?php //login_cookie_check() ?>
+<?php
+	db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+
+	//check_access( ADMINISTRATOR );
+
+	# get all form values from phpcollab
+	$f_id	= $idSession;
+	$f_email = trim($em);
+
+	//echo "f_id	= ".$f_id;
+	//echo "new email	= ".$f_email;
+	
+	# create the almost unique string for each user then insert into the table
+	$t_cookie_string = create_cookie_string();
+
+	// Modify it's update action , so new cookie string will created.
+	# update action
+	$query = "UPDATE $g_mantis_user_table
+		    	SET email='$f_email', cookie_string = '$t_cookie_string'
+		    		WHERE id='$f_id'";
+
+    	$result = db_query( $query );
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/user_proj_add.php /cygdrive/D/mantis/user_proj_add.php
--- /cygdrive/D/mantis-0.18.0rc1/user_proj_add.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/user_proj_add.php	2002-12-05 16:17:32.000000000 -0300
@@ -0,0 +1,18 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+?>
+<?php //include( "mantis/core_API.php" ) ?>
+<?php //login_cookie_check() ?>
+<?php
+	db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+	//check_access( MANAGER );
+
+	# Add a user to project(s)
+	$result = 0;
+	$result = proj_user_add( $f_project_id, $f_user_id, $f_access_level );
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/user_proj_delete.php /cygdrive/D/mantis/user_proj_delete.php
--- /cygdrive/D/mantis-0.18.0rc1/user_proj_delete.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/user_proj_delete.php	2002-12-05 16:17:34.000000000 -0300
@@ -0,0 +1,18 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+?>
+<?php //include( "mantis/core_API.php" ) ?>
+<?php //login_cookie_check() ?>
+<?php
+	db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+	//check_access( MANAGER );
+	//echo "f_project_id=".$f_project_id;
+	//echo "f_user_id=".$f_user_id;
+	$result = proj_user_delete( $f_project_id, $f_user_id );
+
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/user_reset_pwd.php /cygdrive/D/mantis/user_reset_pwd.php
--- /cygdrive/D/mantis-0.18.0rc1/user_reset_pwd.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/user_reset_pwd.php	2002-12-05 16:17:36.000000000 -0300
@@ -0,0 +1,24 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+?>
+<?php include( "../mantis/core_API.php" ) ?>
+<?php //login_cookie_check() ?>
+<?php
+	db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+
+	//check_access( ADMINISTRATOR );
+
+	# get all form values from phpcollab
+	$f_id	= $idSession;
+
+	# update action
+	$query = "UPDATE $g_mantis_user_table
+		  SET password= '$cnpw'
+		  WHERE id='$f_id'";
+	$result = db_query( $query );
+?>
\ No newline at end of file
diff -Nur -x '*admin*' -x '*jpgraph*' /cygdrive/D/mantis-0.18.0rc1/user_update.php /cygdrive/D/mantis/user_update.php
--- /cygdrive/D/mantis-0.18.0rc1/user_update.php	1969-12-31 21:00:00.000000000 -0300
+++ /cygdrive/D/mantis/user_update.php	2002-12-05 16:17:38.000000000 -0300
@@ -0,0 +1,58 @@
+<?php
+#Application name: PhpCollab
+#Status page: 0
+	# Mantis - a php based bugtracking system
+	# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
+	# This program is distributed under the terms and conditions of the GPL
+	# See the README and LICENSE files for details
+?>
+<?php include( "../mantis/core_API.php" ) ?>
+<?php //login_cookie_check() ?>
+<?php
+	db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
+
+	//check_access( ADMINISTRATOR );
+
+	# get all form values from phpcollab
+	$f_id	= $id;
+	$f_username = trim($un);
+	$f_password = trim($pw);
+	$f_email = trim($em);
+
+	$f_protected = 0;  // default value
+	$f_enabled = 1;	// default value
+
+	# update action
+	# administrator is not allowed to change access level or enabled
+	# this is to prevent screwing your own account
+	if ($pw != "" && ($pw != $pwa || $pwa == "")) {
+
+		if ( ON == $f_protected ) {
+		    $query = "UPDATE $g_mantis_user_table
+		    		SET username='$f_username', email='$f_email',
+		    			password= '$pw', protected='$f_protected'
+		    		WHERE id='$f_id'";
+		} else {
+		    $query = "UPDATE $g_mantis_user_table
+		    		SET username='$f_username', email='$f_email',
+		    			access_level='$f_access_level', enabled='$f_enabled',
+		    			password= '$pw',protected='$f_protected'
+		    		WHERE id='$f_id'";
+		}
+	} else {
+		if ( ON == $f_protected ) {
+		    $query = "UPDATE $g_mantis_user_table
+		    		SET username='$f_username', email='$f_email',
+		    			protected='$f_protected' 
+		    		WHERE id='$f_id'";
+		} else {
+		    $query = "UPDATE $g_mantis_user_table
+		    		SET username='$f_username', email='$f_email',
+		    			access_level='$f_access_level', enabled='$f_enabled',
+		    			protected='$f_protected'
+		    		WHERE id='$f_id'";
+		}
+	}
+
+    $result = db_query( $query );
+?>
\ No newline at end of file
