2010-08-08 03:29:24 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GNU social
|
|
|
|
* Copyright (C) 2010, Free Software Foundation, Inc
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-02-13 21:57:15 +09:00
|
|
|
// basename should make sure we can't escape this directory
|
|
|
|
$u = basename($_GET['resource']);
|
2010-08-08 03:29:24 +09:00
|
|
|
|
2016-02-13 21:57:15 +09:00
|
|
|
if (!strpos($u, '@')) {
|
|
|
|
throw new Exception('Bad resource');
|
|
|
|
exit(1);
|
|
|
|
}
|
2010-08-08 03:29:24 +09:00
|
|
|
|
2016-02-13 21:57:15 +09:00
|
|
|
if (mb_strpos($u, 'acct:')===0) {
|
|
|
|
$u = substr($u, 5);
|
|
|
|
}
|
2010-08-08 03:29:24 +09:00
|
|
|
|
2016-02-13 21:57:15 +09:00
|
|
|
$f = $u . ".xml";
|
2010-08-08 03:29:24 +09:00
|
|
|
|
|
|
|
if (file_exists($f)) {
|
2016-02-13 21:57:15 +09:00
|
|
|
header('Content-Disposition: attachment; filename="'.urlencode($f).'"');
|
|
|
|
header('Content-type: application/xrd+xml');
|
|
|
|
echo file_get_contents($f);
|
2010-08-08 03:29:24 +09:00
|
|
|
}
|