Fifth pass at adding key files
This commit is contained in:
		
							
								
								
									
										107
									
								
								site/fitters/include_buttons.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								site/fitters/include_buttons.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,107 @@
 | 
			
		||||
<?PHP  
 | 
			
		||||
 | 
			
		||||
if(is_logged_in($user)){
 | 
			
		||||
$tagtext = "I got fit here";
 | 
			
		||||
$actionlink = "individual.php?fitter_id=$row[fitter_id]&".get_sid();
 | 
			
		||||
}else{
 | 
			
		||||
$tagtext = "Log in to tag this fitter";
 | 
			
		||||
$actionlink = "$forum_url/forum/?do=login&from=fitters";
 | 
			
		||||
$tagstatus = "no";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if(is_logged_in($user)){
 | 
			
		||||
//Get user's uid
 | 
			
		||||
//$testresults = mysql_query("SELECT user_id FROM ".$prefix."User WHERE user_username=\"$username\"") or die(mysql_error());
 | 
			
		||||
//$testrow = mysql_fetch_array($testresults);
 | 
			
		||||
//$useruid = $testrow[user_id];
 | 
			
		||||
$useruid = base64_decode($_SESSION['user_id']);
 | 
			
		||||
 | 
			
		||||
// is the current user the owner of the fitter?
 | 
			
		||||
$fitter_submitted_by = FALSE;
 | 
			
		||||
if($useruid == $row[fitter_submitted_by]){
 | 
			
		||||
  $fitter_submitted_by = TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$tagresults = mysql_query("SELECT fitter_user_tags FROM ".$prefix."Fitters WHERE fitter_id=$row[fitter_id]");
 | 
			
		||||
$tagrow = mysql_fetch_array($tagresults);
 | 
			
		||||
$tags = explode(",", $tagrow[fitter_user_tags]);
 | 
			
		||||
 | 
			
		||||
$profileresults = mysql_query("SELECT user_fittertags FROM ".$prefix."User WHERE user_id='$useruid'") or die(mysql_error());
 | 
			
		||||
$profilerow = mysql_fetch_array($profileresults);
 | 
			
		||||
$profiletags = explode(",", $profilerow[user_fittertags]);
 | 
			
		||||
 | 
			
		||||
if($_POST[status] == "tag"){
 | 
			
		||||
//tag the fitter
 | 
			
		||||
if(array_search($useruid, $tags) == FALSE){
 | 
			
		||||
array_push($tags, $useruid);
 | 
			
		||||
}
 | 
			
		||||
$tags = implode(",", $tags);
 | 
			
		||||
mysql_query("UPDATE ".$prefix."Fitters SET fitter_user_tags='$tags' WHERE fitter_id=$row[fitter_id]") or die(mysql_error());
 | 
			
		||||
$tags = explode(",", $tags);
 | 
			
		||||
 | 
			
		||||
if(array_search($row[fitter_id], $profiletags) == FALSE){
 | 
			
		||||
array_push($profiletags, $row[fitter_id]);
 | 
			
		||||
}
 | 
			
		||||
$profiletags = implode(",", $profiletags);
 | 
			
		||||
mysql_query("UPDATE ".$prefix."User SET user_fittertags='$profiletags' WHERE user_id='$useruid'") or die(mysql_error());
 | 
			
		||||
}else if($_POST[status] == "untag"){
 | 
			
		||||
//untag the fitter
 | 
			
		||||
$key = array_search($useruid, $tags);
 | 
			
		||||
unset($tags[$key]);
 | 
			
		||||
$tags = implode(",", $tags);
 | 
			
		||||
mysql_query("UPDATE ".$prefix."Fitters SET fitter_user_tags='$tags' WHERE fitter_id=$row[fitter_id]") or die(mysql_error()); 
 | 
			
		||||
$tags = explode(",", $tags);
 | 
			
		||||
 | 
			
		||||
$key = array_search($row[fitter_id], $profiletags);
 | 
			
		||||
unset($profiletags[$key]);
 | 
			
		||||
$profiletags = implode(",", $profiletags);
 | 
			
		||||
mysql_query("UPDATE ".$prefix."User SET user_fittertags='$profiletags' WHERE user_id=$useruid");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Is the fitter tagged already?
 | 
			
		||||
if(array_search($useruid, $tags) !== FALSE){ $wasfit = TRUE; }else{ $wasfit = FALSE; }
 | 
			
		||||
 | 
			
		||||
if($wasfit){ $tagstatus = "untag"; $tagtext = "Untag this fitter";}else{ $tagstatus = "tag"; $tagtext = "I was fit";}
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
<form action="<? echo $actionlink; ?>" method="post" style="display: inline;">
 | 
			
		||||
<input type="hidden" value="<? echo $tagstatus; ?>" name="status" />
 | 
			
		||||
<? if (is_logged_in($user)) { ?>
 | 
			
		||||
<input type="submit" value="<? echo $tagtext; ?>" class="btn" />
 | 
			
		||||
<? } else { ?>
 | 
			
		||||
<a href="<? echo $actionlink ?>" class="btn"><? echo $tagtext; ?></a>
 | 
			
		||||
<? } ?>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<form method="post" action="<? echo "individual.php?fitter_id=$row[fitter_id]#wasfit"; ?>" style="display: inline;">
 | 
			
		||||
<input type="submit" value="Who was fit?" class="btn" />
 | 
			
		||||
</form>
 | 
			
		||||
<? if(is_logged_in($user)){ ?>
 | 
			
		||||
        <form method="post" action="<? echo "individual.php?fitter_id=$row[fitter_id]#comment"; ?>" style="display: inline;">
 | 
			
		||||
        <input type="submit" value="Comment on this fitter" class="btn" />
 | 
			
		||||
        </form>
 | 
			
		||||
        
 | 
			
		||||
        <form method="post" action="<? echo "wiki_edit.php?fitter_id=$row[fitter_id]"; ?>" style="display: inline;">
 | 
			
		||||
        <input type="submit" value="Edit this fitter (wiki)" class="btn" />
 | 
			
		||||
        </form>
 | 
			
		||||
 | 
			
		||||
<?
 | 
			
		||||
 if(is_admin($user)) {
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
<form method="post" action="delete_X.php" style="display: inline;">
 | 
			
		||||
<input type="hidden" name="fitter_id" value="<? echo($row[fitter_id]); ?>" />
 | 
			
		||||
<input type="submit" value="Delete this fitter" class="btn" onclick="return confirm('Are you sure you want to DELETE this fitter?');" />
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<?
 | 
			
		||||
 | 
			
		||||
//Get user's username
 | 
			
		||||
$testresults = mysql_query("SELECT user_username FROM ".$prefix."User WHERE user_id='$row[fitter_submitted_by]'") or die(mysql_error());
 | 
			
		||||
$testrow = mysql_fetch_array($testresults);
 | 
			
		||||
$username = $testrow[user_username];
 | 
			
		||||
echo("<br /><br /><strong>Entered By: </strong> <a href='http://forum.slowtwitch.com/gforum.cgi?username=$username;'>$username</a>");  
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
		Reference in New Issue
	
	Block a user