Created
February 26, 2015 20:31
-
-
Save overwine/cf905a980a131751f046 to your computer and use it in GitHub Desktop.
Terrible idea stuff.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<?php | |
/*if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
if(!empty($_POST['locatezip'])){ | |
$_POST['zip'] = $_POST['locatezip']; | |
$_POST['radius'] = $_POST['locateradius']; | |
$_POST['item'] = $_POST['locateitem']; | |
} | |
}*/ | |
if (!empty($_SERVER['HTTP_CLIENT_IP'])) | |
{ | |
$ip=$_SERVER['HTTP_CLIENT_IP']; | |
} | |
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) | |
{ | |
$ip=$_SERVER['HTTP_X_FORWARDED_FOR']; | |
} | |
else | |
{ | |
$ip=$_SERVER['REMOTE_ADDR']; | |
} | |
function findStores() { | |
//creating array of data to be posted | |
$post_data['item'] = $_POST['locateitem']; | |
$post_data['radius'] = $_POST['locateradius']; | |
$post_data['ip'] = $ip; | |
//traverse array and prepare data for posting | |
foreach ( $post_data as $key => $value) { | |
$post_items[] = $key . '=' . $value; | |
} | |
//creating final string to be posted | |
$post_string = implode ('&', $post_items); | |
//creating cURL connection | |
$ch = curl_init('http://www2.itemlocator.net/ils/locatorXML/'); | |
//setting options | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); | |
//curl_setopt($ch, CURLOPT_URL, "http://www2.itemlocator.net/ils/locatorXML/"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_REFERER, 'http://www.marzettikitchens.com/'); | |
curl_setopt($ch, CURLOPT_POST, true); | |
//set data to be posted | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); | |
//perform request | |
$result = curl_exec($curl_connection); | |
//close connection | |
curl_close($ch); | |
//locations in xml format are then made into html | |
$locations = new SimpleXMLElement($result); | |
$htmloutput = ''; | |
if (!empty($location->errorMsg)){ | |
$htmloutput .= "<div>An error has occurred while trying to find a store. Please try again.</div>"; | |
} else { | |
if($locations->storesFound > 0) { | |
foreach ($locations->store as $store){ | |
$htmloutput .= '<div class="store">'; | |
$htmloutput .= '<h3>'. $store->name .'</h3>'; | |
$htmloutput .= '<div>'. $store->address .'</div>'; | |
if (!empty ($store->address2)) $htmloutput .= '<div>'. $store->address2 .'</div>'; | |
$htmloutput .= '<div>'. $store->city.', ';// .'</div>'; | |
$htmloutput .= $store->state .' '. $store->zip .'</div>'; | |
$htmloutput .= '<div>'. $store->phone .'</div>'; | |
$htmloutput .= '<div><strong>Distance:</strong> '. $store->distance .' '. $store->distanceUnit .'</div>'; | |
$htmloutput .= '<div><a href="http://maps.google.com/?q='.preg_replace('/\s+/', '%20', $store->address).','.$store->city.','.$store->state.','.$store->zip.'" target="_blank">Show Map</a></div>'; | |
$htmloutput .= '</div>'; | |
} | |
} else { | |
$htmloutput .= "<div id=\"notfound\">We're sorry we could not find a location near you.</div>"; | |
} | |
} | |
echo $htmloutput; | |
} | |
?> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Site Title</title> | |
<meta name="description" content=""> | |
<meta name="author" content="#"> | |
<link rel="stylesheet" href="css/styles.css?v=1.0"> | |
<!--[if lt IE 9]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<script src="js/jquery-1.11.2.js"></script> | |
<script> | |
$(document).ready(function() { | |
$('.where-to-buy-button').click(function(){ | |
var errs = 0; | |
var zip = $('#zip').val(); | |
if(zip.length<1 || !$.isNumeric(zip)) | |
{ | |
$('#zip').css({'border':'1px solid red'}); | |
errs = 1; | |
} | |
else | |
{ | |
$('#zip').css({'border':'1px solid #ccc'}); | |
} | |
if(errs > 0) | |
{ | |
$('#sErrs').show().focus(); | |
} | |
else | |
{ | |
$('#sErrs').hide(); | |
findStores(); | |
} | |
return false; | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div class="product-container"> | |
<div class="product-detail-left"> | |
<div class="product-image"> | |
<img src="images/og-signature.jpg" alt="Olive Garden Signature Italian Dressing"> | |
</div> | |
<div class="product-wtb"> | |
<?php print_r($ip);?> | |
<div class="product-detail-where"> | |
<form method="post" name="wtb-form"> | |
<label>FIND THIS PRODUCT NEAR YOU </label><input id="productwhere zip" class="product-where" type="text" onfocus="if (this.value=='Zip Code') this.value='';" onblur="if (this.value=='') this.value='Zip Code';" value="Zip Code" maxlength="6" name="locatezip"><input class="product_where_button where-to-buy-button" type="image" text="where to buy" alt="magnify" onclick="this.form.productwhere.focus();" src="/templates/marzetti/img/search_magnify.png" value="Where"> | |
<input type="hidden" name="locateitem" value="7020083811" id="item" /> | |
<input type="hidden" name="locateradius" value="50" /> | |
<input type="hidden" id="ip" name="ip" value="<?php echo $ip; ?>" /> | |
</form> | |
</div> | |
</div> | |
</div> | |
<div class="product-detail-right"> | |
<div class="product-title"> | |
<h2>Light Italian Dressing (16 oz.)</h2> | |
</div> | |
<div class="product-info-tabs"> | |
<div class="product-details-tab selected-tab">Product Details</div> | |
<div class="product-nutrition-tab">Nutrition Facts</div> | |
</div> | |
<div class="product-details-content"> | |
<p>With less fat and fewer calories, our Light Italian Dressing is a great alternative to our Signature Italian Dressing. Try it on salads big enough for a crowd, as a marinade for your favorite lean meats, or as a dip for your favorite vegetables.</p> | |
</div> | |
<div class="product-nutrition-content"> | |
<div class="nutrition-facts"> | |
<table cellpadding="0" cellspacing="0" border="0" class="outer-table"> | |
<tr> | |
<td> | |
<table cellpadding="0" cellspacing="0" border="0" class="left-table"> | |
<tr> | |
<td class="nf-title">Nutrition Facts</td> | |
</tr> | |
<tr> | |
<td class="data">Serving Size 2.00 tbsp. (31g)</td> | |
</tr> | |
<tr> | |
<td class="data">Servings Per Container 12.0</td> | |
</tr> | |
<tr> | |
<td class="data">Calories 60</td> | |
</tr> | |
<tr> | |
<td class="data bump">Calories from Fat 50</td> | |
</tr> | |
<tr> | |
<td class="small-data">*Percent Daily Values are based on a 2,000 calories diet.</td> | |
</tr> | |
</table> | |
</td> | |
<td> | |
<table cellpadding="0" cellspacing="0" border="0" class="right-table"> | |
<tr> | |
<td class="small-head">Amount/Serving <span style="float:right;">% Daily Value*</span></td> | |
<td class="middle"></td> | |
<td class="small-head">Amount/Serving <span style="float:right;">% Daily Value*</span></td> | |
</tr> | |
<tr> | |
<td colspan="3" class="black-bar"></td> | |
</tr> | |
<tr> | |
<td class="data">Total Fat 6.0g <span style="float:right;">9%</span></td> | |
<td class="middle"></td> | |
<td class="data">Cholesterol 5mg <span style="float:right;">2%</span></td> | |
</tr> | |
<tr> | |
<td class="data border bump">Saturated Fat 1g <span style="float:right;">5%</span></td> | |
<td class="middle"></td> | |
<td class="data border">Sodium 360mg <span style="float:right;">15%</span></td> | |
</tr> | |
<tr> | |
<td class="data border bump">Trans Fat 0.0g</td> | |
<td class="middle"></td> | |
<td class="data border">Total Carbohydrate 2g <span style="float:right;">1%</span></td> | |
</tr> | |
<tr> | |
<td class="data border bump">Polyunsaturated Fat 0g</td> | |
<td class="middle"></td> | |
<td class="data border bump"> Dietary Fiber 0g <span style="float:right;">0%</span></td> | |
</tr> | |
<tr> | |
<td class="data border bump">Monounsaturated Fat 0g</td> | |
<td class="middle"></td> | |
<td class="data border bump">Sugars 1g</td> | |
</tr> | |
<tr> | |
<td></td> | |
<td class="middle"></td> | |
<td class="data border">Protein 1g</td> | |
</tr> | |
<tr> | |
<td colspan="3" class="black-bar"></td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
<div class="ingredients"><strong>INGREDIENTS:</strong> WATER, SOYBEAN OIL, DISTILLED VINEGAR, ASIAGO AND PARMESAN CHEESES (MILK, CHEESE CULTURES, SALT, ENZYMES), SUGAR, RED WINE VINEGAR, SALT, DEHYDRATED GARLIC, SPICES, MUSTARD SEED, LACTIC ACID, XANTHAN GUM, LEMON JUICE CONCENTRATE, ANCHOVIES, NATURAL FLAVORS, MOLASSES, CARAMEL COLOR, TAMARIND, CITRIC ACID.</div> | |
<div class="allergen-info">Contains Milk, Anchovies.</div> | |
</div> | |
</div> | |
<div class="product-next-link"><a href="#" target="_self">Signature Italian Dressing</a></div> | |
</div> | |
</div> | |
<script src="js/scripts.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment