Jump to content


Photo

Fetching from textarea into array PHP


  • Please log in to reply
16 replies to this topic

#1 madmike3

madmike3

    Member

  • Members
  • PipPip
  • 15 posts

Posted 20 August 2014 - 05:27 AM

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, 20 August 2014 - 05:29 AM.


#2 cyberRobot

cyberRobot

    Advanced Member

  • Gurus
  • 1,752 posts

Posted 20 August 2014 - 08:12 AM

Sorry, I'm not sure what you're asking. Are you just trying to figure out how to get the value from the textarea? If so, you use $_GET['proxies'] or $_POST['proxies'] depending on what the method attribute for your form is set to.


Blogging about PHP and other web development topics at ScorpBytes.com

#3 madmike3

madmike3

    Member

  • Members
  • PipPip
  • 15 posts

Posted 21 August 2014 - 12:14 AM

Yes thats what iam trying to achive iam trying to get values from textarea and convert them into array since it needs to be randomised using the  curl_setopt($ch, CURLOPT_PROXY,$proxies[array_rand($proxies)]) do u understand me ?



#4 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,660 posts
  • LocationMississauga, Canada

Posted 21 August 2014 - 05:25 AM

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



#5 madmike3

madmike3

    Member

  • Members
  • PipPip
  • 15 posts

Posted 21 August 2014 - 06:30 AM

But i dnt have dabase it is a script i made single php file :)



#6 cyberRobot

cyberRobot

    Advanced Member

  • Gurus
  • 1,752 posts

Posted 21 August 2014 - 07:41 AM

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, 21 August 2014 - 07:42 AM.

Blogging about PHP and other web development topics at ScorpBytes.com

#7 madmike3

madmike3

    Member

  • Members
  • PipPip
  • 15 posts

Posted 21 August 2014 - 09:13 AM

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, 21 August 2014 - 09:16 AM.


#8 madmike3

madmike3

    Member

  • Members
  • PipPip
  • 15 posts

Posted 21 August 2014 - 09:23 AM

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...
 
 
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');
}


#9 cyberRobot

cyberRobot

    Advanced Member

  • Gurus
  • 1,752 posts

Posted 21 August 2014 - 09:58 AM



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.


Blogging about PHP and other web development topics at ScorpBytes.com

#10 Barand

Barand

    Sen . ( ile || sei )

  • Gurus
  • 14,381 posts
  • LocationCheshire, UK

Posted 21 August 2014 - 10:07 AM

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


moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns

 


#11 madmike3

madmike3

    Member

  • Members
  • PipPip
  • 15 posts

Posted 21 August 2014 - 10:22 AM

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 



#12 madmike3

madmike3

    Member

  • Members
  • PipPip
  • 15 posts

Posted 21 August 2014 - 10:22 AM

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 



#13 madmike3

madmike3

    Member

  • Members
  • PipPip
  • 15 posts

Posted 21 August 2014 - 10:25 AM

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, 21 August 2014 - 10:26 AM.


#14 madmike3

madmike3

    Member

  • Members
  • PipPip
  • 15 posts

Posted 21 August 2014 - 10:28 AM

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, 21 August 2014 - 10:28 AM.


#15 CroNiX

CroNiX

    Advanced Member

  • Gurus
  • 874 posts
  • LocationPortland, OR

Posted 21 August 2014 - 10:32 AM

This is starting to look like a hacking/malicious script.



#16 madmike3

madmike3

    Member

  • Members
  • PipPip
  • 15 posts

Posted 21 August 2014 - 10:34 AM

This is starting to look like a hacking/malicious script.

not really, and not gonna be used for bad purposes..... if u can help pls do so



#17 Jacques1

Jacques1

    Advanced Member

  • Members
  • PipPipPip
  • 959 posts

Posted 21 August 2014 - 10:56 AM

I think you'll have to do your script kiddie password cracking bullshit somewhere else.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com