function colis_get_info($name, $profileId) { /** * You could use profileId here to shorten the algorithm a little bit, * but I didn't use it in this particular demo */ return colis_get_info_by_name($name); }
<?php use Tim\TimServer\OpaqueTimServer; use Tim\TimServer\TimServerInterface; //------------------------------------------------------------------------------/ // COLIS LING - INFO SERVICE - FAST VERSION //------------------------------------------------------------------------------/ require_once 'inc/colis_init_fast.php'; // replace this with your application init in prod OpaqueTimServer::create()->setServiceName('colis.ling_info_fast')->start(function (TimServerInterface $s) { if (isset($_POST['name'])) { $name = $_POST['name']; $s->success(colis_get_info_by_name($name)); } else { $s->error("Invalid input data: missing name"); } })->output();
} } else { if (!($in = @fopen("php://input", "rb"))) { http_response_code(403); $s->error("Failed to open input stream"); return false; } } while ($buff = fread($in, 4096)) { fwrite($out, $buff); } @fclose($out); @fclose($in); // Check if file has been uploaded if (!$chunks || $chunk == $chunks - 1) { // Strip the temp .part suffix off rename("{$filePath}.part", $filePath); $name = basename($filePath); $err = ''; if (false !== ($info = colis_get_info_by_name($name, $err))) { $s->success(['name' => $name, 'info' => $info]); } else { http_response_code(403); $s->error($err); return false; } } if ($chunks && $chunk !== $chunks - 1) { die('chunk...'); } })->output();