Skip to content

Easy “PHP Proxy Checker” Writing Tutorial

I started to write this on Eli’s forum but decided to add it here so everyone could reference it.

If you have a list of proxies that you’ve got from somewhere and want to verify if they’re good or not this is simple script that will read a text file and check them.

First we’ll make a text file with our proxies on each line of the file in the format IP:PORT with one per line.

then save that text file as “proxylist.txt” in the same directory as the php file you’re going to make. Then we’ll start our php file with our proxy checking in it. Here’s the complete script that just echo’s the status of each proxy out to the screen. We’ll make a few changes and have it write a new file with only the good proxies next.

// This is the page that that we're going to request going through the proxy
$testpage = "";
// This loads all the proxies from the file into an array
$proxies = file("proxylist.txt");
// Here we loop through each cell of the array with the proxies in them testing each one until we get to the end of the array
foreach($proxies as $proxy)
// This script utilizes cURL which is library you can read more about
//using curl in my intro tutorials
// starting curl and setting the page to get
$ch = curl_init($testpage);
// sets the proxy to go through
// sets to use a tunnel proxy which most http proxies are
// makes the curl call do it's work based on what we've set previously and
//returns that fetched page to $page
$page = curl_exec($ch);
// cleans up the curl set
// this will check that there was some html returned, now some sites might block some
//proxies so you'd want to set for that specific site in the $testpage var and then
//find something on that page to look for with the below function.
$check = stripos($page,'</html>');
// if there was a match in the stripos (string postion) function echo that the
//proxy got the data and works
if($check > 0)
echo $proxy." Works!
// or else echo it doesn't work
echo $proxy." Is Dead!

There’s your code. The gist of this is that we load each line from a file into an array. Then we loop through each array element checking if we can get the google page going through the proxy. Then if it pulls data it prints on the screen that the proxy works or if it doesn’t get something returned it doesn’t.

Now we might not want to print things to the screen and would rather make a new file with the the good proxies. To do that we’d swap this code:

if($check > 0)


 echo $proxy." Works!";

// or else echo it doesn't work


 echo $proxy." Is Dead!";



if($check > 0){file_put_content("newproxylist.txt",$proxy."n",FILE_APPEND);}




And that will write a new file and add each of the good proxies to it. Then rename the the original file to proxylistold.txt in case there was an error it’s good to have a backup. Then we rename the newpoxylist.txt to the standard proxylist.txt and it’s all fresh and ready to go. There you have it a nice simple proxy checker.

P.S. make sure you make the dir that they’re in writable as there’ll be issues with creating a new file in an unwritable dir.

P.P.S Trying this new code plug-in and well let me tell yah. IT’S A HUGE PAIN IN THE ASS!


  1. man I really should get something to improve my code presentation. Oh well what the fuck do you want for free πŸ˜›

  2. Seocracy Seocracy

    Nice job dude. This is great.

    If you want to look into an easy way to present your code, google has a library for it out there….really plug n play easy to use.

    its the same thing I used over at

  3. hey Seocracy do you have a link for that? I’d love to get something that I could present code a little better :/

  4. Seocracy Seocracy

    I’ll fish around for it tonight if you remind on on IRC…I’m at a hockey game till late (box seats baby!) but Ill be around later.

  5. Paul Paul

    where i will write this scripts?

  6. Jay Jay

    I couldn’t get the script to work and finally found out why.

    One of the CURL constants is misnamed in the tutorial.

    Specifically, the code:


    should have been written


    To a novice programmer, unfamiliar with CURL, this could be a problem.


  7. napoleon napoleon

    It is working, but the test page is loading along with the result.

  8. neon neon

    You need also this line before the curl_exec:

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    So it will not echo the output, but return as $page variable.

  9. Bluuuejammm Bluuuejammm

    Good stuff, just what I have been looking for, thx man.

  10. proxy sites wouldnt be needed if we were not spied on at every turn. Some people don’t believe in a right to privacy

  11. Most of the web proxies I know have been banned by my works filters but I found this one that seems to work http:/

  12. I made a proxy site myself, I believe the right to privacy on the internet is important, new ruling about the police in britain being able to hack into people compmuters without warrant is crazy. Anyone remeber george orwells 1984?

  13. You should add this line of code:

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    to assign the output into the $page variable:

    $page = curl_exec($ch);

  14. Justin Justin

    This does nothing to check the anonymity of the proxies though.

  15. Great post , looks 90% like something i wrote a year ago , and klevis is right – you should add the CURLOPT_RETURNTRANSFER flag.

    @justin –
    if you want to check for anonymity you can store a php file on a remote server that shows you your IP , or you can just load a page like that does the same for you (there are many like this one , just google check ip )

  16. Works great thank you was exactly what I needed now I just have to find a place I can get my script to auto update the txt file from.

    Justin the topic never said it did check anonymity.

  17. xpathsfucker xpathsfucker

    Actually you don’t need the CURLOPT_HTTPPROXYTUNNEL flag.

    The script is quite simple, self explanatory and a huge time saver, if you don’t use something like this you are an idiot.

Comments are closed.