@ 2019-07-31T08:40:08Z <?php
// CNIFRA ou CNIBEL ou PERMIS ou TITRESEJOUR ou REGNAT ou CARTEGRISE
$type = "CNIFRA";
//code pour le permis
$codePermis ="D1FRA14AB57212*291222HURABIEL*";
/*-------CNI francaise---------*/
//code pour la CNIFRA 1er ligne
$codeCNI ="IDFRABEKDI<<<<<<<<<<<<<<<<<<<<271051";
//code pour la CNIFRA 2eme ligne
$codeCNI2 ="100727101235*DJAMEL<<<<<<<<810131*M*";
$codeCNI3 =$codeCNI2;
$codeCNI4 =$codeCNI2;
/*-------END CNI francaise---------*/
/*-------CNI Belge---------*/
//code pour la CNIBELGE (ligne jusqu'a la derniere cle de controle)
$codeCNIBEL = "IDBEL592273047<809*<<<<<<<<<<<910312*M251230*BEL91031244758*";
//code suivant la derniere cle de controle
$codeCNIBEL2 = "DE<NOBREGA<<ALEXANDRE<EMMANUEL";
$codeCNIBEL3 = $codeCNIBEL;
$codeCNIBEL4 = $codeCNIBEL;
/*-------END CNI Belge---------*/
//code pour le titre de sejour (ligne jusqu'a la derniere cle de controle)
$codeTitreSejour = "IRFRA2JA3VISG5*<9915026763<<<<900201*M161231*CMR<<<<<<<<<<<*";
//code suivant la derniere cle de controle
$codeTitreSejour2 = "MEYE<MINKOA<<YOHAN<<BORIS<<<<<<";
$codeTitreSejour3 = $codeTitreSejour;
$codeTitreSejour4 = $codeTitreSejour;
//code pour le registre national belge
$codeRegNat="910524295";
//code pour la carte grise
$codeCarteGrise = "CRFRAAB123CD*VF7X18E00018E8472*980105*VP<<<<CI<<MERSSAIDESS<<<SR220TD<<<<<<98TN036623<**";
$codeCarteGrise2 = $codeCarteGrise;
$codeCarteGrise3 = $codeCarteGrise;
$TABCode = [];
$TABCode2 = [];
$allcode="";
$allCleControle="";
if($type == "CNIBEL") {
$TABCode = explode('*',$codeCNIBEL);
array_splice($TABCode, count($TABCode)-1);
$TABCode[0] = substr($TABCode[0],5);
$TABCode[2] = substr($TABCode[2],1);
$codeCNIBEL3 = substr_replace($codeCNIBEL3 ,"",-1);
for ($i = 0; $i < 3; $i++) {
array_push($TABCode2,verifSomme($TABCode[$i]));
}
for ($i = 0; $i < count($TABCode2); $i++) {
$codeCNIBEL3 = str_replace_first('*', $TABCode2[$i],$codeCNIBEL3);
}
//retirer tout les caracteres non numeric (except < ) dans le code
$res = preg_replace("/[^0-9<]/", "",$codeCNIBEL3);
array_push($TABCode2,verifSomme($res));
for ($i = 0; $i < count($TABCode2); $i++) {
$codeCNIBEL4 = str_replace_first('*', $TABCode2[$i],$codeCNIBEL4);
}
for ($i = 0; $i < count($TABCode2); $i++) {
$allCleControle .= $TABCode2[$i]." ";
}
echo htmlspecialchars($codeCNIBEL4);
echo htmlspecialchars($codeCNIBEL2);
echo'<br>';
echo'<br>';
echo $allCleControle;
}
if($type == "CARTEGRISE") {
$TABCode = explode('*',$codeCarteGrise);
array_splice($TABCode, count($TABCode)-2);
$TABCode[0] = substr($TABCode[0],-7);
$TABCode[3] = substr($TABCode[3],-11);
for ($i = 0; $i < count($TABCode); $i++) {
array_push($TABCode2,verifSomme($TABCode[$i]));
}
for ($i = 0; $i < count($TABCode2); $i++) {
$codeCarteGrise2 = str_replace_first('*', $TABCode2[$i],$codeCarteGrise2);
}
$codeCarteGrise2 = substr_replace($codeCarteGrise2 ,"",-1);
array_push($TABCode2,verifSomme($codeCarteGrise2));
for ($i = 0; $i < count($TABCode2); $i++) {
$codeCarteGrise3 = str_replace_first('*', $TABCode2[$i],$codeCarteGrise3);
}
for ($i = 0; $i < count($TABCode2); $i++) {
$allCleControle .= $TABCode2[$i]." ";
}
echo htmlspecialchars($codeCarteGrise3);
echo'<br>';
echo'<br>';
echo $allCleControle;
}
if($type == "TITRESEJOUR"){
$TABCode = explode('*',$codeTitreSejour);
array_splice($TABCode, count($TABCode)-1);
$TABCode[0] = substr($TABCode[0],-9);
$TABCode[1] = substr($TABCode[1],-6);
$TABCode[2] = substr($TABCode[2],-6);
for ($i = 0; $i < 3; $i++) {
array_push($TABCode2,verifSomme($TABCode[$i]));
}
for ($i = 0; $i < count($TABCode2); $i++) {
$codeTitreSejour3 = str_replace_first('*', $TABCode2[$i],$codeTitreSejour3);
}
array_push($TABCode2,verifSomme($codeTitreSejour3));
for ($i = 0; $i < count($TABCode2); $i++) {
$codeTitreSejour4 = str_replace_first('*', $TABCode2[$i],$codeTitreSejour4);
}
for ($i = 0; $i < count($TABCode2); $i++) {
$allCleControle .= $TABCode2[$i]." ";
}
echo htmlspecialchars($codeTitreSejour4);
echo htmlspecialchars($codeTitreSejour2);
echo'<br>';
echo'<br>';
echo $allCleControle;
}
if($type == 'PERMIS'){
$TABCode = explode('*',$codePermis);
array_splice($TABCode, count($TABCode)-1);
for ($i = 0; $i < count($TABCode); $i++) {
array_push($TABCode2,verifSomme($TABCode[$i]));
if($i+1 == count($TABCode)-1){
for ($j = 0; $j < count($TABCode); $j++) {
$allcode .= $TABCode[$j];
if(isset($TABCode2[$j])){
$allcode .= $TABCode2[$j];
}
}
array_push($TABCode2,verifSomme($allcode));
$allcode .= $TABCode2[count($TABCode2)-1];
break;
}
}
for ($i = 0; $i < count($TABCode2); $i++) {
$allCleControle .= $TABCode2[$i]." ";
}
echo htmlspecialchars($allcode);
echo'<br>';
echo $allCleControle;
}
if($type == 'CNIFRA'){
$TABCode = explode('*',$codeCNI2);
array_splice($TABCode, count($TABCode)-1);
$TABCode[1] = substr($TABCode[1],-6);
for ($i = 0; $i < 2; $i++) {
array_push($TABCode2,verifSomme($TABCode[$i]));
}
for ($i = 0; $i < count($TABCode2); $i++) {
$codeCNI3 = str_replace_first('*', $TABCode2[$i],$codeCNI3);
}
$codeCNI3 = substr_replace($codeCNI3 ,"",-1);
array_push($TABCode2,verifSomme($codeCNI.$codeCNI3));
for ($i = 0; $i < count($TABCode2); $i++) {
$codeCNI4 = str_replace_first('*', $TABCode2[$i],$codeCNI4);
}
for ($i = 0; $i < count($TABCode2); $i++) {
$allCleControle .= $TABCode2[$i]." ";
}
echo htmlspecialchars($codeCNI4);
echo'<br>';
echo $allCleControle;
}
if($type == 'REGNAT'){
echo 97 - ($codeRegNat % 97);
}
function verifSomme($ligne) {
$factors = array(7,3,1);
$result = 0;
$offset = 0;
foreach(str_split($ligne,1) as $char) {
if($char == '<') {
$char = 0;
//ord('A') <= ord($char) <= ord('Z')
} elseif(ord($char) >= 65 && ord($char) <= 90) {
$char = ord($char) - 55;
} elseif($char >= 0 && $char <= 9) {
$char = intval($char);
} else {
die('caractère hors borne');
}
$result += $char*$factors[$offset%3];
$offset++;
}
return $result % 10;
}
function str_replace_first($from, $to, $content)
{
$from = '/'.preg_quote($from, '/').'/';
return preg_replace($from, $to, $content, 1);
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 , 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 1007271012355DJAMEL<<<<<<<<8101316M8<br>5 6 8 Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
1007271012355DJAMEL<<<<<<<<8101316M8<br>5 6 8 Output for 4.4.2 - 4.4.9 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 Parse error: syntax error, unexpected '[' in /in/b2V04 on line 76
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 , 5.0.0 - 5.0.5 Parse error: parse error, unexpected '[' in /in/b2V04 on line 76
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error in /in/b2V04 on line 76
Process exited with code 255 . preferences:dark mode live preview
339.48 ms | 401 KiB | 450 Q