Subversion Repository Public Repository

Nextrek

Diff Revisions 578 vs 579 for /Android/SmartCharging/endPoints/delete_immagine.php

Diff revisions: vs.
  @@ -3,14 +3,15 @@
3 3
4 4 header("Access-Control-Allow-Origin: *");
5 5 header('Content-Type: application/json; charset=UTF-8');
6 -
6 +
7 7 require_once("repositories/LocalRepository.php");
8 + require_once("repositories/UserRepository.php");
8 9 require_once("repositories/CommentRepository.php");
9 10 require_once("constants.php");
10 11
11 - $servername = "localhost";
12 + /*$servername = "localhost";
12 13 $username = "smartcharging";
13 - $password = "LXRLBaEAuRr7M7jY";
14 + $password = "LXRLBaEAuRr7M7jY";*/
14 15
15 16 //$params = json_decode($_REQUEST["params"], true);
16 17
  @@ -22,10 +23,17 @@
22 23 $repo;
23 24
24 25 try {
25 - $conn = new PDO("mysql:host=".$servername.";dbname=smartcharging", $username, $password);
26 + $conn = new PDO("mysql:host=".DB_SERVERNAME.";dbname=".DB_NAME, DB_USERNAME, DB_PASSWORD);
26 27 $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
27 28 //echo "Connesso con successo al DB";
28 29
30 + if (!array_key_exists("token", $params) || !UserRepository::checkToken($params["token"], $conn)) {
31 + //$risposta["return"] = -1;
32 + $risposta = createErrorMessage(-1, "Token non valido");
33 + echo json_encode($risposta);
34 + die();
35 + }
36 +
29 37 $type = $params["type"];
30 38
31 39 if ($type=="local") {
  @@ -33,7 +41,8 @@
33 41 } else if ($type=="comment") {
34 42 $repo = new CommentRepository($conn);
35 43 } else {
36 - $risposta["return"] = 1;
44 + $risposta = createErrorMessage(1, "Parametro \"type\" non valido");
45 + //$risposta["return"] = 1;
37 46 echo json_encode($risposta);
38 47 die();
39 48 }
  @@ -46,7 +55,8 @@
46 55 catch(PDOException $e)
47 56 {
48 57 echo $e->getMessage();
49 - $risposta["return"] = 1;
58 + $risposta = createErrorMessage(1, "Errore DB");
59 + //$risposta["return"] = 1;
50 60 }
51 61
52 62 echo json_encode($risposta);