Subversion Repository Public Repository

Nextrek

Diff Revisions 264 vs 281 for /Android/SmartCharging/endPoints/registrazione_utente.php

Diff revisions: vs.
  @@ -15,7 +15,8 @@
15 15 $params = json_decode(file_get_contents('php://input'), true);
16 16
17 17 $conn;
18 - //$risposta = array();
18 + $risposta = array();
19 + $risposta["avatar"] = "";
19 20 $user = new User();
20 21 $user_repo;
21 22
  @@ -32,16 +33,25 @@
32 33 $user->nominativo = $params["nominativo"];
33 34 $user->cell = $params["cell"];
34 35 $user->email = $params["email"];
35 - $user->avatar = $params["avatar"];
36 + //$user->avatar = $params["avatar"];
36 37 $user->is_owner = 0; //non è un gestore
37 38
38 39 $risposta = $user_repo->registerUser($user, $params["password"]);
39 40
41 + $strToHash = $user->username.$user->nominativo.$user->cell.$user->email;
42 +
43 + if ($params["avatar"] != "") {
44 + $imgExtention= substr(strrchr($params["avatar"],'.'),1);
45 + }
46 +
47 + $risposta["avatar_path"] = "./avatar/".sha1($strToHash)."-".strval(time()).".".$imgExtention;
48 +
40 49 }
41 50 catch(PDOException $e)
42 51 {
43 52 echo $e->getMessage();
44 53 $risposta["return"] = 1;
54 + $risposta["avatar_path"] = "";
45 55 }
46 56
47 57 echo json_encode($risposta);