git.cweiske.de
/
anoweco.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Simple latest comment list
[anoweco.git]
/
www
/
micropub.php
diff --git
a/www/micropub.php
b/www/micropub.php
index 375920b4fa400f7ecbcf297fb4a255c0fc900767..eff6ea7f26fde64042859ad3a79d36fa06e486fb 100644
(file)
--- a/
www/micropub.php
+++ b/
www/micropub.php
@@
-82,37
+82,47
@@
function handleCreate($json, $token)
);
}
);
}
- if (!isset($json->properties->{'in-reply-to'})) {
- mpError(
- 'HTTP/1.0 400 Bad Request',
- 'invalid_request',
- 'Only replies accepted'
- );
- }
-
$storage = new Storage();
$storage = new Storage();
+ $lb = new Linkback();
try {
$id = $storage->addComment($json, $userId);
try {
$id = $storage->addComment($json, $userId);
+ $lb->ping($id);
header('HTTP/1.0 201 Created');
header('Location: ' . Urls::full(Urls::comment($id)));
exit();
} catch (\Exception $e) {
header('HTTP/1.0 201 Created');
header('Location: ' . Urls::full(Urls::comment($id)));
exit();
} catch (\Exception $e) {
- //FIXME: return correct status code
- header('HTTP/1.0 500 Internal Server Error');
+ if ($e->getCode() == 400) {
+ mpError(
+ 'HTTP/1.0 400 Bad Request',
+ 'invalid_request',
+ $e->getMessage()
+ );
+ }
+
+ mpError(
+ 'HTTP/1.0 500 Internal Server Error',
+ 'this_violates_the_spec',
+ $e->getMessage()
+ );
exit();
}
}
function getTokenFromHeader()
{
exit();
}
}
function getTokenFromHeader()
{
- if (!isset($_SERVER['HTTP_AUTHORIZATION'])) {
+ if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
+ $auth = $_SERVER['HTTP_AUTHORIZATION'];
+ } else if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
+ //php-cgi has it there
+ $auth = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
+ } else {
mpError(
'HTTP/1.0 403 Forbidden', 'forbidden',
'Authorization HTTP header missing'
);
}
mpError(
'HTTP/1.0 403 Forbidden', 'forbidden',
'Authorization HTTP header missing'
);
}
- list($bearer, $token) = explode(' ', $
_SERVER['HTTP_AUTHORIZATION']
, 2);
+ list($bearer, $token) = explode(' ', $
auth
, 2);
if ($bearer !== 'Bearer') {
mpError(
'HTTP/1.0 403 Forbidden', 'forbidden',
if ($bearer !== 'Bearer') {
mpError(
'HTTP/1.0 403 Forbidden', 'forbidden',
@@
-155,7
+165,8
@@
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
'Content-Type header missing.'
);
}
'Content-Type header missing.'
);
}
- $ctype = $_SERVER['CONTENT_TYPE'];
+ list($ctype) = explode(';', $_SERVER['CONTENT_TYPE'], 2);
+ $ctype = trim($ctype);
if ($ctype == 'application/x-www-form-urlencoded') {
if (!isset($_POST['action'])) {
$_POST['action'] = 'create';
if ($ctype == 'application/x-www-form-urlencoded') {
if (!isset($_POST['action'])) {
$_POST['action'] = 'create';
@@
-201,8
+212,8
@@
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$json = $base;
$json->properties = (object) $data;
handleCreate($json, $token);
$json = $base;
$json->properties = (object) $data;
handleCreate($json, $token);
- } else if ($ctype == 'application/j
avascript
') {
- $input = file_get_contents('php://
stdin
');
+ } else if ($ctype == 'application/j
son
') {
+ $input = file_get_contents('php://
input
');
$json = json_decode($input);
if ($json === null) {
mpError(
$json = json_decode($input);
if ($json === null) {
mpError(