All pastes #792979 Raw Edit

Mine

public php v1 · immutable
·published 2007-11-21 21:16 UTC
rendered paste body
<?	function xmlParseURL() {		$pageURL = 'http';		if (isset($_SERVER["HTTPS"])) {			if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}		}		$pageURL .= "://";		if ($_SERVER["SERVER_PORT"] != "80") {			preg_match("/(.*[\/[^\s]*\/]?)[^\s]*.php/",$_SERVER["REQUEST_URI"],$xmlparse);			$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]. $xmlparse['1'] . 'xmlparse.php';		} else {			preg_match("/(.*[\/[^\s]*\/]?)[^\s]*.php/",$_SERVER["REQUEST_URI"],$xmlparse);			$pageURL .= $_SERVER["SERVER_NAME"] . $xmlparse['1'] . 'xmlparse.php';		}		return $pageURL;	}	function parsewootxml() {		$timeout = 3; // set to zero for no timeout		//retrieve file		$ch = curl_init();		curl_setopt ($ch, CURLOPT_URL, xmlParseURL());		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);		curl_setopt ($ch, CURLOPT_TIMEOUT, $timeout);		$file = curl_exec($ch);		$resp = curl_getinfo($ch,CURLINFO_HTTP_CODE);		curl_close($ch);		$responsecode = substr($resp,0,1);		if($responsecode == 2) {			$productnum = 0;			global $cachedata;			$p = xml_parser_create();			xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1);			xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);			xml_parse_into_struct($p, $file, $values);			xml_parser_free($p);			$cachedata = array();			foreach ($values as $value) {				if ($value['level'] == 2) {					if (isset($value['value'])) $cachedata[$value['tag']] = $value['value'];				}				elseif ($value['level'] == 3) {					$cachedata['woot:product'][$productnum]['item'] = $value['value'];					$cachedata['woot:product'][$productnum++]['qty'] = $value['attributes']['quantity'];				}			}		}		else {			echo "<!DOCTYPE html		PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"		\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">		<html>		<head>    <link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/x-icon\" />    	<link rel=\"icon\" href=\"favicon.ico\" type=\"image/x-icon\" />    	<meta http-equiv=\"refresh\" content=\"5\" /></head><body><center>Cache failed to load, retrying</center></body></html>";		}	}	parsewootxml();	echo "<!DOCTYPE htmlPUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head>    <link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/x-icon\" />    <link rel=\"icon\" href=\"favicon.ico\" type=\"image/x-icon\" />    <meta http-equiv=\"refresh\" content=\"";	if ($cachedata['woot:product']['0']['item'] != "") echo $cachedata['refresh'];	else echo "5";	echo "\" />    <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /><title>";	if ($cachedata['woot:wootoff'] == 'True') echo (round(1 - $cachedata['woot:soldoutpercentage'],2)*100) . "% left - WOOT-OFF!: ";	echo  $cachedata['title'] . "</title><style type=\"text/css\" media=\"screen\">";	include("style.css");	echo "</style></head><body><table cellspacing=\"0\">		<tr>			<td colspan=\"2\" bgcolor=\"#4a6751\" height=\"37\" align=\"left\"><div class=\"title\"><b><a class=\"wootlink\" href=\"http://www.woot.com\" target=\"_blank\">woot!</a>-off checker</b></div></td>		</tr>		<tr>			<td colspan=\"2\" height=\"5\" bgcolor=\"#F29F01\"></td>		</tr>		<tr bgcolor=\"#FFFFFF\">			<td><img src=\"image.jpg";	if ($cachedata['forceimagerefresh'] != 0) echo "?" . $cachedata['forceimagerefresh'];	echo "\" alt=\"\" /></td><td width=\"350\"><div class=\"padded\"><div class=\"producttitle\"><b>" . $cachedata['title'] . "</b></div><div class=\"price\">". $cachedata['woot:price'] . "</div>+ $5 shipping</div>			<br />				<table width=\"75%\">					<tr>						<td><div class=\"CQP\"><br /><b>Condition: </b>" . $cachedata['woot:condition'];	for($i=0;isset($cachedata['woot:product'][$i]['item']);$i++) echo "<br /><b>Quantity:</b> " . $cachedata['woot:product'][$i]['qty'] . "<br /><b>Product:</b> " . $cachedata['woot:product'][$i]['item'];	echo "</div></td>					</tr>					<tr>						<td><a class=\"forumlink\" href=\"" . $cachedata['woot:discussionurl'] . "\">Discuss this product</a></td>					</tr>				</table>		<br /><br />";	if ($cachedata['woot:soldout'] == 'False') echo "<a class=\"buylink\" href=\"" . $cachedata['woot:purchaseurl'] . "\">I want one!</a>";	else echo "<div class=\"soldout\">Item is Sold Out!</div>";	echo "</td></tr>";	if ($cachedata['woot:wootoff'] == 'True') echo "<tr bgcolor=\"#FFFFFF\"><td colspan=\"2\" class=\"wootoff\">woot-off in progress!<br /><h2>" . (round(1 - $cachedata['woot:soldoutpercentage'],2)*100) . "% left</h2></td></tr>";	echo "<tr><td height=\"5\" bgcolor=\"#F29F01\" colspan=\"2\"></td></tr><tr><td colspan=\"2\" height=\"10\" bgcolor=\"#4a6751\"></td></tr></table><a href=\"noajaxtext.php\" class=\"bigtext\">Text-only version</a><br /><br />Cache is updated every " . $cachedata['refresh'] . " seconds.  The current cache is " . (time() - $cachedata['timestamp']) . " second(s) old. (" . date('G:i:s T') . ")<br />The refresh rate depends on whether a woot-off is in progress or not.  The cache helps reduce load on woot.com servers.<br />Darkstar's woot!-off checker.  <a href=\"http://woot.dswebhost.net/download.php\">Download the source.</a><br /><a href=\"http://woot.wikia.com/wiki/Woot-Off_Checkers\">List of Woot-checkers</a></body></html>";?>