$val){ if(preg_match("/[^\"]+\"mainSearch\"[^\"]+\"([^\"]+)\">/", $val, $matches)){ if($i<$num_searches){ search_for_cam_on_page($matches[1]); $i++; } } } if(count($image_list)<8){ // echo "
need more searching"; } // print '
';
//	print_r($image_list);
	//eliminate duplicates:
	$image_list = array_unique($image_list);
	if($_GET['mode']=='xml'){
		foreach($image_list as $key => $val){
			$named_image_list['img' . $key] = $val;
		}
		header( "Content-type: text/xml" ); 
		$xml = array_to_xml($named_image_list);
		print $xml;
	}else if($_GET['mode']=='table'){
	//	print_r($named_image_list);
		echo '';
		for($i=0;$i
				  ';	
		 $i=$i+1;
		}
		echo '
'; if(isset($image_list[$i+1])){ echo ''; } echo '
'; } } function search_for_cam_on_page($url){ // echo $url . "\n"; //check to make sure we are in an external page: //echo ''; //only proccess one external } } function proccess_line($string, $url){ global $image_list, $web_cam_words; //$string='
'; // echo "proccesing line:" . $string; //match image tag: "/]*)/" //image tag <[^>]*\n?.*=("|')?(.*\.jpg)("|')?.*\n?[^<]*> if(preg_match("/<[^>]*\n?.*=(\"|')?(.*\.jpg[^\"|>]*)(\"|')?.*\n?[^<]*>/", $string, $matches)){ //get image tag //preg_match("!src=\"(.*?)\">!", $string, $matches) //print_r($matches); //find out if relative or absolute: if( (strpos($matches[2], 'http://')===false) ){ //path is not absolute add on nessary pices. preg_match("/([^\/]*\/\/([^\/]*\/)*)/", $url, $url_path); $matches[2] = $url_path[1] . $matches[2] ; } //if height or size availbe in tag use that: if( !(preg_match("/(width=[\"|']([0-9]*)\")? height=[\"|']([0-9]*)/", $matches[0], $size)===false) ){ if( (isset($size[2])) AND (isset($size[3])) ){ $image_size[0]=$size[2]; $image_size[1]=$size[3]; }else{ $image_size=getimagesize($matches[2]); } }else{ //go out and get the image size $image_size = getimagesize($matches[2]); // print "web_size"; // print_r($image_size); } if( !(preg_match("/.*\.jpg(\?[^\"|>]*)/", $string, $jpg_name)===false) ){ //if the image has ? path extention information its a likely canidate add it to the list: //and end search // print("FOUND EXTENTION"); // print_r($jpg_name); array_push($image_list, $matches[2]); }else{ // print_r($image_size); //search the path for the words cam if size > 215 add it to the list. if( !(strpos($matches[2], 'cam')===false) ){ if($image_size[0]>215 AND $image_size[1]>215){ // echo "mach found"; //likely canidate at this point added it to the image_list array_push($image_list, $matches[2]); } } } }else{ // echo "not found"; } } function sendToHost($host,$method,$path,$data,$useragent=0) { $buf= array(); // Supply a default method of GET if the one passed was empty if (empty($method)) { $method = 'GET'; } $method = strtoupper($method); $fp = fsockopen($host, 80); if (!$fp) { // echo "$errstr ($errno)
\n"; }else{ stream_set_timeout($fp, 2); //set stream time out at 2 seconds; if ($method == 'GET') { $path .= '?' . $data; } fputs($fp, "$method $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); if ($useragent) { fputs($fp, "User-Agent: MSIE\r\n"); } if ($method == 'POST') { fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: " . strlen($data) . "\r\n"); } fputs($fp, "Connection: close\r\n\r\n"); if ($method == 'POST') { fputs($fp, $data); } while (!feof($fp)) { $buf[] = fgets($fp,128); } fclose($fp); return $buf; } } function array_to_xml($array, $level=1) { $xml = ''; if ($level==1) { $xml .= ''. "\n\n"; } foreach ($array as $key=>$value) { $key = strtolower($key); if (is_array($value)) { $multi_tags = false; foreach($value as $key2=>$value2) { if (is_array($value2)) { $xml .= str_repeat("\t",$level)."<$key>\n"; $xml .= array_to_xml($value2, $level+1); $xml .= str_repeat("\t",$level)."\n"; $multi_tags = true; } else { if (trim($value2)!='') { if (htmlspecialchars($value2)!=$value2) { $xml .= str_repeat("\t",$level). "<$key>". "\n"; } else { $xml .= str_repeat("\t",$level). "<$key>$value2\n"; } } $multi_tags = true; } } if (!$multi_tags and count($value)>0) { $xml .= str_repeat("\t",$level)."<$key>\n"; $xml .= array_to_xml($value, $level+1); $xml .= str_repeat("\t",$level)."\n"; } } else { if (trim($value)!='') { if (htmlspecialchars($value)!=$value) { $xml .= str_repeat("\t",$level)."<$key>". "\n"; } else { $xml .= str_repeat("\t",$level). "<$key>$value\n"; } } } } if ($level==1) { $xml .= "\n"; } return $xml; } ?>