Jump to content

Fetching from textarea into array PHP


madmike3

Recommended Posts

Hello, iam almost done with my project .. except there is one more thing left which somehow i cant manage to figure it out....... i manged to make a proxy array which rotates proxies randomly on every try..... but i want for my users to be able to add them manually via the textarea... so they put their proxies and
as much as they want...... so then i guess explode should be used to fetch the proxies that were added by the user from the textarea and put them in an array like u see down and then with the curl array_rand it randomises them on evry try The real problem is i dnt know how to indetidy the explode cause iam not adding them manually they will be added via textare by users....... so when they add the ips they need to be fetched from the textare.
THNX IN ADVACE

$proxies = array(  
    '000.000.000.00:000',   <----------------- should i keep this ? cause ips will be added from textarea by users ?
    '000.000.000.00:000',  
    '000.000.000.00:000',  
    '000.000.000.00:000',  

);  
curl_setopt($ch, CURLOPT_PROXY,$proxies[array_rand($proxies)]);  <----- AFTER and array is made using exploit this will call it 

<textarea cols='22' class='area' rows='14' name='proxies'>PROXIES</textarea><br><input type='submit' value='Test'><br></p><p align='center' dir='ltr'><b>  
Edited by madmike3
Link to comment
Share on other sites

Get the textarea's value depending on what the method attribute for your form is set to as @cyber already mentioned and store it in your database. then fetch all proxy strings from this database into an array, as for to randomise them  you could use the mysql rand() function and finally set them to CURLOPT_PROXY method, function or whatever is that. 

 

http://php.net/manual/en/faq.html.php

Link to comment
Share on other sites

Just in case you're still looking for help, here's a quick example of a working form:

<?php
//IF THE FORM WAS SUBMITTED
if(isset($_POST['submit'])) {
     //GET USER-SUGGESTED PROXIES
     $proxies = trim($_POST['proxies']);
     var_dump($proxies);  //<-- this line just shows that a value was passed; it isn't needed for your final code
 
     //...do whatever you need to do with the proxies here...
}
?>
<form method="post" action="">
     <textarea cols='22' class='area' rows='14' name='proxies' placeholder="PROXIES"></textarea><br>
     <input type='submit' name="submit" value='Test'>
</form>
Edited by cyberRobot
Link to comment
Share on other sites

Bro, LOOKS PROMOSING GONNA TEST AND LET U KNOW........  but, what do u mean do with this 

     //...do whatever you need to do with the proxies here... 

 

if i post code like this want it work ?

 

or u mean i add this there

 

curl_setopt($ch, CURLOPT_PROXY,$proxies[array_rand($proxies)])

so it chooses random proxy on evry try ?

Edited by madmike3
Link to comment
Share on other sites

do it do it like this ?

 

//IF THE FORM WAS SUBMITTED
if(isset($_POST['submit'])) {
     //GET USER-SUGGESTED PROXIES
     $proxies = trim($_POST['proxies']);
     var_dump($proxies);  //<-- this line just shows that a value was passed; it isn't needed for your final code
 
     //...do whatever you need to do with the proxies here...
 
 
$ch = curl_init('https://www.website.com');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,15);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTP_VERSION,'CURL_HTTP_VERSION_1_1' );
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_ENCODING , "gzip,deflate");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_REFERER, $refer);
curl_setopt($ch, CURLOPT_USERAGENT,$agents[array_rand($agents)]);
curl_setopt($ch, CURLOPT_PROXY,$proxies[array_rand($proxies)]);
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.txt');
}
Link to comment
Share on other sites

Bro, LOOKS PROMOSING GONNA TEST AND LET U KNOW........  but, what do u mean do with this 

     //...do whatever you need to do with the proxies here... 

 

if i post code like this want it work ?

 

or u mean i add this there

 

curl_setopt($ch, CURLOPT_PROXY,$proxies[array_rand($proxies)])

so it chooses random proxy on evry try ?

 

Yep, the "//...do whatever you need to do with the proxies here..." part would be whatever it takes to process the proxies. Note that you'll need to figure out how you're going to break up the proxies supplied by the user, assuming that you're allowing them to enter more than one. You could ask the user to separate multiple proxies with a delimiter or maybe have each listed on a new line. You could then use something like explode() to break the proxies apart to get the array to randomize.

Link to comment
Share on other sites

I wouldn't use a text area for input that relies on the user using the correct delimiter. You have no control whatsoever over the format. It would be better IMO to have several separate text inputs each named "proxies[]"

<input type="text" name="proxies[]" size="25" /><br/>
<input type="text" name="proxies[]" size="25" /><br/>
<input type="text" name="proxies[]" size="25" /><br/>
<input type="text" name="proxies[]" size="25" /><br/>
<input type="text" name="proxies[]" size="25" /><br/>

This way the individual proxies are separated and $_POST['proxies'] will already be your required array

Link to comment
Share on other sites

I wouldn't use a text area for input that relies on the user using the correct delimiter. You have no control whatsoever over the format. It would be better IMO to have several separate text inputs each named "proxies[]"

<input type="text" name="proxies[]" size="25" /><br/>
<input type="text" name="proxies[]" size="25" /><br/>
<input type="text" name="proxies[]" size="25" /><br/>
<input type="text" name="proxies[]" size="25" /><br/>
<input type="text" name="proxies[]" size="25" /><br/>

This way the individual proxies are separated and $_POST['proxies'] will already be your required array

check my code pls 

Link to comment
Share on other sites

Yep, the "//...do whatever you need to do with the proxies here..." part would be whatever it takes to process the proxies. Note that you'll need to figure out how you're going to break up the proxies supplied by the user, assuming that you're allowing them to enter more than one. You could ask the user to separate multiple proxies with a delimiter or maybe have each listed on a new line. You could then use something like explode() to break the proxies apart to get the array to randomize.

check my code pls 

Link to comment
Share on other sites

oK lets say i used as u said eventhough i prefer textarea can u tell me how to covert them into array and then randomised using 

@Barand


 

curl_setopt($ch, CURLOPT_PROXY,$proxies[array_rand($proxies)])

Edited by madmike3
Link to comment
Share on other sites

i also made a version which user upload proxies.txt so......... how can i call proxies.txt to an array and then use them with 

curl_setopt($ch, CURLOPT_PROXY,$proxies[array_rand($proxies)])

according to my code.

 

Best Regards

THNX IN ADVANCE

Edited by madmike3
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.