Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function imei_gen() {
- $str = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- $sum = 0;
- $final_digit = 0;
- $t = 0;
- $len_offset = 0;
- $len = 15;
- $issuer = "";
- $rbi = array("01", "10", "30", "33", "35", "44", "45", "49", "50", "51", "52", "53", "54", "86", "91", "98", "99");
- $random_index = rand(0, count($rbi) - 1);
- $arr = str_split($rbi[$random_index]);
- $str[0] = (int) $arr[0];
- $str[1] = (int) $arr[1];
- $pos = 2;
- while ($pos < $len - 1) {
- $str[$pos++] = rand(0, 9);
- }
- $len_offset = ($len + 1) % 2;
- for ($pos = 0; $pos < $len - 1; $pos++) {
- if (($pos + $len_offset) % 2) {
- $t = $str[$pos] * 2;
- if ($t > 9) {
- $t -= 9;
- }
- $sum += $t;
- } else {
- $sum += $str[$pos];
- }
- }
- $final_digit = (10 - ($sum % 10)) % 10;
- $str[$len - 1] = $final_digit;
- $t = implode('', $str);
- $t = substr($t, 0, $len);
- return $t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement