note 49435 deleted from ref.curl by felipe
| From: | felipe@php.net | Date: | Sun, 10 Feb 2008 13:21:31 +0000 |
| Subject: | note 49435 deleted from ref.curl by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135973@lists.php.net to get a copy of this message | ||
Note Submitter: Sebastian [Jegeras {snabel-a} gmail.com]
----
I did this script to login to a community X number of times
<?php
$url = [the script that handle logins];
if (empty($_GET[u]) && empty($_GET[p]) && empty($_GET[x])){
echo "<FORM NAME=make METHOD=get
ACTION=".$_SERVER[PHP_SELF].">
".$url."?u=<INPUT TYPE=text NAME=u value=nickname>
&p=<INPUT TYPE=text NAME=p value=password>
&x=<INPUT TYPE=text NAME=x value=times>
<input type=submit>";
}else{
if(!intval($_GET[x])) $_GET[x] = 10;
$time=time();
$params = "username=".$_GET[u]."&userpass=".urldecode($_GET[p]);
$count = login($url,$params);
echo $count."/".$_GET[x]." logins tog ".(time() - $time)."
sekunder";
}
//
function login($url,$params){
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
$cnt=0;
for($i=0;$i<($_GET[x]);$i++){
if(curl_exec ($ch))$cnt++;
}
curl_close ($ch);
return $cnt;
}
?>