Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Simple Particle Engine for a shooter game
Snake / Nibbles clone in C and Ncurses
Please improve
Parsing of XML data has high CPU usage
Convert simple Javascript to jQuery plugin
Active Record getting unique records
List the files in a directory without the directory name or the extension
clean the code
ohs system, recruitment software, hr software, oh&s software, human resources software, ohs software
Array parsing in a block
Popular
Parsing of XML data has high CPU usage
Please improve
Snake / Nibbles clone in C and Ncurses
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Simple Particle Engine for a shooter game
Active Record getting unique records
Breadth first cartesian product iterator
php refactoring
first BST
Pastable version of
Interfacing Tor with cURL
<pre class='prettyprint' language='php'><?php /** * PHP Class for interfacing with the Tor Network */ class Tor { var $url; var $userAgent; var $timeout; var $host; var $vector; var $payload; var $returnData; /** * Tor Clas Constructor */ function Tor() { $this->url = null; $this->userAgent = null; $this->timeout = 300; $this->host = '127.0.0.1:9050'; $this->vector = null; } /** * set url */ function setUrl($url) { $this->url = $url; } /** * read url */ function readUrl() { return $this->url; } /** * set useragent */ function setUserAgent() { //list of browsers $agentBrowser = array( 'Firefox', 'Safari', 'Opera', 'Flock', 'Internet Explorer', 'Seamonkey', 'Konqueror', 'GoogleBot' ); //list of operating systems $agentOS = array( 'Windows 3.1', 'Windows 95', 'Windows 98', 'Windows 2000', 'Windows NT', 'Windows XP', 'Windows Vista', 'Redhat Linux', 'Ubuntu', 'Fedora', 'AmigaOS', 'OS 10.5' ); //randomly generate UserAgent $this->userAgent = $agentBrowser[rand(0,7)].'/'.rand(1,8).'.'.rand(0,9).' (' .$agentOS[rand(0,11)].' '.rand(1,7).'.'.rand(0,9).'; en-US;)'; } /** * read useragent */ function readUserAgent() { return $this->userAgent; } /** * set timeout */ function setTimeout($timeout) { $this->timeout = $timeout; } /** * read timeout */ function readTimeout() { return $this->timeout; } /** * set host */ function setHost($ip, $port) { $this->host = $ip . ":" . $port; } /** * read host */ function readHost() { return $this->host; } /** * set vector */ function setVector($vector) { $this->vector = $vector; } /** * read vector */ function readVector() { return $this->vector; } /** * launch payload */ function launchPayload() { //set randomized parameters $this->setUserAgent(); //concatinate url $this->payload = $this->url . $this->vector; //run curl action against url $action = curl_init(); curl_setopt($action, CURLOPT_PROXY, $this->host); curl_setopt($action, CURLOPT_URL, $this->payload); curl_setopt($action, CURLOPT_HEADER, 1); curl_setopt($action, CURLOPT_USERAGENT, $this->userAgent); curl_setopt($action, CURLOPT_RETURNTRANSFER, 1); curl_setopt($action, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($action, CURLOPT_TIMEOUT, $this->timeout); $this->returnData = curl_exec($action); curl_close($action); } function viewReturn() { return $this->returnData; } } ?></pre> <a href="http://www.refactormycode.com/codes/340-interfacing-tor-with-curl" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>