wp/wp-includes/class-snoopy.php
changeset 16 a86126ab1dd4
parent 7 cf61fcea0001
child 21 48c4eec2b7e6
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
   181 					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
   181 					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
   182 					{
   182 					{
   183 						$frameurls = $this->_frameurls;
   183 						$frameurls = $this->_frameurls;
   184 						$this->_frameurls = array();
   184 						$this->_frameurls = array();
   185 
   185 
   186 						while(list(,$frameurl) = each($frameurls))
   186 						foreach ( $frameurls as $frameurl )
   187 						{
   187 						{
   188 							if($this->_framedepth < $this->maxframes)
   188 							if($this->_framedepth < $this->maxframes)
   189 							{
   189 							{
   190 								$this->fetch($frameurl);
   190 								$this->fetch($frameurl);
   191 								$this->_framedepth++;
   191 								$this->_framedepth++;
   241 				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
   241 				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
   242 				{
   242 				{
   243 					$frameurls = $this->_frameurls;
   243 					$frameurls = $this->_frameurls;
   244 					$this->_frameurls = array();
   244 					$this->_frameurls = array();
   245 
   245 
   246 					while(list(,$frameurl) = each($frameurls))
   246 					foreach ( $frameurls as $frameurl )
   247 					{
   247 					{
   248 						if($this->_framedepth < $this->maxframes)
   248 						if($this->_framedepth < $this->maxframes)
   249 						{
   249 						{
   250 							$this->fetch($frameurl);
   250 							$this->fetch($frameurl);
   251 							$this->_framedepth++;
   251 							$this->_framedepth++;
   339 					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
   339 					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
   340 					{
   340 					{
   341 						$frameurls = $this->_frameurls;
   341 						$frameurls = $this->_frameurls;
   342 						$this->_frameurls = array();
   342 						$this->_frameurls = array();
   343 
   343 
   344 						while(list(,$frameurl) = each($frameurls))
   344 						foreach ( $frameurls as $frameurl )
   345 						{
   345 						{
   346 							if($this->_framedepth < $this->maxframes)
   346 							if($this->_framedepth < $this->maxframes)
   347 							{
   347 							{
   348 								$this->fetch($frameurl);
   348 								$this->fetch($frameurl);
   349 								$this->_framedepth++;
   349 								$this->_framedepth++;
   406 				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
   406 				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
   407 				{
   407 				{
   408 					$frameurls = $this->_frameurls;
   408 					$frameurls = $this->_frameurls;
   409 					$this->_frameurls = array();
   409 					$this->_frameurls = array();
   410 
   410 
   411 					while(list(,$frameurl) = each($frameurls))
   411 					foreach ( $frameurls as $frameurl )
   412 					{
   412 					{
   413 						if($this->_framedepth < $this->maxframes)
   413 						if($this->_framedepth < $this->maxframes)
   414 						{
   414 						{
   415 							$this->fetch($frameurl);
   415 							$this->fetch($frameurl);
   416 							$this->_framedepth++;
   416 							$this->_framedepth++;
   627 						'isx",$document,$links);
   627 						'isx",$document,$links);
   628 
   628 
   629 
   629 
   630 		// catenate the non-empty matches from the conditional subpattern
   630 		// catenate the non-empty matches from the conditional subpattern
   631 
   631 
   632 		while(list($key,$val) = each($links[2]))
   632 		foreach ( $links[2] as $key => $val )
   633 		{
   633 		{
   634 			if(!empty($val))
   634 			if(!empty($val))
   635 				$match[] = $val;
   635 				$match[] = $val;
   636 		}
   636 		}
   637 
   637 
   638 		while(list($key,$val) = each($links[3]))
   638 		foreach ( $links[3] as $key => $val )
   639 		{
   639 		{
   640 			if(!empty($val))
   640 			if(!empty($val))
   641 				$match[] = $val;
   641 				$match[] = $val;
   642 		}
   642 		}
   643 
   643 
   819 		}
   819 		}
   820 		if(!empty($this->rawheaders))
   820 		if(!empty($this->rawheaders))
   821 		{
   821 		{
   822 			if(!is_array($this->rawheaders))
   822 			if(!is_array($this->rawheaders))
   823 				$this->rawheaders = (array)$this->rawheaders;
   823 				$this->rawheaders = (array)$this->rawheaders;
   824 			while(list($headerKey,$headerVal) = each($this->rawheaders))
   824 			foreach ( $this->rawheaders as $headerKey => $headerVal )
   825 				$headers .= $headerKey.": ".$headerVal."\r\n";
   825 				$headers .= $headerKey.": ".$headerVal."\r\n";
   826 		}
   826 		}
   827 		if(!empty($content_type)) {
   827 		if(!empty($content_type)) {
   828 			$headers .= "Content-type: $content_type";
   828 			$headers .= "Content-type: $content_type";
   829 			if ($content_type == "multipart/form-data")
   829 			if ($content_type == "multipart/form-data")
   983 		}
   983 		}
   984 		if(!empty($this->rawheaders))
   984 		if(!empty($this->rawheaders))
   985 		{
   985 		{
   986 			if(!is_array($this->rawheaders))
   986 			if(!is_array($this->rawheaders))
   987 				$this->rawheaders = (array)$this->rawheaders;
   987 				$this->rawheaders = (array)$this->rawheaders;
   988 			while(list($headerKey,$headerVal) = each($this->rawheaders))
   988 			foreach ( $this->rawheaders as $headerKey => $headerVal )
   989 				$headers[] = $headerKey.": ".$headerVal;
   989 				$headers[] = $headerKey.": ".$headerVal;
   990 		}
   990 		}
   991 		if(!empty($content_type)) {
   991 		if(!empty($content_type)) {
   992 			if ($content_type == "multipart/form-data")
   992 			if ($content_type == "multipart/form-data")
   993 				$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
   993 				$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
  1202 			return;
  1202 			return;
  1203 
  1203 
  1204 		switch ($this->_submit_type) {
  1204 		switch ($this->_submit_type) {
  1205 			case "application/x-www-form-urlencoded":
  1205 			case "application/x-www-form-urlencoded":
  1206 				reset($formvars);
  1206 				reset($formvars);
  1207 				while(list($key,$val) = each($formvars)) {
  1207 				foreach ( $formvars as $key => $val ) {
  1208 					if (is_array($val) || is_object($val)) {
  1208 					if (is_array($val) || is_object($val)) {
  1209 						while (list($cur_key, $cur_val) = each($val)) {
  1209 						foreach ( $val as $cur_key => $cur_val ) {
  1210 							$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
  1210 							$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
  1211 						}
  1211 						}
  1212 					} else
  1212 					} else
  1213 						$postdata .= urlencode($key)."=".urlencode($val)."&";
  1213 						$postdata .= urlencode($key)."=".urlencode($val)."&";
  1214 				}
  1214 				}
  1216 
  1216 
  1217 			case "multipart/form-data":
  1217 			case "multipart/form-data":
  1218 				$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
  1218 				$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
  1219 
  1219 
  1220 				reset($formvars);
  1220 				reset($formvars);
  1221 				while(list($key,$val) = each($formvars)) {
  1221 				foreach ( $formvars as $key => $val ) {
  1222 					if (is_array($val) || is_object($val)) {
  1222 					if (is_array($val) || is_object($val)) {
  1223 						while (list($cur_key, $cur_val) = each($val)) {
  1223 						foreach ( $val as $cur_key => $cur_val ) {
  1224 							$postdata .= "--".$this->_mime_boundary."\r\n";
  1224 							$postdata .= "--".$this->_mime_boundary."\r\n";
  1225 							$postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
  1225 							$postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
  1226 							$postdata .= "$cur_val\r\n";
  1226 							$postdata .= "$cur_val\r\n";
  1227 						}
  1227 						}
  1228 					} else {
  1228 					} else {
  1231 						$postdata .= "$val\r\n";
  1231 						$postdata .= "$val\r\n";
  1232 					}
  1232 					}
  1233 				}
  1233 				}
  1234 
  1234 
  1235 				reset($formfiles);
  1235 				reset($formfiles);
  1236 				while (list($field_name, $file_names) = each($formfiles)) {
  1236 				foreach ( $formfiles as $field_name => $file_names ) {
  1237 					settype($file_names, "array");
  1237 					settype($file_names, "array");
  1238 					while (list(, $file_name) = each($file_names)) {
  1238 					foreach ( $file_names as $file_name ) {
  1239 						if (!is_readable($file_name)) continue;
  1239 						if (!is_readable($file_name)) continue;
  1240 
  1240 
  1241 						$fp = fopen($file_name, "r");
  1241 						$fp = fopen($file_name, "r");
  1242 						$file_content = fread($fp, filesize($file_name));
  1242 						$file_content = fread($fp, filesize($file_name));
  1243 						fclose($fp);
  1243 						fclose($fp);