|
Lines 5-11
Link Here
|
| 5 |
Snoopy - the PHP net client |
5 |
Snoopy - the PHP net client |
| 6 |
Author: Monte Ohrt <monte@ispi.net> |
6 |
Author: Monte Ohrt <monte@ispi.net> |
| 7 |
Copyright (c): 1999-2000 ispi, all rights reserved |
7 |
Copyright (c): 1999-2000 ispi, all rights reserved |
| 8 |
Version: 1.2 |
8 |
Version: 1.01 |
| 9 |
|
9 |
|
| 10 |
* This library is free software; you can redistribute it and/or |
10 |
* This library is free software; you can redistribute it and/or |
| 11 |
* modify it under the terms of the GNU Lesser General Public |
11 |
* modify it under the terms of the GNU Lesser General Public |
|
Lines 48-54
Link Here
|
| 48 |
var $proxy_user = ""; // proxy user to use |
48 |
var $proxy_user = ""; // proxy user to use |
| 49 |
var $proxy_pass = ""; // proxy password to use |
49 |
var $proxy_pass = ""; // proxy password to use |
| 50 |
|
50 |
|
| 51 |
var $agent = "Snoopy v1.2"; // agent we masquerade as |
51 |
var $agent = "Snoopy v1.01"; // agent we masquerade as |
| 52 |
var $referer = ""; // referer info to pass |
52 |
var $referer = ""; // referer info to pass |
| 53 |
var $cookies = array(); // array of cookies to pass |
53 |
var $cookies = array(); // array of cookies to pass |
| 54 |
// $cookies["username"]="joe"; |
54 |
// $cookies["username"]="joe"; |
|
Lines 61-67
Link Here
|
| 61 |
var $maxframes = 0; // frame content depth maximum. 0 = disallow |
61 |
var $maxframes = 0; // frame content depth maximum. 0 = disallow |
| 62 |
var $expandlinks = true; // expand links to fully qualified URLs. |
62 |
var $expandlinks = true; // expand links to fully qualified URLs. |
| 63 |
// this only applies to fetchlinks() |
63 |
// this only applies to fetchlinks() |
| 64 |
// or submitlinks() |
64 |
// submitlinks(), and submittext() |
| 65 |
var $passcookies = true; // pass set cookies back through redirects |
65 |
var $passcookies = true; // pass set cookies back through redirects |
| 66 |
// NOTE: this currently does not respect |
66 |
// NOTE: this currently does not respect |
| 67 |
// dates, domains or paths. |
67 |
// dates, domains or paths. |
|
Lines 137-142
Link Here
|
| 137 |
$this->pass = $URI_PARTS["pass"]; |
137 |
$this->pass = $URI_PARTS["pass"]; |
| 138 |
if (empty($URI_PARTS["query"])) |
138 |
if (empty($URI_PARTS["query"])) |
| 139 |
$URI_PARTS["query"] = ''; |
139 |
$URI_PARTS["query"] = ''; |
|
|
140 |
if (empty($URI_PARTS["path"])) |
| 141 |
$URI_PARTS["path"] = ''; |
| 140 |
|
142 |
|
| 141 |
switch($URI_PARTS["scheme"]) |
143 |
switch($URI_PARTS["scheme"]) |
| 142 |
{ |
144 |
{ |
|
Lines 287-292
Link Here
|
| 287 |
$this->pass = $URI_PARTS["pass"]; |
289 |
$this->pass = $URI_PARTS["pass"]; |
| 288 |
if (empty($URI_PARTS["query"])) |
290 |
if (empty($URI_PARTS["query"])) |
| 289 |
$URI_PARTS["query"] = ''; |
291 |
$URI_PARTS["query"] = ''; |
|
|
292 |
if (empty($URI_PARTS["path"])) |
| 293 |
$URI_PARTS["path"] = ''; |
| 290 |
|
294 |
|
| 291 |
switch($URI_PARTS["scheme"]) |
295 |
switch($URI_PARTS["scheme"]) |
| 292 |
{ |
296 |
{ |
|
Lines 438-444
Link Here
|
| 438 |
{ |
442 |
{ |
| 439 |
if ($this->fetch($URI)) |
443 |
if ($this->fetch($URI)) |
| 440 |
{ |
444 |
{ |
| 441 |
|
445 |
if($this->lastredirectaddr) |
|
|
446 |
$URI = $this->lastredirectaddr; |
| 442 |
if(is_array($this->results)) |
447 |
if(is_array($this->results)) |
| 443 |
{ |
448 |
{ |
| 444 |
for($x=0;$x<count($this->results);$x++) |
449 |
for($x=0;$x<count($this->results);$x++) |
|
Lines 518-523
Link Here
|
| 518 |
{ |
523 |
{ |
| 519 |
if($this->submit($URI,$formvars, $formfiles)) |
524 |
if($this->submit($URI,$formvars, $formfiles)) |
| 520 |
{ |
525 |
{ |
|
|
526 |
if($this->lastredirectaddr) |
| 527 |
$URI = $this->lastredirectaddr; |
| 521 |
if(is_array($this->results)) |
528 |
if(is_array($this->results)) |
| 522 |
{ |
529 |
{ |
| 523 |
for($x=0;$x<count($this->results);$x++) |
530 |
for($x=0;$x<count($this->results);$x++) |
|
Lines 550-555
Link Here
|
| 550 |
{ |
557 |
{ |
| 551 |
if($this->submit($URI,$formvars, $formfiles)) |
558 |
if($this->submit($URI,$formvars, $formfiles)) |
| 552 |
{ |
559 |
{ |
|
|
560 |
if($this->lastredirectaddr) |
| 561 |
$URI = $this->lastredirectaddr; |
| 553 |
if(is_array($this->results)) |
562 |
if(is_array($this->results)) |
| 554 |
{ |
563 |
{ |
| 555 |
for($x=0;$x<count($this->results);$x++) |
564 |
for($x=0;$x<count($this->results);$x++) |
|
Lines 739-752
Link Here
|
| 739 |
|
748 |
|
| 740 |
$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]); |
749 |
$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]); |
| 741 |
$match = preg_replace("|/$|","",$match); |
750 |
$match = preg_replace("|/$|","",$match); |
|
|
751 |
$match_part = parse_url($match); |
| 752 |
$match_root = |
| 753 |
$match_part["scheme"]."://".$match_part["host"]; |
| 742 |
|
754 |
|
| 743 |
$search = array( "|^http://".preg_quote($this->host)."|i", |
755 |
$search = array( "|^http://".preg_quote($this->host)."|i", |
| 744 |
"|^(?!http://)(\/)?(?!mailto:)|i", |
756 |
"|^(\/)|i", |
|
|
757 |
"|^(?!http://)(?!mailto:)|i", |
| 745 |
"|/\./|", |
758 |
"|/\./|", |
| 746 |
"|/[^\/]+/\.\./|" |
759 |
"|/[^\/]+/\.\./|" |
| 747 |
); |
760 |
); |
| 748 |
|
761 |
|
| 749 |
$replace = array( "", |
762 |
$replace = array( "", |
|
|
763 |
$match_root."/", |
| 750 |
$match."/", |
764 |
$match."/", |
| 751 |
"/", |
765 |
"/", |
| 752 |
"/" |
766 |
"/" |
|
Lines 979-985
Link Here
|
| 979 |
$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); |
993 |
$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); |
| 980 |
|
994 |
|
| 981 |
for($curr_header = 0; $curr_header < count($headers); $curr_header++) |
995 |
for($curr_header = 0; $curr_header < count($headers); $curr_header++) |
| 982 |
$cmdline_params .= " -H \"".$headers[$curr_header]."\""; |
996 |
$safer_header = strtr( $headers[$curr_header], "\"", " " ); |
|
|
997 |
$cmdline_params .= " -H \"".$safer_header."\""; |
| 983 |
|
998 |
|
| 984 |
if(!empty($body)) |
999 |
if(!empty($body)) |
| 985 |
$cmdline_params .= " -d \"$body\""; |
1000 |
$cmdline_params .= " -d \"$body\""; |
|
Lines 1037-1043
Link Here
|
| 1037 |
|
1052 |
|
| 1038 |
// check if there is a a redirect meta tag |
1053 |
// check if there is a a redirect meta tag |
| 1039 |
|
1054 |
|
| 1040 |
if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) |
1055 |
if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) |
| 1041 |
{ |
1056 |
{ |
| 1042 |
$this->_redirectaddr = $this->_expandlinks($match[1],$URI); |
1057 |
$this->_redirectaddr = $this->_expandlinks($match[1],$URI); |
| 1043 |
} |
1058 |
} |