-1
I’m doing a check on proxys putting a list of proxys in the textarea
and the code returns to me on screen 1 by 1 below each other whether they work or not. Almost everything is ready, the only problem is that it does not matter the order in which the list of proxy be, always the proxys "#DIE" is shown before "#LIVE"; if I have a list of 5 proxys that work and 5 that don’t work no matter the order in which they are in the textarea
, always the "#DIE" will be displayed first. I want the results to be displayed in the order in which the proxys were placed in the textarea
, but how do I do it ?
<html>
<head>
<title> chk </title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
function enviar(){
var bin = $("#bin_id").val();
var linhaenviar = bin.split("\n");
var index = 0;
linhaenviar.forEach(function(value){
setTimeout(
function(){
$.ajax({
url: 'chkp.php',
type: 'POST',
dataType: 'html',
data: "bin=" + value,
success: function(resultado){
$('#oi').html($('#oi').html() + resultado + "<br>");
}
})
}, 10 * index);
index = index + 1;
})
}
</script>
</head>
<body>
<center>
<textarea name="bin" placeholder="PROXY|PORTA" id="bin_id" rows="10" cols="40">
</textarea>
<br>
<input type="button" value="testar" onclick="enviar();"></input>
<br>
<div id="oi" name="oi">
<p></p>
</div>
</center>
</body>
</html>
PHP file:
<?php
error_reporting(0);
if(!empty($_POST["proxy"])){
$proxylist = substr($_POST['proxy'], 0, 90);
$proxy = explode("|", $proxy)[0];
$port = explode("|", $proxy)[1];
explode("|", $proxy)[2];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "host.com/prpxytest");
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 10);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, '_proxy=' . urlencode($proxy) . '&_port=' . urlencode($port));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$dados = curl_exec($ch);
$q = explode('</i>', $dados);
$sal = $q[4];
$msg = ' ';
if(strpos($sal, "Sair") !== false){
$msg = "<b><font color='green'>#LIVE $proxy | $port </font></b>";
}else{
$msg = "<b><font color='red'>#DIE $proxy | $port </font></b>";
}
echo $msg;
}else{ echo 'erro'; }
?>
For each proxy in the textarea the script shown is executed?
– Juven_v
How do you perform this script?
– Woss
Yes that each line has a proxy and the port separated by |
– Bruno Lazarine
The script is executed by an ajax jquery that does all the line requests
– Bruno Lazarine
So your problem is not in PHP, but in jQuery. What happens is that the tests that fail probably generate the results before those that do not fail, thus displaying them first. Since no asynchronous requests, this order will never be guaranteed.
– Woss
I edited the question with the part that makes the requests
– Bruno Lazarine
One solution would be to create a recursive function that makes asynchronous requests sequentially, but frankly I see no reason to do so. What is the real need to obtain the result in such an order?
– Woss
To organize the information, tbm would wish if possible that within different iframes the positive and negative results and that the lines of both were counted and displayed on the screen, example: (90 proxys vivo) 2 iframe (100 proxys deceased)
– Bruno Lazarine
Why did you edit the question this way?
– Amadeu Antunes
Hello can help me with this return error ?
– Bruno Lazarine
If it is a new question a little life from the above question should create a new question.
– Amadeu Antunes
And why two iframes? Wouldn’t two elements be enough on the page itself? What you want to do doesn’t seem to make much sense.
– Woss
I want two lists one with the list of dead proxys another with the living that has the sidebar to scroll down
– Bruno Lazarine
Two small frames with different results
– Bruno Lazarine