0

I have the following code and was wondering how I would make the following cURL connection go through a proxy in the format "1.1.1.1:80"

I have tried the following, but even with an invalid proxy the connection still seems to work meaning it must have not gone through the proxy.

Thank you for the help!

    function checkPlayer($player, $user_sess) {
$resultx = mysql_query("SELECT * FROM proxy
WHERE username='$user_sess' ORDER BY rand() LIMIT 1");
$rowx = mysql_fetch_array($resultx);
$proxy = $rowx['proxy'];
echo "$proxy  Result - ";
ob_flush();
flush();
$mcURL = 'https://www.minecraft.net/haspaid.jsp?user=';
$mcURL = $mcURL.$player;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $mcURL);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_PROXY, $proxy);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); //Add this
$auth = curl_exec($curl);
   if (trim($auth) == "true") {
        echo "Premium<BR>";
ob_flush();
flush();
    }
    else {
    echo "Not Premium<BR>";
    }
}

1 Answer 1

1

That didn't work because $proxy variable is not accessible inside your function.

Add it inside like this

function checkPlayer($player) {
$proxy = "1.1.1.1:80"; //<--- Here
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you, I have updated the post with the new method. Now if the proxy is not working the result is not premium, which is good but how do I make it so if the proxy isn't working then it states the proxy is not working rather than Not Premium TY For help sir, you are amazing!
Also, if that can not be done no worries. A major issue with my code is that when that script is running to see if users are premium no other pages on my webserver can load.
Just add an exit; statement after echo "Not Premium<BR>"; so it won't load content after that.
Well it needs to check multiple players, here I'll show you what I mean. The whole webserver crashes for some reason while that script is running and once it completes, the webserver comes back online. Here is a livestream of the problem: twitch.tv/missiontech

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.