• 24-04-2021, 13:07:46
    #1
    Selamlar

    Random olarak böyle bir şey yapmak istiyorum. Nasıl yaparım?
    FHYR-DCSTB-QGTRJ-HIGOP
  • 24-04-2021, 13:10:12
    #2
    Hocam file mining mi yapıcaksın 😂
  • 24-04-2021, 13:10:41
    #3
    night_walker adlı üyeden alıntı: mesajı görüntüle
    Hocam file mining mi yapıcaksın 😂
    O nedir
  • 24-04-2021, 13:11:52
    #4
    function generate_license($suffix = null) {
        // Default tokens contain no "ambiguous" characters: 1,i,0,o
        if(isset($suffix)){
            // Fewer segments if appending suffix
            $num_segments = 3;
            $segment_chars = 6;
        }else{
            $num_segments = 4;
            $segment_chars = 5;
        }
        $tokens = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
        $license_string = '';
        // Build Default License String
        for ($i = 0; $i < $num_segments; $i++) {
            $segment = '';
            for ($j = 0; $j < $segment_chars; $j++) {
                $segment .= $tokens[rand(0, strlen($tokens)-1)];
            }
            $license_string .= $segment;
            if ($i < ($num_segments - 1)) {
                $license_string .= '-';
            }
        }
    $license = generate_license();
    // YF6G2-HJQEZ-8JZKY-8C8ZN
  • 24-04-2021, 13:12:41
    #5
    EnesCanturk adlı üyeden alıntı: mesajı görüntüle
    O nedir
    Epin galiba hocam tamamdır, ben yanlış anladım olayı

    Random string veren fonksiyon var onla 4 karakterli şekilde kodlar oluşturup birleştirebilirsin.
  • 24-04-2021, 13:13:27
    #6
    for ($i=0; $i < 4; $i++) {
      for ($q=0; $q < 4; $q++) {
        echo chr(rand(65,90));
      }
      if($i != 3) echo '-';
    }


  • 24-04-2021, 13:30:46
    #7
    batuhan_polat adlı üyeden alıntı: mesajı görüntüle
    function generate_license($suffix = null) {
        // Default tokens contain no "ambiguous" characters: 1,i,0,o
        if(isset($suffix)){
            // Fewer segments if appending suffix
            $num_segments = 3;
            $segment_chars = 6;
        }else{
            $num_segments = 4;
            $segment_chars = 5;
        }
        $tokens = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
        $license_string = '';
        // Build Default License String
        for ($i = 0; $i < $num_segments; $i++) {
            $segment = '';
            for ($j = 0; $j < $segment_chars; $j++) {
                $segment .= $tokens[rand(0, strlen($tokens)-1)];
            }
            $license_string .= $segment;
            if ($i < ($num_segments - 1)) {
                $license_string .= '-';
            }
        }
    $license = generate_license();
    // YF6G2-HJQEZ-8JZKY-8C8ZN
    bybrown adlı üyeden alıntı: mesajı görüntüle
    for ($i=0; $i < 4; $i++) {
      for ($q=0; $q < 4; $q++) {
        echo chr(rand(65,90));
      }
      if($i != 3) echo '-';
    }


    Herkese teşekkür ederim. Denedim ama nedense çalıştıramadım

    Ben de 4 tane 4 haneli değişken oluşturup birleştirdim.
  • 24-04-2021, 13:49:00
    #8
    <?php 
    function randstr($len=4) {
        $abc="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        $letters = str_split($abc);
        $str = "";
        for ($i=0; $i<=$len; $i++) {
            $str .= $letters[rand(0, count($letters)-1)];
        };
        return $str;
    }
    
    $limit=4;
    $license="";
    for ($i=1; $i<=$limit; $i++) {
        $new=randstr(4);
        $license .= $new.'-';
    }
    
    echo rtrim($license, "-");
    ?>
    Ben bunu kullanıyorum
  • 28-04-2021, 00:28:58
    #9
    Merhaba tekrar kod yazmayayım kodlar yazılmış fakat hayati bir hatırlatma yapayım. Bu kodu veritabanına kaydettiğinizde tekrar bu kodu calıstırdıgınızda veritabanında varmı yokmu kontrol ettirin . gerçi kombinasyonu çok olduğundan tekrar gelme olasılığı %10 bile değil lakin büyük bir sistemde kullanılacaksa ben tercih ediyorum.