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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
    header("Access-Control-Allow-Origin: *");
    header('Content-Type: application/json; charset=UTF-8');

    require_once("constants.php");

	require_once("repositories/UserRepository.php");
	require_once("classes/User.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();
    $risposta["avatar"] = "";
	$user = new User();
	$user_repo;

    //var_dump($params);

    if (is_null($params)) {
        $risposta = createErrorMessage(-1, "Nessun parametro passato");
        echo json_encode($risposta);
        die();
    }

    if (!array_key_exists("username", $params) || $params["username"] === "") {
        $risposta = createErrorMessage(-1, "Parametro \"username\" non valido");
        echo json_encode($risposta);
        die();
    }

    if (!array_key_exists("password", $params) || $params["password"] === "") {
        $risposta = createErrorMessage(-1, "Parametro \"password\" non valido");
        echo json_encode($risposta);
        die();
    }

    if (!array_key_exists("nome", $params) || $params["nome"] === "") {
        $risposta = createErrorMessage(-1, "Parametro \"nome\" non valido");
        echo json_encode($risposta);
        die();
    }

    if (!array_key_exists("cognome", $params) || $params["cognome"] === "") {
        $risposta = createErrorMessage(-1, "Parametro \"cognome\" non valido");
        echo json_encode($risposta);
        die();
    }

	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";

    	$user_repo = new UserRepository($conn);

    	$user->username 		= $params["username"];
		//$user->nominativo		= $params["nominativo"];
        $user->nome             = $params["nome"];
        $user->cognome          = $params["cognome"];
    	$user->cell 			= $params["cell"];
    	$user->email 			= $params["email"];
    	//$user->avatar 		    = $params["avatar"];
    	//$user->is_owner			= 0; //non รจ un gestore

    	$risposta = $user_repo->registerUser($user, $params["password"]);

        $strToHash = $user->username.$user->nome.$user->cognome.$user->cell.$user->email;

        if ($params["avatar"] != "") {
            $imgExtention = substr(strrchr($params["avatar"],'.'),1);
            $risposta["avatar_name"] = uniqid().".".$imgExtention;
        }

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

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

?>

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

Diff revisions: vs.
Revision Author Commited Message
621 Diff Diff FSallustio picture FSallustio Mon 31 Aug, 2015 13:06:11 +0000
537 Diff Diff FSallustio picture FSallustio Mon 24 Aug, 2015 14:46:21 +0000
517 Diff Diff FSallustio picture FSallustio Thu 20 Aug, 2015 14:25:03 +0000
508 Diff Diff FSallustio picture FSallustio Thu 20 Aug, 2015 08:43:10 +0000
465 Diff Diff FSallustio picture FSallustio Mon 03 Aug, 2015 12:59:41 +0000
423 Diff Diff FSallustio picture FSallustio Wed 22 Jul, 2015 13:45:01 +0000
415 Diff Diff FSallustio picture FSallustio Wed 22 Jul, 2015 08:27:42 +0000

Piccolo refactor dei file php...

399 Diff Diff FSallustio picture FSallustio Mon 20 Jul, 2015 10:08:43 +0000

Ora la upload_avatar.php e la upload_image.php puntano a una directory esterna.

378 Diff Diff FSallustio picture FSallustio Fri 17 Jul, 2015 10:31:22 +0000

[DA TESTARE E CORREGGERE] Gestione path immagini tramite costanti.

374 FSallustio picture FSallustio Fri 17 Jul, 2015 08:20:18 +0000

Creazione “branch” nightly