Edit File by line
/home/barbar84/public_h.../wp-inclu...
File: class-snoopy.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Deprecated. Use WP_HTTP (http.php) instead.
[3] Fix | Delete
*/
[4] Fix | Delete
_deprecated_file( basename( __FILE__ ), '3.0.0', WPINC . '/http.php' );
[5] Fix | Delete
[6] Fix | Delete
if ( ! class_exists( 'Snoopy', false ) ) :
[7] Fix | Delete
/*************************************************
[8] Fix | Delete
[9] Fix | Delete
Snoopy - the PHP net client
[10] Fix | Delete
Author: Monte Ohrt <monte@ispi.net>
[11] Fix | Delete
Copyright (c): 1999-2008 New Digital Group, all rights reserved
[12] Fix | Delete
Version: 1.2.4
[13] Fix | Delete
[14] Fix | Delete
* This library is free software; you can redistribute it and/or
[15] Fix | Delete
* modify it under the terms of the GNU Lesser General Public
[16] Fix | Delete
* License as published by the Free Software Foundation; either
[17] Fix | Delete
* version 2.1 of the License, or (at your option) any later version.
[18] Fix | Delete
*
[19] Fix | Delete
* This library is distributed in the hope that it will be useful,
[20] Fix | Delete
* but WITHOUT ANY WARRANTY; without even the implied warranty of
[21] Fix | Delete
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
[22] Fix | Delete
* Lesser General Public License for more details.
[23] Fix | Delete
*
[24] Fix | Delete
* You should have received a copy of the GNU Lesser General Public
[25] Fix | Delete
* License along with this library; if not, write to the Free Software
[26] Fix | Delete
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
[27] Fix | Delete
[28] Fix | Delete
You may contact the author of Snoopy by e-mail at:
[29] Fix | Delete
monte@ohrt.com
[30] Fix | Delete
[31] Fix | Delete
The latest version of Snoopy can be obtained from:
[32] Fix | Delete
http://snoopy.sourceforge.net/
[33] Fix | Delete
[34] Fix | Delete
*************************************************/
[35] Fix | Delete
[36] Fix | Delete
class Snoopy
[37] Fix | Delete
{
[38] Fix | Delete
/**** Public variables ****/
[39] Fix | Delete
[40] Fix | Delete
/* user definable vars */
[41] Fix | Delete
[42] Fix | Delete
var $host = "www.php.net"; // host name we are connecting to
[43] Fix | Delete
var $port = 80; // port we are connecting to
[44] Fix | Delete
var $proxy_host = ""; // proxy host to use
[45] Fix | Delete
var $proxy_port = ""; // proxy port to use
[46] Fix | Delete
var $proxy_user = ""; // proxy user to use
[47] Fix | Delete
var $proxy_pass = ""; // proxy password to use
[48] Fix | Delete
[49] Fix | Delete
var $agent = "Snoopy v1.2.4"; // agent we masquerade as
[50] Fix | Delete
var $referer = ""; // referer info to pass
[51] Fix | Delete
var $cookies = array(); // array of cookies to pass
[52] Fix | Delete
// $cookies["username"]="joe";
[53] Fix | Delete
var $rawheaders = array(); // array of raw headers to send
[54] Fix | Delete
// $rawheaders["Content-type"]="text/html";
[55] Fix | Delete
[56] Fix | Delete
var $maxredirs = 5; // http redirection depth maximum. 0 = disallow
[57] Fix | Delete
var $lastredirectaddr = ""; // contains address of last redirected address
[58] Fix | Delete
var $offsiteok = true; // allows redirection off-site
[59] Fix | Delete
var $maxframes = 0; // frame content depth maximum. 0 = disallow
[60] Fix | Delete
var $expandlinks = true; // expand links to fully qualified URLs.
[61] Fix | Delete
// this only applies to fetchlinks()
[62] Fix | Delete
// submitlinks(), and submittext()
[63] Fix | Delete
var $passcookies = true; // pass set cookies back through redirects
[64] Fix | Delete
// NOTE: this currently does not respect
[65] Fix | Delete
// dates, domains or paths.
[66] Fix | Delete
[67] Fix | Delete
var $user = ""; // user for http authentication
[68] Fix | Delete
var $pass = ""; // password for http authentication
[69] Fix | Delete
[70] Fix | Delete
// http accept types
[71] Fix | Delete
var $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
[72] Fix | Delete
[73] Fix | Delete
var $results = ""; // where the content is put
[74] Fix | Delete
[75] Fix | Delete
var $error = ""; // error messages sent here
[76] Fix | Delete
var $response_code = ""; // response code returned from server
[77] Fix | Delete
var $headers = array(); // headers returned from server sent here
[78] Fix | Delete
var $maxlength = 500000; // max return data length (body)
[79] Fix | Delete
var $read_timeout = 0; // timeout on read operations, in seconds
[80] Fix | Delete
// supported only since PHP 4 Beta 4
[81] Fix | Delete
// set to 0 to disallow timeouts
[82] Fix | Delete
var $timed_out = false; // if a read operation timed out
[83] Fix | Delete
var $status = 0; // http request status
[84] Fix | Delete
[85] Fix | Delete
var $temp_dir = "/tmp"; // temporary directory that the webserver
[86] Fix | Delete
// has permission to write to.
[87] Fix | Delete
// under Windows, this should be C:\temp
[88] Fix | Delete
[89] Fix | Delete
var $curl_path = "/usr/local/bin/curl";
[90] Fix | Delete
// Snoopy will use cURL for fetching
[91] Fix | Delete
// SSL content if a full system path to
[92] Fix | Delete
// the cURL binary is supplied here.
[93] Fix | Delete
// set to false if you do not have
[94] Fix | Delete
// cURL installed. See http://curl.haxx.se
[95] Fix | Delete
// for details on installing cURL.
[96] Fix | Delete
// Snoopy does *not* use the cURL
[97] Fix | Delete
// library functions built into php,
[98] Fix | Delete
// as these functions are not stable
[99] Fix | Delete
// as of this Snoopy release.
[100] Fix | Delete
[101] Fix | Delete
/**** Private variables ****/
[102] Fix | Delete
[103] Fix | Delete
var $_maxlinelen = 4096; // max line length (headers)
[104] Fix | Delete
[105] Fix | Delete
var $_httpmethod = "GET"; // default http request method
[106] Fix | Delete
var $_httpversion = "HTTP/1.0"; // default http request version
[107] Fix | Delete
var $_submit_method = "POST"; // default submit method
[108] Fix | Delete
var $_submit_type = "application/x-www-form-urlencoded"; // default submit type
[109] Fix | Delete
var $_mime_boundary = ""; // MIME boundary for multipart/form-data submit type
[110] Fix | Delete
var $_redirectaddr = false; // will be set if page fetched is a redirect
[111] Fix | Delete
var $_redirectdepth = 0; // increments on an http redirect
[112] Fix | Delete
var $_frameurls = array(); // frame src urls
[113] Fix | Delete
var $_framedepth = 0; // increments on frame depth
[114] Fix | Delete
[115] Fix | Delete
var $_isproxy = false; // set if using a proxy server
[116] Fix | Delete
var $_fp_timeout = 30; // timeout for socket connection
[117] Fix | Delete
[118] Fix | Delete
/*======================================================================*\
[119] Fix | Delete
Function: fetch
[120] Fix | Delete
Purpose: fetch the contents of a web page
[121] Fix | Delete
(and possibly other protocols in the
[122] Fix | Delete
future like ftp, nntp, gopher, etc.)
[123] Fix | Delete
Input: $URI the location of the page to fetch
[124] Fix | Delete
Output: $this->results the output text from the fetch
[125] Fix | Delete
\*======================================================================*/
[126] Fix | Delete
[127] Fix | Delete
function fetch($URI)
[128] Fix | Delete
{
[129] Fix | Delete
[130] Fix | Delete
//preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
[131] Fix | Delete
$URI_PARTS = parse_url($URI);
[132] Fix | Delete
if (!empty($URI_PARTS["user"]))
[133] Fix | Delete
$this->user = $URI_PARTS["user"];
[134] Fix | Delete
if (!empty($URI_PARTS["pass"]))
[135] Fix | Delete
$this->pass = $URI_PARTS["pass"];
[136] Fix | Delete
if (empty($URI_PARTS["query"]))
[137] Fix | Delete
$URI_PARTS["query"] = '';
[138] Fix | Delete
if (empty($URI_PARTS["path"]))
[139] Fix | Delete
$URI_PARTS["path"] = '';
[140] Fix | Delete
[141] Fix | Delete
switch(strtolower($URI_PARTS["scheme"]))
[142] Fix | Delete
{
[143] Fix | Delete
case "http":
[144] Fix | Delete
$this->host = $URI_PARTS["host"];
[145] Fix | Delete
if(!empty($URI_PARTS["port"]))
[146] Fix | Delete
$this->port = $URI_PARTS["port"];
[147] Fix | Delete
if($this->_connect($fp))
[148] Fix | Delete
{
[149] Fix | Delete
if($this->_isproxy)
[150] Fix | Delete
{
[151] Fix | Delete
// using proxy, send entire URI
[152] Fix | Delete
$this->_httprequest($URI,$fp,$URI,$this->_httpmethod);
[153] Fix | Delete
}
[154] Fix | Delete
else
[155] Fix | Delete
{
[156] Fix | Delete
$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
[157] Fix | Delete
// no proxy, send only the path
[158] Fix | Delete
$this->_httprequest($path, $fp, $URI, $this->_httpmethod);
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
$this->_disconnect($fp);
[162] Fix | Delete
[163] Fix | Delete
if($this->_redirectaddr)
[164] Fix | Delete
{
[165] Fix | Delete
/* url was redirected, check if we've hit the max depth */
[166] Fix | Delete
if($this->maxredirs > $this->_redirectdepth)
[167] Fix | Delete
{
[168] Fix | Delete
// only follow redirect if it's on this site, or offsiteok is true
[169] Fix | Delete
if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
[170] Fix | Delete
{
[171] Fix | Delete
/* follow the redirect */
[172] Fix | Delete
$this->_redirectdepth++;
[173] Fix | Delete
$this->lastredirectaddr=$this->_redirectaddr;
[174] Fix | Delete
$this->fetch($this->_redirectaddr);
[175] Fix | Delete
}
[176] Fix | Delete
}
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
[180] Fix | Delete
{
[181] Fix | Delete
$frameurls = $this->_frameurls;
[182] Fix | Delete
$this->_frameurls = array();
[183] Fix | Delete
[184] Fix | Delete
foreach ( $frameurls as $frameurl )
[185] Fix | Delete
{
[186] Fix | Delete
if($this->_framedepth < $this->maxframes)
[187] Fix | Delete
{
[188] Fix | Delete
$this->fetch($frameurl);
[189] Fix | Delete
$this->_framedepth++;
[190] Fix | Delete
}
[191] Fix | Delete
else
[192] Fix | Delete
break;
[193] Fix | Delete
}
[194] Fix | Delete
}
[195] Fix | Delete
}
[196] Fix | Delete
else
[197] Fix | Delete
{
[198] Fix | Delete
return false;
[199] Fix | Delete
}
[200] Fix | Delete
return true;
[201] Fix | Delete
break;
[202] Fix | Delete
case "https":
[203] Fix | Delete
if(!$this->curl_path)
[204] Fix | Delete
return false;
[205] Fix | Delete
if(function_exists("is_executable"))
[206] Fix | Delete
if (!is_executable($this->curl_path))
[207] Fix | Delete
return false;
[208] Fix | Delete
$this->host = $URI_PARTS["host"];
[209] Fix | Delete
if(!empty($URI_PARTS["port"]))
[210] Fix | Delete
$this->port = $URI_PARTS["port"];
[211] Fix | Delete
if($this->_isproxy)
[212] Fix | Delete
{
[213] Fix | Delete
// using proxy, send entire URI
[214] Fix | Delete
$this->_httpsrequest($URI,$URI,$this->_httpmethod);
[215] Fix | Delete
}
[216] Fix | Delete
else
[217] Fix | Delete
{
[218] Fix | Delete
$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
[219] Fix | Delete
// no proxy, send only the path
[220] Fix | Delete
$this->_httpsrequest($path, $URI, $this->_httpmethod);
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
if($this->_redirectaddr)
[224] Fix | Delete
{
[225] Fix | Delete
/* url was redirected, check if we've hit the max depth */
[226] Fix | Delete
if($this->maxredirs > $this->_redirectdepth)
[227] Fix | Delete
{
[228] Fix | Delete
// only follow redirect if it's on this site, or offsiteok is true
[229] Fix | Delete
if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
[230] Fix | Delete
{
[231] Fix | Delete
/* follow the redirect */
[232] Fix | Delete
$this->_redirectdepth++;
[233] Fix | Delete
$this->lastredirectaddr=$this->_redirectaddr;
[234] Fix | Delete
$this->fetch($this->_redirectaddr);
[235] Fix | Delete
}
[236] Fix | Delete
}
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
[240] Fix | Delete
{
[241] Fix | Delete
$frameurls = $this->_frameurls;
[242] Fix | Delete
$this->_frameurls = array();
[243] Fix | Delete
[244] Fix | Delete
foreach ( $frameurls as $frameurl )
[245] Fix | Delete
{
[246] Fix | Delete
if($this->_framedepth < $this->maxframes)
[247] Fix | Delete
{
[248] Fix | Delete
$this->fetch($frameurl);
[249] Fix | Delete
$this->_framedepth++;
[250] Fix | Delete
}
[251] Fix | Delete
else
[252] Fix | Delete
break;
[253] Fix | Delete
}
[254] Fix | Delete
}
[255] Fix | Delete
return true;
[256] Fix | Delete
break;
[257] Fix | Delete
default:
[258] Fix | Delete
// not a valid protocol
[259] Fix | Delete
$this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
[260] Fix | Delete
return false;
[261] Fix | Delete
break;
[262] Fix | Delete
}
[263] Fix | Delete
return true;
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
/*======================================================================*\
[267] Fix | Delete
Function: submit
[268] Fix | Delete
Purpose: submit an http form
[269] Fix | Delete
Input: $URI the location to post the data
[270] Fix | Delete
$formvars the formvars to use.
[271] Fix | Delete
format: $formvars["var"] = "val";
[272] Fix | Delete
$formfiles an array of files to submit
[273] Fix | Delete
format: $formfiles["var"] = "/dir/filename.ext";
[274] Fix | Delete
Output: $this->results the text output from the post
[275] Fix | Delete
\*======================================================================*/
[276] Fix | Delete
[277] Fix | Delete
function submit($URI, $formvars="", $formfiles="")
[278] Fix | Delete
{
[279] Fix | Delete
unset($postdata);
[280] Fix | Delete
[281] Fix | Delete
$postdata = $this->_prepare_post_body($formvars, $formfiles);
[282] Fix | Delete
[283] Fix | Delete
$URI_PARTS = parse_url($URI);
[284] Fix | Delete
if (!empty($URI_PARTS["user"]))
[285] Fix | Delete
$this->user = $URI_PARTS["user"];
[286] Fix | Delete
if (!empty($URI_PARTS["pass"]))
[287] Fix | Delete
$this->pass = $URI_PARTS["pass"];
[288] Fix | Delete
if (empty($URI_PARTS["query"]))
[289] Fix | Delete
$URI_PARTS["query"] = '';
[290] Fix | Delete
if (empty($URI_PARTS["path"]))
[291] Fix | Delete
$URI_PARTS["path"] = '';
[292] Fix | Delete
[293] Fix | Delete
switch(strtolower($URI_PARTS["scheme"]))
[294] Fix | Delete
{
[295] Fix | Delete
case "http":
[296] Fix | Delete
$this->host = $URI_PARTS["host"];
[297] Fix | Delete
if(!empty($URI_PARTS["port"]))
[298] Fix | Delete
$this->port = $URI_PARTS["port"];
[299] Fix | Delete
if($this->_connect($fp))
[300] Fix | Delete
{
[301] Fix | Delete
if($this->_isproxy)
[302] Fix | Delete
{
[303] Fix | Delete
// using proxy, send entire URI
[304] Fix | Delete
$this->_httprequest($URI,$fp,$URI,$this->_submit_method,$this->_submit_type,$postdata);
[305] Fix | Delete
}
[306] Fix | Delete
else
[307] Fix | Delete
{
[308] Fix | Delete
$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
[309] Fix | Delete
// no proxy, send only the path
[310] Fix | Delete
$this->_httprequest($path, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata);
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
$this->_disconnect($fp);
[314] Fix | Delete
[315] Fix | Delete
if($this->_redirectaddr)
[316] Fix | Delete
{
[317] Fix | Delete
/* url was redirected, check if we've hit the max depth */
[318] Fix | Delete
if($this->maxredirs > $this->_redirectdepth)
[319] Fix | Delete
{
[320] Fix | Delete
if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
[321] Fix | Delete
$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
[322] Fix | Delete
[323] Fix | Delete
// only follow redirect if it's on this site, or offsiteok is true
[324] Fix | Delete
if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
[325] Fix | Delete
{
[326] Fix | Delete
/* follow the redirect */
[327] Fix | Delete
$this->_redirectdepth++;
[328] Fix | Delete
$this->lastredirectaddr=$this->_redirectaddr;
[329] Fix | Delete
if( strpos( $this->_redirectaddr, "?" ) > 0 )
[330] Fix | Delete
$this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get
[331] Fix | Delete
else
[332] Fix | Delete
$this->submit($this->_redirectaddr,$formvars, $formfiles);
[333] Fix | Delete
}
[334] Fix | Delete
}
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
[338] Fix | Delete
{
[339] Fix | Delete
$frameurls = $this->_frameurls;
[340] Fix | Delete
$this->_frameurls = array();
[341] Fix | Delete
[342] Fix | Delete
foreach ( $frameurls as $frameurl )
[343] Fix | Delete
{
[344] Fix | Delete
if($this->_framedepth < $this->maxframes)
[345] Fix | Delete
{
[346] Fix | Delete
$this->fetch($frameurl);
[347] Fix | Delete
$this->_framedepth++;
[348] Fix | Delete
}
[349] Fix | Delete
else
[350] Fix | Delete
break;
[351] Fix | Delete
}
[352] Fix | Delete
}
[353] Fix | Delete
[354] Fix | Delete
}
[355] Fix | Delete
else
[356] Fix | Delete
{
[357] Fix | Delete
return false;
[358] Fix | Delete
}
[359] Fix | Delete
return true;
[360] Fix | Delete
break;
[361] Fix | Delete
case "https":
[362] Fix | Delete
if(!$this->curl_path)
[363] Fix | Delete
return false;
[364] Fix | Delete
if(function_exists("is_executable"))
[365] Fix | Delete
if (!is_executable($this->curl_path))
[366] Fix | Delete
return false;
[367] Fix | Delete
$this->host = $URI_PARTS["host"];
[368] Fix | Delete
if(!empty($URI_PARTS["port"]))
[369] Fix | Delete
$this->port = $URI_PARTS["port"];
[370] Fix | Delete
if($this->_isproxy)
[371] Fix | Delete
{
[372] Fix | Delete
// using proxy, send entire URI
[373] Fix | Delete
$this->_httpsrequest($URI, $URI, $this->_submit_method, $this->_submit_type, $postdata);
[374] Fix | Delete
}
[375] Fix | Delete
else
[376] Fix | Delete
{
[377] Fix | Delete
$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
[378] Fix | Delete
// no proxy, send only the path
[379] Fix | Delete
$this->_httpsrequest($path, $URI, $this->_submit_method, $this->_submit_type, $postdata);
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
if($this->_redirectaddr)
[383] Fix | Delete
{
[384] Fix | Delete
/* url was redirected, check if we've hit the max depth */
[385] Fix | Delete
if($this->maxredirs > $this->_redirectdepth)
[386] Fix | Delete
{
[387] Fix | Delete
if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
[388] Fix | Delete
$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
[389] Fix | Delete
[390] Fix | Delete
// only follow redirect if it's on this site, or offsiteok is true
[391] Fix | Delete
if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
[392] Fix | Delete
{
[393] Fix | Delete
/* follow the redirect */
[394] Fix | Delete
$this->_redirectdepth++;
[395] Fix | Delete
$this->lastredirectaddr=$this->_redirectaddr;
[396] Fix | Delete
if( strpos( $this->_redirectaddr, "?" ) > 0 )
[397] Fix | Delete
$this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get
[398] Fix | Delete
else
[399] Fix | Delete
$this->submit($this->_redirectaddr,$formvars, $formfiles);
[400] Fix | Delete
}
[401] Fix | Delete
}
[402] Fix | Delete
}
[403] Fix | Delete
[404] Fix | Delete
if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
[405] Fix | Delete
{
[406] Fix | Delete
$frameurls = $this->_frameurls;
[407] Fix | Delete
$this->_frameurls = array();
[408] Fix | Delete
[409] Fix | Delete
foreach ( $frameurls as $frameurl )
[410] Fix | Delete
{
[411] Fix | Delete
if($this->_framedepth < $this->maxframes)
[412] Fix | Delete
{
[413] Fix | Delete
$this->fetch($frameurl);
[414] Fix | Delete
$this->_framedepth++;
[415] Fix | Delete
}
[416] Fix | Delete
else
[417] Fix | Delete
break;
[418] Fix | Delete
}
[419] Fix | Delete
}
[420] Fix | Delete
return true;
[421] Fix | Delete
break;
[422] Fix | Delete
[423] Fix | Delete
default:
[424] Fix | Delete
// not a valid protocol
[425] Fix | Delete
$this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
[426] Fix | Delete
return false;
[427] Fix | Delete
break;
[428] Fix | Delete
}
[429] Fix | Delete
return true;
[430] Fix | Delete
}
[431] Fix | Delete
[432] Fix | Delete
/*======================================================================*\
[433] Fix | Delete
Function: fetchlinks
[434] Fix | Delete
Purpose: fetch the links from a web page
[435] Fix | Delete
Input: $URI where you are fetching from
[436] Fix | Delete
Output: $this->results an array of the URLs
[437] Fix | Delete
\*======================================================================*/
[438] Fix | Delete
[439] Fix | Delete
function fetchlinks($URI)
[440] Fix | Delete
{
[441] Fix | Delete
if ($this->fetch($URI))
[442] Fix | Delete
{
[443] Fix | Delete
if($this->lastredirectaddr)
[444] Fix | Delete
$URI = $this->lastredirectaddr;
[445] Fix | Delete
if(is_array($this->results))
[446] Fix | Delete
{
[447] Fix | Delete
for($x=0;$x<count($this->results);$x++)
[448] Fix | Delete
$this->results[$x] = $this->_striplinks($this->results[$x]);
[449] Fix | Delete
}
[450] Fix | Delete
else
[451] Fix | Delete
$this->results = $this->_striplinks($this->results);
[452] Fix | Delete
[453] Fix | Delete
if($this->expandlinks)
[454] Fix | Delete
$this->results = $this->_expandlinks($this->results, $URI);
[455] Fix | Delete
return true;
[456] Fix | Delete
}
[457] Fix | Delete
else
[458] Fix | Delete
return false;
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
/*======================================================================*\
[462] Fix | Delete
Function: fetchform
[463] Fix | Delete
Purpose: fetch the form elements from a web page
[464] Fix | Delete
Input: $URI where you are fetching from
[465] Fix | Delete
Output: $this->results the resulting html form
[466] Fix | Delete
\*======================================================================*/
[467] Fix | Delete
[468] Fix | Delete
function fetchform($URI)
[469] Fix | Delete
{
[470] Fix | Delete
[471] Fix | Delete
if ($this->fetch($URI))
[472] Fix | Delete
{
[473] Fix | Delete
[474] Fix | Delete
if(is_array($this->results))
[475] Fix | Delete
{
[476] Fix | Delete
for($x=0;$x<count($this->results);$x++)
[477] Fix | Delete
$this->results[$x] = $this->_stripform($this->results[$x]);
[478] Fix | Delete
}
[479] Fix | Delete
else
[480] Fix | Delete
$this->results = $this->_stripform($this->results);
[481] Fix | Delete
[482] Fix | Delete
return true;
[483] Fix | Delete
}
[484] Fix | Delete
else
[485] Fix | Delete
return false;
[486] Fix | Delete
}
[487] Fix | Delete
[488] Fix | Delete
[489] Fix | Delete
/*======================================================================*\
[490] Fix | Delete
Function: fetchtext
[491] Fix | Delete
Purpose: fetch the text from a web page, stripping the links
[492] Fix | Delete
Input: $URI where you are fetching from
[493] Fix | Delete
Output: $this->results the text from the web page
[494] Fix | Delete
\*======================================================================*/
[495] Fix | Delete
[496] Fix | Delete
function fetchtext($URI)
[497] Fix | Delete
{
[498] Fix | Delete
if($this->fetch($URI))
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function