在Php中从文件中获取Foreach文本

时间:2013-05-07 04:06:41

标签: php loops curl foreach

我创建了这个脚本。

但我有一些问题......

1st Chek出了代码。

<?php 
for($loop=1;$loop<=30;$loop++) {
    post_data2 = "zxcoiesesscd=&MessageLength=140&GlobalKeyValue=1&$mbl=9647478496&$m1=$msssg&$m2=$msssg&$m3=$msssg&$m8=$msssg&$m4=$msssg&$m5=$msssg&$m6=$msssg&$m7=$msssg&SendNow_=Send Now&BtnSendNow_=Send Now&Day=$day&Month=$month&Year=$year&TimeInterval=$time";
}

检查$mbl=9647478496

总共有30个Loop。在每个循环中,它发送相同的数字(9647478496)

我希望从每个循环中的Numbers.txt发送数组列表中的不同数字。

所以它将在30循环中发送30个不同的数字。

顺便说一下。我没有在archive中添加numbers.txt。请从给定的链接下载它。

请帮我编码。 :)

1 个答案:

答案 0 :(得分:0)

试试这个:

sms.php     

?><?php
echo "<title>Ultoo SmS Sender | PRaman.TK</title>";
?>
<?php
      $username = $_POST['uid'];
      $password = $_POST['pwd'];
      $tomob = $_POST['to'];
  $c = $_REQUEST['recaptcha_challenge_field'];
      $cv = $_REQUEST['recaptcha_response_field'];
    $cookie = tempnam("/coki", "CURLCOOKIE");
      $ch = curl_init();
      curl_setopt($ch,CURLOPT_URL,"http://sms.ultoo.com/login.php");
   curl_setopt($ch, CURLOPT_TIMEOUT, 0);

      curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie);
      curl_setopt($ch,CURLOPT_HEADER,1);
      curl_setopt($ch,CURLOPT_VERBOSE,1);
      curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch,CURLOPT_REFERER,"http://sms.ultoo.com/login.php");
               $one=curl_exec($ch);

      preg_match("/input name=\"(.*?)\" type=\"text\" class=\"existing_user round_four\" id=/i",$one,$matches);
      $user = $matches[1];

      preg_match("/input name=\"(.*?)\" type=\"password\" class=\"existing_user round_four\" id=/i",$one,$matches);
      $pass = $matches[1];
 $post_data = "$user=$username&$pass=$password&RememberMe=1&submit2=LOGIN HERE";
   $url = "http://sms.ultoo.com/login.php";
    $cookie = tempnam("/coki", "CURLCOOKIE");
   $ch = curl_init();
   curl_setopt( $ch, CURLOPT_USERAGENT,"User-Agent: Mozilla/7.0 (Windows NT 6.1; rv:10.0) Gecko/20100101 Firefox/9.0" );
   curl_setopt( $ch, CURLOPT_URL, $url );
   curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
   curl_setopt($ch, CURLOPT_TIMEOUT, 0);
   curl_setopt($ch, CURLOPT_POST, true);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
   curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie );
   curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, false );
   curl_setopt( $ch, CURLOPT_ENCODING, "" );
   curl_setopt($ch, CURLOPT_TIMEOUT, 0);
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
   curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
   curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
   curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
   $ct = curl_exec( $ch );


if(stristr($ct,"number & password"))
{
echo "<font color='red'><b>Invalid mobile number / password. Try Again With Correct Details.</b></font>";
}
else
{

if(stristr($ct,"secure.php"))
{
$post_data2 = "recaptcha_challenge_field=$c&recaptcha_response_field=$cv";
   curl_setopt($ch, CURLOPT_URL,"http://sms.ultoo.com/secure.php?zxcoiesesscd=");    
   curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
   curl_setopt($ch, CURLOPT_TIMEOUT, 0);
   curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
   curl_setopt($ch, CURLOPT_TIMEOUT, 0);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data2);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_REFERER, "http://sms.ultoo.com");
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

   $dt = curl_exec($ch);
if(!stristr($dt,"mywallet.php"))
{
die("<font color='red'><b>Invalid Captcha. Try Again.</b></font>");
}
 }  
curl_setopt($ch, CURLOPT_URL,"http://sms.ultoo.com/home.php?zxcoiesesscd=");    

   curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
   curl_setopt($ch, CURLOPT_TIMEOUT, 0);


   curl_setopt($ch, CURLOPT_REFERER, "http://sms.ultoo.com");
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

   $dt = curl_exec($ch);

preg_match_all("/document.getElementById(.*?).value/",$dt,$mbll);
$mbl = $mbll[1][16];
$mbl = str_replace("('","",$mbl);
$mbl = str_replace("')","",$mbl);
preg_match_all('/textarea name=\"(.*?)\"/i',$dt,$msgg);
$m1 = $msgg[1][0];

$m2 = $msgg[1][1];

$m3 = $msgg[1][2];

$m4 = $msgg[1][3];

$m5 = $msgg[1][4];

$m6 = $msgg[1][5];

$m7 = $msgg[1][6];

$m8 = $msgg[1][7];
$ff = $_REQUEST["count"];

$numbers=file_get_contents("numbers.txt");
$numbers=explode("\r\n",$numbers);


         for($loop=1;$loop<=$ff;$loop++)
         {

      $msssg = randomstring();
   $number=$numbers[$loop-1];
   $post_data2 = "zxcoiesesscd=&MessageLength=140&GlobalKeyValue=1&$mbl=$number&$m1=$msssg&$m2=$msssg&$m3=$msssg&$m8=$msssg&$m4=$msssg&$m5=$msssg&$m6=$msssg&$m7=$msssg&SendNow_=Send Now&BtnSendNow_=Send Now&Day=$day&Month=$month&Year=$year&TimeInterval=$time";
   curl_setopt($ch, CURLOPT_URL,"http://sms.ultoo.com/home.php?zxcoiesesscd=");    
   curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
   curl_setopt($ch, CURLOPT_TIMEOUT, 0);
   curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
   curl_setopt($ch, CURLOPT_TIMEOUT, 0);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data2);
   curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
   curl_setopt($ch, CURLOPT_TIMEOUT, 0);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data2);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_REFERER, "http://sms.ultoo.com");
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

   $dt = curl_exec($ch);

   if(strstr($dt,"msgSent.php"))
{
echo "<b><font color=green>".$loop." SmS Sent Successfully.</font></b><br>";
$myFile = "$username.txt";
$fh = fopen($myFile, 'w') or die("");
$stringData = "$username,$password";
fwrite($fh, $stringData);
fclose($fh);

}
else
{
echo "<b><font color=red>SmS Sending Failed.</font></b><br>";
}
}
}
?>

确保numbers.txt与PHP文件位于同一文件夹中。

由于您的循环从一开始,我$number=$numbers[$loop-1];获得numbers.txt的第一行。