42 lines
921 B
PHP
42 lines
921 B
PHP
<?php
|
|
require '../../webdata/init.php';
|
|
|
|
header("Content-Type: application/json");
|
|
|
|
if(!checkLogin()){
|
|
returns("Not logged in",2);
|
|
}
|
|
|
|
$user_id = $_SESSION['user_id'];
|
|
|
|
function returns($content = 'Success', $code = 0){
|
|
if($code != 0 || $content == 'Success'){
|
|
$returns['status'] = $code;
|
|
$returns['message'] = $content;
|
|
}
|
|
else {
|
|
$returns['data'] = $content;
|
|
}
|
|
|
|
echo json_encode($returns);
|
|
die();
|
|
}
|
|
|
|
function sanitize(): array{
|
|
global $_GET, $_POST;
|
|
$data = array();
|
|
|
|
foreach([$_GET, $_POST] as $request){
|
|
if(!empty($request)){
|
|
foreach($request as $key => $value){
|
|
if(($data[$key] = filter($value)) === false){
|
|
print_r($value);
|
|
echo "Failed to sanitize: `".$key."`: ".$value." \t-\t type: ".gettype($value)."\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return $data;
|
|
}
|