function login($name, $password, $permanent)
{
    $_SESSION['name'] = $name;
    $_SESSION['password'] = $password;
    error_log($_SESSION['name'] . ' ' . $_SESSION['password']);
    $response = get_request(get_serverurl() . '/users/' . $name, true);
    if ($response["status"] == 200) {
        $response = json_decode($response["response"], true);
        $_SESSION['mail'] = $response['mail'];
        if ($permanent == true) {
            //ToDo: generate a place and remember me cookie
        }
        return true;
    } else {
        if (isset($_SESSION)) {
            session_destroy();
        }
        $_SESSION['name'] = null;
        $_SESSION['password'] = null;
        return false;
    }
}
Example #2
0
* (at your option) any later version.
*
* enviroCar is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with enviroCar.  If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'connection.php';
//USAGE:
//Get all groups: call GET and groups.php?groups
//Create new group:
//groups.php?createGroup and POST "group_name" and "groupe_description"
$baseURL = get_serverurl();
//as defined in config.php
if (isset($_GET['groups'])) {
    $response = get_request($baseURL . '/groups/', true);
    if ($response['status'] == 200) {
        echo $response['response'];
    } else {
        echo $response['status'];
    }
}
if (isset($_GET['group'])) {
    $response = get_request($baseURL . '/groups/' . rawurlencode($_GET['group']), true);
    if ($response['status'] == 200) {
        echo $response['response'];
    } else {
        echo $response['status'];
Example #3
0
<?php

/*
* This file is part of enviroCar.
* 
* enviroCar is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* enviroCar is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with enviroCar.  If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'connection.php';
//Possible error status: 303,400,401,403,303
if (isset($_GET['getTerms'])) {
    $response = get_request(get_serverurl() . "/termsOfUse", true);
    if ($response['status'] == 200) {
        echo $response['response'];
    } else {
        echo $response['status'];
    }
}