<?PHP 

	if (!is_numeric($_GET[edit_id])) { 	
		header('Location:'.$site_url.'/?error=invalid_id'); 
	}
	  
	include("config.php");
	
	// only admins can validate
	if(!is_admin()){
	  header('Location:'.$site_url.'/');
	  exit(); 
	}
	
	// get the info for the edit based on ID
	// if the ID isn't valid, punt the user
	$edit_id_here = intval(mysql_escape_string($_GET[edit_id]));
	$results = mysql_query("SELECT * FROM ".$prefix."RunshopsEdits WHERE edit_id = '".$edit_id_here."' LIMIT 1") OR die(mysql_error());
	$row = mysql_fetch_array($results);
	if (!$row) { header('Location:'.$site_url.'/?error=no_entry'); }
	
	// set the page title
	$pagetitle = $row[runshop_name];
	
	// set meta tags
	$meta_keywords = "triathlon, ".$row[runshop_name].", ".$row[runshop_state]." triathlon running store";
	$meta_description = "Considering shopping at ".$row[runshop_name]."? Here is all of the information about this running store.";
	
	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 section-static remove-sidebar">
          <div class="sidebar-b">
            <? include("include_sidebar.php"); ?>
          </div>

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

              <div class="clearfix">
<h2 style="display: inline; height: 16px; margin-bottom: 20px;"><!-- class="content-title"--><? echo stripslashes($row[runshop_name]) ; echo " "; ?></h2>

<? 

	// wiki control buttons
	include("wiki_buttons.php") 

?>

<div style="margin-top: 10px;">


<?
	$sqlWikiFetch = "SELECT user_username FROM ".$prefix."User WHERE user_id = ".mysql_escape_string($row[editor_user_id_fk])." LIMIT 1";
	
	$arrUser = mysql_fetch_array(mysql_query($sqlWikiFetch));
	
	$strEditor = $arrUser[user_username];
 ?>
<strong>Editor:</strong> <? echo "<a href=\"http://forum.slowtwitch.com/gforum.cgi?username=".$strEditor.";\" target=\"_blank\">".$strEditor."</a>"; ?>
<br />

<strong>Edit Date:</strong> <? echo date("F j, Y", $row[edit_timestamp]); ?>
<br />

<strong>Street Address: </strong><? echo stripslashes(htmlspecialchars($row[runshop_address])); ?>
<br />
<strong>Street Address Two: </strong><? echo stripslashes(htmlspecialchars($row[runshop_address_two])); ?>
<br />
<strong>City: </strong><? echo stripslashes(htmlspecialchars($row[runshop_city])); ?>
<br />
<strong>State: </strong><? echo stripslashes(htmlspecialchars($row[runshop_state])); ?>
<br />
<strong>Zip/Postal Code: </strong><? echo stripslashes(htmlspecialchars($row[runshop_zip])); ?>
<br />
<strong>Phone: </strong><? echo stripslashes(htmlspecialchars($row[runshop_phone])); ?>
<br />
<strong>Fax / Alternate Phone: </strong><? echo stripslashes(htmlspecialchars($row[runshop_fax])); ?>
<br />
<strong>E-mail: </strong><a href="mailto:<? echo $row[runshop_email]; ?>"><? echo stripslashes(htmlspecialchars($row[runshop_email])); ?></a>
<br />
<strong>Website: </strong><a href="<? echo $row[runshop_website]; ?>" target="_blank"><? echo $row[runshop_website]; ?></a><? if ($row[runshop_cart] == 1) { echo (" **eCommerce Shopping Cart**"); } ?>

<br />
<br />

<div class="indentlarge">
<? 
for ($i = 0; $i < 15; $i++) echo("*"); 
echo (" TECHNOLOGY, COMMUNITY &amp; EDUCATION ");
for ($i = 0; $i < 15; $i++) echo("*"); 
?>
</div>

<br />
<strong>Key Tri-Specific Contact(s): </strong><? if ($row[runshop_contact] == 0) { echo "None"; } else { echo "Yes, Their Names - "; echo stripslashes($row[runshop_contact_names]); } ?> 
<br />
<strong>Diagnostic Equipment: </strong><?

$row[runshop_diagnostics] = ltrim(rtrim($row[runshop_diagnostics], ", "), ", ");
if ($row[runshop_diagnostics]) {

    $sql = ("SELECT * FROM ".$prefix."RunshopsDiagnostics WHERE diagnostic_id IN ($row[runshop_diagnostics]) ORDER BY diagnostic_name ASC");

    //echo $sql;

    $fetch = mysql_query($sql) or die(mysql_error());

    $diagnostic_list = "";
    while ($list = mysql_fetch_array($fetch)) {
        $diagnostic_list  = $diagnostic_list."$list[diagnostic_name], ";
    }
    $diagnostic_list = rtrim($diagnostic_list, ', ');
}

if ($diagnostic_list) {echo $diagnostic_list;} else {echo "None";}

?>

<br /><br />
<div class="indentlarge">
<? 
for ($i = 0; $i < 36; $i++) echo("*"); 
echo (" BRANDS ");
for ($i = 0; $i < 36; $i++) echo("*"); 
?>
</div>

<br />
<strong>Shoes: </strong><?

$row[runshop_shoes] = ltrim(rtrim($row[runshop_shoes], ", "), ", ");

$sql = ("SELECT * FROM ".$prefix."RunshopsShoes WHERE shoe_id IN ($row[runshop_shoes]) ORDER BY shoe_name ASC");

//echo $sql;

$fetch = mysql_query($sql) or die(mysql_error());

$shoe_list = "";
while ($list = mysql_fetch_array($fetch)) {
    $shoe_list  = $shoe_list."$list[shoe_name], ";
}
$shoe_list = rtrim($shoe_list, ', ');

if ($shoe_list) {echo $shoe_list;} else {echo "None";}

?>

<br />
<strong>Socks: </strong><?

$row[runshop_socks] = ltrim(rtrim($row[runshop_socks], ", "), ", ");

$sql = ("SELECT * FROM ".$prefix."RunshopsSocks WHERE sock_id IN ($row[runshop_socks]) ORDER BY sock_name ASC");

//echo $sql;

$fetch = mysql_query($sql) or die(mysql_error());

$sock_list = "";
while ($list = mysql_fetch_array($fetch)) {
    $sock_list  = $sock_list."$list[sock_name], ";
}
$sock_list = rtrim($sock_list, ', ');

if ($sock_list) {echo $sock_list;} else {echo "None";}

?>

<br />
<strong>Run-Focused Apparel: </strong><?

$row[runshop_apparel_run] = ltrim(rtrim($row[runshop_apparel_run], ", "), ", ");

$sql = ("SELECT * FROM ".$prefix."RunshopsApparelRun WHERE apparel_run_id IN ($row[runshop_apparel_run]) ORDER BY apparel_run_name ASC");

//echo $sql;

$fetch = mysql_query($sql) or die(mysql_error());

$apparel_run_list = "";
while ($list = mysql_fetch_array($fetch)) {
    $apparel_run_list  = $apparel_run_list."$list[apparel_run_name], ";
}
$apparel_run_list = rtrim($apparel_run_list, ', ');

if ($apparel_run_list) {echo $apparel_run_list;} else {echo "None";}

?>

<br />
<strong>Tri-Focused Apparel: </strong><?

$row[runshop_apparel_tri] = ltrim(rtrim($row[runshop_apparel_tri], ", "), ", ");

if ($row[runshop_apparel_tri]) {
    $sql = ("SELECT * FROM ".$prefix."RunshopsApparelTri WHERE apparel_tri_id IN ($row[runshop_apparel_tri]) ORDER BY apparel_tri_name ASC");

    //echo $sql;

    $fetch = mysql_query($sql) or die(mysql_error());

    $apparel_tri_list = "";
    while ($list = mysql_fetch_array($fetch)) {
        $apparel_tri_list  = $apparel_tri_list."$list[apparel_tri_name], ";
    }
    $apparel_tri_list = rtrim($apparel_tri_list, ', ');
}

if ($apparel_tri_list) {echo $apparel_tri_list;} else {echo "None";}

?>

<br />
<strong>Swim Gear: </strong><?

$row[runshop_swimgear] = ltrim(rtrim($row[runshop_swimgear], ", "), ", ");

$sql = ("SELECT * FROM ".$prefix."ResourceSwimgear WHERE swimgear_id IN ($row[runshop_swimgear]) ORDER BY swimgear_name ASC");

//echo $sql;

$fetch = mysql_query($sql) or die(mysql_error());

$swimgear_list = "";
while ($list = mysql_fetch_array($fetch)) {
    $swimgear_list  = $swimgear_list."$list[swimgear_name], ";
}
$swimgear_list = rtrim($swimgear_list, ', ');

if ($swimgear_list) {echo $swimgear_list;} else {echo "None";}

?>

<br />
<strong>Wetsuits: </strong><?

$row[runshop_wetsuits] = ltrim(rtrim($row[runshop_wetsuits], ", "), ", ");

if ($row[runshop_wetsuits]) {
    $sql = ("SELECT * FROM ".$prefix."ResourceWetsuit WHERE wetsuit_id IN ($row[runshop_wetsuits]) ORDER BY wetsuit_name ASC");

    //echo $sql;

    $fetch = mysql_query($sql) or die(mysql_error());

    $wetsuit_list = "";
    while ($list = mysql_fetch_array($fetch)) {
        $wetsuit_list  = $wetsuit_list."$list[wetsuit_name], ";
    }
    $wetsuit_list = rtrim($wetsuit_list, ', ');

}

if ($wetsuit_list) {echo $wetsuit_list;} else {echo "None";}

?>

<br /><br />
<div class="indentlarge">
<? 
for ($i = 0; $i < 80; $i++) echo("*"); 
?>
</div>
<br />
<strong>Shop Hours: </strong><? echo stripslashes(htmlspecialchars($row[runshop_hours])); ?>
<br /><br />
<strong>Runs &amp; Classes: </strong><? echo stripslashes(stripslashes($row[runshop_classes])) ?>
<br /><br />
<strong>Shop Info: </strong><? echo stripslashes(stripslashes($row[runshop_info])) ?>
<br /><br />
<strong>Directions: </strong><? echo stripslashes(stripslashes($row[runshop_directions])); ?>

<br />

</div>


              </div><!-- end col-2/3 -->
            </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>
