<?PHP include("settings.php");

if(is_logged_in($user)){
    $useruid = mysql_escape_string(base64_decode($_SESSION['user_id']));
} else { 
    $useruid = false;
}

// set the page title
$pagetitle = "Local Listings";

// set meta tags
$meta_keywords = "Local listings";
$meta_description = "Local listings";
?>

<? include("include_common_head.php"); ?>

<body class="listings">
  <? include($common_path . "/ads/ad_wallpaper.html"); ?>

  <div class="container">
    <? include($common_path . "/templates/include_header.php"); ?>
    <div class="main">
      <div class="contentwrapper clearfix">
        <? include("include_breadcrumb.php"); ?>

        <section class="section listings section-has-widgets remove-sidebar">
          <div class="sidebar-b">
            <? include("include_sidebar.php"); ?>
          </div>

          <div class="content content-has-widgets">
            <div class="grid">

              <div class="clearfix">
                <h1>Your Local Listings</h1>
                
                
                <? //run through each database to determine if this userid owns any local assets
if ($useruid) { ?>

<div>This is a list of all local assets registered to your specific forum user ID.</div>

                <div class="grid icon-view">

                  <div class="col-1-2 listing">
                    <div class="icon">
                      <i class="sprite-running"></i>
                    </div>

                    <div class="list">
                      <h3><a href="<? echo $main_site_url ?>/runshops">Running Stores</a></h3>
                      <? //coaches [Coaches]
						 $sql = "SELECT runshop_id, runshop_name FROM gforum_Runshops WHERE runshop_submitted_by = ".$useruid;
						 $results = mysql_query($sql) OR die(mysql_error());
						 $i = 0;
						 while($row = mysql_fetch_array($results)) {
							 echo ("<a href=\"http://www.slowtwitch.com/runshops/individual.php?runshops_id=".$row['runshops_id']."\">".$row['runshops_name']."</a><br />");
							 $i++;	                    
						 }
						 if ($i == 0) {
							echo ("none<br />");
						 } ?>
                    </div>
                  </div>

                  <div class="col-1-2 listing">
                    <div class="icon">
                      <i class="sprite-biking"></i>
                    </div>

                    <div class="list">
                      <h3><a href="<? echo $main_site_url ?>/retailers">Bike Shops</a></h3>
                      <? $sql = "SELECT retailer_id, retailer_name FROM gforum_Retailers WHERE retailer_submitted_by = ".$useruid;
						 $results = mysql_query($sql) OR die(mysql_error());
						 $i = 0;
						 while($row = mysql_fetch_array($results)) {
							 echo ("<a href=\"http://www.slowtwitch.com/retailers/individual.php?retailer_id=".$row['retailer_id']."\">".$row['retailer_name']."</a><br />");	                    
							$i++;	                    
						 }
						 if ($i == 0) {
							echo ("none<br />");
						 } ?>
                    </div>
                  </div>

                  <div class="col-1-2 listing">
                    <div class="icon">
                      <i class="sprite-coaches"></i>
                    </div>

                    <div class="list">
                      <h3><a href="<? echo $main_site_url ?>/coaches">Coaches</a></h3>
                      <? //coaches [Coaches]
						 $sql = "SELECT coach_id, coach_name FROM gforum_Coaches WHERE coach_submitted_by = ".$useruid;
						 $results = mysql_query($sql) OR die(mysql_error());
						 $i = 0;
						 while($row = mysql_fetch_array($results)) {
							 echo ("<a href=\"http://www.slowtwitch.com/coaches/individual.php?coach_id=".$row['coach_id']."\">".$row['coach_name']."</a><br />");
							 $i++;	                    
						 }
						 if ($i == 0) {
							echo ("none<br />");
						 } ?>
                    </div>
                  </div>

                  <div class="col-1-2 listing">
                    <div class="icon">
                      <i class="sprite-fitters"></i>
                    </div>

                    <div class="list">
                      <h3><a href="<? echo $main_site_url ?>/fitters">Fitters</a></h3>
                      <? //fitters [Fitters]
						 $sql = "SELECT fitter_id, fitter_name FROM gforum_Fitters WHERE fitter_submitted_by = ".$useruid;
						 $results = mysql_query($sql) OR die(mysql_error());
						 $i = 0;
						 while($row = mysql_fetch_array($results)) {
							 echo ("<a href=\"http://www.slowtwitch.com/fitters/individual.php?fitter_id=".$row['fitter_id']."\">".$row['fitter_name']."</a><br />");	 
							$i++;	                    
						 }
						 if ($i == 0) {
							echo ("none<br />");
						 } ?>
                    </div>
                  </div>

                  <div class="col-1-2 listing">
                    <div class="icon">
                      <i class="sprite-clubs"></i>
                    </div>

                    <div class="list">
                      <h3><a href="<? echo $main_site_url ?>/triclubs">Triathlon Clubs</a></h3>
                      <? //triclubs [Tri Clubs]
						 $sql = "SELECT triclub_id, triclub_name FROM gforum_Triclubs WHERE triclub_submitted_by = ".$useruid;
						 $results = mysql_query($sql) OR die(mysql_error());
						 $i = 0;
						 while($row = mysql_fetch_array($results)) {
							 echo ("<a href=\"http://www.slowtwitch.com/triclubs/individual.php?triclub_id=".$row['triclub_id']."\">".$row['triclub_name']."</a><br />");	                    
							$i++;	                    
						 }
						 if ($i == 0) {
							echo ("none<br />");
						 } ?>
                    </div>
                  </div>

                  <div class="col-1-2 listing">
                    <div class="icon">
                      <i class="sprite-race"></i>
                    </div>

                    <div class="list">
                      <h3><a href="<? echo $main_site_url ?>/calendar">Race Calendar</a></h3>
                      <? //triathlons [Race Calendar]
						 $sql = "SELECT uid, name FROM gforum_Triathlons WHERE submitted_by = ".$useruid;
						 $results = mysql_query($sql) OR die(mysql_error());
						 $i = 0;
						 while($row = mysql_fetch_array($results)) {
							 echo ("<a href=\"http://calendar.slowtwitch.com/individual.php?uid=".$row['uid']."\">".$row['name']."</a><br />");	 
							 $i++;
						 }
						 if ($i == 0) {
							echo ("none<br />");
						 } ?>
                    </div>
                  </div>
                  
                </div>
              </div><!-- end col-2/3 -->
            <? } else { echo ("<div>You must be <a href='http://forum.slowtwitch.com/forum/?do=login'>logged in</a> with cookies enabled.</div>"); } ?>

            </div><!-- end grid -->
          </div><!-- end content -->
        </section>

      </div><!-- end contentwrapper -->
    </div> <!-- end main -->

  <? include($common_path . "/templates/include_footer.php") ?>
  </div> <!-- container  -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>


<?

/**
	 //coaches [Coaches]
	 $sql = "SELECT coach_id, coach_name FROM gforum_Coaches WHERE coach_submitted_by = ".$useruid;
	 $results = mysql_query($sql) OR die(mysql_error());
	 $i = 0;
	 while($row = mysql_fetch_array($results)) {
		 echo ("<a href=\"http://www.slowtwitch.com/coaches/individual.php?coach_id=".$row['coach_id']."\">".$row['coach_name']."</a><br />");
		 $i++;	                    
	 }
	 if ($i == 0) {
	 	echo ("none<br />");
	 }

	 //fitters [Fitters]
	 $sql = "SELECT fitter_id, fitter_name FROM gforum_Fitters WHERE fitter_submitted_by = ".$useruid;
	 $results = mysql_query($sql) OR die(mysql_error());
	 $i = 0;
	 while($row = mysql_fetch_array($results)) {
		 echo ("<a href=\"http://www.slowtwitch.com/fitters/individual.php?fitter_id=".$row['fitter_id']."\">".$row['fitter_name']."</a><br />");	 
	 	$i++;	                    
	 }
	 if ($i == 0) {
	 	echo ("none<br />");
	 }

	 //runshops [Running Shops]
	 $sql = "SELECT runshop_id, runshop_name FROM gforum_Runshops WHERE runshop_submitted_by = ".$useruid;
	 $results = mysql_query($sql) OR die(mysql_error());
	 $i = 0;
	 while($row = mysql_fetch_array($results)) {
		 echo ("<a href=\"http://www.slowtwitch.com/runshops/individual.php?runshop_id=".$row['runshop_id']."\">".$row['runshop_name']."</a><br />");	                    
	 	$i++;	                    
	 }
	 if ($i == 0) {
	 	echo ("none<br />");
	 }
	 
	 //retailers [Retailers]
	 $sql = "SELECT retailer_id, retailer_name FROM gforum_Retailers WHERE retailer_submitted_by = ".$useruid;
	 $results = mysql_query($sql) OR die(mysql_error());
	 $i = 0;
	 while($row = mysql_fetch_array($results)) {
		 echo ("<a href=\"http://www.slowtwitch.com/retailers/individual.php?retailer_id=".$row['retailer_id']."\">".$row['retailer_name']."</a><br />");	                    
	 	$i++;	                    
	 }
	 if ($i == 0) {
	 	echo ("none<br />");
	 }

	 //triclubs [Tri Clubs]
	 $sql = "SELECT triclub_id, triclub_name FROM gforum_Triclubs WHERE triclub_submitted_by = ".$useruid;
	 $results = mysql_query($sql) OR die(mysql_error());
	 $i = 0;
	 while($row = mysql_fetch_array($results)) {
		 echo ("<a href=\"http://www.slowtwitch.com/triclubs/individual.php?triclub_id=".$row['triclub_id']."\">".$row['triclub_name']."</a><br />");	                    
	 	$i++;	                    
	 }
	 if ($i == 0) {
	 	echo ("none<br />");
	 }

	 //triathlons [Race Calendar]
	 $sql = "SELECT uid, name FROM gforum_Triathlons WHERE submitted_by = ".$useruid;
	 $results = mysql_query($sql) OR die(mysql_error());
	 $i = 0;
	 while($row = mysql_fetch_array($results)) {
		 echo ("<a href=\"http://calendar.slowtwitch.com/individual.php?uid=".$row['uid']."\">".$row['name']."</a><br />");	 
		 $i++;
	 }
	 if ($i == 0) {
	 	echo ("none<br />");
	 }
	 

	 **/

?>