Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>calcolo codice fiscale</title>
- <?php
- //funzioni
- function convGio($Gio){
- $scelt=$_GET["scelta"];
- if($Gio<10)
- return "0".$Gio;
- return $Gio;
- }
- function convMese($mes){
- switch($mes){
- case 1: return "A";
- break;
- case 2: return "B";
- break;
- case 3: return "C";
- break;
- case 4: return "D";
- break;
- case 5: return "E";
- break;
- case 6: return "H";
- break;
- case 7: return "L";
- break;
- case 8: return "M";
- break;
- case 9: return "P";
- break;
- case 10: return "R";
- break;
- case 11: return "S";
- break;
- case 12: return "T";
- break;
- default: break;
- }
- }
- function codCom($comune){
- switch($comune){
- case "roma": return "H501";
- case "latina": return "E472";
- case "sezze": return "I712";
- case "cori": return "D003";
- case "cisterna": return "C740";
- case "napoli": return "F839";
- case "formia": return "D708";
- case "filippine": return "Z216";
- case "priverno": return "G698";
- case "alatri": return "A123";
- case "aprilia": return "A341";
- case "milano": return "F205";
- break;
- }
- }
- function consonanti($s)
- {
- $s=strtoupper($s);
- $cons="";
- for($i=0;$i<strlen($s);$i++)
- { $car=substr($s,$i,1);
- if($car>="A" && $car<="Z")
- if(!( ($car=="A") ||($car=="E") ||($car=="I") ||($car=="O") ||($car=="U")) )
- $cons=$cons .$car;
- }
- return $cons;
- }
- function vocali($s)
- {
- $s=strtoupper($s);
- $voc="";
- for($i=0;$i<strlen($s);$i++)
- { $car=substr($s,$i,1);
- if($car>="A" && $car<="Z")
- if( ($car=="A") ||($car=="E") ||($car=="I") ||($car=="O") ||($car=="U") )
- $voc=$voc .$car;
- }
- return $voc;
- }
- ?>
- </head>
- <body>
- <?php
- if(!isset($_GET["cognome"] ) || !isset($_GET["nome"]) || !isset($_GET["giorno"] ) || !isset($_GET["mese"]) || !isset($_GET["anno"]) || !isset($_GET["scelta"])){
- die("<h1>Per favore compila tutti i campi</h1>");
- }
- $scelt=$_GET["scelta"];
- $an=$_GET["anno"];
- $mes=$_GET["mese"];
- $gio=$_GET["giorno"];
- $cogn=$_GET["cognome"];
- $nome=$_GET["nome"];
- $comune=$_GET["comune"];
- echo "<h1>$cogn $nome il tuo codice fiscale è </h1>";
- if($scelt=="F")
- $gio=convGio($gio)+40;
- $gio=convGio($gio);
- $codcogn=substr(consonanti($cogn). vocali($cogn). "X",0,3);
- if( strlen(consonanti($nome)) <=3)
- $codnome=substr(consonanti($nome). vocali($nome). "X",0,3);
- else
- $codnome=substr(consonanti($nome),0,1).substr(consonanti($nome),2,2);
- $m=convMese($mes);
- $c=codCom($comune);
- $codan=substr($an,2,3);
- echo "<h2>$codcogn$codnome$codan$m$gio$c</h2>"
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement