Mercurial > hg > anonet-resdb
view doc/www.powerfulproxy.com/public_html/do_it.php @ 822:656b9133db24 draft
See commit b422ead31b077041cb030064008c6cd26ba058d0 for more info.
/NNNC/somerandomnick> Why did you change configure to require bash?
/relayhell/d3v11> you didn't see the commit message?
/NNNC/somerandomnick> /relayhell/d3v11: not yet
/NNNC/somerandomnick> /relayhell/d3v11: I was just looking at the diff.
/NNNC/somerandomnick> /relayhell/d3v11: slackware doesn't even have a dash package available, so I'm not sure how pika managed to get himself that error.
/relayhell/d3v11> if you want to change it back, go for it.
/NNNC/somerandomnick> /relayhell/d3v11: I'd rather not start an edit war with you.
/relayhell/d3v11> LOL if you change it back i won't rechange it
/relayhell/d3v11> i made an executive decision because it gives a bunch of people shit.
/NNNC/somerandomnick> The problem is caused by distributions that give people a bunch of shit.
/NNNC/somerandomnick> "a bunch of shit" == sh pointing to a deliberately stripped down dash
/relayhell/d3v11> right
/NNNC/somerandomnick> sh should point to a useful default shell for users.
/relayhell/d3v11> should but it doesn't always
/NNNC/somerandomnick> really only in systems with upstart
/NNNC/somerandomnick> and bash can do everything dash can do, so it's always safe to fix the distribution
/NNNC/somerandomnick> "fix the distribution" == ln -s bash /bin/sh
/relayhell/d3v11> if you think the change is problematic, then i welcome you rechanging it.
/NNNC/somerandomnick> The change is problematic because it breaks any system that doesn't have bash.
author | Nick <nick@somerandomnick.ano> |
---|---|
date | Tue, 13 Dec 2011 04:12:07 +0000 |
parents | 2b68d711a063 |
children | a929c6303a71 |
line wrap: on
line source
<?php // Copyright Atiti, 2011 // Version 0.1-2 // Heavily modified by Ivo <Ivo@UCIS.nl> if (!isset($_SERVER['PATH_INFO'])) die('PATH_INFO is not set'); $pall = explode("/", $_SERVER['PATH_INFO']); if (count($pall) <= 1) die('Unexpected path format'); array_shift($pall); $proto = array_shift($pall); $host = array_shift($pall); $hostparts = explode('.', $host); if (long2ip(ip2long($host))===$host) { if ($hostparts[0]!='1') die('Bad IP'); } elseif (!preg_match("/ano|ntwrk$/",array_pop($hostparts))) die('Bad host'); $path = implode('/', $pall); array_pop($pall); $rp = implode('/', $pall); /* CONFIGURATION */ $SERVICEURL = "http://powerfulproxy.com/do_it.php/"; $REWRITE_CONTENT_TYPES = array('text/html', 'text/xml', 'text/plain'); $REWRITE_PATTERNS = array( /* Rewrite complete http/https URLs, enable one of the tree, and no more! */ // '@(https?)://(([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@i' => $SERVICEURL.'$1/$2', // '@(src|href|action)\s*=\s*(\'|")(https?)://([^\'"]*)\2@i' => '$1=$2'.$SERVICEURL.'$3/$4$2', '@(<[^>]*)(src|href|action)\s*=\s*(\'|")(https?)://([^\'"]*)\3@i' => '$1$2=$3'.$SERVICEURL.'$4/$5$3', /* Rewrite URLs relative to site root, enable one of the tree, and no more! */ // '@(src|href|action)\s*=\s*(\'|")/([^\'"]*)\2@i' => '$1=$2'.$SERVICEURL.$proto.'/'.$host.'/$3$2', '@(<[^>]*)(src|href|action)\s*=\s*(\'|")/([^\'"]*)\3@i' => '$1$2=$3'.$SERVICEURL.$proto.'/'.$host.'/$4$3', ); if (file_exists("do_it.inc")) include "do_it.inc"; if (!isset($CURL_OPTIONS)) $CURL_OPTIONS = array( // CURLOPT_USERAGENT => "AnoNet proxy", CURLOPT_USERAGENT => $_SERVER["HTTP_USER_AGENT"]." AnoNetProxy", CURLOPT_AUTOREFERER => TRUE, CURLOPT_REFERER => $_SERVER["HTTP_REFERER"], CURLOPT_CONNECTTIMEOUT => 15, CURLOPT_TIMEOUT => 28, CURLOPT_MAXREDIRS => 10, CURLOPT_FAILONERROR => FALSE, CURLOPT_HEADER => 1, CURLOPT_FOLLOWLOCATION => FALSE, // CURLOPT_INTERFACE => '0.0.0.0', CURLOPT_PROXY => "http://b.polipo.srn.ano:8000/", // CURLOPT_PROXYUSERPWD => 'username:password', ); /* END OF CONFIGURATION */ $url = $proto."://".$host."/".$path; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING'])) $url .= "?".$_SERVER['QUERY_STRING']; $ch = curl_init($url); curl_setopt_array($ch, $CURL_OPTIONS); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //curl_setopt($ch, CURLOPT_HEADER, FALSE); if (count($_POST)) { curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); } $response = curl_exec($ch); list($header, $data) = explode("\r\n\r\n", $response, 2); if ($error = curl_error($ch)) die('CURL ERROR: '.$error); $info = curl_getinfo($ch); header('Status: '.$info['http_code']); header('Content-Type: '.$info['content_type']); $redirurl = ""; if ($info['http_code'] === 301) { $headers = explode("\r\n", $header); foreach($headers as $h) { $cur_header = explode(": ", $h); if ($cur_header[0] == "Location") { $redirurl = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $SERVICEURL.str_replace("http://", "http/", "$1"), $cur_header[1]); $redirurl = str_replace(".php/http://", ".php/http/", $redirurl); header('Location: '.$redirurl); } } } else { if (in_array(strtok($info['content_type'], ';'), $REWRITE_CONTENT_TYPES)) $data = preg_replace(array_keys($REWRITE_PATTERNS), array_values($REWRITE_PATTERNS), $data, -1, $count); } header('Content-Length: '.strlen($data)); echo $data; ?>