1, 'status' => $msg ]; if ($url) { $obj['url'] = $url; if ($when) { $obj['when'] = $when; # date('Y-m-d H:i:s', ) } } if ($key) { $obj['key'] = $key; } echo json_encode($obj); } function response_success($bundle_id, $key) { $url = $bundle_id ? 'https://appchk.de/app/'.$bundle_id.'/index.html' : null; # next update will be in ... X seconds (up to 1 min) make_output('ok', $url, ceil(time()/120)*120 - time(), $key); } function response_fail($error) { http_response_code(400); make_output($error); } // MAIN $err = null; $content = file_get_contents('php://input'); // OR: disable json check and store file immediately? $json = json_decode($content); if ($json->v == 1 && $json->duration > 0 && !is_null($json->{'app-bundle'}) && !is_null($json->logs)) { [$bundle_id, $valid] = normalize_bundle($json->{'app-bundle'}); [$filename, $key] = random_filename($bundle_id); $fp = @fopen($filename, 'w'); if ($fp) { @fwrite($fp, $content); @fclose($fp); mark_needs_update($bundle_id); } else { $err = 'could not save.'; } } else { $err = 'wrong json format.'; } if ($err) { response_fail($err); } else { response_success($valid ? $bundle_id : null, $key); } ?>