login:pass

Discussion in 'PHP' started by P3L3NG, 10 Sep 2008.

  1. P3L3NG

    P3L3NG Banned

    Joined:
    4 Jun 2008
    Messages:
    175
    Likes Received:
    204
    Reputations:
    11
    PHP:
    <html><head></head><body>
    <form method="post">
    <TEXTAREA style="width=500;height=1500" name="logins">

    </TEXTAREA>
    <input type="submit" name="go">
    <?php
    for($i=0;$i<=34700;$i++)
    {
    if(isset(
    $_POST['go']))
      {
        
    $acc explode(':',$_POST['logins']);
        
    $login $acc['0'];
        
    $password $acc['1'];
    $recone fopen("logins.txt","a+");
    fwrite($recone,"\n$login\n");
    fclose($recone);
    $rectwo fopen("pass.txt","a+");
    fwrite($rectwo,"\n$password\n");
    fclose($rectwo);
      }
    }
    ?>
    </body></html>
    хочу вбивать в него login:pass , на выходе получать 2 файла: один с логиами, другой с пассами.

    у мну ток первая строчка обрабатывается ((( как поправить? зы цикл должен идти именно столько раз
     
    5 people like this.
  2. m0nsieur

    m0nsieur Elder - Старейшина

    Joined:
    8 Apr 2008
    Messages:
    223
    Likes Received:
    69
    Reputations:
    10
    если за раз много пар логин пасс можно вбивать, то нужно удалять записанные в массив значения, чтобы одни и те же не писались, а то получится, что у тебя значения массива $acc 1-ое и 2-ое запишутся в файлы 34000 раз, если пар будет меньше этого числа, то холостых срабатываний цикла слишком много.
     
    #2 m0nsieur, 10 Sep 2008
    Last edited: 10 Sep 2008
    3 people like this.
  3. Kaimi

    Kaimi Well-Known Member

    Joined:
    23 Aug 2007
    Messages:
    1,732
    Likes Received:
    809
    Reputations:
    231
    Так попробуй:
    PHP:
    <html><head></head><body>
    <form method="post">
    <TEXTAREA style="width=500;height=1500" name="logins">
    </TEXTAREA>
    <input type="submit" name="go">
    <?php
    if(isset($_POST['go'])) {
        
    $recone fopen("logins.txt","a+");
        
    $rectwo fopen("pass.txt","a+");
        for(
    $i=0;$i<=34700;$i++) {
            list(
    $login,$password) = explode(':',$_POST['logins']);
            
    fwrite($recone,"\n$login\n");
            
    fwrite($rectwo,"\n$password\n");
            }
        
    fclose($rectwo);
        
    fclose($recone);
        }
    ?> 
     
    _________________________
  4. +toxa+

    +toxa+ Smack! SMACK!!!

    Joined:
    16 Jan 2005
    Messages:
    1,674
    Likes Received:
    1,028
    Reputations:
    1,228
    попробуй так
    PHP:
    $acc explode("\n",$_POST['logins']);
    foreach(
    $acc as $tmp){
    list(
    $login,$pass) = explode(':'$tmp);
    file_put_contents('./logins.txt',$login);
    file_put_contents('./passwd.txt',$pass);
    }
     
    _________________________
  5. .:EnoT:.

    .:EnoT:. Сексуальное чудовище

    Joined:
    29 May 2007
    Messages:
    803
    Likes Received:
    559
    Reputations:
    50
    опередили))
    PHP:
    <html><head></head><body>
    <form method="post">
    <TEXTAREA style="width=500;height=1500" name="logins">

    </TEXTAREA>
    <input type="submit" name="go"></form>
    <?php  
    if(isset($_POST['go'])){
        
    $acc explode(':',$_POST['logins']);
        
    $login trim($acc[0]);
        
    $password trim($acc[1]);
        
    $recone fopen('logins.txt','a+');
        
    $rectwo fopen('pass.txt','a+');
        for(
    $i=0;$i<=34700;$i++){
            
    fwrite($recone$login."\r\n");
            
    fwrite($rectwo$password."\r\n");
        }
        
    fclose($recone);
        
    fclose($rectwo);
    }
    ?>
    </body></html>

     
  6. P3L3NG

    P3L3NG Banned

    Joined:
    4 Jun 2008
    Messages:
    175
    Likes Received:
    204
    Reputations:
    11
    Kaimi, тоже самое
    +toxa+, выделяет одну последнюю строку
    Enot, тока первая строка =)
     
  7. Gifts

    Gifts Green member

    Joined:
    25 Apr 2008
    Messages:
    2,494
    Likes Received:
    807
    Reputations:
    614
    P3L3NG, на всякий случай убирает повторы уинов и паролей
    Будет работать только для PHP5 из-за file_put_contents.
    PHP:
    <html><head></head><body>
    <form method="post">
    <TEXTAREA style="width=500;height=1500" name="logins">

    </TEXTAREA>
    <input type="submit" name="go"></form>
    <?php  
    if(isset($_POST['go']))
    {
        if (
    preg_match_all('#([^:\r\n]*):([^\r\n]*)#i',$_POST['logins'],$match))
        {
            
    file_put_contents('login.txt',implode("\r\n",array_unique($match[1])));
            
    file_put_contents('pass.txt',implode("\r\n",array_unique($match[2])));
        }
    }
    ?>
    </body></html>
     
    _________________________
    #7 Gifts, 10 Sep 2008
    Last edited: 10 Sep 2008
    1 person likes this.
  8. P3L3NG

    P3L3NG Banned

    Joined:
    4 Jun 2008
    Messages:
    175
    Likes Received:
    204
    Reputations:
    11
    Gifts, +++ все отлично пашет