Archiv für April 2009

Personalausweisnummer überprüfen und auslesen

Dienstag, 28. April 2009

Mit dieser von mir entwickelten Funktion kann man, via PHP, eine deutsche Personalausweisnummer auf ihre Gültigkeit prüfen.
Ist die Personalausweisnummer gültig, erhält man ein Array mit allen Information zu der Person.

// Edit: Habe am 13. Mai 2009 nochmal eine überarbeitete Funktion in diesen Beitrag integriert.

< ?php
/**
 * PASS    : XXXXXXXXXXD << XXXXXXX < XXXXXXX <<<<<<< X
 * FUNCTION: $ID01       << $ID02   < $ID03   <<<<<<< $ID04
 *
 * by Frank Burian, nQuee netappz - http://www.nquee.com
 */
function checkGermanPersonalId($ID01,$ID02,$ID03,$ID04) {
 
	$arrResult = array();
	// Prüfsumme ermitteln
	if (!function_exists('buildChecksum')) {
		function buildChecksum($intID) {
			$intMultiplier = 7;
			$intSum = 0;
			if (strlen($intID) == 11) {
				$intIDLength = 9;
			} elseif (strlen($intID) == 7) {
				$intIDLength = 6;
			} else {
				$intIDLength = strlen($intID);
			}
			for ($a=0; $a<$intIDLength; $a++) {
				$intSign = (integer) substr($intID,$a,1);
				$intTmpSum = ($intSign*$intMultiplier);
				$intSum += (integer) substr($intTmpSum,strlen($intTmpSum)-1,1);
				if ($intMultiplier == 7) {
					$intMultiplier = 3;
				} elseif ($intMultiplier == 3) {
					$intMultiplier = 1;
				} else {
					$intMultiplier = 7;
				}
			}
			return substr($intSum,strlen($intSum)-1,1);
		}
	}
	// Erste ID prüfen
	if (strlen($ID01) != 11) {
		return false;
	}
	if (buildChecksum($ID01) != substr($ID01,9,1)) {
		return false;
	}
	$arrResult['firstLocation'] = substr($ID01,0,4);
	$arrResult['origin'] = strtoupper($ID01{10});
	$arrResult['isGerman'] = ($arrResult['origin'] == 'D') ? true : false;
	// Zweite ID prüfen
	if (strlen($ID02) != 7) {
		return false;
	}
	if (buildChecksum($ID02) != $ID02{6}) {
		return false;
	}
	$arrResult['birthday']['day'] = $ID02{4}.$ID02{5};
	$arrResult['birthday']['month'] = $ID02{2}.$ID02{3};
	$arrResult['birthday']['year'] = $ID02{0}.$ID02{1};
	$arrResult['age'] = intval((mktime(0,0,0,date("m"),date("d"),date("Y")) -
						mktime(0,0,0,$arrResult['birthday']['month'],$arrResult['birthday']['day'],$arrResult['birthday']['year']))
						/ (3600 * 24 * 365));
	$arrResult['isAdult'] = ($arrResult['age'] >= 18) ? true : false;
 
	// Dritte ID prüfen
	if (strlen($ID03) != 7) {
		return false;
	}
	if (buildChecksum($ID03) != $ID03{6}) {
		return false;
	}
	$arrResult['expiration']['day'] = $ID03{4}.$ID03{5};
	$arrResult['expiration']['month'] = $ID03{2}.$ID03{3};
	$arrResult['expiration']['year'] = $ID03{0}.$ID03{1};
	// Vierte ID prüfen
	$intCompletePersonalId = substr($ID01,0,10).$ID02.$ID03;
	if (buildChecksum($intCompletePersonalId) != $ID04) {
		return false;
	}
	return $arrResult;
}
// Aufruf:
print_r(checkGermanPersonalId('6127057594D','8703189','1911149','2'));
?>

Notepad durch Notepad2 unter Windows XP ersetzen

Donnerstag, 09. April 2009

Da ich Notepad2 als Notepad-Ersatz am Besten finde, möchte ich euch zeigen wie ihr Notepad mit Notepad2 ersetzt, denn so einfach ist das garnicht, da Windows immer wieder den ursprünglichen Notepad-Stand herstellt.

Ladet euch Notepad2 herunter und entpackt es in einem Ordner. In diesem Ordner, wo auch die notepad2.exe nach dem Entpacken liegt, erstellt ihr euch eine Bat-Datei z.B. “install.bat”. In diese Datei fügt ihr folgendes ein:

copy /y notepad.exe “%windir%\system32\dllcache\notepad.exe”
copy /y notepad.exe “%windir%\system32\notepad.exe”
copy /y notepad.exe “%windir%\notepad.exe”
copy /y notepad.exe “%windir%\$NtServicePackUninstall$\notepad.exe”
copy /y notepad.exe “%windir%\LastGood\notepad.exe”
copy /y notepad.exe “%windir%\LastGood\system32\notepad.exe”
copy /y notepad.exe “%windir%\ServicePackFiles\i386\notepad.exe”

Und zum Schluss benennt ihr die “notepad2.exe” in “notepad.exe” um, und führt dann die “install.bat” aus.