PHP function to anonymize HTTP GET requests using the Tor network

Recovered from my old blog.

function torHttpGet($url, $ref) {  
$torIPPort=""; //tor's ip and port
$agentBrowser = array('Firefox','Safari','Opera','Flock','Internet Explorer','Ephifany','AOL Explorer','Seamonkey','Konqueror','GoogleBot');
$agentOS = array('Windows 2000','Windows NT','Windows XP','Windows Vista','Redhat Linux','Ubuntu','Fedora','FreeBSD','OpenBSD','OS 10.5');

$useragent=$agentBrowser[rand(0,7)].'/'.rand(1,8).'.'.rand(0,9).' (' .$agentOS[rand(0,11)].' '.rand(1,7).'.'.rand(0,9).'; en-US;)';
$curl_obj = curl_init();
curl_setopt($curl_obj, CURLOPT_URL, $url); curl_setopt($curl_obj, CURLOPT_REFERER, $ref);
curl_setopt($curl_obj, CURLOPT_HEADER, TRUE); curl_setopt($curl_obj, CURLOPT_HTTPGET, TRUE);
curl_setopt($curl_obj, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl_obj, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl_obj, CURLOPT_MAXREDIRS, 3); curl_setopt($curl_obj, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl_obj, CURLOPT_TIMEOUT, 10); curl_setopt($curl_obj, CURLOPT_USERAGENT, $useragent);
curl_setopt($curl_obj, CURLOPT_PROXY, $torIPPort); curl_setopt($curl_obj, CURLOPT_CURLOPT_ERRORBUFFER, TRUE); //human readable errors
$page = curl_exec($curl_obj);
$err = curl_error($curl_obj);

if(strlen($err) > 0)
return -1;
return $page;


Watermarking videos with ffmpeg in Ubuntu 9.1

Last week I wanted to automatize watermarking some .flv videos but ffmpeg’s vhook support is deprecated in newer versions including the one in the repositories of Ubuntu 9.1.

Since it took me some time to figure out what packages and compilation flags I needed I wrote this short tutorial about watermarking videos with ffmpeg in Ubuntu 9.1. Including compiling ffmpeg from source to support deprecated vhooks.

Get ffmpeg’s source code

Download and untar ffmpeg 0.5.2 stable. We are using this version because they have removed vhook support from their repositories.

Install the dependencies

Install the following packages:

sudo apt-get install libfreetype6-dev libfaac-dev libfaad-dev
libmp3lame-dev libtheora-dev libx264-dev libxvidcore4-dev libpostproc-dev

Compile ffmpeg from source

cd <ffmpeg's src dir>
./configure --enable-gpl --enable-nonfree --enable-pthreads
--enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libtheora
--enable-libx264 --enable-libxvid --enable-postproc
sudo make install

Watermarking videos with ffmpeg with

ffmpeg -i video.flv -vhook '/usr/local/lib/vhook/ 
-f /usr/share/fonts/truetype/msttcorefonts/arial.ttf -x 5 -y 5 -t yourtext'