/dev/null`; //echo "gpg says\n".htmlspecialchars($gpg); foreach (explode("\n", $gpg) as $line) { $bits = explode(":", $line); if ($bits[0] != "pub" && $bits[0] != "uid") { continue; } $match = false; $problem = ""; $uid = " ".preg_replace('~\\\\x([0-9a-f])([0-9a-f])~ei', 'chr(hexdec("\\1\\2"))', $bits[9]); //print "$uid\n"; if (iconv("UTF-8", "UTF-8", $uid)) { $uid = mb_ereg_replace("\\\\", "\\x5c", $uid); $uid = mb_ereg_replace("\\:", "\\x3a", $uid); } else { if ($tmp = iconv("ISO-8859-1", "UTF-8", $uid)) { $problem = ":BAD_ENCODING:"; $uid = $tmp; $uid = mb_ereg_replace("\\\\", "\\x5c", $uid); $uid = mb_ereg_replace("\\:", "\\x3a", $uid); } else { $problem = ":UNKNOWN_ENCODING:"; $uid = $bits[9]; } } //print "$uid\n"; foreach ($addrs as $addr) { //print "$uid, $addr\n"; //print mb_convert_encoding($addr, "UTF-8")."\n"; $uid = mb_replace($uid, mb_convert_encoding($addr, "UTF-8"), "V_A_L_I_D__E_M_A_I_L"); } //print "$uid\n"; $uid = mb_replace($uid, mb_convert_encoding($user['lname'], "UTF-8"), "L_N_A_M_E"); $uid = mb_replace($uid, mb_convert_encoding($user['fname'], "UTF-8"), "F_N_A_M_E"); $uid = mb_replace($uid, mb_convert_encoding($user['mname'], "UTF-8"), "M_N_A_M_E"); $uid = mb_replace($uid, mb_convert_encoding($user['suffix'], "UTF-8"), "S_U_F_F_I_X"); $uid = mb_replace($uid, deUmlaut($user['lname']), "L_N_A_M_E__U_M_L_A_U_T"); $uid = mb_replace($uid, deUmlaut($user['fname']), "F_N_A_M_E__U_M_L_A_U_T"); $uid = mb_replace($uid, deUmlaut($user['mname']), "M_N_A_M_E__U_M_L_A_U_T"); $uid = mb_replace($uid, deUmlaut($user['suffix']), "S_U_F_F_I_X__U_M_L_A_U_T"); //print deUmlaut2($user['lname'])."\n"; $uid = mb_replace($uid, deUmlaut2($user['lname']), "L_N_A_M_E__U_M_L_A_U_T"); $uid = mb_replace($uid, deUmlaut2($user['fname']), "F_N_A_M_E__U_M_L_A_U_T"); $uid = mb_replace($uid, deUmlaut2($user['mname']), "M_N_A_M_E__U_M_L_A_U_T"); $uid = mb_replace($uid, deUmlaut2($user['suffix']), "S_U_F_F_I_X__U_M_L_A_U_T"); if (strlen($user['mname']) > 0) { $uid = mb_replace($uid, mb_convert_encoding(substr($user['mname'], 0, 1) . ".", "UTF-8"), "M_N_A_M_E__I_N_I_T_I_A_L"); } if (strlen($user['fname']) > 0) { $uid = mb_replace($uid, mb_convert_encoding(substr($user['fname'], 0, 1) . ".", "UTF-8"), "F_N_A_M_E__I_N_I_T_I_A_L"); } $nameRegEx = "^ (:F_N_A_M_E([^:]*):\s+" . "(:M_N_A_M_E([^:]*):\s+)?" . ":L_N_A_M_E([^:]*):" . "(\s+:S_U_F_F_I_X([^:]*):)?)?" . "(\s*\(.*\))?" // optional comment . "(\s*?)?" . "\$"; if (!mb_ereg_search_init($uid, $nameRegEx)) { $problem .= ":REGEX_FAILED:"; } $res = mb_ereg_search_regs(); if ($res) { $match = true; if ($res[8] != "") { $problem .= ":UNPARSED_COMMENT:"; } if ($res[2] != "") { $problem .= ":".$res[2].":"; } if ($res[4] != "") { $problem .= ":".$res[4].":"; } if ($res[5] != "") { $problem .= ":".$res[5].":"; } if ($res[7] != "") { $problem .= ":".$res[7].":"; } //print $res[0].",".$res[1].",".$res[2].",".$res[3].",".$res[4]."," // .$res[5].",".$res[6].",".$res[7].",".$res[8].",".$res[9]."," // .$res[10]."\n"; } else { $problem = ":MISMATCH:$problem"; } if (!$match || $problem != "") { print $key[0] . "," . csvize($problem) . "," . csvize($uid) . "," . csvize(preg_replace('/([^ -~])/ei', '"\\\\x".sprintf("%02x", ord("\\1"))', $bits[9])) . "," . mb_convert_encoding(csvize($user['fname']), "UTF-8") . "," . mb_convert_encoding(csvize($user['mname']), "UTF-8") . "," . mb_convert_encoding(csvize($user['lname']), "UTF-8") . "," . mb_convert_encoding(csvize($user['suffix']), "UTF-8"); foreach ($addrs as $addr) { print "," . mb_convert_encoding(csvize($addr), "UTF-8"); } print "\n"; } } } ?>