progetto201 API
|
USERPLAN: manages user's plan (returns paths and names). More...
Functions | |
get_userplan ($t_conn_res) | |
This function returns data relative to the plan selected from the user. More... | |
userplan_isvalid ($t_plan_data) | |
Checks if plan data is valid. More... | |
post_userplan ($t_conn_res) | |
Sets user's desired plan. More... | |
Variables | |
$response = array("errors" => array()) | |
Prepare default response array with no errors. More... | |
$planspath = $_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . "static" . DIRECTORY_SEPARATOR . "img" . DIRECTORY_SEPARATOR . "maps" | |
Plan's path (file system) More... | |
USERPLAN: manages user's plan (returns paths and names).
Client perspective:
The script tries to connect to the database and then checks the request method.
If the method is GET get_userplan() is called. Else post_userplan() is called.
userplan_isvalid() is used to check if plan's data is correct
Error codes:
get_userplan | ( | $t_conn_res | ) |
This function returns data relative to the plan selected from the user.
The function selects the plan name from the options table inside the database, concatenates the expected plan path with the name and returns both path and name inside an array.
Errors list:
array | $t_conn_res | file system path with plans |
post_userplan | ( | $t_conn_res | ) |
Sets user's desired plan.
First it checks if the client passed the plan name, then it checks if its expected path is valid using the userplan_isvalid() function.
After that it executes an UPDATE query to set the new plan.
Errors list:
array | $t_conn_res | array with connection object or errors |
userplan_isvalid | ( | $t_plan_data | ) |
Checks if plan data is valid.
To do this first its existance is checked using file_exists() function, then the function checks the mime type (it must be "SVG") If data is valid the "data" value will be true. Else the returned array has errors data.
Errors list:
array | $t_plan_data | plan's data to validate |
$planspath = $_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . "static" . DIRECTORY_SEPARATOR . "img" . DIRECTORY_SEPARATOR . "maps" |
Plan's path (file system)
$response = array("errors" => array()) |
Prepare default response array with no errors.