All pastes #190462 Raw Edit

Mine

public text v1 · immutable
·published 2006-10-04 00:39 UTC
rendered paste body
<?
$cur_row = 0;
$cur_col = 0;


$curstate = getcurstate($content);



curl_setopt($ch, CURLOPT_URL, 'http://ekeystone.com/WebPage.aspx?pn=1100000BrowseByDescr');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "name=_ctl0:_ctl6:_ctl0");
$content = curl_exec ($ch);
$curstate = getcurstate($content);
///TEST

//for ($i = 65; $i < 92; $i++)
for ($i = 65; $i < 92; $i++)
{
$data_next = false;
$data_now = false;
$inputbefore = false;
$html = "";
echo "getting cat $i.<BR>";

if($i == 65)
{
curl_setopt($ch, CURLOPT_URL, 'http://ekeystone.com/WebPage.aspx?pn=1100000BrowseByDescr');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "name=_ctl0:_ctl6:_ctl0");
$content = curl_exec ($ch);



} else {

curl_setopt($ch, CURLOPT_URL, 'http://ekeystone.com/WebPage.aspx?pn=1100000BrowseByDescr');
curl_setopt($ch, CURLOPT_POST, 1);
$POSTAL = array('__VIEWSTATE' => $curstate, '__EVENTTARGET' => "lblbbd".$i, '__EVENTARGUMENT' => '', 'SearchOptions' => 'rb1Search', 'txtSearchKey' => '');
curl_setopt($ch, CURLOPT_POSTFIELDS, $POSTAL);
$content = curl_exec ($ch);

}



//echo $content;




$html = $content;

		$parser = new HtmlParser ($html);
			
		while ($parser->parse()) 
		{
			echo "INSIDE WHILE";
			$attributes = $parser->iNodeAttributes;
			
			if($data_now)
			{
			
				//Open or closed -- open
				if($parser->iNodeType != "2")
				{
				
					//
					if($data_next)
					{
					
						if($parser->iNodeName == "input" && preg_match("/browse/i", $attributes['title']))
						{
							$num = str_replace("(","",$attributes['title']);
							$num = str_replace(")","",$num);
							$num = explode(" ", $num);
							$categories[][1] = $num[count($num)-1];
							echo "NEW CAT:".$num[count($num)-1];
							$inputbefore = true;
						
						}
						
						if($parser->iNodeType == "3" && $inputbefore )
						{
							$categories[(count($categories) - 1)][0] = preg_replace("/&nbsp;/", "", $parser->iNodeValue);
							$data_next = false;
							$inputbefore = false;
							echo "should quit";
						
						}
					
					
					}
					//Row number
					if($parser->iNodeName == "tr")
						$cur_row++;
					
					//Column
					if($parser->iNodeName == "td")
					{
						$data_next = true;
					
					
					}
			
			
			
			
			
			
				} else {
				//Closed
				
				
				
				
				
				
				}
			
			
			
			
			echo "END OF ELSE";
			error_reporting(E_ALL);
			
			} else {
						
						echo "START OF ELSE CONDITION";
				if($parser->iNodeName == "input")
				{
					if($attributes['name'] == "__VIEWSTATE")
						$curstate = $attributes['value'];
				}
				if($parser->iNodeName == "table")
				{
					if($attributes['id'] == "BrowseDG")
						$data_now = true;
				}
				
			}
		
	echo "AFTER END OF ELSE";
		}
echo "while is done";

//echo "<PRE>";


}