friendica_2021-01/mod/modexp.php
Andrej Stieben db949bb802 Updated modules to allow for partial overrides without errors
Only define functions if they have not been defined before, e.g. in themes. This makes it possible to override parts of a module and still use the other functions.
2016-02-05 21:52:39 +01:00

35 lines
682 B
PHP

<?php
require_once('library/asn1.php');
if(! function_exists('modexp_init')) {
function modexp_init(&$a) {
if($a->argc != 2)
killme();
$nick = $a->argv[1];
$r = q("SELECT `spubkey` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
dbesc($nick)
);
if(! count($r))
killme();
$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 ;
killme();
}
}