Nextrek
@ 309
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
<?php session_start(); header("Access-Control-Allow-Origin: *"); header('Content-Type: application/json; charset=UTF-8'); require_once("CommentRepository.php"); $servername = "localhost"; $username = "smartcharging"; $password = "LXRLBaEAuRr7M7jY"; //$params = json_decode($_REQUEST["params"], true); //$input = file_get_contents('php://input'); $params = json_decode(file_get_contents('php://input'), true); $conn; //$risposta = array(); $comment = new Comment(); $comment_repo; try { $conn = new PDO("mysql:host=".$servername.";dbname=smartcharging", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //echo "Connesso con successo al DB"; $comment_repo = new CommentRepository($conn); $comment->id_locale = $params["local_id"]; $comment->id_user = $params["user_id"]; $comment->voto = $params["voto"]; $comment->descrizione = $params["descrizione"]; $comment->data = $params["data"]; //$comment->imgs = $params["imgs"]; $risposta = $comment_repo->addComment($comment); $commentImgs = array_key_exists("imgs", $params) ? $params["imgs"] : null; if ($risposta["return"] == 0 && count($commentImgs)>0) { foreach($commentImgs as $image) { rename("./images/temp/".session_id()."/".$image, "./images/".$image); } rmdir("./images/temp/".session_id()."/"); } $comment_repo->addImages($risposta["id"], $commentImgs); //unset($_SESSION["images"]); } catch(PDOException $e) { echo $e->getMessage(); $risposta["return"] = 1; } echo json_encode($risposta); $conn = null; //Close the connection to the DBMS ?> |
Commits for Nextrek/Android/SmartCharging/endPoints/add_commento.php
Revision | Author | Commited | Message |
---|---|---|---|
309 Diff | FSallustio | Mon 13 Jul, 2015 16:08:26 +0000 | |
301 Diff | FSallustio | Mon 13 Jul, 2015 15:25:22 +0000 | |
300 Diff | FSallustio | Mon 13 Jul, 2015 15:15:58 +0000 | |
265 Diff | FSallustio | Fri 10 Jul, 2015 12:50:57 +0000 | Risolto problema con l’application/json negli altri endpoint. |
249 Diff | FSallustio | Fri 10 Jul, 2015 07:17:20 +0000 | Risolto bug chiamate POST |
242 Diff | FSallustio | Thu 09 Jul, 2015 11:18:36 +0000 | get_commenti.php implementata + bugfix |
240 | FSallustio | Thu 09 Jul, 2015 10:08:30 +0000 | Implementati add_commento.php, cambia_nome_locale.php e set_descrizione.php |