<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	//  Track/Stop Tracking Thread
	// ========================================================================================
	
			
		
		
		$ThreadID = intval($Arguments3);
		
		if ($ThreadID > 0) {
		
			if ($LoggedIn == 'y') {
			
				$query = "select * from `".$Settings['DBPrefix']."mb-Threads` where RecordNumber=".$ThreadID." limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$row = mysql_fetch_array($result);
				
				$BoardID = $row['BoardID'];
			
			
			
				$query = "select NotifyThreads from `".$Settings['DBPrefix']."core-Users` where Username='".$CookieUsername."' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$row = mysql_fetch_array($result);
				
				
				$WorkingString = substr($row['NotifyThreads'],1,strlen($row['NotifyThreads'])-2);
				
				$NotifyThreadsArray = explode('-',$WorkingString);
				
				for ($i = 0; $i < count($NotifyThreadsArray); $i++) {
					if ($NotifyThreadsArray[$i] == $ThreadID) {
						$CurrentlySet = 'y';					
					}
				}
				
				
				if ($CurrentlySet == 'y') {
					// already in there, so remove it
					
					for ($i = 0; $i < count($NotifyThreadsArray); $i++) {
						if ($NotifyThreadsArray[$i] != $ThreadID) {
							$NotifyThreadsString .= '-'.$NotifyThreadsArray[$i];
						}
					}
					
					if ($NotifyThreadsString != '') {
						$NotifyThreadsString .= '-';
					}
				
				}
				else {
					// not already in there, so add it
					if ($row['NotifyThreads'] == '') {
						$row['NotifyThreads'] = '-';
					}
					$NotifyThreadsString = $row['NotifyThreads'] . $ThreadID . '-';
				
				}
				
					
				$query = "update `".$Settings['DBPrefix']."core-Users` set NotifyThreads='".$NotifyThreadsString."' where Username='".$CookieUsername."' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
					
				
				header('Location: ' . $MainURL . '/forum/'.$BoardID.'/'.$ThreadID.'.html');
					
					
				
				
			}		
			else {
			
				$PageContents = $MsgText[2][56];
			
			}	
		
	}
	else {
	
		$PageContents = $MsgText[2][58];
	
	}

	
	
?>
