function getAnonWS() { return getUserWS(0); }
<?php header('Content-Type: application/json'); require_once "hortapp.getData.php"; echo json_encode(getUserWS(41)); /* //comment //echo "GET BANCALS <br><br>"; //comment //echo "<br>getBancals(41) -> "; echo getBancals(41); //comment //echo "<br>********************************************************************************************"; //comment //echo "********************************************************************************************<br><br>"; //comment //echo "GET PARCELES <br><br>"; //comment //echo "<br>getParceles(41) -> "; echo getParceles(41); //comment //echo "<br>getParceles(42) -> "; echo getParceles(42); //comment //echo "<br>getParceles(43) -> ";
/** * Receive validated and password and check it on DB. If success, set $_SESSION parameters and send user's workspace * * @param string $login new user's login * @param string $password new user's password * * @return int|array if success, array with user's workspace. If error, returns [-4, -1] */ function login($login, $password) { $return = -1; //error not captured if ($dbAdmin = dbCon(0)) { $pas = hash('sha256', mysqli_real_escape_string($dbAdmin, $password)); $exists = query_escaped($dbAdmin, "SELECT id, login FROM user WHERE login = '******' AND password = '******' LIMIT 1;"); if (mysqli_num_rows($exists) == 1) { $user = mysqli_fetch_assoc($exists); if (isset($_SESSION['login'])) { //error session already started $return = -4; } else { $_SESSION['login'] = $user['login']; $_SESSION['id'] = $user['id']; $return = getUserWS($user['id']); //success login } } else { $return = -3; //usuari o contrassenya incorrectes o no existents a la BD } mysqli_close($dbAdmin); } else { $return = -2; //error dbCon } return $return; }