friendica/mod/modexp.php

37 wiersze
672 B
PHP
Czysty Zwykły widok Historia

<?php
use Friendica\App;
use Friendica\Database\DBA;
function modexp_init(App $a) {
if($a->argc != 2)
2018-12-26 05:40:12 +00:00
exit();
$nick = $a->argv[1];
2010-10-12 11:07:03 +00:00
$r = q("SELECT `spubkey` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
2018-07-21 13:10:13 +00:00
DBA::escape($nick)
);
2018-07-21 12:46:04 +00:00
if (! DBA::isResult($r)) {
2018-12-26 05:40:12 +00:00
exit();
}
2010-10-12 11:07:03 +00:00
$lines = explode("\n",$r[0]['spubkey']);
unset($lines[0]);
unset($lines[count($lines)]);
$x = base64_decode(implode('',$lines));
$r = ASN_BASE::parseASNString($x);
$m = $r[0]->asnData[1]->asnData[0]->asnData[0]->asnData;
$e = $r[0]->asnData[1]->asnData[0]->asnData[1]->asnData;
header("Content-type: application/magic-public-key");
echo 'RSA' . '.' . $m . '.' . $e;
2018-12-26 05:40:12 +00:00
exit();
2010-10-12 11:07:03 +00:00
}