if (isset($_POST['socks'])) {
$bin=substr($_POST['socks'], 0,33);
so that instead of just taking the first 33 characters of your text box and checking that address, instead you figure out how many separate IP addresses there are, and call the check for each one.
I’d take the actual code that does the check (starting with your curl_init() line) and split that out into a function, then I’d call that repeatedly, and perhaps build the results into an array for displaying later.
I would consider changing from a textarea to a series of text inputs. It could shift some of the heavy lifting from the code to the user, but it might be an acceptable alternative that would have some benefits.
OK, but what does it do? There’s nothing in that code to actually connect to anything, just to separate out a list of IP/Port combinations. Does that part work? If it does, then package the connection part of your first code into a function and call it for each ip/port pair.
We are at cross-purposes here. The function you have written is to try to split out IP/port sets, whereas I am talking about writing another function that actually does the curl section of things. I can’t help on the regular expressions - if splitting the IP addresses out is causing a major issue, then perhaps you should use one of the suggestions from further up, to provide several text boxes rather than a single text area.
Roughly I’d be thinking:
// split incoming IP/Port pairs into an array
// foreach array element:
// call checksite() function
// display results
// end of foreach
// function checksite() {
// starting with $ch = curl_init();
// ending with return $result;
// } end of function
I would remove all the display stuff from the checksite() function, just deal with that in your calling code.
If you’re having issues with it, just do as you’d normally do and break it down. If your first code works, modify that to have the checksite() function (or whatever you want to call it) that does all the curl stuff, and get that working. Once you have that working, you can modify the calling code to deal with multiple inputs.