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
<?php
	header("Access-Control-Allow-Origin: *");
    header('Content-Type: application/json; charset=UTF-8');

    require_once("constants.php");
    
	require_once("repositories/LocalRepository.php");
    require_once("repositories/UserRepository.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();
	$local_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)) {
            $risposta = createErrorMessage(-1, "Token non valido");
            //$risposta["return"] = -1;
            echo json_encode($risposta);
            die();
        }

    	$local_repo = new LocalRepository($conn);

    	$query_status = $local_repo->setLocalDescription($params["id"], $params["descrizione"]);		
		if ($query_status!=0) {
            $risposta["return"] = 0;
        } else {
            $risposta = createErrorMessage(1, "Errore nel modificare la descrizione del locale");
        }
    }
	catch(PDOException $e)
    {
   		echo $e->getMessage();
        $risposta = createErrorMessage(1, "Errore DB");
   		//$risposta["return"] = 1;
    }

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

?>

Commits for Nextrek/Android/SmartCharging/endPoints/set_descrizione.php

Diff revisions: vs.
Revision Author Commited Message
579 Diff Diff FSallustio picture FSallustio Thu 27 Aug, 2015 08:25:11 +0000
507 Diff Diff FSallustio picture FSallustio Thu 20 Aug, 2015 07:51:22 +0000

Merge ramo stable con la nightly.

265 Diff Diff FSallustio picture FSallustio Fri 10 Jul, 2015 12:50:57 +0000

Risolto problema con l’application/json negli altri endpoint.

249 Diff Diff FSallustio picture FSallustio Fri 10 Jul, 2015 07:17:20 +0000

Risolto bug chiamate POST

242 Diff Diff FSallustio picture FSallustio Thu 09 Jul, 2015 11:18:36 +0000

get_commenti.php implementata + bugfix

240 FSallustio picture FSallustio Thu 09 Jul, 2015 10:08:30 +0000

Implementati add_commento.php, cambia_nome_locale.php e set_descrizione.php