src/Tor.php
public function curl($url)
    {
        $ip = '127.0.0.1';
        $port = '9051';
        $auth = 'PASSWORD';
        $command = 'signal NEWNYM';

        $fp = fsockopen($ip, $port, $error_number, $err_string, 2);
        if (!$fp) {
            echo "ERROR: $error_number : $err_string";

            return false;
        } else {
            fwrite($fp, "AUTHENTICATE \"".$auth."\"\n");
            fread($fp, 512);
            fwrite($fp, $command."\n");
            fread($fp, 512);
        }

        fclose($fp);

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050');
        curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_VERBOSE, 0);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent());  // $this->getUserAgent(true) for random);
        curl_setopt($ch, CURLOPT_ENCODING , 'gzip');
        $response = curl_exec($ch);

        return [$response, $ch];
    }
public function curl($url)
    {
        $ip = '127.0.0.1';
        $port = '9051';
        $auth = 'PASSWORD';
        $command = 'signal NEWNYM';

        $fp = fsockopen($ip, $port, $error_number, $err_string, 2);
        if (!$fp) {
            echo "ERROR: $error_number : $err_string";

            return false;
        } else {
            fwrite($fp, "AUTHENTICATE \"".$auth."\"\n");
            fread($fp, 512);
            fwrite($fp, $command."\n");
            fread($fp, 512);
        }

        fclose($fp);

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050');
        curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_VERBOSE, 0);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent());  // $this->getUserAgent(true) for random);
        curl_setopt($ch, CURLOPT_ENCODING , 'gzip');
        $response = curl_exec($ch);

        return [$response, $ch];
    }
public function curl ( $ url ) { $ ip = '127.0.0.1' ; $ port = '9051' ; $ auth = 'PASSWORD' ; $ command = 'signal NEWNYM' ; $ fp = fsockopen ( $ ip , $ port , $ error_number , $ err_string , 2 ) ; if ( ! $ fp ) { echo "ERROR: $error_number : $err_string" ; return false ; } else { fwrite ( $ fp , "AUTHENTICATE \"" . $ auth . "\"\n" ) ; fread ( $ fp , 512 ) ; fwrite ( $ fp , $ command . "\n" ) ; fread ( $ fp , 512 ) ; } fclose ( $ fp ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_PROXY , '127.0.0.1:9050' ) ; curl_setopt ( $ ch , CURLOPT_PROXYTYPE , CURLPROXY_SOCKS5 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_VERBOSE , 0 ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , true ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , $ this -> getUserAgent ( ) ) ; // $this->getUserAgent(true) for random); curl_setopt ( $ ch , CURLOPT_ENCODING , 'gzip' ) ; $ response = curl_exec ( $ ch ) ; return [ $ response , $ ch ] ; }
Tor curl wrapper
@param $url
@return bool|mixed
Tor curl wrapper