Subversion Repository Public Repository

Nextrek

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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
    session_start();

    header("Access-Control-Allow-Origin: *");
    header('Content-Type: application/json; charset=UTF-8');

    require_once("constants.php");
	require_once("repositories/CommentRepository.php");
    require_once("repositories/UserRepository.php");
    require_once("utilities.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=".DB_SERVERNAME.";dbname=".DB_NAME, DB_USERNAME, DB_PASSWORD);
    	$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    	//echo "Connesso con successo al DB";

        //if (!array_key_exists("token", $params) || !UserRepository::checkToken($params["token"], $conn)) {
        if (!array_key_exists("token", $params) || $params["token"] === "" ||
            (!UserRepository::checkUserByToken($params["user_id"], $params["token"], $conn) &&
            !UserRepository::checkAdminByToken($params["token"], $conn))) {
            //$risposta["return"] = -1;
            $risposta = createErrorMessage(-1, "Token non valido");
            echo json_encode($risposta);
            die();
        }

    	$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->data              = date(DATE_ATOM);
        //$comment->imgs              = $params["imgs"];

    	$risposta = $comment_repo->addComment($comment);

        /* ============= SUPPORTO IMMAGINI NEI COMMENTI DROPPATO =============== */

        /*$commentImgs = array_key_exists("imgs", $params) ? $params["imgs"] : null;

        if ($risposta["return"] == 0 && count($commentImgs)>0) {
            foreach($commentImgs as $image) {
                //rename($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH.session_id()."/".$image, $_SERVER['DOCUMENT_ROOT'].IMAGES_PATH.$image);
                rename($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH."/".$image, $_SERVER['DOCUMENT_ROOT'].IMAGES_PATH.$image);
            }
            //rmdir("./images/temp/".session_id()."/");
            //deleteDirectory($_SERVER['DOCUMENT_ROOT'].TEMP_IMAGES_PATH.session_id()."/");
            $comment_repo->addImages($risposta["id"], $commentImgs);
        }*/

        //unset($_SESSION["images"]);

        /* =========== FINE SUPPORTO IMMAGINI NEI COMMENTI DROPPATO ============= */

    }
	catch(PDOException $e)
    {
   		echo $e->getMessage();
   		//$risposta["return"] = 1;
        $risposta = createErrorMessage(2, "Errore DB");
    }

    echo json_encode($risposta);
	$conn = null; //Close the connection to the DBMS

?>

Commits for Nextrek/Android/SmartCharging/endPoints/nightly/add_commento.php

Diff revisions: vs.
Revision Author Commited Message
727 Diff Diff FSallustio picture FSallustio Fri 11 Sep, 2015 10:27:04 +0000
725 Diff Diff FSallustio picture FSallustio Wed 09 Sep, 2015 07:51:47 +0000

Gestione utenze admin in SC

723 Diff Diff FSallustio picture FSallustio Tue 08 Sep, 2015 15:05:25 +0000

Aggiunto check sull’associazione tra utente e token.

706 Diff Diff FSallustio picture FSallustio Mon 07 Sep, 2015 15:50:07 +0000
695 Diff Diff FSallustio picture FSallustio Mon 07 Sep, 2015 10:31:36 +0000

Implementata chiamata get_commento.php

537 Diff Diff FSallustio picture FSallustio Mon 24 Aug, 2015 14:46:21 +0000
533 Diff Diff FSallustio picture FSallustio Mon 24 Aug, 2015 12:58:42 +0000
517 Diff Diff FSallustio picture FSallustio Thu 20 Aug, 2015 14:25:03 +0000
441 Diff Diff FSallustio picture FSallustio Tue 28 Jul, 2015 08:01:07 +0000

Rimossa creazione delle cartelle temporanee per le immagini (ora verranno tutte salvate nella root di temp)

424 FSallustio picture FSallustio Wed 22 Jul, 2015 14:40:43 +0000

Aggiunto supporto token ad alcune chiamate.