Modulus 11 Generator
5
This module is used to generate the unique number and self check the numbers in social security, band accounts and etc.
Here you can find detailed explanation:
http://www.eclectica.ca/howto/modulus-11-self-check.php?start=1&count=5&generate=Generate#calculator
I have made this scirpt generate numbers in drop down list and write brojevi.txt file that you can download with numbers you have generated...
Here you can find detailed explanation:
http://www.eclectica.ca/howto/modulus-11-self-check.php?start=1&count=5&generate=Generate#calculator
I have made this scirpt generate numbers in drop down list and write brojevi.txt file that you can download with numbers you have generated...
<?php
$broj = $_POST['pocetni'];
$ponavljanja = $_POST['ponavljanja'];
$get = $_GET['get'];
if (!empty($get)) {
// force to download a file
$file = "brojevi.txt";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header( "Content-Disposition: attachment; filename=".basename($file));
header( "Content-Description: File Transfer");
@readfile($file);
die();
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Fakin Generator</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
body {
background-color: #002448;
}
.input {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
background-color: #003399;
border: 1px solid #3366CC;
color: #FFFFFF;
}
a:link {
color: #0099FF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #0099FF;
}
a:hover {
text-decoration: none;
color: #0066CC;
}
a:active {
text-decoration: none;
color: #0099FF;
}
-->
</style>
</head>
<body>
<form name="form1" method="post" action="">
<table width="145" border="0">
<tr>
<td width="66">Pocetni</td>
<td width="254"><input name="pocetni" type="text" class="input" id="pocetni" value="<?php echo $broj; ?>" size="5"></td>
</tr>
<tr>
<td>Brojeva</td>
<td><input name="ponavljanja" type="text" class="input" id="ponavljanja" value="<?php echo $ponavljanja; ?>" size="5"></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="button" type="submit" class="input" id="button" value="Generisi"></td>
</tr>
</table>
<br>
<br>
</form>
<br>
<label></label>
<br>
<?php
/* Append modulus 11 check digit to supplied string of digits. */
function GenMOD11( $base_val )
{
$result = "";
$weight = array( 2, 3, 4, 5, 6, 7,
2, 3, 4, 5, 6, 7,
2, 3, 4, 5, 6, 7,
2, 3, 4, 5, 6, 7 );
/* For convenience, reverse the string and work left to right. */
$reversed_base_val = strrev( $base_val );
for ( $i = 0, $sum = 0; $i < strlen( $reversed_base_val ); $i++ )
{
/* Calculate product and accumulate. */
$sum += substr( $reversed_base_val, $i, 1 ) * $weight[ $i ];
}
/* Determine check digit, and concatenate to base value. */
$remainder = $sum % 11;
switch ( $remainder )
{
case 0:
$result = $base_val . 0;
break;
case 1:
$result = "n/a";
break;
default:
$check_digit = 11 - $remainder;
$result = $base_val . $check_digit;
break;
}
return $result;
}
function napravi10 ($cifra) {
if ($cifra != "n/a") {
$duzina = strlen($cifra);
for ($duzina; $duzina < 10; $duzina++) {
$cifra = "0". $cifra;
}
}
return $cifra;
}
if ((!empty($broj)) && (!empty($ponavljanja))) {
set_time_limit(0);
$txt = "";
print "Your generated list of numbers ready to download in .txt -> <a href='?get=brojevi.txt'>brojevi.txt</a><br><br>";
print "<select name=\"select\" id=\"select\" class='input'>";
for($i='1'; $i<=$ponavljanja; $i++) {
$cifra = GenMOD11("$broj");
$cifra = napravi10("$cifra");
$txt .= "$cifra \r\n";
print "<option value='$cifra'>$cifra</option>";
$broj++;
}
print "</select>";
$fajl = 'brojevi.txt';
$open = fopen($fajl, 'w');
$write = fwrite($open, $txt);
$close = fclose($open);
}
?>
</body>
</html>






There are currently no comments for this snippet.