]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class-snoopy.php
WordPress 4.6.2
[autoinstalls/wordpress.git] / wp-includes / class-snoopy.php
index 5ec5dce4d8c1dca0d39a4747fd3e6b62ef2bfeb2..f26eb0e25a4001d1b28c72369a3e87dacd6037a3 100644 (file)
@@ -1,22 +1,18 @@
 <?php
+
 /**
- * Snoopy - the PHP net client
- * @author Monte Ohrt <monte@ispi.net>
- * @copyright 1999-2000 ispi, all rights reserved
- * @version 1.01
- * @license GNU Lesser GPL
- * @link http://snoopy.sourceforge.net/
- * @package Snoopy
+ * Deprecated. Use WP_HTTP (http.php) instead.
  */
+_deprecated_file( basename( __FILE__ ), '3.0.0', WPINC . '/http.php' );
+
+if ( ! class_exists( 'Snoopy', false ) ) :
+/*************************************************
+
+Snoopy - the PHP net client
+Author: Monte Ohrt <monte@ispi.net>
+Copyright (c): 1999-2008 New Digital Group, all rights reserved
+Version: 1.2.4
 
-if ( !in_array('Snoopy', get_declared_classes() ) ) :
-/**
- * Snoopy - the PHP net client
- *
- * @author Monte Ohrt <monte@ispi.net>
- * @copyright (c): 1999-2000 ispi, all rights reserved
- * @version 1.01
- *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
@@ -30,19 +26,15 @@ if ( !in_array('Snoopy', get_declared_classes() ) ) :
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * You may contact the author of Snoopy by e-mail at:
- * monte@ispi.net
- *
- * Or, write to:
- * Monte Ohrt
- * CTO, ispi
- * 237 S. 70th suite 220
- * Lincoln, NE 68510
- *
- * @link http://snoopy.sourceforge.net/ The latest version of Snoopy can be
- *             obtained
- */
+
+You may contact the author of Snoopy by e-mail at:
+monte@ohrt.com
+
+The latest version of Snoopy can be obtained from:
+http://snoopy.sourceforge.net/
+
+*************************************************/
+
 class Snoopy
 {
        /**** Public variables ****/
@@ -56,7 +48,7 @@ class Snoopy
        var $proxy_user         =       "";                                     // proxy user to use
        var $proxy_pass         =       "";                                     // proxy password to use
 
-       var $agent                      =       "Snoopy v1.2.3";        // agent we masquerade as
+       var $agent                      =       "Snoopy v1.2.4";        // agent we masquerade as
        var     $referer                =       "";                                     // referer info to pass
        var $cookies            =       array();                        // array of cookies to pass
                                                                                                // $cookies["username"]="joe";
@@ -85,7 +77,7 @@ class Snoopy
        var $error                      =       "";                                     // error messages sent here
        var     $response_code  =       "";                                     // response code returned from server
        var     $headers                =       array();                        // headers returned from server sent here
-       var     $maxlength              =       8192;                           // max return data length (body)
+       var     $maxlength              =       500000;                         // max return data length (body)
        var $read_timeout       =       0;                                      // timeout on read operations, in seconds
                                                                                                // supported only since PHP 4 Beta 4
                                                                                                // set to 0 to disallow timeouts
@@ -727,13 +719,13 @@ class Snoopy
                                                        chr(176),
                                                        chr(39),
                                                        chr(128),
-                                                       "ä",
-                                                       "ö",
-                                                       "ü",
-                                                       "Ä",
-                                                       "Ö",
-                                                       "Ü",
-                                                       "ß",
+                                                       chr(0xE4), // ANSI &auml;
+                                                       chr(0xF6), // ANSI &ouml;
+                                                       chr(0xFC), // ANSI &uuml;
+                                                       chr(0xC4), // ANSI &Auml;
+                                                       chr(0xD6), // ANSI &Ouml;
+                                                       chr(0xDC), // ANSI &Uuml;
+                                                       chr(0xDF), // ANSI &szlig;
                                                );
 
                $text = preg_replace($search,$replace,$document);
@@ -918,7 +910,7 @@ class Snoopy
                        return false;
                }
 
-               // check if there is a redirect meta tag
+               // check if there is a redirect meta tag
 
                if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
 
@@ -1007,21 +999,23 @@ class Snoopy
                if(!empty($this->user) || !empty($this->pass))
                        $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
 
-               for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
-                       $safer_header = strtr( $headers[$curr_header], "\"", " " );
-                       $cmdline_params .= " -H \"".$safer_header."\"";
+               $headerfile = tempnam( $this->temp_dir, "sno" );
+               $cmdline_params = '-k -D ' . escapeshellarg( $headerfile );
+
+               foreach ( $headers as $header ) {
+                       $cmdline_params .= ' -H ' . escapeshellarg( $header );
                }
 
-               if(!empty($body))
-                       $cmdline_params .= " -d \"$body\"";
+               if ( ! empty( $body ) ) {
+                       $cmdline_params .= ' -d ' . escapeshellarg( $body );
+               }
 
-               if($this->read_timeout > 0)
-                       $cmdline_params .= " -m ".$this->read_timeout;
+               if ( $this->read_timeout > 0 ) {
+                       $cmdline_params .= ' -m ' . escapeshellarg( $this->read_timeout );
+               }
 
-               $headerfile = tempnam($temp_dir, "sno");
 
-               $safer_URI = strtr( $URI, "\"", " " ); // strip quotes from the URI to avoid shell access
-               exec(escapeshellcmd($this->curl_path." -D \"$headerfile\"".$cmdline_params." \"".$safer_URI."\""),$results,$return);
+               exec( $this->curl_path . ' ' . $cmdline_params . ' ' . escapeshellarg( $URI ), $results, $return );
 
                if($return)
                {
@@ -1066,7 +1060,7 @@ class Snoopy
                        $this->headers[] = $result_headers[$currentHeader];
                }
 
-               // check if there is a redirect meta tag
+               // check if there is a redirect meta tag
 
                if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
                {
@@ -1245,9 +1239,7 @@ class Snoopy
                                                if (!is_readable($file_name)) continue;
 
                                                $fp = fopen($file_name, "r");
-                                               while (!feof($fp)) {
-                                                       $file_content .= fread($fp, filesize($file_name));
-                                               }
+                                               $file_content = fread($fp, filesize($file_name));
                                                fclose($fp);
                                                $base_name = basename($file_name);
 
@@ -1264,5 +1256,4 @@ class Snoopy
        }
 }
 endif;
-
 ?>