Skip to content

Instantly share code, notes, and snippets.

@aelipek
Created December 5, 2013 09:53
Show Gist options
  • Save aelipek/bd9dfb0fa68516ee9348 to your computer and use it in GitHub Desktop.
Save aelipek/bd9dfb0fa68516ee9348 to your computer and use it in GitHub Desktop.
PHP Vergi Kimlik No Kontrol
function validation_vkn($vkn)
{
$balance = true;
for ($i = 0; $i < strlen($vkn); $i++) {
if (is_numeric($vkn[$i])) {
} else
$balance = false;
}
if (strlen($vkn) == 10 && $balance) {
$vkn_1 = $vkn[0];
$vkn_2 = $vkn[1];
$vkn_3 = $vkn[2];
$vkn_4 = $vkn[3];
$vkn_5 = $vkn[4];
$vkn_6 = $vkn[5];
$vkn_7 = $vkn[6];
$vkn_8 = $vkn[7];
$vkn_9 = $vkn[8];
$vkn_10 = $vkn[9];
$vkn_1_1 = ($vkn_1 + 9) % 10;
$vkn_2_2 = ($vkn_2 + 8) % 10;
$vkn_3_3 = ($vkn_3 + 7) % 10;
$vkn_4_4 = ($vkn_4 + 6) % 10;
$vkn_5_5 = ($vkn_5 + 5) % 10;
$vkn_6_6 = ($vkn_6 + 4) % 10;
$vkn_7_7 = ($vkn_7 + 3) % 10;
$vkn_8_8 = ($vkn_8 + 2) % 10;
$vkn_9_9 = ($vkn_9 + 1) % 10;
$vkn_1_1_1 = ($vkn_1_1 * pow(2, 9)) % 9;
$vkn_2_2_2 = ($vkn_2_2 * pow(2, 8)) % 9;
$vkn_3_3_3 = ($vkn_3_3 * pow(2, 7)) % 9;
$vkn_4_4_4 = ($vkn_4_4 * pow(2, 6)) % 9;
$vkn_5_5_5 = ($vkn_5_5 * pow(2, 5)) % 9;
$vkn_6_6_6 = ($vkn_6_6 * pow(2, 4)) % 9;
$vkn_7_7_7 = ($vkn_7_7 * pow(2, 3)) % 9;
$vkn_8_8_8 = ($vkn_8_8 * pow(2, 2)) % 9;
$vkn_9_9_9 = ($vkn_9_9 * pow(2, 1)) % 9;
if ($vkn_1_1 != 0 and $vkn_1_1_1 == 0)
$vkn_1_1_1 = 9;
if ($vkn_2_2 != 0 and $vkn_2_2_2 == 0)
$vkn_2_2_2 = 9;
if ($vkn_3_3 != 0 and $vkn_3_3_3 == 0)
$vkn_3_3_3 = 9;
if ($vkn_4_4 != 0 and $vkn_4_4_4 == 0)
$vkn_4_4_4 = 9;
if ($vkn_5_5 != 0 and $vkn_5_5_5 == 0)
$vkn_5_5_5 = 9;
if ($vkn_6_6 != 0 and $vkn_6_6_6 == 0)
$vkn_6_6_6 = 9;
if ($vkn_7_7 != 0 and $vkn_7_7_7 == 0)
$vkn_7_7_7 = 9;
if ($vkn_8_8 != 0 and $vkn_8_8_8 == 0)
$vkn_8_8_8 = 9;
if ($vkn_9_9 != 0 and $vkn_9_9_9 == 0)
$vkn_9_9_9 = 9;
$toplam = $vkn_9_9_9 + $vkn_8_8_8 + $vkn_7_7_7 + $vkn_6_6_6 + $vkn_5_5_5 + $vkn_4_4_4 +
$vkn_3_3_3 + $vkn_2_2_2 + $vkn_1_1_1;
if ($toplam % 10 == 0)
$toplam_son = 0;
else
$toplam_son = 10 - ($toplam % 10);
if ($toplam_son == $vkn_10)
return true;
else
return false;
} else
return false;
}
@aelipek
Copy link
Author

aelipek commented Dec 5, 2013

Vergi Kimlik No Doğrulama

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment