Nextrek
Diff Revisions
441
vs
507
for /Android/SmartCharging/endPoints/add_commento.php
|
@@ -4,8 +4,9 @@ |
4 |
4 |
|
header("Access-Control-Allow-Origin: *"); |
5 |
5 |
|
header('Content-Type: application/json; charset=UTF-8'); |
6 |
6 |
|
|
7 |
|
- |
require_once("CommentRepository.php"); |
8 |
|
- |
|
|
7 |
+ |
require_once("constants.php"); |
|
8 |
+ |
require_once("repositories/CommentRepository.php"); |
|
9 |
+ |
require_once("repositories/UserRepository.php"); |
9 |
10 |
|
require_once("utilities.php"); |
10 |
11 |
|
|
11 |
12 |
|
$servername = "localhost"; |
|
@@ -27,13 +28,20 @@ |
27 |
28 |
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
28 |
29 |
|
//echo "Connesso con successo al DB"; |
29 |
30 |
|
|
|
31 |
+ |
if (!array_key_exists("token", $params) || !UserRepository::checkToken($params["token"], $conn)) { |
|
32 |
+ |
$risposta["return"] = -1; |
|
33 |
+ |
echo json_encode($risposta); |
|
34 |
+ |
die(); |
|
35 |
+ |
} |
|
36 |
+ |
|
30 |
37 |
|
$comment_repo = new CommentRepository($conn); |
31 |
38 |
|
|
32 |
39 |
|
$comment->id_locale = $params["local_id"]; |
33 |
40 |
|
$comment->id_user = $params["user_id"]; |
34 |
41 |
|
$comment->voto = $params["voto"]; |
35 |
42 |
|
$comment->descrizione = $params["descrizione"]; |
36 |
|
- |
$comment->data = $params["data"]; |
|
43 |
+ |
//$comment->data = $params["data"]; |
|
44 |
+ |
$comment->data = date(DATE_ATOM); |
37 |
45 |
|
//$comment->imgs = $params["imgs"]; |
38 |
46 |
|
|
39 |
47 |
|
$risposta = $comment_repo->addComment($comment); |
|
@@ -42,10 +50,11 @@ |
42 |
50 |
|
|
43 |
51 |
|
if ($risposta["return"] == 0 && count($commentImgs)>0) { |
44 |
52 |
|
foreach($commentImgs as $image) { |
45 |
|
- |
rename("./images/temp/".$image, "./images/".$image); |
|
53 |
+ |
//rename($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH.session_id()."/".$image, $_SERVER['DOCUMENT_ROOT'].IMAGES_PATH.$image); |
|
54 |
+ |
rename($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH."/".$image, $_SERVER['DOCUMENT_ROOT'].IMAGES_PATH.$image); |
46 |
55 |
|
} |
47 |
56 |
|
//rmdir("./images/temp/".session_id()."/"); |
48 |
|
- |
//deleteDirectory("./images/temp/".session_id()."/"); |
|
57 |
+ |
//deleteDirectory($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH.session_id()."/"); |
49 |
58 |
|
$comment_repo->addImages($risposta["id"], $commentImgs); |
50 |
59 |
|
} |
51 |
60 |
|
|