117 lines
4.6 KiB
PHP
117 lines
4.6 KiB
PHP
<?PHP
|
|
|
|
if (eregi("include", $_SERVER['SCRIPT_NAME'])) {
|
|
Header("Location: ".$site_url."/index.php"); die();
|
|
}
|
|
|
|
if(is_logged_in($user)){
|
|
$tagtext = "I shop here";
|
|
$actionlink = "individual.php?runshop_id=$row[runshop_id]&".get_sid();
|
|
}else{
|
|
$tagtext = "Log in to tag this shop";
|
|
$actionlink = "$forum_url/forum/?do=login&from=runshops";
|
|
$tagstatus = "no";
|
|
}
|
|
|
|
if(is_logged_in($user)){
|
|
//Get user's uid
|
|
$useruid = base64_decode($_SESSION['user_id']);
|
|
|
|
// is the current user the owner of the shop?
|
|
$runshop_submitted_by = FALSE;
|
|
if($useruid == $row[runshop_submitted_by]){
|
|
$runshop_submitted_by = TRUE;
|
|
}
|
|
|
|
$tagresults = mysql_query("SELECT runshop_shopper_tags FROM ".$prefix."Runshops WHERE runshop_id=$row[runshop_id]");
|
|
$tagrow = mysql_fetch_array($tagresults);
|
|
$tags = explode(",", $tagrow[runshop_shopper_tags]);
|
|
|
|
$profileresults = mysql_query("SELECT user_runshoptags FROM ".$prefix."User WHERE user_id='$useruid'") or die(mysql_error());
|
|
$profilerow = mysql_fetch_array($profileresults);
|
|
$profiletags = explode(",", $profilerow[user_runshoptags]);
|
|
|
|
if($_POST[status] == "tag"){
|
|
//tag the shop
|
|
if(array_search($useruid, $tags) == FALSE){
|
|
array_push($tags, $useruid);
|
|
}
|
|
$tags = implode(",", $tags);
|
|
mysql_query("UPDATE ".$prefix."Runshops SET runshop_shopper_tags='$tags' WHERE runshop_id=$row[runshop_id]") or die(mysql_error());
|
|
$tags = explode(",", $tags);
|
|
|
|
if(array_search($row[runshop_id], $profiletags) == FALSE){
|
|
array_push($profiletags, $row[runshop_id]);
|
|
}
|
|
$profiletags = implode(",", $profiletags);
|
|
mysql_query("UPDATE ".$prefix."User SET user_runshoptags='$profiletags' WHERE user_id='$useruid'") or die(mysql_error());
|
|
}else if($_POST[status] == "untag"){
|
|
//untag the shop
|
|
$key = array_search($useruid, $tags);
|
|
unset($tags[$key]);
|
|
$tags = implode(",", $tags);
|
|
mysql_query("UPDATE ".$prefix."Runshops SET runshop_shopper_tags='$tags' WHERE runshop_id=$row[runshop_id]") or die(mysql_error());
|
|
$tags = explode(",", $tags);
|
|
|
|
$key = array_search($row[runshop_id], $profiletags);
|
|
unset($profiletags[$key]);
|
|
$profiletags = implode(",", $profiletags);
|
|
mysql_query("UPDATE ".$prefix."User SET user_runshoptags='$profiletags' WHERE user_id=$useruid");
|
|
}
|
|
|
|
//Is the shop tagged already?
|
|
if(array_search($useruid, $tags) !== FALSE){
|
|
$racing = TRUE;
|
|
} else {
|
|
$racing = FALSE;
|
|
}
|
|
|
|
if($racing){
|
|
$tagstatus = "untag";
|
|
$tagtext = "Untag this shop";
|
|
} else {
|
|
$tagstatus = "tag";
|
|
$tagtext = "I shop here";
|
|
}
|
|
}
|
|
?>
|
|
|
|
<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?runshop_id=$row[runshop_id]#tagged"; ?>" style="display: inline;">
|
|
<input type="submit" value="Who shops here?" class="btn" />
|
|
</form>
|
|
<?
|
|
// begin is is_logged_in check
|
|
if(is_logged_in($user)) { ?>
|
|
<form method="post" action="<? echo "wiki_edit.php?runshop_id=$row[runshop_id]"; ?>" style="display: inline;">
|
|
<input type="submit" value="Edit this shop (wiki)" class="btn" />
|
|
</form>
|
|
<? }
|
|
// end is_logged_in check
|
|
|
|
//begin is_admin check
|
|
if(is_admin()) {
|
|
?>
|
|
|
|
<form method="post" action="delete_X.php" style="display: inline;">
|
|
<input type="hidden" name="runshop_id" value="<? echo($row[runshop_id]); ?>" />
|
|
<input type="submit" value="Delete this shop" class="btn" onclick="return confirm('Are you sure you want to DELETE this shop?');" />
|
|
</form>
|
|
|
|
<?
|
|
//Get user's uid
|
|
$testresults = mysql_query("SELECT user_username FROM ".$prefix."User WHERE user_id='$row[runshop_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>");
|
|
}
|
|
// end is_admin check
|
|
?>
|