mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 07:49:27 +00:00
Get securely a timestamp sent in a POST request
This commit is contained in:
parent
52ab3aa206
commit
c83fd453a0
@ -236,6 +236,28 @@ function getPostMovieId(string $name = "movieID") : int {
|
||||
return $movieID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a timestamp posted in a post request
|
||||
*
|
||||
* @param string $name The name of the $_POST entry
|
||||
* @return int The timestamp if everything went well
|
||||
*/
|
||||
function getPostTimeStamp(string $name) : int {
|
||||
|
||||
//Check if the variable exists
|
||||
if(!isset($_POST[$name]))
|
||||
Rest_fatal_error(400, "Please specify a timestamp in '".$name."' ! ");
|
||||
$timestamp = toInt($_POST[$name]);
|
||||
|
||||
//Check timestamp validity
|
||||
if($timestamp < 10000)
|
||||
Rest_fatal_error(400, "Please specify a valid timestamp value in ".$timestamp." !");
|
||||
|
||||
//Return timestamp
|
||||
return $timestamp;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the validity of an file posted in a request
|
||||
*
|
||||
@ -244,7 +266,7 @@ function getPostMovieId(string $name = "movieID") : int {
|
||||
*/
|
||||
function check_post_file(string $name) : bool {
|
||||
|
||||
//Check if image exists
|
||||
//Check if file exists
|
||||
if(!isset($_FILES[$name]))
|
||||
return false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user