1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Simple PHP Help

Discussion in 'Black Hat SEO' started by bluemagic, Apr 14, 2009.

  1. bluemagic

    bluemagic Regular Member

    Joined:
    Apr 22, 2008
    Messages:
    276
    Likes Received:
    40
    Hey guys,

    I need a simple php code that creates a list of two characters from the alphabet at random, like:

    jy
    gu
    yd
    qb
    ik
    jp

    etc, to how many times I want.

    It doesn't need a GUI. I can edit the part of the code to change the number of results I need.
     
  2. bluemagic

    bluemagic Regular Member

    Joined:
    Apr 22, 2008
    Messages:
    276
    Likes Received:
    40
    Winner gets 100 autopligg links (the ones that work) to anywhere they want!
     
  3. catchout

    catchout Newbie

    Joined:
    Feb 20, 2009
    Messages:
    3
    Likes Received:
    2
    Hi,
    Hope this helps you.

    Code:
    <?php 
    function rand_chars($c, $l, $u = FALSE) { 
     if (!$u) for ($s = '', $i = 0, $z = strlen($c)-1; $i < $l; $x = rand(0,$z), $s .= $c{$x}, $i++); 
     else for ($i = 0, $z = strlen($c)-1, $s = $c{rand(0,$z)}, $i = 1; $i != $l; $x = rand(0,$z), $s .= $c{$x}, $s = ($s{$i} == $s{$i-1} ? substr($s,0,-1) : $s), $i=strlen($s)); 
     return $s; 
    } 
    ?> 
     
    string $c is the string of characters to use. 
    integer $l is how long you want the string to be. 
    boolean $u is whether or not a character can appear beside itself. 
     
    Examples: 
    rand_chars("ABCEDFG", 2);
    rand_chars("ABCEDFG", 2, TRUE);
    
     
    • Thanks Thanks x 1
  4. catchout

    catchout Newbie

    Joined:
    Feb 20, 2009
    Messages:
    3
    Likes Received:
    2
    let me know if you need more specific code.

    Thanks
     
    • Thanks Thanks x 1
  5. bluemagic

    bluemagic Regular Member

    Joined:
    Apr 22, 2008
    Messages:
    276
    Likes Received:
    40
    Thanks. Please give me more instructions on how to edit this. How can I customize how many of these I want?
     
  6. bluemagic

    bluemagic Regular Member

    Joined:
    Apr 22, 2008
    Messages:
    276
    Likes Received:
    40
    Lets say one day I need 10000 and another I need 1000000.
     
  7. drkenneth

    drkenneth Executive VIP

    Joined:
    Nov 13, 2008
    Messages:
    285
    Likes Received:
    176
    Occupation:
    Developer/Entrepreneur
    Location:
    USA
    Here's what you need (edited the posted script, so some credit to catchout)
    PHP:
    <?php
    function rand_chars($c$l$u FALSE) {
         if (!
    $u) for ($s ''$i 0$z strlen($c)-1$i $l$x rand(0,$z), $s .= $c{$x}, $i++);
         else for (
    $i 0$z strlen($c)-1$s $c{rand(0,$z)}, $i 1$i != $l$x rand(0,$z), $s .= $c{$x}, $s = ($s{$i} == $s{$i-1} ? substr($s,0,-1) : $s), $i=strlen($s));
         return 
    $s;
    }

    function 
    print_list($num$seperator)
    {
        
    $I 0;
        for (
    $I 0$I $num$I++)
        {
            echo 
    rand_chars("abcdefghijklmnopqrstuvwxyz"2).$seperator;
        }

    }

        
    print_list(100,"<br />");
    ?>
    Just run print_list with w/e number you want and whatever separator you want and it will print them. (An example is shown at the bottom.)
     
    • Thanks Thanks x 1
  8. bluemagic

    bluemagic Regular Member

    Joined:
    Apr 22, 2008
    Messages:
    276
    Likes Received:
    40
    Okay

    Both of you get 1000 links each for free to unlimited sites.

    Please PM me your URLs!
     
  9. bluemagic

    bluemagic Regular Member

    Joined:
    Apr 22, 2008
    Messages:
    276
    Likes Received:
    40
    It didnt work.

    Parse error: syntax error, unexpected T_LNUMBER, expecting '&' or T_VARIABLE in /home/site/public_html/script.php on line 8
     
  10. MuonTrail

    MuonTrail Registered Member

    Joined:
    Mar 5, 2009
    Messages:
    96
    Likes Received:
    93
    Did you by chance mis-copy the code? I tested the snippet drkenneth provided and it worked fine.
     
    • Thanks Thanks x 1
  11. bluemagic

    bluemagic Regular Member

    Joined:
    Apr 22, 2008
    Messages:
    276
    Likes Received:
    40
    okay I made a careless mistake.

    People send me your urls!
     
  12. bluemagic

    bluemagic Regular Member

    Joined:
    Apr 22, 2008
    Messages:
    276
    Likes Received:
    40
    I also need this function not to repeat!!
     
  13. drkenneth

    drkenneth Executive VIP

    Joined:
    Nov 13, 2008
    Messages:
    285
    Likes Received:
    176
    Occupation:
    Developer/Entrepreneur
    Location:
    USA
    What do you mean? You want just 1 at a time or a list of a bunch?
     
  14. bluemagic

    bluemagic Regular Member

    Joined:
    Apr 22, 2008
    Messages:
    276
    Likes Received:
    40
    I dont want a result repeated.

    I generated 10000

    and sg was repeated more than 5 times.
     
  15. jinjangjoe

    jinjangjoe Newbie

    Joined:
    Jan 14, 2009
    Messages:
    34
    Likes Received:
    6
    Location:
    New York, NY
    You only can get 2*26*25 = 1,300 unique combinations, so of course
    you'll get repetitions of you ask for 10,000.
     
    • Thanks Thanks x 1
  16. bluemagic

    bluemagic Regular Member

    Joined:
    Apr 22, 2008
    Messages:
    276
    Likes Received:
    40
    oh okay.

    Anyone that contributed here, send me a PM and i'll run 1000 links for you!
     
  17. skweekykleen

    skweekykleen Newbie

    Joined:
    Jul 8, 2008
    Messages:
    45
    Likes Received:
    68
    here's another way...

    PHP:
    <?php

    $how_many_times 
    10;
    $group_size 2;
    $letters str_split("abcdefghijklmnopqrstuvwxyz");

    while(
    $i++ <= $how_many_times) {
        
    shuffle($letters);
        print 
    implode(""array_shift(array_chunk($letters$group_size))) . "<br>";
    }

    ?>
    $how_many_times is how many times you want to print the characters out...
    $group_size is how many letters in the group...your request was 2...
    $letters is the alphabet, but you could add any other text, punctuation, etc in there...

    This one basically stacks commands to keep the code short, but it loops 'x' number of times, shuffles (randomizes) the list of letters each time, then breaks it into groups of whatever size you specify, and spits out one of those random groups...it's fast and simple.

    Note...for anyone curious, I use array_shift instead of array_pop, because pop takes from the right end, and without knowing the size of the letters array and group_size beforehand, we could end up with odd numbers in chunking, so it's better to take from the left...

    anyway, any questions hit me up...
     
  18. BrianO

    BrianO Junior Member

    Joined:
    Apr 13, 2009
    Messages:
    173
    Likes Received:
    9
    If anybody of U have some more specific codes, expect those which are enlisted here, do give me a PM. I m interested in getting those.
     
  19. oldenstylehats

    oldenstylehats Elite Member Premium Member

    Joined:
    Apr 10, 2008
    Messages:
    1,893
    Likes Received:
    1,196
    More specific than what?