[PHP] Random Code Generator
2015-10-13, 03:46 AM,
#1
I'm here with quick share for CPAElites and all IMers.

Basically, this little PHP function will help you to quickly generate random codes for an niche that you're working on (e.g. gift card codes or online game keys)


I did not create exact example that you may use, but here's quick screenshot from one of my works:
[Image: ss.png]

Here's very simple demo to see it in action...
Demo Redirect

Register or login to see this content

As you can see in the end of this code, I have an `if` and `die` inside of it which runs the function without any parameters. So that will work with default settings as defined in function. Let's explain each of those parameters below:

Code:
<?php

function codeGen ( $maskChar = '*', $mask = '****-****-****', $type = 'alphanumeric' ) {
    $generated     = null;
    $types         = [
        'alphanumeric'  => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
        'alphabetic'    => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
        'numeric'       => '0123456789'
    ];

    for ( $i = 0, $l = strlen($mask); $i < $l; $i++ ) {
        if ( $types[$type] && $mask[$i] === $maskChar ) {
            $generated .= $types[$type][rand(0, strlen($types[$type]) - 1 )];
        } else {
            $generated .= $mask[$i];
        }
    }

    return $generated;
}

if ( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) &&
     strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) {
    die( codeGen() );
}

Thank you for reading. Enjoy!
As always, you can contact me on Skype: `dvLden` if you need any freelance work.
Latest Thanks - View all

masterbig(2017-09-15 10:16 AM) Jack99(2017-04-12 04:06 PM) iengkimhao(2017-04-02 06:45 PM) BucksMaker(2017-02-09 11:43 AM) geocath(2016-12-26 06:22 AM) BadSpawn(2016-08-28 04:19 AM) naathanz(2016-08-18 06:09 PM) Sitmantic(2016-07-12 10:30 AM) Bloxie(2016-06-24 01:40 AM) Cygnus(2016-04-29 05:14 AM) Bshito(2016-04-24 08:13 PM) honeydew(2016-04-07 06:42 PM) singgi11(2016-04-06 04:21 PM) LieToMe(2016-03-24 10:42 AM) jhonwhite(2016-03-16 07:40 PM) JonnyCash(2016-02-21 06:14 AM) t0ks1ck(2016-01-09 07:56 PM) Strix(2015-12-24 06:36 PM) lankan12(2015-12-24 05:17 PM) LordCPA(2015-12-22 04:14 PM) Dark7Lion(2015-12-14 02:09 AM) bmn(2015-12-10 10:42 AM) firmpress(2015-12-06 02:01 AM) Bestsku(2015-12-05 03:49 AM) Qartis(2015-12-05 12:47 AM) jeterboy(2015-12-04 11:05 PM) siu9(2015-12-04 02:38 PM) alexjer12(2015-12-02 10:37 PM) Jose77(2015-12-02 10:20 PM) fiks29(2015-12-02 08:41 PM) itsacrow(2015-11-27 12:27 PM) Nem(2015-11-27 03:28 AM) Deea(2015-11-22 09:26 PM) edmonleung(2015-11-22 03:43 PM) tprays1(2015-11-19 07:48 PM) brxboot(2015-11-18 06:16 AM) Awesomeness(2015-11-18 12:12 AM) mariusik9931(2015-11-17 08:39 PM) Ivan92(2015-11-09 12:51 PM) p1k1p(2015-11-07 10:08 PM) iscriptz(2015-11-06 04:05 AM) hansama(2015-10-30 09:38 AM) boboMarley(2015-10-28 02:23 PM) bioreset(2015-10-25 12:20 AM) erises(2015-10-15 10:30 PM) contentcouch(2015-10-15 01:15 AM) MarijuanaXTC(2015-10-14 11:15 PM) thetrue(2015-10-14 03:28 PM) LeoDios(2015-10-14 12:57 AM) PRELIATOR(2015-10-13 08:49 PM) batnight(2015-10-13 08:35 PM) cpadoom(2015-10-13 08:00 PM) kinaks(2015-10-13 07:18 PM) g3lux(2015-10-13 06:51 PM) fiozo(2015-10-13 06:31 PM) myxmo(2015-10-13 06:17 PM) jeredoc(2015-10-13 06:12 PM) toofast(2015-10-13 05:47 PM) kelwyre(2015-10-13 05:11 PM) immart247(2015-10-13 04:08 PM) mpneethiraj(2015-10-13 01:41 PM) staffer(2015-10-13 12:50 PM) polinro(2015-10-13 11:18 AM) ManagerRage(2015-10-13 10:46 AM) - NiNSHUU -(2015-10-13 10:39 AM) adarshawasthi5(2015-10-13 10:17 AM) Watwew(2015-10-13 09:48 AM) awesomexbox3(2015-10-13 06:41 AM) LarryTalks(2015-10-13 06:10 AM) MIG92(2015-10-13 03:47 AM) 
Reply
2015-10-13, 10:09 AM,
#2
This is GOLD. thank you
Latest Thanks - View all

masterbig(2017-09-15 10:16 AM) honeydew(2016-04-08 05:20 AM) hackwithvikash(2016-03-03 06:48 PM) 
Reply
2015-10-13, 12:53 PM,
#3
Nice share, thanks so much bro!

Thanks LB'Decoy for the free VIP
Reply
2015-10-13, 05:19 PM,
#4
I understood everything until "Finally, here's the PHP function...." I'm still lost :)
Reply
2015-10-13, 06:14 PM,
#5
thanks , that's seems good
Reply
2015-10-19, 03:57 PM,
#6
Great share for code and key niches. Salute!

Terrible obvious LQ posts to bypass PM restriction. Read the rules. All posts are removed, take a month of to learn the rules.
Reply
2015-10-22, 05:29 AM,
#7
Amazing share. Great job!
Reply
2015-12-02, 03:21 PM,
#8
very useful , thank you very much
Reply
2015-12-03, 11:51 PM,
#9
thank you very much.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Shadow Fight 3 Hack Generator Landing Page MrLions 5 185 2017-12-10, 11:07 PM
Last Post: tamnga
  Madden NFL Mobile Hack Generator Landing Page MrLions 7 709 2017-12-06, 01:06 PM
Last Post: WillydaDon
  War Dragon Resources Generator Landing Page Elites_Mate 3 195 2017-12-05, 10:19 PM
Last Post: daddyoh
  Bit Heroes Hack Generator Landing Page iBrobot 2 177 2017-11-28, 11:20 PM
Last Post: baymaxy
  [GET] HQ PHP Script - Watch Movies Online - GROF 55 18,330 2017-11-26, 12:04 PM
Last Post: botxtrem





About Us | Contact Us | CPA Elites | Advertise | Stats | Staff Team

© 2013-2017 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top