-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.php
41 lines (35 loc) · 936 Bytes
/
publish.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
if (!defined('CORRECT_ENTRY')) {
http_response_code(500);
echo 'Internal server error';
exit();
}
if($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo ';ethod not allowed';
exit();
}
$poststr = file_get_contents('php://input');
$post_data = json_decode($poststr, true);
if(!isset($post_data) || !is_array($post_data) ||
!isset($post_data['type']) || !is_string($post_data['type']) ||
!isset($post_data['ver']) || !is_string($post_data['ver']) ) {
http_response_code(400);
echo 'Bad request';
exit();
}
$type = $post_data['type'];
$ver = $post_data['ver'];
if($ver != '0.3' && $ver != '0.4') {
http_response_code(400);
echo 'Bad request';
exit();
}
if($type == 'prepare_post') {
require_once('publish-prepare.php');
} elseif($type == 'post') {
require_once('publish-post.php');
} else {
http_response_code(400);
echo 'Bad request';
}