3
Use Volley to make POST request to a url that returns user data... But you can see this data, creating a simple html form with action set to the url 192.168.0.101/project/user.php . Ai shows all the JSON... how to prevent the guy to see this data without harming the app when listing this data in recyclerview? NOTE: I used header("Location: www.teste.com"); and redirect without showing the JSON to the possible "hacker", BUT does not list the data in the app
PHP:
<?php
require_once('config.php');
require_once 'classes/BD.class.php';
BD::conn();
if(isset($_POST['user']) && $_POST['user'] != ""){
$user = (int)$_POST['user'];
$searchPhotos = BD::conn()->prepare("SELECT * FROM `photos` WHERE `id_user` = ? ORDER BY `id` DESC");
$searchPhotos->execute(array($user));
$resultPhotos = $searchPhotos->rowCount();
$searchQtdFollowers = BD::conn()->prepare("SELECT id FROM `follows` WHERE `user` = ?");
$searchQtdFollowers->execute(array($user));
$resultFollowers = $searchQtdFollowers->rowCount();
$searchQtdFollowing = BD::conn()->prepare("SELECT id FROM `follows` WHERE `follower` = ?");
$searchQtdFollowing->execute(array($user));
$resultFollowing = $searchQtdFollowing->rowCount();
$array = array(
"photos" => $resultPhotos,
"followers" => $resultFollowers,
"following" => $resultFollowing
);
$result[] = array_map("utf8_encode", $array);
while($data = $searchPhotos->fetch(PDO::FETCH_ASSOC)){
$array = array(
"photo" => PATH.$data["photo"],
"date_creation" => date('d/m/Y', strtotime($data["date_creation"]))
);
$result[] = array_map("utf8_encode", $array);
}
header('Content-type: application/json');
echo json_encode($result);
}
?>
your system has a login or you want to limit the view of data only to people who are using your application?
– Nicolas Bontempo
@Nicolasbontempo has a login, but it also has data search through POST, if the guy access/search.php in the html form and send such value to a parameter, he sees the JSON... I want all these JSON seal accessed only in the application and not by browsers
– Jonathan Silva