Nextrek
Diff Revisions
537
vs
543
for /Android/SmartCharging/endPoints/nightly/add_immagini.php
|
@@ -7,11 +7,12 @@ |
7 |
7 |
|
require_once("constants.php"); |
8 |
8 |
|
|
9 |
9 |
|
require_once("repositories/LocalRepository.php"); |
|
10 |
+ |
require_once("repositories/UserRepository.php"); |
10 |
11 |
|
require_once("repositories/CommentRepository.php"); |
11 |
12 |
|
|
12 |
|
- |
$servername = "localhost"; |
|
13 |
+ |
/*$servername = "localhost"; |
13 |
14 |
|
$username = "smartcharging"; |
14 |
|
- |
$password = "LXRLBaEAuRr7M7jY"; |
|
15 |
+ |
$password = "LXRLBaEAuRr7M7jY";*/ |
15 |
16 |
|
|
16 |
17 |
|
//$params = json_decode($_REQUEST["params"], true); |
17 |
18 |
|
|
|
@@ -27,6 +28,13 @@ |
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 |
+ |
$risposta = createErrorMessage(-1, "Token non valido"); |
|
34 |
+ |
echo json_encode($risposta); |
|
35 |
+ |
die(); |
|
36 |
+ |
} |
|
37 |
+ |
|
30 |
38 |
|
$type = $params["type"]; |
31 |
39 |
|
|
32 |
40 |
|
if ($type=="local") { |
|
@@ -44,9 +52,10 @@ |
44 |
52 |
|
|
45 |
53 |
|
if (count($imgs)) { |
46 |
54 |
|
foreach($imgs as $image) { |
47 |
|
- |
rename($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH.session_id()."/".$image, $_SERVER['DOCUMENT_ROOT'].IMAGES_PATH.$image); |
|
55 |
+ |
//rename($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH.session_id()."/".$image, $_SERVER['DOCUMENT_ROOT'].IMAGES_PATH.$image); |
|
56 |
+ |
rename($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH."/".$image, $_SERVER['DOCUMENT_ROOT'].IMAGES_PATH.$image); |
48 |
57 |
|
} |
49 |
|
- |
rmdir($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH.session_id()."/"); |
|
58 |
+ |
//rmdir($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH.session_id()."/"); |
50 |
59 |
|
} |
51 |
60 |
|
|
52 |
61 |
|
$risposta["return"] = $repo->addImages($params["id"], $imgs); |